Chromium Code Reviews| Index: Source/core/svg/SVGElement.cpp |
| diff --git a/Source/core/svg/SVGElement.cpp b/Source/core/svg/SVGElement.cpp |
| index 7f1904c2b9d4b2db6f74236dd3ac24ed2f8dae74..3a9898fc0694ce2fde8e34a04520741f5d955cd1 100644 |
| --- a/Source/core/svg/SVGElement.cpp |
| +++ b/Source/core/svg/SVGElement.cpp |
| @@ -107,6 +107,20 @@ SVGElement::~SVGElement() |
| #endif |
| } |
| +void SVGElement::detach(const AttachContext& context) |
| +{ |
| + Element::detach(context); |
| + if (correspondingElement()) |
|
esprehn
2014/06/05 20:57:24
Save in a local in the if()
|
| + correspondingElement()->removeInstanceMapping(this); |
| +} |
| + |
| +void SVGElement::attach(const AttachContext& context) |
| +{ |
| + Element::attach(context); |
| + if (correspondingElement()) |
|
esprehn
2014/06/05 20:57:24
There's a hidden branch in there, I'd suggest:
if
|
| + correspondingElement()->mapInstanceToElement(this); |
| +} |
| + |
| short SVGElement::tabIndex() const |
| { |
| if (supportsFocus()) |
| @@ -330,7 +344,7 @@ void SVGElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* |
| { |
| Element::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); |
| - // Invalidate all SVGElementInstances associated with us. |
| + // Invalidate all instances associated with us. |
| if (!changedByParser) |
| invalidateInstances(); |
| } |
| @@ -525,6 +539,9 @@ void SVGElement::removeInstanceMapping(SVGElement* instance) |
| ASSERT(instance); |
| ASSERT(instance->inUseShadowTree()); |
| + if (!hasSVGRareData()) |
| + return; |
| + |
| WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >& instances = svgRareData()->elementInstances(); |
| ASSERT(instances.contains(instance)); |
| @@ -1042,6 +1059,8 @@ void SVGElement::invalidateInstances() |
| } |
| } |
| + svgRareData()->elementInstances().clear(); |
| + |
| document().updateRenderTreeIfNeeded(); |
| } |