Chromium Code Reviews| OLD | NEW |
|---|---|
| (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', | |
| 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 element was removed from the | |
| 56 // document tree etc.) This should generally only be called via a proxy | |
| 57 // tracker. | |
|
pdr.
2016/10/20 03:11:05
This also seems to be called from notifyFinished
fs
2016/10/20 11:28:00
That's kind of an implementation detail that ought
| |
| 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 03:11:05
Are there any security issues here if a mean user
fs
2016/10/20 11:28:00
What you can achieve by that is to make two operat
| |
| 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 void notifyFinished(Resource*) override; | |
|
pdr.
2016/10/20 03:11:05
Can you add a comment here about how this is calle
fs
2016/10/20 11:28:00
Done.
| |
| 74 String debugName() const override { return "SVGElementProxy"; } | |
| 75 | |
| 76 void nextGeneration() { m_generation++; } | |
|
pdr.
2016/10/20 03:11:05
Bikeshed nit: incrementCacheGeneration?
fs
2016/10/20 11:28:00
Made it incrementGeneration (there's nothing "cach
| |
| 77 TreeScope* treeScopeForLookup(TreeScope&) const; | |
| 78 | |
| 79 HeapHashSet<Member<SVGResourceClient>> m_clients; | |
| 80 Member<DocumentResource> m_document; | |
| 81 AtomicString m_id; | |
| 82 String m_url; | |
|
pdr.
2016/10/20 03:11:05
Can you add a comment about how this will be clear
fs
2016/10/20 11:28:00
Done.
| |
| 83 unsigned m_generation; | |
| 84 bool m_isLocal; | |
| 85 }; | |
| 86 | |
| 87 // Tracker of SVGElementProxys. This is hosted by elements that can be subject | |
| 88 // to proxies (currently only SVGFilterElement), and is mainly a helper for | |
| 89 // dealing with the many-to-one structure of SVGElementProxy. | |
| 90 class SVGElementProxyTracker : public GarbageCollected<SVGElementProxyTracker> { | |
|
pdr.
2016/10/20 03:11:05
This name confused me for a bit because I thought
fs
2016/10/20 11:28:00
Renamed to SVGElementProxySet.
| |
| 91 public: | |
| 92 void attachElementProxy(SVGElementProxy&); | |
|
pdr.
2016/10/20 03:11:05
Maybe just "add(SVGElementProxy&)"?
fs
2016/10/20 11:28:00
Done.
| |
| 93 bool isEmpty() const; | |
| 94 | |
| 95 // Notify proxy clients that the (content of the) proxied element has | |
| 96 // changed. | |
| 97 void invalidateProxyClients(); | |
|
pdr.
2016/10/20 03:11:05
Maybe just "notifyThatContentChanged"?
fs
2016/10/20 11:28:00
Done (minus "That".)
| |
| 98 | |
| 99 // Notify proxy clients that the reference to the is no longer valid. This | |
| 100 // also clears references to the proxied element. | |
| 101 void invalidateProxies(); | |
| 102 | |
| 103 DECLARE_TRACE(); | |
| 104 | |
| 105 private: | |
| 106 HeapHashSet<WeakMember<SVGElementProxy>> m_elementProxies; | |
| 107 }; | |
| 108 | |
| 109 } // namespace blink | |
| 110 | |
| 111 #endif // SVGElementProxy_h | |
| OLD | NEW |