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 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 | 790 |
791 String id = SVGURIReference::getTarget(use->href()); | 791 String id = SVGURIReference::getTarget(use->href()); |
792 Element* targetElement = document()->getElementById(id); | 792 Element* targetElement = document()->getElementById(id); |
793 SVGElement* target = 0; | 793 SVGElement* target = 0; |
794 if (targetElement && targetElement->isSVGElement()) | 794 if (targetElement && targetElement->isSVGElement()) |
795 target = static_cast<SVGElement*>(targetElement); | 795 target = static_cast<SVGElement*>(targetElement); |
796 | 796 |
797 // Don't ASSERT(target) here, it may be "pending", too. | 797 // Don't ASSERT(target) here, it may be "pending", too. |
798 // Setup sub-shadow tree root node | 798 // Setup sub-shadow tree root node |
799 RefPtr<SVGShadowTreeContainerElement> cloneParent = SVGShadowTreeContain
erElement::create(document()); | 799 RefPtr<SVGShadowTreeContainerElement> cloneParent = SVGShadowTreeContain
erElement::create(document()); |
| 800 use->cloneChildNodes(cloneParent.get()); |
800 | 801 |
801 // Spec: In the generated content, the 'use' will be replaced by 'g', wh
ere all attributes from the | 802 // Spec: In the generated content, the 'use' will be replaced by 'g', wh
ere all attributes from the |
802 // 'use' element except for x, y, width, height and xlink:href are trans
ferred to the generated 'g' element. | 803 // 'use' element except for x, y, width, height and xlink:href are trans
ferred to the generated 'g' element. |
803 transferUseAttributesToReplacedElement(use, cloneParent.get()); | 804 transferUseAttributesToReplacedElement(use, cloneParent.get()); |
804 | 805 |
805 ExceptionCode ec = 0; | 806 ExceptionCode ec = 0; |
806 if (target && !isDisallowedElement(target)) { | 807 if (target && !isDisallowedElement(target)) { |
807 RefPtr<Element> newChild = target->cloneElementWithChildren(); | 808 RefPtr<Element> newChild = target->cloneElementWithChildren(); |
808 | 809 |
809 // We don't walk the target tree element-by-element, and clone each
element, | |
810 // but instead use cloneElementWithChildren(). This is an optimizati
on for the common | |
811 // case where <use> doesn't contain disallowed elements (ie. <foreig
nObject>). | |
812 // Though if there are disallowed elements in the subtree, we have t
o remove them. | |
813 // For instance: <use> on <g> containing <foreignObject> (indirect c
ase). | |
814 if (subtreeContainsDisallowedElement(newChild.get())) | |
815 removeDisallowedElementsFromSubtree(newChild.get()); | |
816 | |
817 SVGElement* newChildPtr = 0; | 810 SVGElement* newChildPtr = 0; |
818 if (newChild->isSVGElement()) | 811 if (newChild->isSVGElement()) |
819 newChildPtr = static_cast<SVGElement*>(newChild.get()); | 812 newChildPtr = static_cast<SVGElement*>(newChild.get()); |
820 ASSERT(newChildPtr); | 813 ASSERT(newChildPtr); |
821 | 814 |
822 cloneParent->appendChild(newChild.release(), ec); | 815 cloneParent->appendChild(newChild.release(), ec); |
823 ASSERT(!ec); | 816 ASSERT(!ec); |
824 } | 817 } |
825 | 818 |
| 819 // We don't walk the target tree element-by-element, and clone each elem
ent, |
| 820 // but instead use cloneElementWithChildren(). This is an optimization f
or the common |
| 821 // case where <use> doesn't contain disallowed elements (ie. <foreignObj
ect>). |
| 822 // Though if there are disallowed elements in the subtree, we have to re
move them. |
| 823 // For instance: <use> on <g> containing <foreignObject> (indirect case)
. |
| 824 if (subtreeContainsDisallowedElement(cloneParent.get())) |
| 825 removeDisallowedElementsFromSubtree(cloneParent.get()); |
| 826 |
826 // Replace <use> with referenced content. | 827 // Replace <use> with referenced content. |
827 ASSERT(use->parentNode()); | 828 ASSERT(use->parentNode()); |
828 use->parentNode()->replaceChild(cloneParent.release(), use, ec); | 829 use->parentNode()->replaceChild(cloneParent.release(), use, ec); |
829 ASSERT(!ec); | 830 ASSERT(!ec); |
830 | 831 |
831 // Immediately stop here, and restart expanding. | 832 // Immediately stop here, and restart expanding. |
832 expandUseElementsInShadowTree(shadowRoot, shadowRoot); | 833 expandUseElementsInShadowTree(shadowRoot, shadowRoot); |
833 return; | 834 return; |
834 } | 835 } |
835 | 836 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 SVGElement* element = m_targetElementInstance->correspondingElement(); | 1032 SVGElement* element = m_targetElementInstance->correspondingElement(); |
1032 if (!element || !element->isStyled()) | 1033 if (!element || !element->isStyled()) |
1033 return false; | 1034 return false; |
1034 | 1035 |
1035 return static_cast<SVGStyledElement*>(element)->hasRelativeLengths(); | 1036 return static_cast<SVGStyledElement*>(element)->hasRelativeLengths(); |
1036 } | 1037 } |
1037 | 1038 |
1038 } | 1039 } |
1039 | 1040 |
1040 #endif // ENABLE(SVG) | 1041 #endif // ENABLE(SVG) |
OLD | NEW |