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

Side by Side Diff: Source/core/svg/SVGDocumentExtensions.cpp

Issue 344883007: SVG: Move/rename reference management to SVGElement (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remove sed script from CL Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/svg/SVGDocumentExtensions.h ('k') | Source/core/svg/SVGElement.h » ('j') | 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) 2006 Apple Inc. All rights reserved. 2 * Copyright (C) 2006 Apple Inc. All rights reserved.
3 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> 3 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
4 * Copyright (C) 2007 Rob Buis <buis@kde.org> 4 * Copyright (C) 2007 Rob Buis <buis@kde.org>
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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 Element* element = *firstElement; 301 Element* element = *firstElement;
302 302
303 resourceSet->remove(firstElement); 303 resourceSet->remove(firstElement);
304 304
305 if (resourceSet->isEmpty()) 305 if (resourceSet->isEmpty())
306 removePendingResourceForRemoval(id); 306 removePendingResourceForRemoval(id);
307 307
308 return element; 308 return element;
309 } 309 }
310 310
311 SVGElementSet* SVGDocumentExtensions::setOfElementsReferencingTarget(SVGElement* referencedElement) const
312 {
313 ASSERT(referencedElement);
314 if (!referencedElement->hasSVGRareData())
315 return 0;
316 return &referencedElement->svgRareData()->referencingElements();
317 }
318
319 void SVGDocumentExtensions::addElementReferencingTarget(SVGElement* referencingE lement, SVGElement* referencedElement)
320 {
321 ASSERT(referencingElement);
322 ASSERT(referencedElement);
323 ASSERT(!referencingElement->isStructurallyExternal());
324
325 referencedElement->ensureSVGRareData()->referencingElements().add(referencin gElement);
326 referencingElement->ensureSVGRareData()->referencedElements().add(referenced Element);
327 }
328
329 void SVGDocumentExtensions::removeAllTargetReferencesForElement(SVGElement* refe rencingElement)
330 {
331 if (!referencingElement->hasSVGRareData())
332 return;
333
334 SVGElementSet& referencedElements = referencingElement->svgRareData()->refer encedElements();
335 for (SVGElementSet::iterator it = referencedElements.begin(), itEnd = refere ncedElements.end(); it != itEnd; ++it) {
336 SVGElement* referencedElement = *it;
337 ASSERT(referencedElement->hasSVGRareData());
338 referencedElement->ensureSVGRareData()->referencingElements().remove(ref erencingElement);
339 }
340 referencedElements.clear();
341 }
342
343 void SVGDocumentExtensions::rebuildAllElementReferencesForTarget(SVGElement* ref erencedElement)
344 {
345 ASSERT(referencedElement);
346 if (!referencedElement->hasSVGRareData())
347 return;
348
349 const SVGElementSet& referencingElements = referencedElement->svgRareData()- >referencingElements();
350
351 // Iterate on a snapshot as |referencingElements| may be altered inside loop .
352 WillBeHeapVector<RawPtrWillBeMember<SVGElement> > referencingElementsSnapSho t;
353 copyToVector(referencingElements, referencingElementsSnapShot);
354
355 // Force rebuilding the referencingElement so it knows about this change.
356 for (WillBeHeapVector<RawPtrWillBeMember<SVGElement> >::iterator it = refere ncingElementsSnapShot.begin(), itEnd = referencingElementsSnapShot.end(); it != itEnd; ++it) {
357 SVGElement* referencingElement = *it;
358
359 // Before rebuilding referencingElement ensure it was not removed from u nder us.
360 if (referencingElements.contains(referencingElement))
361 referencingElement->svgAttributeChanged(XLinkNames::hrefAttr);
362 }
363 }
364
365 void SVGDocumentExtensions::removeAllElementReferencesForTarget(SVGElement* refe rencedElement)
366 {
367 ASSERT(referencedElement);
368 if (!referencedElement->hasSVGRareData())
369 return;
370
371 SVGElementSet& referencingElements = referencedElement->svgRareData()->refer encingElements();
372 for (SVGElementSet::iterator it = referencingElements.begin(), itEnd = refer encingElements.end(); it != itEnd; ++it) {
373 SVGElement* referencingElement = *it;
374 ASSERT(referencedElement->hasSVGRareData());
375 referencingElement->ensureSVGRareData()->referencedElements().remove(ref erencedElement);
376 }
377 referencingElements.clear();
378 }
379
380 void SVGDocumentExtensions::addSVGRootWithRelativeLengthDescendents(SVGSVGElemen t* svgRoot) 311 void SVGDocumentExtensions::addSVGRootWithRelativeLengthDescendents(SVGSVGElemen t* svgRoot)
381 { 312 {
382 ASSERT(!m_inRelativeLengthSVGRootsInvalidation); 313 ASSERT(!m_inRelativeLengthSVGRootsInvalidation);
383 m_relativeLengthSVGRoots.add(svgRoot); 314 m_relativeLengthSVGRoots.add(svgRoot);
384 } 315 }
385 316
386 void SVGDocumentExtensions::removeSVGRootWithRelativeLengthDescendents(SVGSVGEle ment* svgRoot) 317 void SVGDocumentExtensions::removeSVGRootWithRelativeLengthDescendents(SVGSVGEle ment* svgRoot)
387 { 318 {
388 ASSERT(!m_inRelativeLengthSVGRootsInvalidation); 319 ASSERT(!m_inRelativeLengthSVGRootsInvalidation);
389 m_relativeLengthSVGRoots.remove(svgRoot); 320 m_relativeLengthSVGRoots.remove(svgRoot);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 visitor->trace(m_document); 404 visitor->trace(m_document);
474 visitor->trace(m_timeContainers); 405 visitor->trace(m_timeContainers);
475 #if ENABLE(SVG_FONTS) 406 #if ENABLE(SVG_FONTS)
476 visitor->trace(m_svgFontFaceElements); 407 visitor->trace(m_svgFontFaceElements);
477 visitor->trace(m_pendingSVGFontFaceElementsForRemoval); 408 visitor->trace(m_pendingSVGFontFaceElementsForRemoval);
478 #endif 409 #endif
479 visitor->trace(m_relativeLengthSVGRoots); 410 visitor->trace(m_relativeLengthSVGRoots);
480 } 411 }
481 412
482 } 413 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGDocumentExtensions.h ('k') | Source/core/svg/SVGElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698