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

Side by Side Diff: Source/WebCore/svg/SVGTRefElement.cpp

Issue 8041053: Revert 96034 - Merge 95791 - use after free in WebCore::SVGTRefElement::updateReferencedText (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/835/
Patch Set: Created 9 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
« no previous file with comments | « Source/WebCore/svg/SVGTRefElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005 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 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 4 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 m_eventListener->removeFromTarget(); 186 m_eventListener->removeFromTarget();
187 m_eventListener = 0; 187 m_eventListener = 0;
188 } 188 }
189 String id = SVGURIReference::getTarget(href()); 189 String id = SVGURIReference::getTarget(href());
190 Element* target = treeScope()->getElementById(id); 190 Element* target = treeScope()->getElementById(id);
191 if (!target) { 191 if (!target) {
192 document()->accessSVGExtensions()->addPendingResource(id, this); 192 document()->accessSVGExtensions()->addPendingResource(id, this);
193 return; 193 return;
194 } 194 }
195 updateReferencedText(); 195 updateReferencedText();
196 if (inDocument()) { 196 m_eventListener = SubtreeModificationEventListener::create(this, id);
197 m_eventListener = SubtreeModificationEventListener::create(this, id) ; 197 ASSERT(target->parentNode());
198 ASSERT(target->parentNode()); 198 target->parentNode()->addEventListener(eventNames().DOMSubtreeModifiedEv ent, m_eventListener.get(), false);
199 target->parentNode()->addEventListener(eventNames().DOMSubtreeModifi edEvent, m_eventListener.get(), false);
200 }
201 if (RenderObject* renderer = this->renderer()) 199 if (RenderObject* renderer = this->renderer())
202 RenderSVGResource::markForLayoutAndParentResourceInvalidation(render er); 200 RenderSVGResource::markForLayoutAndParentResourceInvalidation(render er);
203 return; 201 return;
204 } 202 }
205 203
206 ASSERT_NOT_REACHED(); 204 ASSERT_NOT_REACHED();
207 } 205 }
208 206
209 RenderObject* SVGTRefElement::createRenderer(RenderArena* arena, RenderStyle*) 207 RenderObject* SVGTRefElement::createRenderer(RenderArena* arena, RenderStyle*)
210 { 208 {
(...skipping 25 matching lines...) Expand all
236 updateReferencedText(); 234 updateReferencedText();
237 String id = SVGURIReference::getTarget(href()); 235 String id = SVGURIReference::getTarget(href());
238 if (Element* target = treeScope()->getElementById(id)) { 236 if (Element* target = treeScope()->getElementById(id)) {
239 ASSERT(!m_eventListener); 237 ASSERT(!m_eventListener);
240 m_eventListener = SubtreeModificationEventListener::create(this, id); 238 m_eventListener = SubtreeModificationEventListener::create(this, id);
241 ASSERT(target->parentNode()); 239 ASSERT(target->parentNode());
242 target->parentNode()->addEventListener(eventNames().DOMSubtreeModifiedEv ent, m_eventListener.get(), false); 240 target->parentNode()->addEventListener(eventNames().DOMSubtreeModifiedEv ent, m_eventListener.get(), false);
243 } 241 }
244 } 242 }
245 243
246 void SVGTRefElement::insertedIntoDocument()
247 {
248 SVGStyledElement::insertedIntoDocument();
249 String id;
250 Element* target = SVGURIReference::targetElementFromIRIString(href(), docume nt(), &id);
251 if (!target) {
252 document()->accessSVGExtensions()->addPendingResource(id, this);
253 return;
254 }
255 updateReferencedText();
256 m_eventListener = SubtreeModificationEventListener::create(this, id);
257 ASSERT(target->parentNode());
258 target->parentNode()->addEventListener(eventNames().DOMSubtreeModifiedEvent, m_eventListener.get(), false);
259 }
260
261 void SVGTRefElement::removedFromDocument() 244 void SVGTRefElement::removedFromDocument()
262 { 245 {
263 SVGStyledElement::removedFromDocument(); 246 SVGStyledElement::removedFromDocument();
264 247
265 if (!m_eventListener) 248 if (!m_eventListener)
266 return; 249 return;
267 250
268 m_eventListener->removeFromTarget(); 251 m_eventListener->removeFromTarget();
269 m_eventListener = 0; 252 m_eventListener = 0;
270 } 253 }
271 254
272 } 255 }
273 256
274 #endif // ENABLE(SVG) 257 #endif // ENABLE(SVG)
OLDNEW
« no previous file with comments | « Source/WebCore/svg/SVGTRefElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698