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

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

Issue 1858163002: Rename inDocument() to inShadowIncludingDocument() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 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
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 if (document->isXMLDocument()) 115 if (document->isXMLDocument())
116 return static_cast<XMLDocumentParser*>(document->parser())->wellFormed() ; 116 return static_cast<XMLDocumentParser*>(document->parser())->wellFormed() ;
117 return true; 117 return true;
118 } 118 }
119 #endif 119 #endif
120 120
121 Node::InsertionNotificationRequest SVGUseElement::insertedInto(ContainerNode* ro otParent) 121 Node::InsertionNotificationRequest SVGUseElement::insertedInto(ContainerNode* ro otParent)
122 { 122 {
123 // This functions exists to assure assumptions made in the code regarding SV GElementInstance creation/destruction are satisfied. 123 // This functions exists to assure assumptions made in the code regarding SV GElementInstance creation/destruction are satisfied.
124 SVGGraphicsElement::insertedInto(rootParent); 124 SVGGraphicsElement::insertedInto(rootParent);
125 if (!rootParent->inDocument()) 125 if (!rootParent->inShadowIncludingDocument())
126 return InsertionDone; 126 return InsertionDone;
127 ASSERT(!m_targetElementInstance || !isWellFormedDocument(&document())); 127 ASSERT(!m_targetElementInstance || !isWellFormedDocument(&document()));
128 ASSERT(!hasPendingResources() || !isWellFormedDocument(&document())); 128 ASSERT(!hasPendingResources() || !isWellFormedDocument(&document()));
129 invalidateShadowTree(); 129 invalidateShadowTree();
130 return InsertionDone; 130 return InsertionDone;
131 } 131 }
132 132
133 void SVGUseElement::removedFrom(ContainerNode* rootParent) 133 void SVGUseElement::removedFrom(ContainerNode* rootParent)
134 { 134 {
135 SVGGraphicsElement::removedFrom(rootParent); 135 SVGGraphicsElement::removedFrom(rootParent);
136 if (rootParent->inDocument()) { 136 if (rootParent->inShadowIncludingDocument()) {
137 clearShadowTree(); 137 clearShadowTree();
138 cancelShadowTreeRecreation(); 138 cancelShadowTreeRecreation();
139 } 139 }
140 } 140 }
141 141
142 Document* SVGUseElement::externalDocument() const 142 Document* SVGUseElement::externalDocument() const
143 { 143 {
144 // Gracefully handle error condition. 144 // Gracefully handle error condition.
145 if (!resourceIsValid()) 145 if (!resourceIsValid())
146 return nullptr; 146 return nullptr;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 313
314 removeAllOutgoingReferences(); 314 removeAllOutgoingReferences();
315 } 315 }
316 316
317 void SVGUseElement::buildPendingResource() 317 void SVGUseElement::buildPendingResource()
318 { 318 {
319 if (inUseShadowTree()) 319 if (inUseShadowTree())
320 return; 320 return;
321 clearShadowTree(); 321 clearShadowTree();
322 cancelShadowTreeRecreation(); 322 cancelShadowTreeRecreation();
323 if (!inDocument()) 323 if (!inShadowIncludingDocument())
324 return; 324 return;
325 Document* externalDocument = this->externalDocument(); 325 Document* externalDocument = this->externalDocument();
326 if (isStructurallyExternal() && !externalDocument) 326 if (isStructurallyExternal() && !externalDocument)
327 return; 327 return;
328 328
329 AtomicString id; 329 AtomicString id;
330 Element* target = targetElementFromIRIString(hrefString(), treeScope(), &id, externalDocument); 330 Element* target = targetElementFromIRIString(hrefString(), treeScope(), &id, externalDocument);
331 if (!target || !target->inDocument()) { 331 if (!target || !target->inShadowIncludingDocument()) {
332 // If we can't find the target of an external element, just give up. 332 // If we can't find the target of an external element, just give up.
333 // We can't observe if the target somewhen enters the external document, nor should we do it. 333 // We can't observe if the target somewhen enters the external document, nor should we do it.
334 if (externalDocument) 334 if (externalDocument)
335 return; 335 return;
336 if (id.isEmpty()) 336 if (id.isEmpty())
337 return; 337 return;
338 338
339 document().accessSVGExtensions().addPendingResource(id, this); 339 document().accessSVGExtensions().addPendingResource(id, this);
340 ASSERT(hasPendingResources()); 340 ASSERT(hasPendingResources());
341 return; 341 return;
(...skipping 20 matching lines...) Expand all
362 } 362 }
363 363
364 // We don't walk the target tree element-by-element, and clone each element, 364 // We don't walk the target tree element-by-element, and clone each element,
365 // but instead use cloneNode(deep=true). This is an optimization for the common 365 // but instead use cloneNode(deep=true). This is an optimization for the common
366 // case where <use> doesn't contain disallowed elements (ie. <foreignObject>). 366 // case where <use> doesn't contain disallowed elements (ie. <foreignObject>).
367 // Though if there are disallowed elements in the subtree, we have to remove 367 // Though if there are disallowed elements in the subtree, we have to remove
368 // them. For instance: <use> on <g> containing <foreignObject> (indirect 368 // them. For instance: <use> on <g> containing <foreignObject> (indirect
369 // case). 369 // case).
370 static inline void removeDisallowedElementsFromSubtree(SVGElement& subtree) 370 static inline void removeDisallowedElementsFromSubtree(SVGElement& subtree)
371 { 371 {
372 ASSERT(!subtree.inDocument()); 372 ASSERT(!subtree.inShadowIncludingDocument());
373 Element* element = ElementTraversal::firstWithin(subtree); 373 Element* element = ElementTraversal::firstWithin(subtree);
374 while (element) { 374 while (element) {
375 if (isDisallowedElement(*element)) { 375 if (isDisallowedElement(*element)) {
376 Element* next = ElementTraversal::nextSkippingChildren(*element, &su btree); 376 Element* next = ElementTraversal::nextSkippingChildren(*element, &su btree);
377 // The subtree is not in document so this won't generate events that could mutate the tree. 377 // The subtree is not in document so this won't generate events that could mutate the tree.
378 element->parentNode()->removeChild(element); 378 element->parentNode()->removeChild(element);
379 element = next; 379 element = next;
380 } else { 380 } else {
381 element = ElementTraversal::next(*element, &subtree); 381 element = ElementTraversal::next(*element, &subtree);
382 } 382 }
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 } 645 }
646 646
647 void SVGUseElement::invalidateDependentShadowTrees() 647 void SVGUseElement::invalidateDependentShadowTrees()
648 { 648 {
649 // Recursively invalidate dependent <use> shadow trees 649 // Recursively invalidate dependent <use> shadow trees
650 const HeapHashSet<WeakMember<SVGElement>>& rawInstances = instancesForElemen t(); 650 const HeapHashSet<WeakMember<SVGElement>>& rawInstances = instancesForElemen t();
651 HeapVector<Member<SVGElement>> instances; 651 HeapVector<Member<SVGElement>> instances;
652 instances.appendRange(rawInstances.begin(), rawInstances.end()); 652 instances.appendRange(rawInstances.begin(), rawInstances.end());
653 for (auto& instance : instances) { 653 for (auto& instance : instances) {
654 if (SVGUseElement* element = instance->correspondingUseElement()) { 654 if (SVGUseElement* element = instance->correspondingUseElement()) {
655 ASSERT(element->inDocument()); 655 ASSERT(element->inShadowIncludingDocument());
656 element->invalidateShadowTree(); 656 element->invalidateShadowTree();
657 } 657 }
658 } 658 }
659 } 659 }
660 660
661 bool SVGUseElement::selfHasRelativeLengths() const 661 bool SVGUseElement::selfHasRelativeLengths() const
662 { 662 {
663 if (m_x->currentValue()->isRelative() 663 if (m_x->currentValue()->isRelative()
664 || m_y->currentValue()->isRelative() 664 || m_y->currentValue()->isRelative()
665 || m_width->currentValue()->isRelative() 665 || m_width->currentValue()->isRelative()
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 void SVGUseElement::dispatchPendingEvent(SVGUseEventSender* eventSender) 698 void SVGUseElement::dispatchPendingEvent(SVGUseEventSender* eventSender)
699 { 699 {
700 ASSERT_UNUSED(eventSender, eventSender == &svgUseLoadEventSender()); 700 ASSERT_UNUSED(eventSender, eventSender == &svgUseLoadEventSender());
701 ASSERT(isStructurallyExternal() && m_haveFiredLoadEvent); 701 ASSERT(isStructurallyExternal() && m_haveFiredLoadEvent);
702 dispatchEvent(Event::create(EventTypeNames::load)); 702 dispatchEvent(Event::create(EventTypeNames::load));
703 } 703 }
704 704
705 void SVGUseElement::notifyFinished(Resource* resource) 705 void SVGUseElement::notifyFinished(Resource* resource)
706 { 706 {
707 ASSERT(m_resource == resource); 707 ASSERT(m_resource == resource);
708 if (!inDocument()) 708 if (!inShadowIncludingDocument())
709 return; 709 return;
710 710
711 invalidateShadowTree(); 711 invalidateShadowTree();
712 if (!resourceIsValid()) { 712 if (!resourceIsValid()) {
713 dispatchEvent(Event::create(EventTypeNames::error)); 713 dispatchEvent(Event::create(EventTypeNames::error));
714 } else if (!resource->wasCanceled()) { 714 } else if (!resource->wasCanceled()) {
715 if (m_haveFiredLoadEvent) 715 if (m_haveFiredLoadEvent)
716 return; 716 return;
717 if (!isStructurallyExternal()) 717 if (!isStructurallyExternal())
718 return; 718 return;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 751
752 if (m_resource) 752 if (m_resource)
753 m_resource->removeClient(this); 753 m_resource->removeClient(this);
754 754
755 m_resource = resource; 755 m_resource = resource;
756 if (m_resource) 756 if (m_resource)
757 m_resource->addClient(this); 757 m_resource->addClient(this);
758 } 758 }
759 759
760 } // namespace blink 760 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698