Chromium Code Reviews| Index: Source/core/svg/SVGElement.cpp |
| diff --git a/Source/core/svg/SVGElement.cpp b/Source/core/svg/SVGElement.cpp |
| index a8a6ec4c071b3c06c011963d107f39cb61cf2dc6..70ab23774aba087ba0f2f42727638218adfd89e1 100644 |
| --- a/Source/core/svg/SVGElement.cpp |
| +++ b/Source/core/svg/SVGElement.cpp |
| @@ -342,7 +342,7 @@ void SVGElement::removedFrom(ContainerNode* rootParent) |
| document().accessSVGExtensions().removeAllElementReferencesForTarget(this); |
| } |
| - SVGElementInstance::invalidateAllInstancesOfElement(this); |
| + SVGElement::invalidateAllInstancesOfElement(this); |
| } |
| void SVGElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) |
| @@ -351,7 +351,7 @@ void SVGElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* |
| // Invalidate all SVGElementInstances associated with us. |
| if (!changedByParser) |
| - SVGElementInstance::invalidateAllInstancesOfElement(this); |
| + SVGElement::invalidateAllInstancesOfElement(this); |
| } |
| CSSPropertyID SVGElement::cssPropertyIdForSVGAttributeName(const QualifiedName& attrName) |
| @@ -952,13 +952,13 @@ void SVGElement::svgAttributeChanged(const QualifiedName& attrName) |
| { |
| CSSPropertyID propId = SVGElement::cssPropertyIdForSVGAttributeName(attrName); |
| if (propId > 0) { |
| - SVGElementInstance::invalidateAllInstancesOfElement(this); |
| + SVGElement::invalidateAllInstancesOfElement(this); |
| return; |
| } |
| if (attrName == HTMLNames::classAttr) { |
| classAttributeChanged(AtomicString(m_className->currentValue()->value())); |
| - SVGElementInstance::invalidateAllInstancesOfElement(this); |
| + SVGElement::invalidateAllInstancesOfElement(this); |
| return; |
| } |
| @@ -969,7 +969,7 @@ void SVGElement::svgAttributeChanged(const QualifiedName& attrName) |
| toRenderSVGResourceContainer(object)->idChanged(); |
| if (inDocument()) |
| buildPendingResourcesIfNeeded(); |
| - SVGElementInstance::invalidateAllInstancesOfElement(this); |
| + SVGElement::invalidateAllInstancesOfElement(this); |
| return; |
| } |
| } |
| @@ -1047,6 +1047,45 @@ bool SVGElement::hasFocusEventListeners() const |
| || hasEventListeners(EventTypeNames::focus) || hasEventListeners(EventTypeNames::blur); |
| } |
| +void SVGElement::invalidateAllInstancesOfElement(SVGElement* element) |
|
pdr.
2014/05/05 21:00:15
There are only a few callers of this. Could we go
|
| +{ |
| + if (!element || !element->inDocument()) |
| + return; |
| + |
| + if (element->instanceUpdatesBlocked()) |
| + return; |
| + |
| + const HashSet<SVGElement*>& set = element->instancesForElement(); |
| + if (set.isEmpty()) |
| + return; |
| + |
| + // Mark all use elements referencing 'element' for rebuilding |
| + const HashSet<SVGElement*>::const_iterator end = set.end(); |
| + for (HashSet<SVGElement*>::const_iterator it = set.begin(); it != end; ++it) { |
| + (*it)->setCorrespondingElement(0); |
| + |
| + if (SVGUseElement* element = (*it)->correspondingUseElement()) { |
| + ASSERT(element->inDocument()); |
| + element->invalidateShadowTree(); |
| + } |
| + } |
| + |
| + element->document().updateRenderTreeIfNeeded(); |
| +} |
| + |
| +SVGElement::InstanceUpdateBlocker::InstanceUpdateBlocker(SVGElement* targetElement) |
| + : m_targetElement(targetElement) |
| +{ |
| + if (m_targetElement) |
| + m_targetElement->setInstanceUpdatesBlocked(true); |
| +} |
| + |
| +SVGElement::InstanceUpdateBlocker::~InstanceUpdateBlocker() |
| +{ |
| + if (m_targetElement) |
| + m_targetElement->setInstanceUpdatesBlocked(false); |
| +} |
| + |
| #ifndef NDEBUG |
| bool SVGElement::isAnimatableAttribute(const QualifiedName& name) const |
| { |