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

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGURIReference.cpp

Issue 2737403003: Use IdTargetObserver in SVGSMILElement (Closed)
Patch Set: Rebase; always attempt to unobserve Created 3 years, 9 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 /* 1 /*
2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 AtomicString id = fragmentIdentifierFromIRIString(urlString, treeScope); 111 AtomicString id = fragmentIdentifierFromIRIString(urlString, treeScope);
112 if (id.isEmpty()) 112 if (id.isEmpty())
113 return nullptr; 113 return nullptr;
114 if (fragmentIdentifier) 114 if (fragmentIdentifier)
115 *fragmentIdentifier = id; 115 *fragmentIdentifier = id;
116 return treeScope.getElementById(id); 116 return treeScope.getElementById(id);
117 } 117 }
118 118
119 Element* SVGURIReference::observeTarget(Member<IdTargetObserver>& observer, 119 Element* SVGURIReference::observeTarget(Member<IdTargetObserver>& observer,
120 SVGElement& contextElement) { 120 SVGElement& contextElement) {
121 return observeTarget(observer, contextElement, hrefString());
122 }
123
124 Element* SVGURIReference::observeTarget(Member<IdTargetObserver>& observer,
125 SVGElement& contextElement,
126 const String& hrefString) {
121 TreeScope& treeScope = contextElement.treeScope(); 127 TreeScope& treeScope = contextElement.treeScope();
122 AtomicString id = fragmentIdentifierFromIRIString(hrefString(), treeScope); 128 AtomicString id = fragmentIdentifierFromIRIString(hrefString, treeScope);
123 return observeTarget(observer, treeScope, id, 129 return observeTarget(observer, treeScope, id,
124 WTF::bind(&SVGElement::buildPendingResource, 130 WTF::bind(&SVGElement::buildPendingResource,
125 wrapWeakPersistent(&contextElement))); 131 wrapWeakPersistent(&contextElement)));
126 } 132 }
127 133
128 Element* SVGURIReference::observeTarget(Member<IdTargetObserver>& observer, 134 Element* SVGURIReference::observeTarget(Member<IdTargetObserver>& observer,
129 TreeScope& treeScope, 135 TreeScope& treeScope,
130 const AtomicString& id, 136 const AtomicString& id,
131 std::unique_ptr<WTF::Closure> closure) { 137 std::unique_ptr<WTF::Closure> closure) {
132 DCHECK(!observer); 138 DCHECK(!observer);
133 if (id.isEmpty()) 139 if (id.isEmpty())
134 return nullptr; 140 return nullptr;
135 observer = new SVGElementReferenceObserver(treeScope, id, std::move(closure)); 141 observer = new SVGElementReferenceObserver(treeScope, id, std::move(closure));
136 return treeScope.getElementById(id); 142 return treeScope.getElementById(id);
137 } 143 }
138 144
139 void SVGURIReference::unobserveTarget(Member<IdTargetObserver>& observer) { 145 void SVGURIReference::unobserveTarget(Member<IdTargetObserver>& observer) {
140 if (!observer) 146 if (!observer)
141 return; 147 return;
142 observer->unregister(); 148 observer->unregister();
143 observer = nullptr; 149 observer = nullptr;
144 } 150 }
145 151
146 } // namespace blink 152 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGURIReference.h ('k') | third_party/WebKit/Source/core/svg/animation/SVGSMILElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698