Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1181)

Unified Diff: Source/core/svg/SVGUseElement.cpp

Issue 278683003: Move instead of clone shadow tree children (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: do same in use expanding Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGUseElement.cpp
diff --git a/Source/core/svg/SVGUseElement.cpp b/Source/core/svg/SVGUseElement.cpp
index cdb277c033d1fc467a8d29f2b34f37f3188f3baa..8a8a1d6c16ef63805a0f77bb36f1b581611683fb 100644
--- a/Source/core/svg/SVGUseElement.cpp
+++ b/Source/core/svg/SVGUseElement.cpp
@@ -650,7 +650,11 @@ void SVGUseElement::expandUseElementsInShadowTree(Node* element)
// Don't ASSERT(target) here, it may be "pending", too.
// Setup sub-shadow tree root node
RefPtr<SVGGElement> cloneParent = SVGGElement::create(referencedScope()->document());
- use->cloneChildNodes(cloneParent.get());
+ for (Node* child = use->firstChild(); child;) {
+ Node* oldChild = child;
+ child = child->nextSibling();
+ cloneParent->appendChild(oldChild);
+ }
// 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.
@@ -705,9 +709,10 @@ void SVGUseElement::expandSymbolElementsInShadowTree(Node* element)
svgElement->cloneDataFromElement(*toElement(element));
// Only clone symbol children, and add them to the new <svg> element
- for (Node* child = element->firstChild(); child; child = child->nextSibling()) {
- RefPtr<Node> newChild = child->cloneNode(true);
- svgElement->appendChild(newChild.release());
+ for (Node* child = toSVGElement(element)->firstChild(); child;) {
+ Node* oldChild = child;
+ child = child->nextSibling();
+ svgElement->appendChild(oldChild);
}
// We don't walk the target tree element-by-element, and clone each element,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698