Index: WebCore/svg/SVGUseElement.cpp |
=================================================================== |
--- WebCore/svg/SVGUseElement.cpp (revision 70351) |
+++ WebCore/svg/SVGUseElement.cpp (working copy) |
@@ -797,6 +797,7 @@ |
// Don't ASSERT(target) here, it may be "pending", too. |
// Setup sub-shadow tree root node |
RefPtr<SVGShadowTreeContainerElement> cloneParent = SVGShadowTreeContainerElement::create(document()); |
+ use->cloneChildNodes(cloneParent.get()); |
// Spec: In the generated content, the 'use' will be replaced by 'g', where all attributes from the |
// 'use' element except for x, y, width, height and xlink:href are transferred to the generated 'g' element. |
@@ -806,14 +807,6 @@ |
if (target && !isDisallowedElement(target)) { |
RefPtr<Element> newChild = target->cloneElementWithChildren(); |
- // We don't walk the target tree element-by-element, and clone each element, |
- // but instead use cloneElementWithChildren(). This is an optimization for the common |
- // case where <use> doesn't contain disallowed elements (ie. <foreignObject>). |
- // Though if there are disallowed elements in the subtree, we have to remove them. |
- // For instance: <use> on <g> containing <foreignObject> (indirect case). |
- if (subtreeContainsDisallowedElement(newChild.get())) |
- removeDisallowedElementsFromSubtree(newChild.get()); |
- |
SVGElement* newChildPtr = 0; |
if (newChild->isSVGElement()) |
newChildPtr = static_cast<SVGElement*>(newChild.get()); |
@@ -823,6 +816,14 @@ |
ASSERT(!ec); |
} |
+ // We don't walk the target tree element-by-element, and clone each element, |
+ // but instead use cloneElementWithChildren(). This is an optimization for the common |
+ // case where <use> doesn't contain disallowed elements (ie. <foreignObject>). |
+ // Though if there are disallowed elements in the subtree, we have to remove them. |
+ // For instance: <use> on <g> containing <foreignObject> (indirect case). |
+ if (subtreeContainsDisallowedElement(cloneParent.get())) |
+ removeDisallowedElementsFromSubtree(cloneParent.get()); |
+ |
// Replace <use> with referenced content. |
ASSERT(use->parentNode()); |
use->parentNode()->replaceChild(cloneParent.release(), use, ec); |