summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/svg/svg_resource.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/core/svg/svg_resource.h')
-rw-r--r--chromium/third_party/blink/renderer/core/svg/svg_resource.h53
1 files changed, 37 insertions, 16 deletions
diff --git a/chromium/third_party/blink/renderer/core/svg/svg_resource.h b/chromium/third_party/blink/renderer/core/svg/svg_resource.h
index 7a2006d5f95..7f591d7ce8c 100644
--- a/chromium/third_party/blink/renderer/core/svg/svg_resource.h
+++ b/chromium/third_party/blink/renderer/core/svg/svg_resource.h
@@ -6,12 +6,10 @@
#define THIRD_PARTY_BLINK_RENDERER_CORE_SVG_SVG_RESOURCE_H_
#include "base/macros.h"
-#include "third_party/blink/renderer/core/svg/svg_external_document_cache.h"
-#include "third_party/blink/renderer/core/svg/svg_resource_client.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
+#include "third_party/blink/renderer/platform/loader/fetch/resource_client.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
-#include "third_party/blink/renderer/platform/wtf/hash_counted_set.h"
-#include "third_party/blink/renderer/platform/wtf/hash_set.h"
+#include "third_party/blink/renderer/platform/wtf/hash_map.h"
#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h"
namespace blink {
@@ -20,6 +18,10 @@ class Document;
class Element;
class IdTargetObserver;
class LayoutSVGResourceContainer;
+class QualifiedName;
+class SVGFilterPrimitiveStandardAttributes;
+class SVGResourceClient;
+class SVGResourceDocumentContent;
class TreeScope;
// A class tracking a reference to an SVG resource (an element that constitutes
@@ -66,7 +68,16 @@ class SVGResource : public GarbageCollected<SVGResource> {
virtual void LoadWithoutCSP(Document&) {}
Element* Target() const { return target_; }
- LayoutSVGResourceContainer* ResourceContainer() const;
+ // Returns the target's LayoutObject (if target exists and is attached to the
+ // layout tree). Also perform cycle-checking, and may thus return nullptr if
+ // this SVGResourceClient -> SVGResource reference would start a cycle.
+ LayoutSVGResourceContainer* ResourceContainer(SVGResourceClient&) const;
+ // Same as the above, minus the cycle-checking.
+ LayoutSVGResourceContainer* ResourceContainerNoCycleCheck() const;
+ // Run cycle-checking for this SVGResourceClient -> SVGResource
+ // reference. Used internally by the cycle-checking, and shouldn't be called
+ // directly in general.
+ bool FindCycle(SVGResourceClient&) const;
void AddClient(SVGResourceClient&);
void RemoveClient(SVGResourceClient&);
@@ -76,10 +87,22 @@ class SVGResource : public GarbageCollected<SVGResource> {
protected:
SVGResource();
- void NotifyElementChanged();
+ void InvalidateCycleCache();
+ void NotifyContentChanged();
Member<Element> target_;
- HeapHashCountedSet<Member<SVGResourceClient>> clients_;
+
+ enum CycleState {
+ kNeedCheck,
+ kPerformingCheck,
+ kHasCycle,
+ kNoCycle,
+ };
+ struct ClientEntry {
+ int count = 0;
+ CycleState cached_cycle_check = kNeedCheck;
+ };
+ mutable HeapHashMap<Member<SVGResourceClient>, ClientEntry> clients_;
private:
DISALLOW_COPY_AND_ASSIGN(SVGResource);
@@ -92,14 +115,12 @@ class LocalSVGResource final : public SVGResource {
void Unregister();
- void NotifyContentChanged(InvalidationModeMask);
+ using SVGResource::NotifyContentChanged;
+
void NotifyFilterPrimitiveChanged(
SVGFilterPrimitiveStandardAttributes& primitive,
const QualifiedName& attribute);
- void NotifyResourceAttached(LayoutSVGResourceContainer&);
- void NotifyResourceDestroyed(LayoutSVGResourceContainer&);
-
void Trace(Visitor*) const override;
private:
@@ -110,8 +131,7 @@ class LocalSVGResource final : public SVGResource {
};
// External resource reference (see SVGResource.)
-class ExternalSVGResource final : public SVGResource,
- private SVGExternalDocumentCache::Client {
+class ExternalSVGResource final : public SVGResource, public ResourceClient {
public:
explicit ExternalSVGResource(const KURL&);
@@ -123,10 +143,11 @@ class ExternalSVGResource final : public SVGResource,
private:
Element* ResolveTarget();
- // SVGExternalDocumentCache::Client implementation
- void NotifyFinished(Document*) override;
+ // ResourceClient implementation
+ void NotifyFinished(Resource*) override;
+ String DebugName() const override;
- Member<SVGExternalDocumentCache::Entry> cache_entry_;
+ Member<SVGResourceDocumentContent> document_content_;
KURL url_;
};