| OLD | NEW |
| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 if (document->isXMLDocument()) | 107 if (document->isXMLDocument()) |
| 108 return static_cast<XMLDocumentParser*>(document->parser())->wellFormed()
; | 108 return static_cast<XMLDocumentParser*>(document->parser())->wellFormed()
; |
| 109 return true; | 109 return true; |
| 110 } | 110 } |
| 111 #endif | 111 #endif |
| 112 | 112 |
| 113 Node::InsertionNotificationRequest SVGUseElement::insertedInto(ContainerNode* ro
otParent) | 113 Node::InsertionNotificationRequest SVGUseElement::insertedInto(ContainerNode* ro
otParent) |
| 114 { | 114 { |
| 115 // This functions exists to assure assumptions made in the code regarding SV
GElementInstance creation/destruction are satisfied. | 115 // This functions exists to assure assumptions made in the code regarding SV
GElementInstance creation/destruction are satisfied. |
| 116 SVGGraphicsElement::insertedInto(rootParent); | 116 SVGGraphicsElement::insertedInto(rootParent); |
| 117 if (!rootParent->inShadowIncludingDocument()) | 117 if (!rootParent->isConnected()) |
| 118 return InsertionDone; | 118 return InsertionDone; |
| 119 ASSERT(!m_targetElementInstance || !isWellFormedDocument(&document())); | 119 ASSERT(!m_targetElementInstance || !isWellFormedDocument(&document())); |
| 120 ASSERT(!hasPendingResources() || !isWellFormedDocument(&document())); | 120 ASSERT(!hasPendingResources() || !isWellFormedDocument(&document())); |
| 121 invalidateShadowTree(); | 121 invalidateShadowTree(); |
| 122 return InsertionDone; | 122 return InsertionDone; |
| 123 } | 123 } |
| 124 | 124 |
| 125 void SVGUseElement::removedFrom(ContainerNode* rootParent) | 125 void SVGUseElement::removedFrom(ContainerNode* rootParent) |
| 126 { | 126 { |
| 127 SVGGraphicsElement::removedFrom(rootParent); | 127 SVGGraphicsElement::removedFrom(rootParent); |
| 128 if (rootParent->inShadowIncludingDocument()) { | 128 if (rootParent->isConnected()) { |
| 129 clearShadowTree(); | 129 clearShadowTree(); |
| 130 cancelShadowTreeRecreation(); | 130 cancelShadowTreeRecreation(); |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 | 133 |
| 134 Document* SVGUseElement::externalDocument() const | 134 Document* SVGUseElement::externalDocument() const |
| 135 { | 135 { |
| 136 // Gracefully handle error condition. | 136 // Gracefully handle error condition. |
| 137 if (!resourceIsValid()) | 137 if (!resourceIsValid()) |
| 138 return nullptr; | 138 return nullptr; |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 | 304 |
| 305 removeAllOutgoingReferences(); | 305 removeAllOutgoingReferences(); |
| 306 } | 306 } |
| 307 | 307 |
| 308 void SVGUseElement::buildPendingResource() | 308 void SVGUseElement::buildPendingResource() |
| 309 { | 309 { |
| 310 if (inUseShadowTree()) | 310 if (inUseShadowTree()) |
| 311 return; | 311 return; |
| 312 clearShadowTree(); | 312 clearShadowTree(); |
| 313 cancelShadowTreeRecreation(); | 313 cancelShadowTreeRecreation(); |
| 314 if (!inShadowIncludingDocument()) | 314 if (!isConnected()) |
| 315 return; | 315 return; |
| 316 Document* externalDocument = this->externalDocument(); | 316 Document* externalDocument = this->externalDocument(); |
| 317 if (isStructurallyExternal() && !externalDocument) | 317 if (isStructurallyExternal() && !externalDocument) |
| 318 return; | 318 return; |
| 319 | 319 |
| 320 AtomicString id; | 320 AtomicString id; |
| 321 Element* target = targetElementFromIRIString(hrefString(), treeScope(), &id,
externalDocument); | 321 Element* target = targetElementFromIRIString(hrefString(), treeScope(), &id,
externalDocument); |
| 322 if (!target || !target->inShadowIncludingDocument()) { | 322 if (!target || !target->isConnected()) { |
| 323 // If we can't find the target of an external element, just give up. | 323 // If we can't find the target of an external element, just give up. |
| 324 // We can't observe if the target somewhen enters the external document,
nor should we do it. | 324 // We can't observe if the target somewhen enters the external document,
nor should we do it. |
| 325 if (externalDocument) | 325 if (externalDocument) |
| 326 return; | 326 return; |
| 327 if (id.isEmpty()) | 327 if (id.isEmpty()) |
| 328 return; | 328 return; |
| 329 | 329 |
| 330 document().accessSVGExtensions().addPendingResource(id, this); | 330 document().accessSVGExtensions().addPendingResource(id, this); |
| 331 ASSERT(hasPendingResources()); | 331 ASSERT(hasPendingResources()); |
| 332 return; | 332 return; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 353 } | 353 } |
| 354 | 354 |
| 355 // We don't walk the target tree element-by-element, and clone each element, | 355 // We don't walk the target tree element-by-element, and clone each element, |
| 356 // but instead use cloneNode(deep=true). This is an optimization for the common | 356 // but instead use cloneNode(deep=true). This is an optimization for the common |
| 357 // case where <use> doesn't contain disallowed elements (ie. <foreignObject>). | 357 // case where <use> doesn't contain disallowed elements (ie. <foreignObject>). |
| 358 // Though if there are disallowed elements in the subtree, we have to remove | 358 // Though if there are disallowed elements in the subtree, we have to remove |
| 359 // them. For instance: <use> on <g> containing <foreignObject> (indirect | 359 // them. For instance: <use> on <g> containing <foreignObject> (indirect |
| 360 // case). | 360 // case). |
| 361 static inline void removeDisallowedElementsFromSubtree(SVGElement& subtree) | 361 static inline void removeDisallowedElementsFromSubtree(SVGElement& subtree) |
| 362 { | 362 { |
| 363 ASSERT(!subtree.inShadowIncludingDocument()); | 363 ASSERT(!subtree.isConnected()); |
| 364 Element* element = ElementTraversal::firstWithin(subtree); | 364 Element* element = ElementTraversal::firstWithin(subtree); |
| 365 while (element) { | 365 while (element) { |
| 366 if (isDisallowedElement(*element)) { | 366 if (isDisallowedElement(*element)) { |
| 367 Element* next = ElementTraversal::nextSkippingChildren(*element, &su
btree); | 367 Element* next = ElementTraversal::nextSkippingChildren(*element, &su
btree); |
| 368 // The subtree is not in document so this won't generate events that
could mutate the tree. | 368 // The subtree is not in document so this won't generate events that
could mutate the tree. |
| 369 element->parentNode()->removeChild(element); | 369 element->parentNode()->removeChild(element); |
| 370 element = next; | 370 element = next; |
| 371 } else { | 371 } else { |
| 372 element = ElementTraversal::next(*element, &subtree); | 372 element = ElementTraversal::next(*element, &subtree); |
| 373 } | 373 } |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 } | 642 } |
| 643 | 643 |
| 644 void SVGUseElement::invalidateDependentShadowTrees() | 644 void SVGUseElement::invalidateDependentShadowTrees() |
| 645 { | 645 { |
| 646 // Recursively invalidate dependent <use> shadow trees | 646 // Recursively invalidate dependent <use> shadow trees |
| 647 const HeapHashSet<WeakMember<SVGElement>>& rawInstances = instancesForElemen
t(); | 647 const HeapHashSet<WeakMember<SVGElement>>& rawInstances = instancesForElemen
t(); |
| 648 HeapVector<Member<SVGElement>> instances; | 648 HeapVector<Member<SVGElement>> instances; |
| 649 instances.appendRange(rawInstances.begin(), rawInstances.end()); | 649 instances.appendRange(rawInstances.begin(), rawInstances.end()); |
| 650 for (auto& instance : instances) { | 650 for (auto& instance : instances) { |
| 651 if (SVGUseElement* element = instance->correspondingUseElement()) { | 651 if (SVGUseElement* element = instance->correspondingUseElement()) { |
| 652 ASSERT(element->inShadowIncludingDocument()); | 652 ASSERT(element->isConnected()); |
| 653 element->invalidateShadowTree(); | 653 element->invalidateShadowTree(); |
| 654 } | 654 } |
| 655 } | 655 } |
| 656 } | 656 } |
| 657 | 657 |
| 658 bool SVGUseElement::selfHasRelativeLengths() const | 658 bool SVGUseElement::selfHasRelativeLengths() const |
| 659 { | 659 { |
| 660 if (m_x->currentValue()->isRelative() | 660 if (m_x->currentValue()->isRelative() |
| 661 || m_y->currentValue()->isRelative() | 661 || m_y->currentValue()->isRelative() |
| 662 || m_width->currentValue()->isRelative() | 662 || m_width->currentValue()->isRelative() |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 void SVGUseElement::dispatchPendingEvent(SVGUseEventSender* eventSender) | 695 void SVGUseElement::dispatchPendingEvent(SVGUseEventSender* eventSender) |
| 696 { | 696 { |
| 697 ASSERT_UNUSED(eventSender, eventSender == &svgUseLoadEventSender()); | 697 ASSERT_UNUSED(eventSender, eventSender == &svgUseLoadEventSender()); |
| 698 ASSERT(isStructurallyExternal() && m_haveFiredLoadEvent); | 698 ASSERT(isStructurallyExternal() && m_haveFiredLoadEvent); |
| 699 dispatchEvent(Event::create(EventTypeNames::load)); | 699 dispatchEvent(Event::create(EventTypeNames::load)); |
| 700 } | 700 } |
| 701 | 701 |
| 702 void SVGUseElement::notifyFinished(Resource* resource) | 702 void SVGUseElement::notifyFinished(Resource* resource) |
| 703 { | 703 { |
| 704 ASSERT(m_resource == resource); | 704 ASSERT(m_resource == resource); |
| 705 if (!inShadowIncludingDocument()) | 705 if (!isConnected()) |
| 706 return; | 706 return; |
| 707 | 707 |
| 708 invalidateShadowTree(); | 708 invalidateShadowTree(); |
| 709 if (!resourceIsValid()) { | 709 if (!resourceIsValid()) { |
| 710 dispatchEvent(Event::create(EventTypeNames::error)); | 710 dispatchEvent(Event::create(EventTypeNames::error)); |
| 711 } else if (!resource->wasCanceled()) { | 711 } else if (!resource->wasCanceled()) { |
| 712 if (m_haveFiredLoadEvent) | 712 if (m_haveFiredLoadEvent) |
| 713 return; | 713 return; |
| 714 if (!isStructurallyExternal()) | 714 if (!isStructurallyExternal()) |
| 715 return; | 715 return; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 | 748 |
| 749 if (m_resource) | 749 if (m_resource) |
| 750 m_resource->removeClient(this); | 750 m_resource->removeClient(this); |
| 751 | 751 |
| 752 m_resource = resource; | 752 m_resource = resource; |
| 753 if (m_resource) | 753 if (m_resource) |
| 754 m_resource->addClient(this); | 754 m_resource->addClient(this); |
| 755 } | 755 } |
| 756 | 756 |
| 757 } // namespace blink | 757 } // namespace blink |
| OLD | NEW |