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

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

Issue 9937002: Merge 111556 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1025/
Patch Set: Created 8 years, 8 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 | « no previous file | 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 return StyledElement::rendererIsNeeded(context); 220 return StyledElement::rendererIsNeeded(context);
221 221
222 return false; 222 return false;
223 } 223 }
224 224
225 void SVGTRefElement::buildPendingResource() 225 void SVGTRefElement::buildPendingResource()
226 { 226 {
227 // Remove any existing event listener. 227 // Remove any existing event listener.
228 clearEventListener(); 228 clearEventListener();
229 229
230 // If we're not yet in a document, this function will be called again from i nsertedIntoDocument().
231 if (!inDocument())
232 return;
233
230 String id; 234 String id;
231 Element* target = SVGURIReference::targetElementFromIRIString(href(), docume nt(), &id); 235 Element* target = SVGURIReference::targetElementFromIRIString(href(), docume nt(), &id);
232 if (!target) { 236 if (!target) {
233 if (hasPendingResources() || id.isEmpty()) 237 if (hasPendingResources() || id.isEmpty())
234 return; 238 return;
235 239
236 ASSERT(!hasPendingResources()); 240 ASSERT(!hasPendingResources());
237 document()->accessSVGExtensions()->addPendingResource(id, this); 241 document()->accessSVGExtensions()->addPendingResource(id, this);
238 ASSERT(hasPendingResources()); 242 ASSERT(hasPendingResources());
239 return; 243 return;
240 } 244 }
241 245
242 updateReferencedText(); 246 updateReferencedText();
243 247
244 // We should not add the event listener if we are not in document yet.
245 if (!inDocument())
246 return;
247
248 m_eventListener = SubtreeModificationEventListener::create(this, id); 248 m_eventListener = SubtreeModificationEventListener::create(this, id);
249 ASSERT(target->parentNode()); 249 ASSERT(target->parentNode());
250 target->parentNode()->addEventListener(eventNames().DOMSubtreeModifiedEvent, m_eventListener.get(), false); 250 target->parentNode()->addEventListener(eventNames().DOMSubtreeModifiedEvent, m_eventListener.get(), false);
251 } 251 }
252 252
253 void SVGTRefElement::insertedIntoDocument() 253 void SVGTRefElement::insertedIntoDocument()
254 { 254 {
255 SVGStyledElement::insertedIntoDocument(); 255 SVGStyledElement::insertedIntoDocument();
256 buildPendingResource(); 256 buildPendingResource();
257 } 257 }
258 258
259 void SVGTRefElement::removedFromDocument() 259 void SVGTRefElement::removedFromDocument()
260 { 260 {
261 SVGStyledElement::removedFromDocument(); 261 SVGStyledElement::removedFromDocument();
262 clearEventListener(); 262 clearEventListener();
263 } 263 }
264 264
265 void SVGTRefElement::clearEventListener() 265 void SVGTRefElement::clearEventListener()
266 { 266 {
267 if (m_eventListener) { 267 if (m_eventListener) {
268 m_eventListener->clear(); 268 m_eventListener->clear();
269 m_eventListener = 0; 269 m_eventListener = 0;
270 } 270 }
271 } 271 }
272 272
273 } 273 }
274 274
275 #endif // ENABLE(SVG) 275 #endif // ENABLE(SVG)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698