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

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

Issue 19539003: Introduce toSVGUseElement(), use it (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased Created 7 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
« no previous file with comments | « Source/core/svg/SVGUseElement.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, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde .org> 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde .org>
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
5 * Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 5 * Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
6 * Copyright (C) 2012 University of Szeged 6 * Copyright (C) 2012 University of Szeged
7 * Copyright (C) 2012 Renata Hodovan <reni@webkit.org> 7 * Copyright (C) 2012 Renata Hodovan <reni@webkit.org>
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 buildPendingResource(); 263 buildPendingResource();
264 } 264 }
265 265
266 #ifdef DUMP_INSTANCE_TREE 266 #ifdef DUMP_INSTANCE_TREE
267 static void dumpInstanceTree(unsigned int& depth, String& text, SVGElementInstan ce* targetInstance) 267 static void dumpInstanceTree(unsigned int& depth, String& text, SVGElementInstan ce* targetInstance)
268 { 268 {
269 SVGElement* element = targetInstance->correspondingElement(); 269 SVGElement* element = targetInstance->correspondingElement();
270 ASSERT(element); 270 ASSERT(element);
271 271
272 if (element->hasTagName(SVGNames::useTag)) { 272 if (element->hasTagName(SVGNames::useTag)) {
273 if (static_cast<SVGUseElement*>(element)->cachedDocumentIsStillLoading() ) 273 if (toSVGUseElement(element)->cachedDocumentIsStillLoading())
274 return; 274 return;
275 } 275 }
276 276
277 SVGElement* shadowTreeElement = targetInstance->shadowTreeElement(); 277 SVGElement* shadowTreeElement = targetInstance->shadowTreeElement();
278 ASSERT(shadowTreeElement); 278 ASSERT(shadowTreeElement);
279 279
280 SVGUseElement* directUseElement = targetInstance->directUseElement(); 280 SVGUseElement* directUseElement = targetInstance->directUseElement();
281 String directUseElementName = directUseElement ? directUseElement->nodeName( ) : "null"; 281 String directUseElementName = directUseElement ? directUseElement->nodeName( ) : "null";
282 282
283 String elementId = element->getIdAttribute(); 283 String elementId = element->getIdAttribute();
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 void SVGUseElement::buildInstanceTree(SVGElement* target, SVGElementInstance* ta rgetInstance, bool& foundProblem, bool foundUse) 572 void SVGUseElement::buildInstanceTree(SVGElement* target, SVGElementInstance* ta rgetInstance, bool& foundProblem, bool foundUse)
573 { 573 {
574 ASSERT(target); 574 ASSERT(target);
575 ASSERT(targetInstance); 575 ASSERT(targetInstance);
576 576
577 // Spec: If the referenced object is itself a 'use', or if there are 'use' s ubelements within the referenced 577 // Spec: If the referenced object is itself a 'use', or if there are 'use' s ubelements within the referenced
578 // object, the instance tree will contain recursive expansion of the indirec t references to form a complete tree. 578 // object, the instance tree will contain recursive expansion of the indirec t references to form a complete tree.
579 bool targetHasUseTag = target->hasTagName(SVGNames::useTag); 579 bool targetHasUseTag = target->hasTagName(SVGNames::useTag);
580 SVGElement* newTarget = 0; 580 SVGElement* newTarget = 0;
581 if (targetHasUseTag) { 581 if (targetHasUseTag) {
582 foundProblem = hasCycleUseReferencing(static_cast<SVGUseElement*>(target ), targetInstance, newTarget); 582 foundProblem = hasCycleUseReferencing(toSVGUseElement(target), targetIns tance, newTarget);
583 if (foundProblem) 583 if (foundProblem)
584 return; 584 return;
585 585
586 // We only need to track first degree <use> dependencies. Indirect refer ences are handled 586 // We only need to track first degree <use> dependencies. Indirect refer ences are handled
587 // as the invalidation bubbles up the dependency chain. 587 // as the invalidation bubbles up the dependency chain.
588 if (!foundUse) { 588 if (!foundUse) {
589 ASSERT(document()); 589 ASSERT(document());
590 document()->accessSVGExtensions()->addElementReferencingTarget(this, target); 590 document()->accessSVGExtensions()->addElementReferencingTarget(this, target);
591 foundUse = true; 591 foundUse = true;
592 } 592 }
(...skipping 25 matching lines...) Expand all
618 618
619 // Enter recursion, appending new instance tree nodes to the "instance" object. 619 // Enter recursion, appending new instance tree nodes to the "instance" object.
620 buildInstanceTree(element, instancePtr, foundProblem, foundUse); 620 buildInstanceTree(element, instancePtr, foundProblem, foundUse);
621 if (foundProblem) 621 if (foundProblem)
622 return; 622 return;
623 } 623 }
624 624
625 if (!targetHasUseTag || !newTarget) 625 if (!targetHasUseTag || !newTarget)
626 return; 626 return;
627 627
628 RefPtr<SVGElementInstance> newInstance = SVGElementInstance::create(this, st atic_cast<SVGUseElement*>(target), newTarget); 628 RefPtr<SVGElementInstance> newInstance = SVGElementInstance::create(this, to SVGUseElement(target), newTarget);
629 SVGElementInstance* newInstancePtr = newInstance.get(); 629 SVGElementInstance* newInstancePtr = newInstance.get();
630 targetInstance->appendChild(newInstance.release()); 630 targetInstance->appendChild(newInstance.release());
631 buildInstanceTree(newTarget, newInstancePtr, foundProblem, foundUse); 631 buildInstanceTree(newTarget, newInstancePtr, foundProblem, foundUse);
632 } 632 }
633 633
634 bool SVGUseElement::hasCycleUseReferencing(SVGUseElement* use, SVGElementInstanc e* targetInstance, SVGElement*& newTarget) 634 bool SVGUseElement::hasCycleUseReferencing(SVGUseElement* use, SVGElementInstanc e* targetInstance, SVGElement*& newTarget)
635 { 635 {
636 Element* targetElement = SVGURIReference::targetElementFromIRIString(use->hr efCurrentValue(), referencedDocument()); 636 Element* targetElement = SVGURIReference::targetElementFromIRIString(use->hr efCurrentValue(), referencedDocument());
637 newTarget = 0; 637 newTarget = 0;
638 if (targetElement && targetElement->isSVGElement()) 638 if (targetElement && targetElement->isSVGElement())
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 void SVGUseElement::expandUseElementsInShadowTree(Node* element) 695 void SVGUseElement::expandUseElementsInShadowTree(Node* element)
696 { 696 {
697 // Why expand the <use> elements in the shadow tree here, and not just 697 // Why expand the <use> elements in the shadow tree here, and not just
698 // do this directly in buildShadowTree, if we encounter a <use> element? 698 // do this directly in buildShadowTree, if we encounter a <use> element?
699 // 699 //
700 // Short answer: Because we may miss to expand some elements. Ie. if a <symb ol> 700 // Short answer: Because we may miss to expand some elements. Ie. if a <symb ol>
701 // contains <use> tags, we'd miss them. So once we're done with settin' up t he 701 // contains <use> tags, we'd miss them. So once we're done with settin' up t he
702 // actual shadow tree (after the special case modification for svg/symbol) w e have 702 // actual shadow tree (after the special case modification for svg/symbol) w e have
703 // to walk it completely and expand all <use> elements. 703 // to walk it completely and expand all <use> elements.
704 if (element->hasTagName(SVGNames::useTag)) { 704 if (element->hasTagName(SVGNames::useTag)) {
705 SVGUseElement* use = static_cast<SVGUseElement*>(element); 705 SVGUseElement* use = toSVGUseElement(element);
706 ASSERT(!use->cachedDocumentIsStillLoading()); 706 ASSERT(!use->cachedDocumentIsStillLoading());
707 707
708 Element* targetElement = SVGURIReference::targetElementFromIRIString(use ->hrefCurrentValue(), referencedDocument()); 708 Element* targetElement = SVGURIReference::targetElementFromIRIString(use ->hrefCurrentValue(), referencedDocument());
709 SVGElement* target = 0; 709 SVGElement* target = 0;
710 if (targetElement && targetElement->isSVGElement()) 710 if (targetElement && targetElement->isSVGElement())
711 target = toSVGElement(targetElement); 711 target = toSVGElement(targetElement);
712 712
713 // Don't ASSERT(target) here, it may be "pending", too. 713 // Don't ASSERT(target) here, it may be "pending", too.
714 // Setup sub-shadow tree root node 714 // Setup sub-shadow tree root node
715 RefPtr<SVGGElement> cloneParent = SVGGElement::create(SVGNames::gTag, re ferencedDocument()); 715 RefPtr<SVGGElement> cloneParent = SVGGElement::create(SVGNames::gTag, re ferencedDocument());
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 983
984 if (m_cachedDocument) 984 if (m_cachedDocument)
985 m_cachedDocument->removeClient(this); 985 m_cachedDocument->removeClient(this);
986 986
987 m_cachedDocument = cachedDocument; 987 m_cachedDocument = cachedDocument;
988 if (m_cachedDocument) 988 if (m_cachedDocument)
989 m_cachedDocument->addClient(this); 989 m_cachedDocument->addClient(this);
990 } 990 }
991 991
992 } 992 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGUseElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698