| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 void SVGUseElement::removedFrom(ContainerNode* rootParent) | 120 void SVGUseElement::removedFrom(ContainerNode* rootParent) |
| 121 { | 121 { |
| 122 SVGGraphicsElement::removedFrom(rootParent); | 122 SVGGraphicsElement::removedFrom(rootParent); |
| 123 if (rootParent->inDocument()) | 123 if (rootParent->inDocument()) |
| 124 clearResourceReferences(); | 124 clearResourceReferences(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 TreeScope* SVGUseElement::referencedScope() const | 127 TreeScope* SVGUseElement::referencedScope() const |
| 128 { | 128 { |
| 129 if (!isExternalURIReference(hrefString(), document())) | 129 if (isStructurallyExternal()) |
| 130 return &treeScope(); | 130 return externalDocument(); |
| 131 return externalDocument(); | 131 return &treeScope(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 Document* SVGUseElement::externalDocument() const | 134 Document* SVGUseElement::externalDocument() const |
| 135 { | 135 { |
| 136 if (m_resource && m_resource->isLoaded()) { | 136 if (m_resource && m_resource->isLoaded()) { |
| 137 // Gracefully handle error condition. | 137 // Gracefully handle error condition. |
| 138 if (m_resource->errorOccurred()) | 138 if (m_resource->errorOccurred()) |
| 139 return nullptr; | 139 return nullptr; |
| 140 ASSERT(m_resource->document()); | 140 ASSERT(m_resource->document()); |
| 141 return m_resource->document(); | 141 return m_resource->document(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 } | 215 } |
| 216 | 216 |
| 217 LayoutObject* object = this->layoutObject(); | 217 LayoutObject* object = this->layoutObject(); |
| 218 if (object) | 218 if (object) |
| 219 markForLayoutAndParentResourceInvalidation(object); | 219 markForLayoutAndParentResourceInvalidation(object); |
| 220 return; | 220 return; |
| 221 } | 221 } |
| 222 | 222 |
| 223 if (SVGURIReference::isKnownAttribute(attrName)) { | 223 if (SVGURIReference::isKnownAttribute(attrName)) { |
| 224 SVGElement::InvalidationGuard invalidationGuard(this); | 224 SVGElement::InvalidationGuard invalidationGuard(this); |
| 225 bool isExternalReference = isExternalURIReference(hrefString(), document
()); | 225 if (isStructurallyExternal()) { |
| 226 if (isExternalReference) { | |
| 227 KURL url = document().completeURL(hrefString()); | 226 KURL url = document().completeURL(hrefString()); |
| 228 if (url.hasFragmentIdentifier()) { | 227 if (url.hasFragmentIdentifier()) { |
| 229 FetchRequest request(ResourceRequest(url), localName()); | 228 FetchRequest request(ResourceRequest(url), localName()); |
| 230 setDocumentResource(DocumentResource::fetchSVGDocument(request,
document().fetcher())); | 229 setDocumentResource(DocumentResource::fetchSVGDocument(request,
document().fetcher())); |
| 231 } | 230 } |
| 232 } else { | 231 } else { |
| 233 setDocumentResource(0); | 232 setDocumentResource(0); |
| 234 } | 233 } |
| 235 | 234 |
| 236 invalidateShadowTree(); | 235 invalidateShadowTree(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 for (Node* cur = start->firstChild(); cur; cur = cur->nextSibling()) { | 289 for (Node* cur = start->firstChild(); cur; cur = cur->nextSibling()) { |
| 291 if (subtreeContainsDisallowedElement(cur)) | 290 if (subtreeContainsDisallowedElement(cur)) |
| 292 return true; | 291 return true; |
| 293 } | 292 } |
| 294 | 293 |
| 295 return false; | 294 return false; |
| 296 } | 295 } |
| 297 | 296 |
| 298 void SVGUseElement::scheduleShadowTreeRecreation() | 297 void SVGUseElement::scheduleShadowTreeRecreation() |
| 299 { | 298 { |
| 300 if (!referencedScope() || inUseShadowTree()) | 299 if (inUseShadowTree()) |
| 301 return; | 300 return; |
| 302 m_needsShadowTreeRecreation = true; | 301 m_needsShadowTreeRecreation = true; |
| 303 document().scheduleUseShadowTreeUpdate(*this); | 302 document().scheduleUseShadowTreeUpdate(*this); |
| 304 } | 303 } |
| 305 | 304 |
| 306 void SVGUseElement::clearResourceReferences() | 305 void SVGUseElement::clearResourceReferences() |
| 307 { | 306 { |
| 308 if (m_targetElementInstance) | 307 if (m_targetElementInstance) |
| 309 m_targetElementInstance = nullptr; | 308 m_targetElementInstance = nullptr; |
| 310 | 309 |
| 311 // FIXME: We should try to optimize this, to at least allow partial reclones
. | 310 // FIXME: We should try to optimize this, to at least allow partial reclones
. |
| 312 if (ShadowRoot* shadowTreeRootElement = userAgentShadowRoot()) | 311 if (ShadowRoot* shadowTreeRootElement = userAgentShadowRoot()) |
| 313 shadowTreeRootElement->removeChildren(OmitSubtreeModifiedEvent); | 312 shadowTreeRootElement->removeChildren(OmitSubtreeModifiedEvent); |
| 314 | 313 |
| 315 m_needsShadowTreeRecreation = false; | 314 m_needsShadowTreeRecreation = false; |
| 316 document().unscheduleUseShadowTreeUpdate(*this); | 315 document().unscheduleUseShadowTreeUpdate(*this); |
| 317 | 316 |
| 318 removeAllOutgoingReferences(); | 317 removeAllOutgoingReferences(); |
| 319 } | 318 } |
| 320 | 319 |
| 321 void SVGUseElement::buildPendingResource() | 320 void SVGUseElement::buildPendingResource() |
| 322 { | 321 { |
| 323 if (!referencedScope() || inUseShadowTree()) | 322 if (inUseShadowTree()) |
| 324 return; | 323 return; |
| 325 clearResourceReferences(); | 324 clearResourceReferences(); |
| 326 if (!inDocument()) | 325 if (!referencedScope() || !inDocument()) |
| 327 return; | 326 return; |
| 328 | 327 |
| 329 AtomicString id; | 328 AtomicString id; |
| 330 Element* target = SVGURIReference::targetElementFromIRIString(hrefString(),
treeScope(), &id, externalDocument()); | 329 Element* target = SVGURIReference::targetElementFromIRIString(hrefString(),
treeScope(), &id, externalDocument()); |
| 331 if (!target || !target->inDocument()) { | 330 if (!target || !target->inDocument()) { |
| 332 // If we can't find the target of an external element, just give up. | 331 // 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. | 332 // We can't observe if the target somewhen enters the external document,
nor should we do it. |
| 334 if (externalDocument()) | 333 if (externalDocument()) |
| 335 return; | 334 return; |
| 336 if (id.isEmpty()) | 335 if (id.isEmpty()) |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 | 782 |
| 784 if (m_resource) | 783 if (m_resource) |
| 785 m_resource->removeClient(this); | 784 m_resource->removeClient(this); |
| 786 | 785 |
| 787 m_resource = resource; | 786 m_resource = resource; |
| 788 if (m_resource) | 787 if (m_resource) |
| 789 m_resource->addClient(this); | 788 m_resource->addClient(this); |
| 790 } | 789 } |
| 791 | 790 |
| 792 } | 791 } |
| OLD | NEW |