Chromium Code Reviews| Index: third_party/WebKit/Source/core/svg/SVGUseElement.cpp |
| diff --git a/third_party/WebKit/Source/core/svg/SVGUseElement.cpp b/third_party/WebKit/Source/core/svg/SVGUseElement.cpp |
| index 0293b9e0379b059380a1cb89e820ab4545731fc0..46e52916022ba0e0e07e88645fd129e80e90cf68 100644 |
| --- a/third_party/WebKit/Source/core/svg/SVGUseElement.cpp |
| +++ b/third_party/WebKit/Source/core/svg/SVGUseElement.cpp |
| @@ -356,19 +356,16 @@ void SVGUseElement::buildPendingResource() |
| ASSERT(!m_needsShadowTreeRecreation); |
| } |
| -static PassRefPtrWillBeRawPtr<Node> cloneNodeAndAssociate(Node& toClone) |
| -{ |
| - RefPtrWillBeRawPtr<Node> clone = toClone.cloneNode(false); |
| - if (!clone->isSVGElement()) |
| - return clone.release(); |
| - |
| - SVGElement& svgElement = toSVGElement(toClone); |
| - ASSERT(!svgElement.correspondingElement()); |
| - toSVGElement(clone.get())->setCorrespondingElement(&svgElement); |
| - TrackExceptionState exceptionState; |
| - for (RefPtrWillBeRawPtr<Node> node = toClone.firstChild(); node && !exceptionState.hadException(); node = node->nextSibling()) |
| - clone->appendChild(cloneNodeAndAssociate(*node), exceptionState); |
| - return clone.release(); |
| +static void associateCorrespondingElements(SVGElement& targetRoot, SVGElement& instanceRoot) |
| +{ |
| + auto targetRange = Traversal<SVGElement>::inclusiveDescendantsOf(targetRoot); |
| + auto targetIterator = targetRange.begin(); |
| + for (SVGElement& instance : Traversal<SVGElement>::inclusiveDescendantsOf(instanceRoot)) { |
| + ASSERT(!instance.correspondingElement()); |
| + instance.setCorrespondingElement(&*targetIterator); |
| + ++targetIterator; |
| + } |
| + ASSERT(!(targetIterator != targetRange.end())); |
|
Stephen Chennney
2016/03/03 16:42:01
So we have a != operator but no == operator? Inter
fs
2016/03/03 16:59:07
Yeah, I guess it's heavily tailored to the range-b
|
| } |
| void SVGUseElement::buildShadowAndInstanceTree(SVGElement& target) |
| @@ -629,14 +626,14 @@ bool SVGUseElement::expandUseElementsInShadowTree() |
| moveChildrenToReplacementElement(*use, *cloneParent); |
| if (target) { |
| - RefPtrWillBeRawPtr<Node> newChild = cloneNodeAndAssociate(*target); |
| - ASSERT(newChild->isSVGElement()); |
| - transferUseWidthAndHeightIfNeeded(*use, toSVGElement(*newChild), *target); |
| - cloneParent->appendChild(newChild.release()); |
| + RefPtrWillBeRawPtr<Element> instanceRoot = target->cloneElementWithChildren(); |
| + ASSERT(instanceRoot->isSVGElement()); |
| + associateCorrespondingElements(*target, toSVGElement(*instanceRoot)); |
| + transferUseWidthAndHeightIfNeeded(*use, toSVGElement(*instanceRoot), *target); |
| + removeDisallowedElementsFromSubtree(toSVGElement(*instanceRoot)); |
| + cloneParent->appendChild(instanceRoot.release()); |
| } |
| - removeDisallowedElementsFromSubtree(*cloneParent); |
| - |
| RefPtrWillBeRawPtr<SVGElement> replacingElement(cloneParent.get()); |
| // Replace <use> with referenced content. |