Index: third_party/WebKit/Source/core/svg/SVGTreeScopeResources.h |
diff --git a/third_party/WebKit/Source/core/svg/SVGTreeScopeResources.h b/third_party/WebKit/Source/core/svg/SVGTreeScopeResources.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..725cb0c84745120f3c24d32bf13a6935fcf9ddfd |
--- /dev/null |
+++ b/third_party/WebKit/Source/core/svg/SVGTreeScopeResources.h |
@@ -0,0 +1,56 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef SVGTreeScopeResources_h |
+#define SVGTreeScopeResources_h |
+ |
+#include "platform/geometry/FloatPoint.h" |
+#include "platform/heap/Handle.h" |
+#include "wtf/Forward.h" |
+#include "wtf/HashMap.h" |
+#include "wtf/HashSet.h" |
+#include "wtf/text/AtomicStringHash.h" |
+ |
+ |
+namespace blink { |
+class Element; |
+class TreeScope; |
+class LayoutSVGResourceContainer; |
+ |
+class SVGTreeScopeResources : public GarbageCollectedFinalized<SVGTreeScopeResources> { |
+ WTF_MAKE_NONCOPYABLE(SVGTreeScopeResources); |
+public: |
+ typedef HeapHashSet<Member<Element>> SVGPendingElements; |
+ explicit SVGTreeScopeResources(TreeScope*); |
+ ~SVGTreeScopeResources(); |
+ void addResource(const AtomicString& id, LayoutSVGResourceContainer*); |
+ void removeResource(const AtomicString& id); |
+ LayoutSVGResourceContainer* resourceById(const AtomicString& id) const; |
+ |
+ // This HashMap contains a list of pending resources. Pending resources, are such |
+ // which are referenced by any object in the SVG document, but do NOT exist yet. |
+ // For instance, dynamically build gradients / patterns / clippers... |
+ void addPendingResource(const AtomicString& id, Element*); |
+ bool hasPendingResource(const AtomicString& id) const; |
+ bool isElementPendingResources(Element*) const; |
+ bool isElementPendingResource(Element*, const AtomicString& id) const; |
+ void clearHasPendingResourcesIfPossible(Element*); |
+ void removeElementFromPendingResources(Element*); |
+ SVGPendingElements* removePendingResource(const AtomicString& id); |
+ |
+ // The following two functions are used for scheduling a pending resource to be removed. |
+ void markPendingResourcesForRemoval(const AtomicString&); |
+ Element* removeElementFromPendingResourcesForRemoval(const AtomicString&); |
+ |
+ DECLARE_TRACE(); |
+private: |
+ Member<TreeScope> m_treeScope; |
+ HashMap<AtomicString, LayoutSVGResourceContainer*> m_resources; |
+ HeapHashMap<AtomicString, Member<SVGPendingElements>> m_pendingResources; // Resources that are pending. |
+ HeapHashMap<AtomicString, Member<SVGPendingElements>> m_pendingResourcesForRemoval; // Resources that are pending and scheduled for removal. |
+ |
+ SVGPendingElements* removePendingResourceForRemoval(const AtomicString&); |
+ }; |
+} |
+#endif // SVGTreeScopeResources_h |