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

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

Issue 2401343002: Tracking filter mutation via SVGElementProxy (Closed)
Patch Set: Touchups Created 4 years, 2 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
(Empty)
1 // Copyright 2016 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 SVGElementProxy_h
6 #define SVGElementProxy_h
7
8 #include "core/fetch/DocumentResource.h"
9 #include "platform/heap/Handle.h"
10 #include "wtf/text/AtomicString.h"
11 #include "wtf/text/WTFString.h"
12
13 namespace blink {
14
15 class Document;
16 class SVGElement;
17 class SVGResourceClient;
18 class TreeScope;
19
20 // A proxy to an SVGElement. Allows access to an element with a certain 'id',
pdr. 2016/10/20 19:03:42 Do you mind expanding this comment to describe the
fs 2016/10/21 11:17:12 Thanks, I tried to jot something down that I hope
21 // and provides its clients with notifications when the reference changes.
22 class SVGElementProxy : public GarbageCollectedFinalized<SVGElementProxy>,
23 private DocumentResourceClient {
24 USING_GARBAGE_COLLECTED_MIXIN(SVGElementProxy);
25 USING_PRE_FINALIZER(SVGElementProxy, detachDocumentClient);
26
27 public:
28 // Create a proxy to an element in the same document. (See also
29 // SVGURLReferenceResolver and the definition of 'local url'.)
30 static SVGElementProxy* create(const AtomicString& id) {
31 return new SVGElementProxy(id);
32 }
33
34 // Create a proxy to an element in a different document (indicated by |url|.)
35 static SVGElementProxy* create(const String& url, const AtomicString& id) {
36 return new SVGElementProxy(url, id);
37 }
38 virtual ~SVGElementProxy();
39
40 void addClient(SVGResourceClient*);
41 void removeClient(SVGResourceClient*);
42
43 // Resolve a potentially external reference.
44 void resolve(Document&);
45
46 // Returns the proxied element, or null if the proxy is invalid.
47 SVGElement* element(TreeScope&);
48
49 // Notify the proxy that the structure of the subtree rooted at the proxied
50 // element has mutated. This should generally only be called via a proxy
51 // tracker.
52 void contentChanged();
53
54 // Notify the proxy that the reference it holds may now be pointing somewhere
55 // else (the id of an element changed, the resource document of the proxy
56 // finished loading, the element was removed from the document tree etc.)
57 // This should generally only be called via a proxy tracker.
58 void referenceChanged();
59
60 const AtomicString& id() const { return m_id; }
61
62 // The current "generation" of this proxy. This is essentially a sequence
63 // number (or counter) incremented with each change to the proxy reference.
pdr. 2016/10/20 19:03:42 Nit: "reference" was a little confusing to me when
fs 2016/10/21 11:17:12 I tried to replace "reference" with "proxied eleme
64 unsigned generation() const { return m_generation; }
65
66 DECLARE_VIRTUAL_TRACE();
67
68 private:
69 explicit SVGElementProxy(const AtomicString&);
70 SVGElementProxy(const String&, const AtomicString&);
71
72 void detachDocumentClient();
73 // ResourceClient implementation. Used when referencing an external resource
74 // document.
75 void notifyFinished(Resource*) override;
76 String debugName() const override { return "SVGElementProxy"; }
77
78 void incrementGeneration() { m_generation++; }
79 TreeScope* treeScopeForLookup(TreeScope&) const;
80
81 HeapHashSet<Member<SVGResourceClient>> m_clients;
82 Member<DocumentResource> m_document;
83 AtomicString m_id;
84 // URL for resolving references to external resource documents. Contains an
85 // absolute URL to the resource to load. Cleared when a load has been
86 // initiated. Ignored if m_isLocal is true.
87 String m_url;
88 unsigned m_generation;
89 bool m_isLocal;
90 };
91
92 // Collection of SVGElementProxys. This is hosted by elements that can be
93 // subject to proxies (currently only SVGFilterElement), and is mainly a helper
94 // for dealing with the many-to-one structure of SVGElementProxy.
95 class SVGElementProxySet : public GarbageCollected<SVGElementProxySet> {
96 public:
97 void add(SVGElementProxy&);
98 bool isEmpty() const;
99
100 // Notify proxy clients that the (content of the) proxied element has
101 // changed.
102 void notifyContentChanged();
103
104 // Notify proxy clients that the reference to the is no longer valid. This
105 // also clears references to the proxied element.
106 void invalidateProxies();
107
108 DECLARE_TRACE();
109
110 private:
111 using ProxySet = HeapHashSet<WeakMember<SVGElementProxy>>;
112 ProxySet m_elementProxies;
113 };
114
115 } // namespace blink
116
117 #endif // SVGElementProxy_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGDocumentExtensions.cpp ('k') | third_party/WebKit/Source/core/svg/SVGElementProxy.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698