| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 182 |
| 183 void SVGUseElement::removedFrom(ContainerNode* rootParent) | 183 void SVGUseElement::removedFrom(ContainerNode* rootParent) |
| 184 { | 184 { |
| 185 SVGGraphicsElement::removedFrom(rootParent); | 185 SVGGraphicsElement::removedFrom(rootParent); |
| 186 if (rootParent->inDocument()) | 186 if (rootParent->inDocument()) |
| 187 clearResourceReferences(); | 187 clearResourceReferences(); |
| 188 } | 188 } |
| 189 | 189 |
| 190 Document* SVGUseElement::referencedDocument() const | 190 Document* SVGUseElement::referencedDocument() const |
| 191 { | 191 { |
| 192 if (!isExternalURIReference(hrefCurrentValue(), &document())) | 192 if (!isExternalURIReference(hrefCurrentValue(), document())) |
| 193 return &document(); | 193 return &document(); |
| 194 return externalDocument(); | 194 return externalDocument(); |
| 195 } | 195 } |
| 196 | 196 |
| 197 Document* SVGUseElement::externalDocument() const | 197 Document* SVGUseElement::externalDocument() const |
| 198 { | 198 { |
| 199 if (m_resource && m_resource->isLoaded()) { | 199 if (m_resource && m_resource->isLoaded()) { |
| 200 // Gracefully handle error condition. | 200 // Gracefully handle error condition. |
| 201 if (m_resource->errorOccurred()) | 201 if (m_resource->errorOccurred()) |
| 202 return 0; | 202 return 0; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 223 updateRelativeLengthsInformation(); | 223 updateRelativeLengthsInformation(); |
| 224 if (renderer) | 224 if (renderer) |
| 225 RenderSVGResource::markForLayoutAndParentResourceInvalidation(render
er); | 225 RenderSVGResource::markForLayoutAndParentResourceInvalidation(render
er); |
| 226 return; | 226 return; |
| 227 } | 227 } |
| 228 | 228 |
| 229 if (SVGExternalResourcesRequired::handleAttributeChange(this, attrName)) | 229 if (SVGExternalResourcesRequired::handleAttributeChange(this, attrName)) |
| 230 return; | 230 return; |
| 231 | 231 |
| 232 if (SVGURIReference::isKnownAttribute(attrName)) { | 232 if (SVGURIReference::isKnownAttribute(attrName)) { |
| 233 bool isExternalReference = isExternalURIReference(hrefCurrentValue(), &d
ocument()); | 233 bool isExternalReference = isExternalURIReference(hrefCurrentValue(), do
cument()); |
| 234 if (isExternalReference) { | 234 if (isExternalReference) { |
| 235 KURL url = document().completeURL(hrefCurrentValue()); | 235 KURL url = document().completeURL(hrefCurrentValue()); |
| 236 if (url.hasFragmentIdentifier()) { | 236 if (url.hasFragmentIdentifier()) { |
| 237 FetchRequest request(ResourceRequest(url.string()), localName())
; | 237 FetchRequest request(ResourceRequest(url.string()), localName())
; |
| 238 setDocumentResource(document().fetcher()->fetchSVGDocument(reque
st)); | 238 setDocumentResource(document().fetcher()->fetchSVGDocument(reque
st)); |
| 239 } | 239 } |
| 240 } else { | 240 } else { |
| 241 setDocumentResource(0); | 241 setDocumentResource(0); |
| 242 } | 242 } |
| 243 | 243 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 | 399 |
| 400 void SVGUseElement::buildPendingResource() | 400 void SVGUseElement::buildPendingResource() |
| 401 { | 401 { |
| 402 if (!referencedDocument() || isInShadowTree()) | 402 if (!referencedDocument() || isInShadowTree()) |
| 403 return; | 403 return; |
| 404 clearResourceReferences(); | 404 clearResourceReferences(); |
| 405 if (!inDocument()) | 405 if (!inDocument()) |
| 406 return; | 406 return; |
| 407 | 407 |
| 408 String id; | 408 String id; |
| 409 Element* target = SVGURIReference::targetElementFromIRIString(hrefCurrentVal
ue(), &document(), &id, externalDocument()); | 409 Element* target = SVGURIReference::targetElementFromIRIString(hrefCurrentVal
ue(), document(), &id, externalDocument()); |
| 410 if (!target || !target->inDocument()) { | 410 if (!target || !target->inDocument()) { |
| 411 // If we can't find the target of an external element, just give up. | 411 // If we can't find the target of an external element, just give up. |
| 412 // We can't observe if the target somewhen enters the external document,
nor should we do it. | 412 // We can't observe if the target somewhen enters the external document,
nor should we do it. |
| 413 if (externalDocument()) | 413 if (externalDocument()) |
| 414 return; | 414 return; |
| 415 if (id.isEmpty()) | 415 if (id.isEmpty()) |
| 416 return; | 416 return; |
| 417 | 417 |
| 418 referencedDocument()->accessSVGExtensions()->addPendingResource(id, this
); | 418 referencedDocument()->accessSVGExtensions()->addPendingResource(id, this
); |
| 419 ASSERT(hasPendingResources()); | 419 ASSERT(hasPendingResources()); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 return; | 633 return; |
| 634 | 634 |
| 635 RefPtr<SVGElementInstance> newInstance = SVGElementInstance::create(this, to
SVGUseElement(target), newTarget); | 635 RefPtr<SVGElementInstance> newInstance = SVGElementInstance::create(this, to
SVGUseElement(target), newTarget); |
| 636 SVGElementInstance* newInstancePtr = newInstance.get(); | 636 SVGElementInstance* newInstancePtr = newInstance.get(); |
| 637 targetInstance->appendChild(newInstance.release()); | 637 targetInstance->appendChild(newInstance.release()); |
| 638 buildInstanceTree(newTarget, newInstancePtr, foundProblem, foundUse); | 638 buildInstanceTree(newTarget, newInstancePtr, foundProblem, foundUse); |
| 639 } | 639 } |
| 640 | 640 |
| 641 bool SVGUseElement::hasCycleUseReferencing(SVGUseElement* use, SVGElementInstanc
e* targetInstance, SVGElement*& newTarget) | 641 bool SVGUseElement::hasCycleUseReferencing(SVGUseElement* use, SVGElementInstanc
e* targetInstance, SVGElement*& newTarget) |
| 642 { | 642 { |
| 643 Element* targetElement = SVGURIReference::targetElementFromIRIString(use->hr
efCurrentValue(), referencedDocument()); | 643 ASSERT(referencedDocument()); |
| 644 Element* targetElement = SVGURIReference::targetElementFromIRIString(use->hr
efCurrentValue(), *referencedDocument()); |
| 644 newTarget = 0; | 645 newTarget = 0; |
| 645 if (targetElement && targetElement->isSVGElement()) | 646 if (targetElement && targetElement->isSVGElement()) |
| 646 newTarget = toSVGElement(targetElement); | 647 newTarget = toSVGElement(targetElement); |
| 647 | 648 |
| 648 if (!newTarget) | 649 if (!newTarget) |
| 649 return false; | 650 return false; |
| 650 | 651 |
| 651 // Shortcut for self-references | 652 // Shortcut for self-references |
| 652 if (newTarget == this) | 653 if (newTarget == this) |
| 653 return true; | 654 return true; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 // do this directly in buildShadowTree, if we encounter a <use> element? | 706 // do this directly in buildShadowTree, if we encounter a <use> element? |
| 706 // | 707 // |
| 707 // Short answer: Because we may miss to expand some elements. Ie. if a <symb
ol> | 708 // Short answer: Because we may miss to expand some elements. Ie. if a <symb
ol> |
| 708 // contains <use> tags, we'd miss them. So once we're done with settin' up t
he | 709 // contains <use> tags, we'd miss them. So once we're done with settin' up t
he |
| 709 // actual shadow tree (after the special case modification for svg/symbol) w
e have | 710 // actual shadow tree (after the special case modification for svg/symbol) w
e have |
| 710 // to walk it completely and expand all <use> elements. | 711 // to walk it completely and expand all <use> elements. |
| 711 if (element->hasTagName(SVGNames::useTag)) { | 712 if (element->hasTagName(SVGNames::useTag)) { |
| 712 SVGUseElement* use = toSVGUseElement(element); | 713 SVGUseElement* use = toSVGUseElement(element); |
| 713 ASSERT(!use->resourceIsStillLoading()); | 714 ASSERT(!use->resourceIsStillLoading()); |
| 714 | 715 |
| 715 Element* targetElement = SVGURIReference::targetElementFromIRIString(use
->hrefCurrentValue(), referencedDocument()); | 716 ASSERT(referencedDocument()); |
| 717 Element* targetElement = SVGURIReference::targetElementFromIRIString(use
->hrefCurrentValue(), *referencedDocument()); |
| 716 SVGElement* target = 0; | 718 SVGElement* target = 0; |
| 717 if (targetElement && targetElement->isSVGElement()) | 719 if (targetElement && targetElement->isSVGElement()) |
| 718 target = toSVGElement(targetElement); | 720 target = toSVGElement(targetElement); |
| 719 | 721 |
| 720 // Don't ASSERT(target) here, it may be "pending", too. | 722 // Don't ASSERT(target) here, it may be "pending", too. |
| 721 // Setup sub-shadow tree root node | 723 // Setup sub-shadow tree root node |
| 722 RefPtr<SVGGElement> cloneParent = SVGGElement::create(SVGNames::gTag, re
ferencedDocument()); | 724 RefPtr<SVGGElement> cloneParent = SVGGElement::create(SVGNames::gTag, re
ferencedDocument()); |
| 723 use->cloneChildNodes(cloneParent.get()); | 725 use->cloneChildNodes(cloneParent.get()); |
| 724 | 726 |
| 725 // Spec: In the generated content, the 'use' will be replaced by 'g', wh
ere all attributes from the | 727 // Spec: In the generated content, the 'use' will be replaced by 'g', wh
ere all attributes from the |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 | 992 |
| 991 if (m_resource) | 993 if (m_resource) |
| 992 m_resource->removeClient(this); | 994 m_resource->removeClient(this); |
| 993 | 995 |
| 994 m_resource = resource; | 996 m_resource = resource; |
| 995 if (m_resource) | 997 if (m_resource) |
| 996 m_resource->addClient(this); | 998 m_resource->addClient(this); |
| 997 } | 999 } |
| 998 | 1000 |
| 999 } | 1001 } |
| OLD | NEW |