Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGTreeScopeResources.h

Issue 2705163008: Cleanup the SVGTreeScopeResources interface (Closed)
Patch Set: Rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef SVGTreeScopeResources_h 5 #ifndef SVGTreeScopeResources_h
6 #define SVGTreeScopeResources_h 6 #define SVGTreeScopeResources_h
7 7
8 #include "platform/heap/Handle.h" 8 #include "platform/heap/Handle.h"
9 #include "wtf/Forward.h" 9 #include "wtf/Forward.h"
10 #include "wtf/HashMap.h" 10 #include "wtf/HashMap.h"
11 #include "wtf/HashSet.h" 11 #include "wtf/HashSet.h"
12 #include "wtf/text/AtomicStringHash.h" 12 #include "wtf/text/AtomicStringHash.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 class Element; 16 class Element;
17 class TreeScope; 17 class TreeScope;
18 class LayoutSVGResourceContainer; 18 class LayoutSVGResourceContainer;
19 19
20 // This class keeps track of SVG resources and pending references to such for a 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 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.) 22 // element's id (which is used to identify a resource.)
23 class SVGTreeScopeResources 23 class SVGTreeScopeResources
24 : public GarbageCollectedFinalized<SVGTreeScopeResources> { 24 : public GarbageCollectedFinalized<SVGTreeScopeResources> {
25 WTF_MAKE_NONCOPYABLE(SVGTreeScopeResources); 25 WTF_MAKE_NONCOPYABLE(SVGTreeScopeResources);
26 26
27 public: 27 public:
28 typedef HeapHashSet<Member<Element>> SVGPendingElements;
29
30 explicit SVGTreeScopeResources(TreeScope*); 28 explicit SVGTreeScopeResources(TreeScope*);
31 ~SVGTreeScopeResources(); 29 ~SVGTreeScopeResources();
32 30
33 void updateResource(const AtomicString& id, LayoutSVGResourceContainer*); 31 void updateResource(const AtomicString& id, LayoutSVGResourceContainer*);
34 void removeResource(const AtomicString& id); 32 void removeResource(const AtomicString& id);
35 LayoutSVGResourceContainer* resourceById(const AtomicString& id) const; 33 LayoutSVGResourceContainer* resourceById(const AtomicString& id) const;
36 34
37 // Pending resources are such which are referenced by any object in the SVG 35 // 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 36 // document, but do NOT exist yet. For instance, dynamically built gradients
39 // / patterns / clippers... 37 // / patterns / clippers...
40 void addPendingResource(const AtomicString& id, Element*); 38 void addPendingResource(const AtomicString& id, Element&);
41 bool hasPendingResource(const AtomicString& id) const; 39 bool isElementPendingResource(Element&, const AtomicString& id) const;
42 bool isElementPendingResources(Element*) const;
43 bool isElementPendingResource(Element*, const AtomicString& id) const;
44 void notifyResourceAvailable(const AtomicString& id); 40 void notifyResourceAvailable(const AtomicString& id);
45 void clearHasPendingResourcesIfPossible(Element*); 41 void removeElementFromPendingResources(Element&);
46 void removeElementFromPendingResources(Element*);
47 SVGPendingElements* removePendingResource(const AtomicString& id);
48 42
49 DECLARE_TRACE(); 43 DECLARE_TRACE();
50 44
51 private: 45 private:
46 void clearHasPendingResourcesIfPossible(Element&);
47
48 using SVGPendingElements = HeapHashSet<Member<Element>>;
49
52 HashMap<AtomicString, LayoutSVGResourceContainer*> m_resources; 50 HashMap<AtomicString, LayoutSVGResourceContainer*> m_resources;
53 // Resources that are pending. 51 // Resources that are pending.
54 HeapHashMap<AtomicString, Member<SVGPendingElements>> m_pendingResources; 52 HeapHashMap<AtomicString, Member<SVGPendingElements>> m_pendingResources;
55 }; 53 };
56 54
57 } // namespace blink 55 } // namespace blink
58 56
59 #endif // SVGTreeScopeResources_h 57 #endif // SVGTreeScopeResources_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698