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

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

Issue 1754693002: Remove redundant check in SVGUseElement::buildShadowTree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « third_party/WebKit/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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 // Set up root SVG element in shadow tree. 404 // Set up root SVG element in shadow tree.
405 RefPtrWillBeRawPtr<Element> newChild = target->cloneElementWithoutChildren() ; 405 RefPtrWillBeRawPtr<Element> newChild = target->cloneElementWithoutChildren() ;
406 m_targetElementInstance = toSVGElement(newChild.get()); 406 m_targetElementInstance = toSVGElement(newChild.get());
407 ShadowRoot* shadowTreeRootElement = userAgentShadowRoot(); 407 ShadowRoot* shadowTreeRootElement = userAgentShadowRoot();
408 shadowTreeRootElement->appendChild(newChild.release()); 408 shadowTreeRootElement->appendChild(newChild.release());
409 409
410 // Clone the target subtree into the shadow tree, not handling <use> and <sy mbol> yet. 410 // Clone the target subtree into the shadow tree, not handling <use> and <sy mbol> yet.
411 411
412 // SVG specification does not say a word about <use> & cycles. My view on th is is: just ignore it! 412 // SVG specification does not say a word about <use> & cycles. My view on th is is: just ignore it!
413 // Non-appearing <use> content is easier to debug, then half-appearing conte nt. 413 // Non-appearing <use> content is easier to debug, then half-appearing conte nt.
414 if (!buildShadowTree(target, m_targetElementInstance.get(), false)) { 414 buildShadowTree(target, m_targetElementInstance.get(), false);
415 clearShadowTree();
416 return;
417 }
418 415
419 if (instanceTreeIsLoading(m_targetElementInstance.get())) 416 if (instanceTreeIsLoading(m_targetElementInstance.get()))
420 return; 417 return;
421 418
422 // Assure shadow tree building was successfull 419 // Assure shadow tree building was successful.
423 ASSERT(m_targetElementInstance); 420 ASSERT(m_targetElementInstance);
424 ASSERT(m_targetElementInstance->correspondingUseElement() == this); 421 ASSERT(m_targetElementInstance->correspondingUseElement() == this);
425 ASSERT(m_targetElementInstance->correspondingElement() == target); 422 ASSERT(m_targetElementInstance->correspondingElement() == target);
426 423
427 // Expand all <use> elements in the shadow tree. 424 // Expand all <use> elements in the shadow tree.
428 // Expand means: replace the actual <use> element by what it references. 425 // Expand means: replace the actual <use> element by what it references.
429 if (!expandUseElementsInShadowTree(m_targetElementInstance.get())) { 426 if (!expandUseElementsInShadowTree(m_targetElementInstance.get())) {
430 clearShadowTree(); 427 clearShadowTree();
431 return; 428 return;
432 } 429 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 // http://dev.w3.org/fxtf/css-masking-1/#the-clip-path 492 // http://dev.w3.org/fxtf/css-masking-1/#the-clip-path
496 if (!isDirectReference(element)) { 493 if (!isDirectReference(element)) {
497 // Spec: Indirect references are an error (14.3.5) 494 // Spec: Indirect references are an error (14.3.5)
498 document().accessSVGExtensions().reportError("Not allowed to use indirec t reference in <clip-path>"); 495 document().accessSVGExtensions().reportError("Not allowed to use indirec t reference in <clip-path>");
499 return nullptr; 496 return nullptr;
500 } 497 }
501 498
502 return &toSVGGraphicsElement(element); 499 return &toSVGGraphicsElement(element);
503 } 500 }
504 501
505 bool SVGUseElement::buildShadowTree(SVGElement* target, SVGElement* targetInstan ce, bool foundUse) 502 void SVGUseElement::buildShadowTree(SVGElement* target, SVGElement* targetInstan ce, bool foundUse)
506 { 503 {
507 ASSERT(target); 504 ASSERT(target);
508 ASSERT(targetInstance); 505 ASSERT(targetInstance);
506 ASSERT(!isDisallowedElement(target));
509 507
510 // Spec: If the referenced object is itself a 'use', or if there are 'use' s ubelements within the referenced 508 // Spec: If the referenced object is itself a 'use', or if there are 'use' s ubelements within the referenced
511 // object, the instance tree will contain recursive expansion of the indirec t references to form a complete tree. 509 // object, the instance tree will contain recursive expansion of the indirec t references to form a complete tree.
512 if (isSVGUseElement(*target)) { 510 if (isSVGUseElement(*target)) {
513 // We only need to track first degree <use> dependencies. Indirect refer ences are handled 511 // We only need to track first degree <use> dependencies. Indirect refer ences are handled
514 // as the invalidation bubbles up the dependency chain. 512 // as the invalidation bubbles up the dependency chain.
515 if (!foundUse && !isStructurallyExternal()) { 513 if (!foundUse && !isStructurallyExternal()) {
516 addReferenceTo(target); 514 addReferenceTo(target);
517 foundUse = true; 515 foundUse = true;
518 } 516 }
519 } else if (isDisallowedElement(target)) {
520 return false;
521 } 517 }
522 518
523 targetInstance->setCorrespondingElement(target); 519 targetInstance->setCorrespondingElement(target);
524 if (EventTargetData* data = target->eventTargetData()) 520 if (EventTargetData* data = target->eventTargetData())
525 data->eventListenerMap.copyEventListenersNotCreatedFromMarkupToTarget(ta rgetInstance); 521 data->eventListenerMap.copyEventListenersNotCreatedFromMarkupToTarget(ta rgetInstance);
526 522
527 for (RefPtrWillBeRawPtr<Node> child = target->firstChild(); child; child = c hild->nextSibling()) { 523 for (RefPtrWillBeRawPtr<Node> child = target->firstChild(); child; child = c hild->nextSibling()) {
528 // Skip any disallowed element. 524 // Skip any disallowed element.
529 if (isDisallowedElement(child.get())) 525 if (isDisallowedElement(child.get()))
530 continue; 526 continue;
531 527
532 RefPtrWillBeRawPtr<Node> newChild = child->cloneNode(false); 528 RefPtrWillBeRawPtr<Node> newChild = child->cloneNode(false);
533 targetInstance->appendChild(newChild.get()); 529 targetInstance->appendChild(newChild.get());
534 if (newChild->isSVGElement()) { 530 if (newChild->isSVGElement()) {
535 // Enter recursion, appending new instance tree nodes to the "instan ce" object. 531 // Enter recursion, appending new instance tree nodes to the "instan ce" object.
536 if (!buildShadowTree(toSVGElement(child), toSVGElement(newChild), fo undUse)) 532 buildShadowTree(toSVGElement(child), toSVGElement(newChild), foundUs e);
537 return false;
538 } 533 }
539 } 534 }
540 return true;
541 } 535 }
542 536
543 bool SVGUseElement::hasCycleUseReferencing(SVGUseElement* use, ContainerNode* ta rgetInstance, SVGElement*& newTarget) 537 bool SVGUseElement::hasCycleUseReferencing(SVGUseElement* use, ContainerNode* ta rgetInstance, SVGElement*& newTarget)
544 { 538 {
545 ASSERT(referencedScope()); 539 ASSERT(referencedScope());
546 Element* targetElement = SVGURIReference::targetElementFromIRIString(use->hr efString(), *referencedScope()); 540 Element* targetElement = SVGURIReference::targetElementFromIRIString(use->hr efString(), *referencedScope());
547 newTarget = 0; 541 newTarget = 0;
548 if (targetElement && targetElement->isSVGElement()) 542 if (targetElement && targetElement->isSVGElement())
549 newTarget = toSVGElement(targetElement); 543 newTarget = toSVGElement(targetElement);
550 544
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 829
836 if (m_resource) 830 if (m_resource)
837 m_resource->removeClient(this); 831 m_resource->removeClient(this);
838 832
839 m_resource = resource; 833 m_resource = resource;
840 if (m_resource) 834 if (m_resource)
841 m_resource->addClient(this); 835 m_resource->addClient(this);
842 } 836 }
843 837
844 } // namespace blink 838 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGUseElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698