Index: WebCore/svg/SVGUseElement.cpp |
=================================================================== |
--- WebCore/svg/SVGUseElement.cpp (revision 75429) |
+++ WebCore/svg/SVGUseElement.cpp (working copy) |
@@ -130,7 +130,7 @@ |
void SVGUseElement::removedFromDocument() |
{ |
SVGStyledTransformableElement::removedFromDocument(); |
- m_targetElementInstance = 0; |
+ detachInstance(); |
} |
void SVGUseElement::svgAttributeChanged(const QualifiedName& attrName) |
@@ -496,8 +496,7 @@ |
if (targetElement && targetElement->isSVGElement()) |
target = static_cast<SVGElement*>(targetElement); |
- if (m_targetElementInstance) |
- m_targetElementInstance = 0; |
+ detachInstance(); |
// Do not allow self-referencing. |
// 'target' may be null, if it's a non SVG namespaced element. |
@@ -523,7 +522,7 @@ |
// SVG specification does not say a word about <use> & cycles. My view on this is: just ignore it! |
// Non-appearing <use> content is easier to debug, then half-appearing content. |
if (foundProblem) { |
- m_targetElementInstance = 0; |
+ detachInstance(); |
return; |
} |
@@ -556,7 +555,7 @@ |
// Do NOT leave an inconsistent instance tree around, instead destruct it. |
if (!m_targetElementInstance->shadowTreeElement()) { |
shadowRoot->removeAllChildren(); |
- m_targetElementInstance = 0; |
+ detachInstance(); |
return; |
} |
@@ -595,6 +594,14 @@ |
updateRelativeLengthsInformation(); |
} |
+void SVGUseElement::detachInstance() |
+{ |
+ if (!m_targetElementInstance) |
+ return; |
+ m_targetElementInstance->clearUseElement(); |
+ m_targetElementInstance = 0; |
+} |
+ |
RenderObject* SVGUseElement::createRenderer(RenderArena* arena, RenderStyle*) |
{ |
return new (arena) RenderSVGShadowTreeRootContainer(this); |
@@ -617,7 +624,7 @@ |
void SVGUseElement::detach() |
{ |
SVGStyledTransformableElement::detach(); |
- m_targetElementInstance = 0; |
+ detachInstance(); |
} |
static bool isDirectReference(Node* n) |