OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef SVGTreeScopeResources_h |
| 6 #define SVGTreeScopeResources_h |
| 7 |
| 8 #include "platform/heap/Handle.h" |
| 9 #include "wtf/Forward.h" |
| 10 #include "wtf/HashMap.h" |
| 11 #include "wtf/HashSet.h" |
| 12 #include "wtf/text/AtomicStringHash.h" |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 class Element; |
| 17 class TreeScope; |
| 18 class LayoutSVGResourceContainer; |
| 19 |
| 20 // This class keeps track of SVG resources and pending references to such for a |
| 21 // TreeScope. It's per-TreeScope because that matches the lookup scope of an |
| 22 // element's id (which is used to identify a resource.) |
| 23 class SVGTreeScopeResources |
| 24 : public GarbageCollectedFinalized<SVGTreeScopeResources> { |
| 25 WTF_MAKE_NONCOPYABLE(SVGTreeScopeResources); |
| 26 |
| 27 public: |
| 28 typedef HeapHashSet<Member<Element>> SVGPendingElements; |
| 29 |
| 30 explicit SVGTreeScopeResources(TreeScope*); |
| 31 ~SVGTreeScopeResources(); |
| 32 |
| 33 void addResource(const AtomicString& id, LayoutSVGResourceContainer*); |
| 34 void removeResource(const AtomicString& id); |
| 35 LayoutSVGResourceContainer* resourceById(const AtomicString& id) const; |
| 36 |
| 37 // Pending resources are such which are referenced by any object in the SVG |
| 38 // document, but do NOT exist yet. For instance, dynamically built gradients |
| 39 // / patterns / clippers... |
| 40 void addPendingResource(const AtomicString& id, Element*); |
| 41 bool hasPendingResource(const AtomicString& id) const; |
| 42 bool isElementPendingResources(Element*) const; |
| 43 bool isElementPendingResource(Element*, const AtomicString& id) const; |
| 44 void clearHasPendingResourcesIfPossible(Element*); |
| 45 void removeElementFromPendingResources(Element*); |
| 46 SVGPendingElements* removePendingResource(const AtomicString& id); |
| 47 |
| 48 DECLARE_TRACE(); |
| 49 |
| 50 private: |
| 51 HashMap<AtomicString, LayoutSVGResourceContainer*> m_resources; |
| 52 // Resources that are pending. |
| 53 HeapHashMap<AtomicString, Member<SVGPendingElements>> m_pendingResources; |
| 54 }; |
| 55 |
| 56 } // namespace blink |
| 57 |
| 58 #endif // SVGTreeScopeResources_h |
OLD | NEW |