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

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

Issue 192143002: Use isSVG*Element() helpers more in SVG code (Part 2) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/svg/SVGTextPathElement.cpp ('k') | Source/core/svg/SVGVKernElement.cpp » ('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) 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 236
237 ASSERT_NOT_REACHED(); 237 ASSERT_NOT_REACHED();
238 } 238 }
239 239
240 #ifdef DUMP_INSTANCE_TREE 240 #ifdef DUMP_INSTANCE_TREE
241 static void dumpInstanceTree(unsigned int& depth, String& text, SVGElementInstan ce* targetInstance) 241 static void dumpInstanceTree(unsigned int& depth, String& text, SVGElementInstan ce* targetInstance)
242 { 242 {
243 SVGElement* element = targetInstance->correspondingElement(); 243 SVGElement* element = targetInstance->correspondingElement();
244 ASSERT(element); 244 ASSERT(element);
245 245
246 if (element->hasTagName(SVGNames::useTag)) { 246 if (isSVGUseElement(*element) && toSVGUseElement(*element).resourceIsStillLo ading())
247 if (toSVGUseElement(element)->resourceIsStillLoading()) 247 return;
248 return;
249 }
250 248
251 SVGElement* shadowTreeElement = targetInstance->shadowTreeElement(); 249 SVGElement* shadowTreeElement = targetInstance->shadowTreeElement();
252 ASSERT(shadowTreeElement); 250 ASSERT(shadowTreeElement);
253 251
254 SVGUseElement* directUseElement = targetInstance->directUseElement(); 252 SVGUseElement* directUseElement = targetInstance->directUseElement();
255 String directUseElementName = directUseElement ? directUseElement->nodeName( ) : "null"; 253 String directUseElementName = directUseElement ? directUseElement->nodeName( ) : "null";
256 254
257 String elementId = element->getIdAttribute(); 255 String elementId = element->getIdAttribute();
258 String elementNodeName = element->nodeName(); 256 String elementNodeName = element->nodeName();
259 String shadowTreeElementNodeName = shadowTreeElement->nodeName(); 257 String shadowTreeElementNodeName = shadowTreeElement->nodeName();
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 return 0; 548 return 0;
551 } 549 }
552 550
553 void SVGUseElement::buildInstanceTree(SVGElement* target, SVGElementInstance* ta rgetInstance, bool& foundProblem, bool foundUse) 551 void SVGUseElement::buildInstanceTree(SVGElement* target, SVGElementInstance* ta rgetInstance, bool& foundProblem, bool foundUse)
554 { 552 {
555 ASSERT(target); 553 ASSERT(target);
556 ASSERT(targetInstance); 554 ASSERT(targetInstance);
557 555
558 // Spec: If the referenced object is itself a 'use', or if there are 'use' s ubelements within the referenced 556 // Spec: If the referenced object is itself a 'use', or if there are 'use' s ubelements within the referenced
559 // object, the instance tree will contain recursive expansion of the indirec t references to form a complete tree. 557 // object, the instance tree will contain recursive expansion of the indirec t references to form a complete tree.
560 bool targetHasUseTag = target->hasTagName(SVGNames::useTag); 558 bool targetIsUseElement = isSVGUseElement(*target);
561 SVGElement* newTarget = 0; 559 SVGElement* newTarget = 0;
562 if (targetHasUseTag) { 560 if (targetIsUseElement) {
563 foundProblem = hasCycleUseReferencing(toSVGUseElement(target), targetIns tance, newTarget); 561 foundProblem = hasCycleUseReferencing(toSVGUseElement(target), targetIns tance, newTarget);
564 if (foundProblem) 562 if (foundProblem)
565 return; 563 return;
566 564
567 // We only need to track first degree <use> dependencies. Indirect refer ences are handled 565 // We only need to track first degree <use> dependencies. Indirect refer ences are handled
568 // as the invalidation bubbles up the dependency chain. 566 // as the invalidation bubbles up the dependency chain.
569 if (!foundUse) { 567 if (!foundUse) {
570 document().accessSVGExtensions().addElementReferencingTarget(this, t arget); 568 document().accessSVGExtensions().addElementReferencingTarget(this, t arget);
571 foundUse = true; 569 foundUse = true;
572 } 570 }
(...skipping 22 matching lines...) Expand all
595 RefPtr<SVGElementInstance> instance = SVGElementInstance::create(this, 0 , element); 593 RefPtr<SVGElementInstance> instance = SVGElementInstance::create(this, 0 , element);
596 SVGElementInstance* instancePtr = instance.get(); 594 SVGElementInstance* instancePtr = instance.get();
597 targetInstance->appendChild(instance.release()); 595 targetInstance->appendChild(instance.release());
598 596
599 // Enter recursion, appending new instance tree nodes to the "instance" object. 597 // Enter recursion, appending new instance tree nodes to the "instance" object.
600 buildInstanceTree(element, instancePtr, foundProblem, foundUse); 598 buildInstanceTree(element, instancePtr, foundProblem, foundUse);
601 if (foundProblem) 599 if (foundProblem)
602 return; 600 return;
603 } 601 }
604 602
605 if (!targetHasUseTag || !newTarget) 603 if (!targetIsUseElement || !newTarget)
606 return; 604 return;
607 605
608 RefPtr<SVGElementInstance> newInstance = SVGElementInstance::create(this, to SVGUseElement(target), newTarget); 606 RefPtr<SVGElementInstance> newInstance = SVGElementInstance::create(this, to SVGUseElement(target), newTarget);
609 SVGElementInstance* newInstancePtr = newInstance.get(); 607 SVGElementInstance* newInstancePtr = newInstance.get();
610 targetInstance->appendChild(newInstance.release()); 608 targetInstance->appendChild(newInstance.release());
611 buildInstanceTree(newTarget, newInstancePtr, foundProblem, foundUse); 609 buildInstanceTree(newTarget, newInstancePtr, foundProblem, foundUse);
612 } 610 }
613 611
614 bool SVGUseElement::hasCycleUseReferencing(SVGUseElement* use, SVGElementInstanc e* targetInstance, SVGElement*& newTarget) 612 bool SVGUseElement::hasCycleUseReferencing(SVGUseElement* use, SVGElementInstanc e* targetInstance, SVGElement*& newTarget)
615 { 613 {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 // Though if there are disallowed elements in the subtree, we have to remove them. 667 // Though if there are disallowed elements in the subtree, we have to remove them.
670 // For instance: <use> on <g> containing <foreignObject> (indirect case). 668 // For instance: <use> on <g> containing <foreignObject> (indirect case).
671 if (subtreeContainsDisallowedElement(newChild.get())) 669 if (subtreeContainsDisallowedElement(newChild.get()))
672 removeDisallowedElementsFromSubtree(*newChild); 670 removeDisallowedElementsFromSubtree(*newChild);
673 671
674 userAgentShadowRoot()->appendChild(newChild.release()); 672 userAgentShadowRoot()->appendChild(newChild.release());
675 } 673 }
676 674
677 void SVGUseElement::expandUseElementsInShadowTree(Node* element) 675 void SVGUseElement::expandUseElementsInShadowTree(Node* element)
678 { 676 {
677 ASSERT(element);
679 // Why expand the <use> elements in the shadow tree here, and not just 678 // Why expand the <use> elements in the shadow tree here, and not just
680 // do this directly in buildShadowTree, if we encounter a <use> element? 679 // do this directly in buildShadowTree, if we encounter a <use> element?
681 // 680 //
682 // Short answer: Because we may miss to expand some elements. Ie. if a <symb ol> 681 // Short answer: Because we may miss to expand some elements. Ie. if a <symb ol>
683 // contains <use> tags, we'd miss them. So once we're done with settin' up t he 682 // contains <use> tags, we'd miss them. So once we're done with settin' up t he
684 // actual shadow tree (after the special case modification for svg/symbol) w e have 683 // actual shadow tree (after the special case modification for svg/symbol) w e have
685 // to walk it completely and expand all <use> elements. 684 // to walk it completely and expand all <use> elements.
686 if (element->hasTagName(SVGNames::useTag)) { 685 if (isSVGUseElement(*element)) {
687 SVGUseElement* use = toSVGUseElement(element); 686 SVGUseElement* use = toSVGUseElement(element);
688 ASSERT(!use->resourceIsStillLoading()); 687 ASSERT(!use->resourceIsStillLoading());
689 688
690 ASSERT(referencedDocument()); 689 ASSERT(referencedDocument());
691 Element* targetElement = SVGURIReference::targetElementFromIRIString(use ->hrefString(), *referencedDocument()); 690 Element* targetElement = SVGURIReference::targetElementFromIRIString(use ->hrefString(), *referencedDocument());
692 SVGElement* target = 0; 691 SVGElement* target = 0;
693 if (targetElement && targetElement->isSVGElement()) 692 if (targetElement && targetElement->isSVGElement())
694 target = toSVGElement(targetElement); 693 target = toSVGElement(targetElement);
695 694
696 // Don't ASSERT(target) here, it may be "pending", too. 695 // Don't ASSERT(target) here, it may be "pending", too.
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 973
975 if (m_resource) 974 if (m_resource)
976 m_resource->removeClient(this); 975 m_resource->removeClient(this);
977 976
978 m_resource = resource; 977 m_resource = resource;
979 if (m_resource) 978 if (m_resource)
980 m_resource->addClient(this); 979 m_resource->addClient(this);
981 } 980 }
982 981
983 } 982 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGTextPathElement.cpp ('k') | Source/core/svg/SVGVKernElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698