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 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 | 643 |
644 ASSERT(referencedScope()); | 644 ASSERT(referencedScope()); |
645 Element* targetElement = SVGURIReference::targetElementFromIRIString(use
->hrefString(), *referencedScope()); | 645 Element* targetElement = SVGURIReference::targetElementFromIRIString(use
->hrefString(), *referencedScope()); |
646 SVGElement* target = 0; | 646 SVGElement* target = 0; |
647 if (targetElement && targetElement->isSVGElement()) | 647 if (targetElement && targetElement->isSVGElement()) |
648 target = toSVGElement(targetElement); | 648 target = toSVGElement(targetElement); |
649 | 649 |
650 // Don't ASSERT(target) here, it may be "pending", too. | 650 // Don't ASSERT(target) here, it may be "pending", too. |
651 // Setup sub-shadow tree root node | 651 // Setup sub-shadow tree root node |
652 RefPtr<SVGGElement> cloneParent = SVGGElement::create(referencedScope()-
>document()); | 652 RefPtr<SVGGElement> cloneParent = SVGGElement::create(referencedScope()-
>document()); |
653 use->cloneChildNodes(cloneParent.get()); | 653 for (Node* child = use->firstChild(); child;) { |
| 654 Node* oldChild = child; |
| 655 child = child->nextSibling(); |
| 656 cloneParent->appendChild(oldChild); |
| 657 } |
654 | 658 |
655 // Spec: In the generated content, the 'use' will be replaced by 'g', wh
ere all attributes from the | 659 // Spec: In the generated content, the 'use' will be replaced by 'g', wh
ere all attributes from the |
656 // 'use' element except for x, y, width, height and xlink:href are trans
ferred to the generated 'g' element. | 660 // 'use' element except for x, y, width, height and xlink:href are trans
ferred to the generated 'g' element. |
657 transferUseAttributesToReplacedElement(use, cloneParent.get()); | 661 transferUseAttributesToReplacedElement(use, cloneParent.get()); |
658 | 662 |
659 if (target && !isDisallowedElement(target)) { | 663 if (target && !isDisallowedElement(target)) { |
660 RefPtr<Element> newChild = target->cloneElementWithChildren(); | 664 RefPtr<Element> newChild = target->cloneElementWithChildren(); |
661 ASSERT(newChild->isSVGElement()); | 665 ASSERT(newChild->isSVGElement()); |
662 transferUseWidthAndHeightIfNeeded(*use, toSVGElement(newChild.get())
, *target); | 666 transferUseWidthAndHeightIfNeeded(*use, toSVGElement(newChild.get())
, *target); |
663 cloneParent->appendChild(newChild.release()); | 667 cloneParent->appendChild(newChild.release()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 // height are provided on the 'use' element, then these attributes will
be transferred to | 702 // height are provided on the 'use' element, then these attributes will
be transferred to |
699 // the generated 'svg'. If attributes width and/or height are not specif
ied, the generated | 703 // the generated 'svg'. If attributes width and/or height are not specif
ied, the generated |
700 // 'svg' element will use values of 100% for these attributes. | 704 // 'svg' element will use values of 100% for these attributes. |
701 ASSERT(referencedScope()); | 705 ASSERT(referencedScope()); |
702 RefPtr<SVGSVGElement> svgElement = SVGSVGElement::create(referencedScope
()->document()); | 706 RefPtr<SVGSVGElement> svgElement = SVGSVGElement::create(referencedScope
()->document()); |
703 | 707 |
704 // Transfer all data (attributes, etc.) from <symbol> to the new <svg> e
lement. | 708 // Transfer all data (attributes, etc.) from <symbol> to the new <svg> e
lement. |
705 svgElement->cloneDataFromElement(*toElement(element)); | 709 svgElement->cloneDataFromElement(*toElement(element)); |
706 | 710 |
707 // Only clone symbol children, and add them to the new <svg> element | 711 // Only clone symbol children, and add them to the new <svg> element |
708 for (Node* child = element->firstChild(); child; child = child->nextSibl
ing()) { | 712 for (Node* child = toSVGElement(element)->firstChild(); child;) { |
709 RefPtr<Node> newChild = child->cloneNode(true); | 713 Node* oldChild = child; |
710 svgElement->appendChild(newChild.release()); | 714 child = child->nextSibling(); |
| 715 svgElement->appendChild(oldChild); |
711 } | 716 } |
712 | 717 |
713 // We don't walk the target tree element-by-element, and clone each elem
ent, | 718 // We don't walk the target tree element-by-element, and clone each elem
ent, |
714 // but instead use cloneNode(deep=true). This is an optimization for the
common | 719 // but instead use cloneNode(deep=true). This is an optimization for the
common |
715 // case where <use> doesn't contain disallowed elements (ie. <foreignObj
ect>). | 720 // case where <use> doesn't contain disallowed elements (ie. <foreignObj
ect>). |
716 // Though if there are disallowed elements in the subtree, we have to re
move them. | 721 // Though if there are disallowed elements in the subtree, we have to re
move them. |
717 // For instance: <use> on <g> containing <foreignObject> (indirect case)
. | 722 // For instance: <use> on <g> containing <foreignObject> (indirect case)
. |
718 if (subtreeContainsDisallowedElement(svgElement.get())) | 723 if (subtreeContainsDisallowedElement(svgElement.get())) |
719 removeDisallowedElementsFromSubtree(*svgElement); | 724 removeDisallowedElementsFromSubtree(*svgElement); |
720 | 725 |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 | 925 |
921 if (m_resource) | 926 if (m_resource) |
922 m_resource->removeClient(this); | 927 m_resource->removeClient(this); |
923 | 928 |
924 m_resource = resource; | 929 m_resource = resource; |
925 if (m_resource) | 930 if (m_resource) |
926 m_resource->addClient(this); | 931 m_resource->addClient(this); |
927 } | 932 } |
928 | 933 |
929 } | 934 } |
OLD | NEW |