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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGUseElement) | 64 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGUseElement) |
65 REGISTER_LOCAL_ANIMATED_PROPERTY(x) | 65 REGISTER_LOCAL_ANIMATED_PROPERTY(x) |
66 REGISTER_LOCAL_ANIMATED_PROPERTY(y) | 66 REGISTER_LOCAL_ANIMATED_PROPERTY(y) |
67 REGISTER_LOCAL_ANIMATED_PROPERTY(width) | 67 REGISTER_LOCAL_ANIMATED_PROPERTY(width) |
68 REGISTER_LOCAL_ANIMATED_PROPERTY(height) | 68 REGISTER_LOCAL_ANIMATED_PROPERTY(height) |
69 REGISTER_LOCAL_ANIMATED_PROPERTY(href) | 69 REGISTER_LOCAL_ANIMATED_PROPERTY(href) |
70 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) | 70 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) |
71 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) | 71 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) |
72 END_REGISTER_ANIMATED_PROPERTIES | 72 END_REGISTER_ANIMATED_PROPERTIES |
73 | 73 |
74 inline SVGUseElement::SVGUseElement(const QualifiedName& tagName, Document& docu
ment, bool wasInsertedByParser) | 74 inline SVGUseElement::SVGUseElement(Document& document, bool wasInsertedByParser
) |
75 : SVGGraphicsElement(tagName, document) | 75 : SVGGraphicsElement(SVGNames::useTag, document) |
76 , m_x(LengthModeWidth) | 76 , m_x(LengthModeWidth) |
77 , m_y(LengthModeHeight) | 77 , m_y(LengthModeHeight) |
78 , m_width(LengthModeWidth) | 78 , m_width(LengthModeWidth) |
79 , m_height(LengthModeHeight) | 79 , m_height(LengthModeHeight) |
80 , m_wasInsertedByParser(wasInsertedByParser) | 80 , m_wasInsertedByParser(wasInsertedByParser) |
81 , m_haveFiredLoadEvent(false) | 81 , m_haveFiredLoadEvent(false) |
82 , m_needsShadowTreeRecreation(false) | 82 , m_needsShadowTreeRecreation(false) |
83 , m_svgLoadEventTimer(this, &SVGElement::svgLoadEventTimerFired) | 83 , m_svgLoadEventTimer(this, &SVGElement::svgLoadEventTimerFired) |
84 { | 84 { |
85 ASSERT(hasCustomStyleCallbacks()); | 85 ASSERT(hasCustomStyleCallbacks()); |
86 ASSERT(hasTagName(SVGNames::useTag)); | |
87 ScriptWrappable::init(this); | 86 ScriptWrappable::init(this); |
88 registerAnimatedPropertiesForSVGUseElement(); | 87 registerAnimatedPropertiesForSVGUseElement(); |
89 } | 88 } |
90 | 89 |
91 PassRefPtr<SVGUseElement> SVGUseElement::create(const QualifiedName& tagName, Do
cument& document, bool wasInsertedByParser) | 90 PassRefPtr<SVGUseElement> SVGUseElement::create(Document& document, bool wasInse
rtedByParser) |
92 { | 91 { |
93 // Always build a #shadow-root for SVGUseElement. | 92 // Always build a #shadow-root for SVGUseElement. |
94 RefPtr<SVGUseElement> use = adoptRef(new SVGUseElement(tagName, document, wa
sInsertedByParser)); | 93 RefPtr<SVGUseElement> use = adoptRef(new SVGUseElement(document, wasInserted
ByParser)); |
95 use->ensureUserAgentShadowRoot(); | 94 use->ensureUserAgentShadowRoot(); |
96 return use.release(); | 95 return use.release(); |
97 } | 96 } |
98 | 97 |
99 SVGUseElement::~SVGUseElement() | 98 SVGUseElement::~SVGUseElement() |
100 { | 99 { |
101 setDocumentResource(0); | 100 setDocumentResource(0); |
102 | 101 |
103 clearResourceReferences(); | 102 clearResourceReferences(); |
104 } | 103 } |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 ASSERT(!use->resourceIsStillLoading()); | 715 ASSERT(!use->resourceIsStillLoading()); |
717 | 716 |
718 ASSERT(referencedDocument()); | 717 ASSERT(referencedDocument()); |
719 Element* targetElement = SVGURIReference::targetElementFromIRIString(use
->hrefCurrentValue(), *referencedDocument()); | 718 Element* targetElement = SVGURIReference::targetElementFromIRIString(use
->hrefCurrentValue(), *referencedDocument()); |
720 SVGElement* target = 0; | 719 SVGElement* target = 0; |
721 if (targetElement && targetElement->isSVGElement()) | 720 if (targetElement && targetElement->isSVGElement()) |
722 target = toSVGElement(targetElement); | 721 target = toSVGElement(targetElement); |
723 | 722 |
724 // Don't ASSERT(target) here, it may be "pending", too. | 723 // Don't ASSERT(target) here, it may be "pending", too. |
725 // Setup sub-shadow tree root node | 724 // Setup sub-shadow tree root node |
726 RefPtr<SVGGElement> cloneParent = SVGGElement::create(SVGNames::gTag, *r
eferencedDocument()); | 725 RefPtr<SVGGElement> cloneParent = SVGGElement::create(*referencedDocumen
t()); |
727 use->cloneChildNodes(cloneParent.get()); | 726 use->cloneChildNodes(cloneParent.get()); |
728 | 727 |
729 // Spec: In the generated content, the 'use' will be replaced by 'g', wh
ere all attributes from the | 728 // Spec: In the generated content, the 'use' will be replaced by 'g', wh
ere all attributes from the |
730 // 'use' element except for x, y, width, height and xlink:href are trans
ferred to the generated 'g' element. | 729 // 'use' element except for x, y, width, height and xlink:href are trans
ferred to the generated 'g' element. |
731 transferUseAttributesToReplacedElement(use, cloneParent.get()); | 730 transferUseAttributesToReplacedElement(use, cloneParent.get()); |
732 | 731 |
733 if (target && !isDisallowedElement(target)) { | 732 if (target && !isDisallowedElement(target)) { |
734 RefPtr<Element> newChild = target->cloneElementWithChildren(); | 733 RefPtr<Element> newChild = target->cloneElementWithChildren(); |
735 ASSERT(newChild->isSVGElement()); | 734 ASSERT(newChild->isSVGElement()); |
736 cloneParent->appendChild(newChild.release()); | 735 cloneParent->appendChild(newChild.release()); |
(...skipping 27 matching lines...) Expand all Loading... |
764 void SVGUseElement::expandSymbolElementsInShadowTree(Node* element) | 763 void SVGUseElement::expandSymbolElementsInShadowTree(Node* element) |
765 { | 764 { |
766 if (element->hasTagName(SVGNames::symbolTag)) { | 765 if (element->hasTagName(SVGNames::symbolTag)) { |
767 // Spec: The referenced 'symbol' and its contents are deep-cloned into t
he generated tree, | 766 // Spec: The referenced 'symbol' and its contents are deep-cloned into t
he generated tree, |
768 // with the exception that the 'symbol' is replaced by an 'svg'. This ge
nerated 'svg' will | 767 // with the exception that the 'symbol' is replaced by an 'svg'. This ge
nerated 'svg' will |
769 // always have explicit values for attributes width and height. If attri
butes width and/or | 768 // always have explicit values for attributes width and height. If attri
butes width and/or |
770 // height are provided on the 'use' element, then these attributes will
be transferred to | 769 // height are provided on the 'use' element, then these attributes will
be transferred to |
771 // the generated 'svg'. If attributes width and/or height are not specif
ied, the generated | 770 // the generated 'svg'. If attributes width and/or height are not specif
ied, the generated |
772 // 'svg' element will use values of 100% for these attributes. | 771 // 'svg' element will use values of 100% for these attributes. |
773 ASSERT(referencedDocument()); | 772 ASSERT(referencedDocument()); |
774 RefPtr<SVGSVGElement> svgElement = SVGSVGElement::create(SVGNames::svgTa
g, *referencedDocument()); | 773 RefPtr<SVGSVGElement> svgElement = SVGSVGElement::create(*referencedDocu
ment()); |
775 | 774 |
776 // Transfer all data (attributes, etc.) from <symbol> to the new <svg> e
lement. | 775 // Transfer all data (attributes, etc.) from <symbol> to the new <svg> e
lement. |
777 svgElement->cloneDataFromElement(*toElement(element)); | 776 svgElement->cloneDataFromElement(*toElement(element)); |
778 | 777 |
779 // Only clone symbol children, and add them to the new <svg> element | 778 // Only clone symbol children, and add them to the new <svg> element |
780 for (Node* child = element->firstChild(); child; child = child->nextSibl
ing()) { | 779 for (Node* child = element->firstChild(); child; child = child->nextSibl
ing()) { |
781 RefPtr<Node> newChild = child->cloneNode(true); | 780 RefPtr<Node> newChild = child->cloneNode(true); |
782 svgElement->appendChild(newChild.release()); | 781 svgElement->appendChild(newChild.release()); |
783 } | 782 } |
784 | 783 |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 | 994 |
996 if (m_resource) | 995 if (m_resource) |
997 m_resource->removeClient(this); | 996 m_resource->removeClient(this); |
998 | 997 |
999 m_resource = resource; | 998 m_resource = resource; |
1000 if (m_resource) | 999 if (m_resource) |
1001 m_resource->addClient(this); | 1000 m_resource->addClient(this); |
1002 } | 1001 } |
1003 | 1002 |
1004 } | 1003 } |
OLD | NEW |