Changeset 179695 in webkit


Ignore:
Timestamp:
Feb 5, 2015 10:07:10 AM (9 years ago)
Author:
Brent Fulgham
Message:

Move InstanceInvalidationGuard/UpdateBlocker to SVGElement from SVGElementInstance
https://bugs.webkit.org/show_bug.cgi?id=141148

Patch by Darin Adler <Darin Adler> on 2015-02-05
Reviewed by Brent Fulgham and Anders Carlsson.

Inspired by this change Rob Buis made in Blink:

http://src.chromium.org/viewvc/blink?view=revision&revision=173343

I actually wrote the whole thing and then discovered we did it almost identically.

  • svg/SVGAnimatedTypeAnimator.cpp:

(WebCore::SVGElementAnimatedPropertyList::setInstanceUpdatesBlocked): Added this
helper function to get around a circular header dependency.

  • svg/SVGAnimatedTypeAnimator.h:

(WebCore::SVGAnimatedTypeAnimator::executeAction): Use setInstanceUpdatesBlocked.

  • svg/SVGElement.cpp:

(WebCore::SVGElement::removedFrom): Use invalidateInstances.
(WebCore::SVGElement::finishParsingChildren): Ditto.
(WebCore::SVGElement::svgAttributeChanged): Ditto.
(WebCore::SVGElement::childrenChanged): Ditto.
(WebCore::SVGElement::setInstanceUpdatesBlocked): Added an assertion that will
catch anyone who nests InstanceUpdateBlocker by accident.
(WebCore::SVGElement::invalidateInstances): Moved this here from
SVGElementInstance::invalidateAllInstancesOfElement. I had already modified this
so it had nothing to do with SVGElementInstance, so it was a simple matter of
converting this into a member function. Added a FIXME about the mysterious
updateStyleIfNeeded that makes multiple tests fail if it's removed.

  • svg/SVGElement.h: Added public InstanceUpdateBlocker class, protected

InstanceInvalidationGuard class, and private invalidateInstances function.
Unlike the ones in SVGElementInstance these use references so they are then
not copyable without using the WTF_MAKE_NONCOPYABLE macro.

  • svg/SVGElementInstance.cpp:

(WebCore::SVGElementInstance::invalidateAllInstancesOfElement): Deleted.
(WebCore::SVGElementInstance::InstanceUpdateBlocker::InstanceUpdateBlocker): Deleted.
(WebCore::SVGElementInstance::InstanceUpdateBlocker::~InstanceUpdateBlocker): Deleted.

  • svg/SVGElementInstance.h: Removed InvalidationGuard, InstanceUpdateBlocker, and

invalidateAllInstancesOfElement. Didn't do any further cleanup since we soon will
delete this entire file.

  • svg/SVGAElement.cpp:

(WebCore::SVGAElement::svgAttributeChanged): Updated to use new name and reference
instead of pointer.

  • svg/SVGAnimateElementBase.cpp:

(WebCore::applyCSSPropertyToTargetAndInstances): Ditto.
(WebCore::removeCSSPropertyFromTargetAndInstances): Ditto.
(WebCore::notifyTargetAndInstancesAboutAnimValChange): Ditto.

  • svg/SVGAnimatedPath.cpp:

(WebCore::SVGAnimatedPathAnimator::startAnimValAnimation): Ditto.

  • svg/SVGCircleElement.cpp:

(WebCore::SVGCircleElement::svgAttributeChanged): Ditto.

  • svg/SVGClipPathElement.cpp:

(WebCore::SVGClipPathElement::svgAttributeChanged): Ditto.

  • svg/SVGComponentTransferFunctionElement.cpp:

(WebCore::SVGComponentTransferFunctionElement::svgAttributeChanged): Ditto.

  • svg/SVGCursorElement.cpp:

(WebCore::SVGCursorElement::svgAttributeChanged): Ditto.

  • svg/SVGEllipseElement.cpp:

(WebCore::SVGEllipseElement::svgAttributeChanged): Ditto.

  • svg/SVGFEBlendElement.cpp:

(WebCore::SVGFEBlendElement::svgAttributeChanged): Ditto.

  • svg/SVGFEColorMatrixElement.cpp:

(WebCore::SVGFEColorMatrixElement::svgAttributeChanged): Ditto.

  • svg/SVGFECompositeElement.cpp:

(WebCore::SVGFECompositeElement::svgAttributeChanged): Ditto.

  • svg/SVGFEConvolveMatrixElement.cpp:

(WebCore::SVGFEConvolveMatrixElement::svgAttributeChanged): Ditto.

  • svg/SVGFEDiffuseLightingElement.cpp:

(WebCore::SVGFEDiffuseLightingElement::svgAttributeChanged): Ditto.

  • svg/SVGFEDisplacementMapElement.cpp:

(WebCore::SVGFEDisplacementMapElement::svgAttributeChanged): Ditto.

  • svg/SVGFEDropShadowElement.cpp:

(WebCore::SVGFEDropShadowElement::svgAttributeChanged): Ditto.

  • svg/SVGFEGaussianBlurElement.cpp:

(WebCore::SVGFEGaussianBlurElement::svgAttributeChanged): Ditto.

  • svg/SVGFEImageElement.cpp:

(WebCore::SVGFEImageElement::svgAttributeChanged): Ditto.

  • svg/SVGFELightElement.cpp:

(WebCore::SVGFELightElement::svgAttributeChanged): Ditto.

  • svg/SVGFEMergeNodeElement.cpp:

(WebCore::SVGFEMergeNodeElement::svgAttributeChanged): Ditto.

  • svg/SVGFEMorphologyElement.cpp:

(WebCore::SVGFEMorphologyElement::svgAttributeChanged): Ditto.

  • svg/SVGFEOffsetElement.cpp:

(WebCore::SVGFEOffsetElement::svgAttributeChanged): Ditto.

  • svg/SVGFESpecularLightingElement.cpp:

(WebCore::SVGFESpecularLightingElement::svgAttributeChanged): Ditto.

  • svg/SVGFETileElement.cpp:

(WebCore::SVGFETileElement::svgAttributeChanged): Ditto.

  • svg/SVGFETurbulenceElement.cpp:

(WebCore::SVGFETurbulenceElement::svgAttributeChanged): Ditto.

  • svg/SVGFilterElement.cpp:

(WebCore::SVGFilterElement::svgAttributeChanged): Ditto.

  • svg/SVGFilterPrimitiveStandardAttributes.cpp:

(WebCore::SVGFilterPrimitiveStandardAttributes::svgAttributeChanged): Ditto.

  • svg/SVGForeignObjectElement.cpp:

(WebCore::SVGForeignObjectElement::svgAttributeChanged): Ditto.

  • svg/SVGGElement.cpp:

(WebCore::SVGGElement::svgAttributeChanged): Ditto.

  • svg/SVGGradientElement.cpp:

(WebCore::SVGGradientElement::svgAttributeChanged): Ditto.

  • svg/SVGGraphicsElement.cpp:

(WebCore::SVGGraphicsElement::svgAttributeChanged): Ditto.

  • svg/SVGImageElement.cpp:

(WebCore::SVGImageElement::svgAttributeChanged): Ditto.

  • svg/SVGLineElement.cpp:

(WebCore::SVGLineElement::svgAttributeChanged): Ditto.

  • svg/SVGLinearGradientElement.cpp:

(WebCore::SVGLinearGradientElement::svgAttributeChanged): Ditto.

  • svg/SVGMPathElement.cpp:

(WebCore::SVGMPathElement::svgAttributeChanged): Ditto.

  • svg/SVGMarkerElement.cpp:

(WebCore::SVGMarkerElement::svgAttributeChanged): Ditto.

  • svg/SVGMaskElement.cpp:

(WebCore::SVGMaskElement::svgAttributeChanged): Ditto.

  • svg/SVGPathElement.cpp:

(WebCore::SVGPathElement::svgAttributeChanged): Ditto.

  • svg/SVGPatternElement.cpp:

(WebCore::SVGPatternElement::svgAttributeChanged): Ditto.

  • svg/SVGPolyElement.cpp:

(WebCore::SVGPolyElement::svgAttributeChanged): Ditto.

  • svg/SVGRadialGradientElement.cpp:

(WebCore::SVGRadialGradientElement::svgAttributeChanged): Ditto.

  • svg/SVGRectElement.cpp:

(WebCore::SVGRectElement::svgAttributeChanged): Ditto.

  • svg/SVGSVGElement.cpp:

(WebCore::SVGSVGElement::svgAttributeChanged): Ditto.

  • svg/SVGScriptElement.cpp:

(WebCore::SVGScriptElement::svgAttributeChanged): Ditto.

  • svg/SVGStopElement.cpp:

(WebCore::SVGStopElement::svgAttributeChanged): Ditto.

  • svg/SVGSymbolElement.cpp:

(WebCore::SVGSymbolElement::svgAttributeChanged): Ditto.

  • svg/SVGTRefElement.cpp:

(WebCore::SVGTRefElement::svgAttributeChanged): Ditto.

  • svg/SVGTextContentElement.cpp:

(WebCore::SVGTextContentElement::svgAttributeChanged): Ditto.

  • svg/SVGTextPathElement.cpp:

(WebCore::SVGTextPathElement::svgAttributeChanged): Ditto.

  • svg/SVGTextPositioningElement.cpp:

(WebCore::SVGTextPositioningElement::svgAttributeChanged): Ditto.

  • svg/SVGUseElement.cpp:

(WebCore::SVGUseElement::svgAttributeChanged): Ditto.

  • svg/animation/SVGSMILElement.cpp:

(WebCore::SVGSMILElement::svgAttributeChanged): Ditto.

Location:
trunk/Source/WebCore
Files:
58 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r179693 r179695  
     12015-02-05  Darin Adler  <darin@apple.com>
     2
     3        Move InstanceInvalidationGuard/UpdateBlocker to SVGElement from SVGElementInstance
     4        https://bugs.webkit.org/show_bug.cgi?id=141148
     5
     6        Reviewed by Brent Fulgham and Anders Carlsson.
     7
     8        Inspired by this change Rob Buis made in Blink:
     9
     10            http://src.chromium.org/viewvc/blink?view=revision&revision=173343
     11
     12        I actually wrote the whole thing and then discovered we did it almost identically.
     13
     14        * svg/SVGAnimatedTypeAnimator.cpp:
     15        (WebCore::SVGElementAnimatedPropertyList::setInstanceUpdatesBlocked): Added this
     16        helper function to get around a circular header dependency.
     17        * svg/SVGAnimatedTypeAnimator.h:
     18        (WebCore::SVGAnimatedTypeAnimator::executeAction): Use setInstanceUpdatesBlocked.
     19
     20        * svg/SVGElement.cpp:
     21        (WebCore::SVGElement::removedFrom): Use invalidateInstances.
     22        (WebCore::SVGElement::finishParsingChildren): Ditto.
     23        (WebCore::SVGElement::svgAttributeChanged): Ditto.
     24        (WebCore::SVGElement::childrenChanged): Ditto.
     25        (WebCore::SVGElement::setInstanceUpdatesBlocked): Added an assertion that will
     26        catch anyone who nests InstanceUpdateBlocker by accident.
     27        (WebCore::SVGElement::invalidateInstances): Moved this here from
     28        SVGElementInstance::invalidateAllInstancesOfElement. I had already modified this
     29        so it had nothing to do with SVGElementInstance, so it was a simple matter of
     30        converting this into a member function. Added a FIXME about the mysterious
     31        updateStyleIfNeeded that makes multiple tests fail if it's removed.
     32
     33        * svg/SVGElement.h: Added public InstanceUpdateBlocker class, protected
     34        InstanceInvalidationGuard class, and private invalidateInstances function.
     35        Unlike the ones in SVGElementInstance these use references so they are then
     36        not copyable without using the WTF_MAKE_NONCOPYABLE macro.
     37
     38        * svg/SVGElementInstance.cpp:
     39        (WebCore::SVGElementInstance::invalidateAllInstancesOfElement): Deleted.
     40        (WebCore::SVGElementInstance::InstanceUpdateBlocker::InstanceUpdateBlocker): Deleted.
     41        (WebCore::SVGElementInstance::InstanceUpdateBlocker::~InstanceUpdateBlocker): Deleted.
     42        * svg/SVGElementInstance.h: Removed InvalidationGuard, InstanceUpdateBlocker, and
     43        invalidateAllInstancesOfElement. Didn't do any further cleanup since we soon will
     44        delete this entire file.
     45
     46        * svg/SVGAElement.cpp:
     47        (WebCore::SVGAElement::svgAttributeChanged): Updated to use new name and reference
     48        instead of pointer.
     49        * svg/SVGAnimateElementBase.cpp:
     50        (WebCore::applyCSSPropertyToTargetAndInstances): Ditto.
     51        (WebCore::removeCSSPropertyFromTargetAndInstances): Ditto.
     52        (WebCore::notifyTargetAndInstancesAboutAnimValChange): Ditto.
     53        * svg/SVGAnimatedPath.cpp:
     54        (WebCore::SVGAnimatedPathAnimator::startAnimValAnimation): Ditto.
     55        * svg/SVGCircleElement.cpp:
     56        (WebCore::SVGCircleElement::svgAttributeChanged): Ditto.
     57        * svg/SVGClipPathElement.cpp:
     58        (WebCore::SVGClipPathElement::svgAttributeChanged): Ditto.
     59        * svg/SVGComponentTransferFunctionElement.cpp:
     60        (WebCore::SVGComponentTransferFunctionElement::svgAttributeChanged): Ditto.
     61        * svg/SVGCursorElement.cpp:
     62        (WebCore::SVGCursorElement::svgAttributeChanged): Ditto.
     63        * svg/SVGEllipseElement.cpp:
     64        (WebCore::SVGEllipseElement::svgAttributeChanged): Ditto.
     65        * svg/SVGFEBlendElement.cpp:
     66        (WebCore::SVGFEBlendElement::svgAttributeChanged): Ditto.
     67        * svg/SVGFEColorMatrixElement.cpp:
     68        (WebCore::SVGFEColorMatrixElement::svgAttributeChanged): Ditto.
     69        * svg/SVGFECompositeElement.cpp:
     70        (WebCore::SVGFECompositeElement::svgAttributeChanged): Ditto.
     71        * svg/SVGFEConvolveMatrixElement.cpp:
     72        (WebCore::SVGFEConvolveMatrixElement::svgAttributeChanged): Ditto.
     73        * svg/SVGFEDiffuseLightingElement.cpp:
     74        (WebCore::SVGFEDiffuseLightingElement::svgAttributeChanged): Ditto.
     75        * svg/SVGFEDisplacementMapElement.cpp:
     76        (WebCore::SVGFEDisplacementMapElement::svgAttributeChanged): Ditto.
     77        * svg/SVGFEDropShadowElement.cpp:
     78        (WebCore::SVGFEDropShadowElement::svgAttributeChanged): Ditto.
     79        * svg/SVGFEGaussianBlurElement.cpp:
     80        (WebCore::SVGFEGaussianBlurElement::svgAttributeChanged): Ditto.
     81        * svg/SVGFEImageElement.cpp:
     82        (WebCore::SVGFEImageElement::svgAttributeChanged): Ditto.
     83        * svg/SVGFELightElement.cpp:
     84        (WebCore::SVGFELightElement::svgAttributeChanged): Ditto.
     85        * svg/SVGFEMergeNodeElement.cpp:
     86        (WebCore::SVGFEMergeNodeElement::svgAttributeChanged): Ditto.
     87        * svg/SVGFEMorphologyElement.cpp:
     88        (WebCore::SVGFEMorphologyElement::svgAttributeChanged): Ditto.
     89        * svg/SVGFEOffsetElement.cpp:
     90        (WebCore::SVGFEOffsetElement::svgAttributeChanged): Ditto.
     91        * svg/SVGFESpecularLightingElement.cpp:
     92        (WebCore::SVGFESpecularLightingElement::svgAttributeChanged): Ditto.
     93        * svg/SVGFETileElement.cpp:
     94        (WebCore::SVGFETileElement::svgAttributeChanged): Ditto.
     95        * svg/SVGFETurbulenceElement.cpp:
     96        (WebCore::SVGFETurbulenceElement::svgAttributeChanged): Ditto.
     97        * svg/SVGFilterElement.cpp:
     98        (WebCore::SVGFilterElement::svgAttributeChanged): Ditto.
     99        * svg/SVGFilterPrimitiveStandardAttributes.cpp:
     100        (WebCore::SVGFilterPrimitiveStandardAttributes::svgAttributeChanged): Ditto.
     101        * svg/SVGForeignObjectElement.cpp:
     102        (WebCore::SVGForeignObjectElement::svgAttributeChanged): Ditto.
     103        * svg/SVGGElement.cpp:
     104        (WebCore::SVGGElement::svgAttributeChanged): Ditto.
     105        * svg/SVGGradientElement.cpp:
     106        (WebCore::SVGGradientElement::svgAttributeChanged): Ditto.
     107        * svg/SVGGraphicsElement.cpp:
     108        (WebCore::SVGGraphicsElement::svgAttributeChanged): Ditto.
     109        * svg/SVGImageElement.cpp:
     110        (WebCore::SVGImageElement::svgAttributeChanged): Ditto.
     111        * svg/SVGLineElement.cpp:
     112        (WebCore::SVGLineElement::svgAttributeChanged): Ditto.
     113        * svg/SVGLinearGradientElement.cpp:
     114        (WebCore::SVGLinearGradientElement::svgAttributeChanged): Ditto.
     115        * svg/SVGMPathElement.cpp:
     116        (WebCore::SVGMPathElement::svgAttributeChanged): Ditto.
     117        * svg/SVGMarkerElement.cpp:
     118        (WebCore::SVGMarkerElement::svgAttributeChanged): Ditto.
     119        * svg/SVGMaskElement.cpp:
     120        (WebCore::SVGMaskElement::svgAttributeChanged): Ditto.
     121        * svg/SVGPathElement.cpp:
     122        (WebCore::SVGPathElement::svgAttributeChanged): Ditto.
     123        * svg/SVGPatternElement.cpp:
     124        (WebCore::SVGPatternElement::svgAttributeChanged): Ditto.
     125        * svg/SVGPolyElement.cpp:
     126        (WebCore::SVGPolyElement::svgAttributeChanged): Ditto.
     127        * svg/SVGRadialGradientElement.cpp:
     128        (WebCore::SVGRadialGradientElement::svgAttributeChanged): Ditto.
     129        * svg/SVGRectElement.cpp:
     130        (WebCore::SVGRectElement::svgAttributeChanged): Ditto.
     131        * svg/SVGSVGElement.cpp:
     132        (WebCore::SVGSVGElement::svgAttributeChanged): Ditto.
     133        * svg/SVGScriptElement.cpp:
     134        (WebCore::SVGScriptElement::svgAttributeChanged): Ditto.
     135        * svg/SVGStopElement.cpp:
     136        (WebCore::SVGStopElement::svgAttributeChanged): Ditto.
     137        * svg/SVGSymbolElement.cpp:
     138        (WebCore::SVGSymbolElement::svgAttributeChanged): Ditto.
     139        * svg/SVGTRefElement.cpp:
     140        (WebCore::SVGTRefElement::svgAttributeChanged): Ditto.
     141        * svg/SVGTextContentElement.cpp:
     142        (WebCore::SVGTextContentElement::svgAttributeChanged): Ditto.
     143        * svg/SVGTextPathElement.cpp:
     144        (WebCore::SVGTextPathElement::svgAttributeChanged): Ditto.
     145        * svg/SVGTextPositioningElement.cpp:
     146        (WebCore::SVGTextPositioningElement::svgAttributeChanged): Ditto.
     147        * svg/SVGUseElement.cpp:
     148        (WebCore::SVGUseElement::svgAttributeChanged): Ditto.
     149        * svg/animation/SVGSMILElement.cpp:
     150        (WebCore::SVGSMILElement::svgAttributeChanged): Ditto.
     151
    11522015-02-05  Brent Fulgham  <bfulgham@apple.com>
    2153
  • trunk/Source/WebCore/svg/SVGAElement.cpp

    r179555 r179695  
    127127    }
    128128
    129     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     129    InstanceInvalidationGuard guard(*this);
    130130
    131131    // Unlike other SVG*Element classes, SVGAElement only listens to SVGURIReference changes
  • trunk/Source/WebCore/svg/SVGAnimateElementBase.cpp

    r179555 r179695  
    259259    CSSPropertyID id = cssPropertyID(attributeName.localName());
    260260
    261     SVGElementInstance::InstanceUpdateBlocker blocker(&targetElement);
     261    SVGElement::InstanceUpdateBlocker blocker(targetElement);
    262262    applyCSSPropertyToTarget(targetElement, id, valueAsString);
    263263
     
    275275    CSSPropertyID id = cssPropertyID(attributeName.localName());
    276276
    277     SVGElementInstance::InstanceUpdateBlocker blocker(&targetElement);
     277    SVGElement::InstanceUpdateBlocker blocker(targetElement);
    278278    removeCSSPropertyFromTarget(targetElement, id);
    279279
     
    294294        return;
    295295
    296     SVGElementInstance::InstanceUpdateBlocker blocker(&targetElement);
     296    SVGElement::InstanceUpdateBlocker blocker(targetElement);
    297297    notifyTargetAboutAnimValChange(targetElement, attributeName);
    298298
  • trunk/Source/WebCore/svg/SVGAnimatedPath.cpp

    r179555 r179695  
    5555        result.append(castAnimatedPropertyToActualType<SVGAnimatedPathSegListPropertyTearOff>(it->properties[0].get()));
    5656
    57     SVGElementInstance::InstanceUpdateBlocker blocker(property->contextElement());
     57    SVGElement::InstanceUpdateBlocker blocker(*property->contextElement());
    5858
    5959    size_t resultSize = result.size();
  • trunk/Source/WebCore/svg/SVGAnimatedTypeAnimator.cpp

    r179555 r179695  
    8484}
    8585
     86void SVGAnimatedTypeAnimator::setInstanceUpdatesBlocked(SVGElement& element, bool blocked)
     87{
     88    element.setInstanceUpdatesBlocked(blocked);
     89}
     90
    8691} // namespace WebCore
  • trunk/Source/WebCore/svg/SVGAnimatedTypeAnimator.h

    r179555 r179695  
    190190    void executeAction(AnimationAction action, const SVGElementAnimatedPropertyList& animatedTypes, unsigned whichProperty, typename AnimValType::ContentType* type = 0)
    191191    {
    192         SVGElementInstance::InstanceUpdateBlocker blocker(animatedTypes[0].element);
     192        // FIXME: Can't use SVGElement::InstanceUpdateBlocker because of circular header dependency. Would be nice to untangle this.
     193        setInstanceUpdatesBlocked(*animatedTypes[0].element, true);
    193194
    194195        SVGElementAnimatedPropertyList::const_iterator end = animatedTypes.end();
     
    217218            }
    218219        }
    219     }
     220
     221        setInstanceUpdatesBlocked(*animatedTypes[0].element, false);
     222    }
     223
     224    static void setInstanceUpdatesBlocked(SVGElement&, bool);
    220225};
    221226
  • trunk/Source/WebCore/svg/SVGCircleElement.cpp

    r179555 r179695  
    105105    }
    106106
    107     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     107    InstanceInvalidationGuard guard(*this);
    108108
    109109    if (attrName == SVGNames::cxAttr
  • trunk/Source/WebCore/svg/SVGClipPathElement.cpp

    r179555 r179695  
    9797    }
    9898
    99     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     99    InstanceInvalidationGuard guard(*this);
    100100
    101101    if (RenderObject* object = renderer())
  • trunk/Source/WebCore/svg/SVGComponentTransferFunctionElement.cpp

    r179555 r179695  
    132132    }
    133133
    134     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     134    InstanceInvalidationGuard guard(*this);
    135135
    136136    invalidateFilterPrimitiveParent(this);
  • trunk/Source/WebCore/svg/SVGCursorElement.cpp

    r179555 r179695  
    122122    }
    123123
    124     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     124    InstanceInvalidationGuard guard(*this);
    125125
    126126    // Any change of a cursor specific attribute triggers this recalc.
  • trunk/Source/WebCore/svg/SVGElement.cpp

    r179555 r179695  
    393393        document().accessSVGExtensions().removeAllElementReferencesForTarget(this);
    394394    }
    395     SVGElementInstance::invalidateAllInstancesOfElement(this);
     395    invalidateInstances();
    396396}
    397397
     
    714714    // Notify all the elements which have references to this element to rebuild their shadow and render
    715715    // trees, e.g. a <use> element references a target element before this target element is defined.
    716     SVGElementInstance::invalidateAllInstancesOfElement(this);
     716    invalidateInstances();
    717717}
    718718
     
    10451045    CSSPropertyID propId = cssPropertyIdForSVGAttributeName(attrName);
    10461046    if (propId > 0) {
    1047         SVGElementInstance::invalidateAllInstancesOfElement(this);
     1047        invalidateInstances();
    10481048        return;
    10491049    }
     
    10511051    if (attrName == HTMLNames::classAttr) {
    10521052        classAttributeChanged(className());
    1053         SVGElementInstance::invalidateAllInstancesOfElement(this);
     1053        invalidateInstances();
    10541054        return;
    10551055    }
     
    10621062        if (inDocument())
    10631063            buildPendingResourcesIfNeeded();
    1064         SVGElementInstance::invalidateAllInstancesOfElement(this);
     1064        invalidateInstances();
    10651065        return;
    10661066    }
     
    11041104    if (change.source == ChildChangeSourceParser)
    11051105        return;
    1106     SVGElementInstance::invalidateAllInstancesOfElement(this);
     1106    invalidateInstances();
    11071107}
    11081108
     
    11311131void SVGElement::setInstanceUpdatesBlocked(bool value)
    11321132{
     1133    // Catch any callers that calls setInstanceUpdatesBlocked(true) twice in a row.
     1134    // That probably indicates nested use of InstanceUpdateBlocker and a bug.
     1135    ASSERT(!value || !instanceUpdatesBlocked());
     1136
    11331137    if (m_svgRareData)
    11341138        m_svgRareData->setInstanceUpdatesBlocked(value);
     
    12021206}
    12031207
    1204 }
     1208void SVGElement::invalidateInstances()
     1209{
     1210    if (!inDocument())
     1211        return;
     1212
     1213    if (instanceUpdatesBlocked())
     1214        return;
     1215
     1216    auto& instances = this->instances();
     1217    if (instances.isEmpty())
     1218        return;
     1219
     1220    // Mark all use elements referencing 'element' for rebuilding
     1221    do {
     1222        SVGElement* instance = *instances.begin();
     1223        if (SVGUseElement* element = instance->correspondingUseElement()) {
     1224            ASSERT(element->inDocument());
     1225            element->invalidateShadowTree();
     1226        }
     1227        instance->setCorrespondingElement(nullptr);
     1228    } while (!instances.isEmpty());
     1229
     1230    // FIXME: Why is this needed?
     1231    document().updateStyleIfNeeded();
     1232}
     1233
     1234}
  • trunk/Source/WebCore/svg/SVGElement.h

    r179555 r179695  
    156156    void callClearTarget() { clearTarget(); }
    157157
     158    class InstanceUpdateBlocker;
     159
    158160protected:
    159161    SVGElement(const QualifiedName&, Document&);
     
    184186    void updateRelativeLengthsInformation(bool hasRelativeLengths, SVGElement*);
    185187
     188    class InstanceInvalidationGuard;
     189
    186190private:
    187191    friend class SVGElementInstance;
     
    200204    virtual bool filterOutAnimatableAttribute(const QualifiedName&) const;
    201205#endif
     206
     207    void invalidateInstances();
    202208
    203209    std::unique_ptr<SVGElementRareData> m_svgRareData;
     
    209215    END_DECLARE_ANIMATED_PROPERTIES
    210216
     217};
     218
     219class SVGElement::InstanceInvalidationGuard {
     220public:
     221    InstanceInvalidationGuard(SVGElement&);
     222    ~InstanceInvalidationGuard();
     223private:
     224    SVGElement& m_element;
     225};
     226
     227class SVGElement::InstanceUpdateBlocker {
     228public:
     229    InstanceUpdateBlocker(SVGElement&);
     230    ~InstanceUpdateBlocker();
     231private:
     232    SVGElement& m_element;
    211233};
    212234
     
    223245};
    224246
     247inline SVGElement::InstanceInvalidationGuard::InstanceInvalidationGuard(SVGElement& element)
     248    : m_element(element)
     249{
     250}
     251
     252inline SVGElement::InstanceInvalidationGuard::~InstanceInvalidationGuard()
     253{
     254    m_element.invalidateInstances();
     255}
     256
     257inline SVGElement::InstanceUpdateBlocker::InstanceUpdateBlocker(SVGElement& element)
     258    : m_element(element)
     259{
     260    m_element.setInstanceUpdatesBlocked(true);
     261}
     262
     263inline SVGElement::InstanceUpdateBlocker::~InstanceUpdateBlocker()
     264{
     265    m_element.setInstanceUpdatesBlocked(false);
     266}
     267
    225268inline bool Node::hasTagName(const SVGQualifiedName& name) const
    226269{
  • trunk/Source/WebCore/svg/SVGElementInstance.cpp

    r179555 r179695  
    168168}
    169169
    170 void SVGElementInstance::invalidateAllInstancesOfElement(SVGElement* element)
    171 {
    172     if (!element || !element->inDocument())
    173         return;
    174 
    175     if (element->instanceUpdatesBlocked())
    176         return;
    177 
    178     auto& instances = element->instances();
    179     if (instances.isEmpty())
    180         return;
    181 
    182     // Mark all use elements referencing 'element' for rebuilding
    183     do {
    184         SVGElement* instance = *instances.begin();
    185         if (SVGUseElement* element = instance->correspondingUseElement()) {
    186             ASSERT(element->inDocument());
    187             element->invalidateShadowTree();
    188         }
    189         instance->setCorrespondingElement(nullptr);
    190     } while (!instances.isEmpty());
    191 
    192     element->document().updateStyleIfNeeded();
    193 }
    194 
    195170EventTargetInterface SVGElementInstance::eventTargetInterface() const
    196171{
     
    241216}
    242217
    243 SVGElementInstance::InstanceUpdateBlocker::InstanceUpdateBlocker(SVGElement* targetElement)
    244     : m_targetElement(targetElement)
    245 {
    246     if (m_targetElement)
    247         m_targetElement->setInstanceUpdatesBlocked(true);
    248 }
    249 
    250 SVGElementInstance::InstanceUpdateBlocker::~InstanceUpdateBlocker()
    251 {
    252     if (m_targetElement)
    253         m_targetElement->setInstanceUpdatesBlocked(false);
    254 }
    255    
    256 }
     218}
  • trunk/Source/WebCore/svg/SVGElementInstance.h

    r179555 r179695  
    7171
    7272    Document* ownerDocument() const;
    73 
    74     class InvalidationGuard {
    75         WTF_MAKE_NONCOPYABLE(InvalidationGuard);
    76     public:   
    77         InvalidationGuard(SVGElement* element) : m_element(element) { }
    78         ~InvalidationGuard() { SVGElementInstance::invalidateAllInstancesOfElement(m_element); }
    79     private:
    80         SVGElement* m_element;
    81     };
    82 
    83     class InstanceUpdateBlocker {
    84         WTF_MAKE_NONCOPYABLE(InstanceUpdateBlocker);
    85     public:
    86         InstanceUpdateBlocker(SVGElement* targetElement);
    87         ~InstanceUpdateBlocker();
    88 
    89     private:
    90         SVGElement* m_targetElement;
    91     };
    92    
    93     static void invalidateAllInstancesOfElement(SVGElement*);
    9473
    9574    using TreeShared<SVGElementInstance>::ref;
  • trunk/Source/WebCore/svg/SVGEllipseElement.cpp

    r179555 r179695  
    109109    }
    110110
    111     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     111    InstanceInvalidationGuard guard(*this);
    112112
    113113    if (attrName == SVGNames::cxAttr
  • trunk/Source/WebCore/svg/SVGFEBlendElement.cpp

    r179555 r179695  
    112112    }
    113113
    114     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     114    InstanceInvalidationGuard guard(*this);
    115115
    116116    if (attrName == SVGNames::modeAttr) {
  • trunk/Source/WebCore/svg/SVGFEColorMatrixElement.cpp

    r179555 r179695  
    116116    }
    117117
    118     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     118    InstanceInvalidationGuard guard(*this);
    119119
    120120    if (attrName == SVGNames::typeAttr || attrName == SVGNames::valuesAttr) {
  • trunk/Source/WebCore/svg/SVGFECompositeElement.cpp

    r179555 r179695  
    152152    }
    153153
    154     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     154    InstanceInvalidationGuard guard(*this);
    155155
    156156    if (attrName == SVGNames::operatorAttr
  • trunk/Source/WebCore/svg/SVGFEConvolveMatrixElement.cpp

    r179555 r179695  
    258258    }
    259259
    260     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     260    InstanceInvalidationGuard guard(*this);
    261261
    262262    if (attrName == SVGNames::edgeModeAttr
  • trunk/Source/WebCore/svg/SVGFEDiffuseLightingElement.cpp

    r179555 r179695  
    175175    }
    176176
    177     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     177    InstanceInvalidationGuard guard(*this);
    178178   
    179179    if (attrName == SVGNames::surfaceScaleAttr
  • trunk/Source/WebCore/svg/SVGFEDisplacementMapElement.cpp

    r179555 r179695  
    133133    }
    134134
    135     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     135    InstanceInvalidationGuard guard(*this);
    136136   
    137137    if (attrName == SVGNames::xChannelSelectorAttr || attrName == SVGNames::yChannelSelectorAttr || attrName == SVGNames::scaleAttr) {
  • trunk/Source/WebCore/svg/SVGFEDropShadowElement.cpp

    r179555 r179695  
    136136    }
    137137
    138     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     138    InstanceInvalidationGuard guard(*this);
    139139   
    140140    if (attrName == SVGNames::inAttr
  • trunk/Source/WebCore/svg/SVGFEGaussianBlurElement.cpp

    r179555 r179695  
    131131    }
    132132
    133     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     133    InstanceInvalidationGuard guard(*this);
    134134   
    135135    if (attrName == SVGNames::inAttr
  • trunk/Source/WebCore/svg/SVGFEImageElement.cpp

    r179555 r179695  
    156156    }
    157157
    158     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     158    InstanceInvalidationGuard guard(*this);
    159159   
    160160    if (attrName == SVGNames::preserveAspectRatioAttr) {
  • trunk/Source/WebCore/svg/SVGFELightElement.cpp

    r179555 r179695  
    171171    }
    172172
    173     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     173    InstanceInvalidationGuard guard(*this);
    174174   
    175175    if (attrName == SVGNames::azimuthAttr
  • trunk/Source/WebCore/svg/SVGFEMergeNodeElement.cpp

    r179555 r179695  
    8282    }
    8383
    84     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     84    InstanceInvalidationGuard guard(*this);
    8585
    8686    if (attrName == SVGNames::inAttr) {
  • trunk/Source/WebCore/svg/SVGFEMorphologyElement.cpp

    r179555 r179695  
    142142    }
    143143
    144     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     144    InstanceInvalidationGuard guard(*this);
    145145   
    146146    if (attrName == SVGNames::operatorAttr || attrName == SVGNames::radiusAttr) {
  • trunk/Source/WebCore/svg/SVGFEOffsetElement.cpp

    r179555 r179695  
    9898    }
    9999
    100     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     100    InstanceInvalidationGuard guard(*this);
    101101   
    102102    if (attrName == SVGNames::inAttr || attrName == SVGNames::dxAttr || attrName == SVGNames::dyAttr) {
  • trunk/Source/WebCore/svg/SVGFESpecularLightingElement.cpp

    r179555 r179695  
    186186    }
    187187
    188     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     188    InstanceInvalidationGuard guard(*this);
    189189   
    190190    if (attrName == SVGNames::surfaceScaleAttr
  • trunk/Source/WebCore/svg/SVGFETileElement.cpp

    r179555 r179695  
    8282    }
    8383
    84     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     84    InstanceInvalidationGuard guard(*this);
    8585
    8686    if (attrName == SVGNames::inAttr) {
  • trunk/Source/WebCore/svg/SVGFETurbulenceElement.cpp

    r179555 r179695  
    156156    }
    157157
    158     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     158    InstanceInvalidationGuard guard(*this);
    159159   
    160160    if (attrName == SVGNames::baseFrequencyAttr
  • trunk/Source/WebCore/svg/SVGFilterElement.cpp

    r179555 r179695  
    166166    }
    167167
    168     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     168    InstanceInvalidationGuard guard(*this);
    169169
    170170    if (attrName == SVGNames::xAttr
  • trunk/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp

    r179555 r179695  
    113113    }
    114114
    115     SVGElementInstance::InvalidationGuard invalidationGuard(this);   
     115    InstanceInvalidationGuard guard(*this);
    116116    invalidate();
    117117}
  • trunk/Source/WebCore/svg/SVGForeignObjectElement.cpp

    r179555 r179695  
    113113    }
    114114
    115     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     115    InstanceInvalidationGuard guard(*this);
    116116
    117117    if (attrName == SVGNames::widthAttr
  • trunk/Source/WebCore/svg/SVGGElement.cpp

    r179555 r179695  
    8383    }
    8484
    85     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     85    InstanceInvalidationGuard guard(*this);
    8686
    8787    if (auto renderer = this->renderer())
  • trunk/Source/WebCore/svg/SVGGradientElement.cpp

    r179555 r179695  
    120120    }
    121121
    122     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     122    InstanceInvalidationGuard guard(*this);
    123123   
    124124    if (RenderObject* object = renderer())
  • trunk/Source/WebCore/svg/SVGGraphicsElement.cpp

    r179555 r179695  
    138138    }
    139139
    140     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     140    InstanceInvalidationGuard guard(*this);
    141141
    142142    if (SVGTests::handleAttributeChange(this, attrName))
  • trunk/Source/WebCore/svg/SVGImageElement.cpp

    r179555 r179695  
    123123    }
    124124
    125     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     125    InstanceInvalidationGuard guard(*this);
    126126
    127127    if (attrName == SVGNames::widthAttr
  • trunk/Source/WebCore/svg/SVGLineElement.cpp

    r179555 r179695  
    108108    }
    109109
    110     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     110    InstanceInvalidationGuard guard(*this);
    111111   
    112112    bool isLengthAttribute = attrName == SVGNames::x1Attr
  • trunk/Source/WebCore/svg/SVGLinearGradientElement.cpp

    r179555 r179695  
    110110    }
    111111
    112     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     112    InstanceInvalidationGuard guard(*this);
    113113   
    114114    updateRelativeLengthsInformation();
  • trunk/Source/WebCore/svg/SVGMPathElement.cpp

    r179555 r179695  
    141141    }
    142142
    143     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     143    InstanceInvalidationGuard guard(*this);
    144144
    145145    if (SVGURIReference::isKnownAttribute(attrName)) {
  • trunk/Source/WebCore/svg/SVGMarkerElement.cpp

    r179555 r179695  
    167167    }
    168168
    169     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     169    InstanceInvalidationGuard guard(*this);
    170170   
    171171    if (attrName == SVGNames::refXAttr
  • trunk/Source/WebCore/svg/SVGMaskElement.cpp

    r179555 r179695  
    135135    }
    136136
    137     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     137    InstanceInvalidationGuard guard(*this);
    138138
    139139    if (attrName == SVGNames::xAttr
  • trunk/Source/WebCore/svg/SVGPathElement.cpp

    r179555 r179695  
    260260    }
    261261
    262     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     262    InstanceInvalidationGuard guard(*this);
    263263
    264264    RenderSVGPath* renderer = downcast<RenderSVGPath>(this->renderer());
  • trunk/Source/WebCore/svg/SVGPatternElement.cpp

    r179555 r179695  
    160160    }
    161161
    162     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     162    InstanceInvalidationGuard guard(*this);
    163163
    164164    if (attrName == SVGNames::xAttr
  • trunk/Source/WebCore/svg/SVGPolyElement.cpp

    r179555 r179695  
    110110    }
    111111
    112     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     112    InstanceInvalidationGuard guard(*this);
    113113
    114114    auto* renderer = downcast<RenderSVGShape>(this->renderer());
  • trunk/Source/WebCore/svg/SVGRadialGradientElement.cpp

    r179555 r179695  
    122122    }
    123123
    124     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     124    InstanceInvalidationGuard guard(*this);
    125125   
    126126    updateRelativeLengthsInformation();
  • trunk/Source/WebCore/svg/SVGRectElement.cpp

    r179555 r179695  
    121121    }
    122122
    123     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     123    InstanceInvalidationGuard guard(*this);
    124124
    125125    if (attrName == SVGNames::xAttr
  • trunk/Source/WebCore/svg/SVGSVGElement.cpp

    r179555 r179695  
    301301    }
    302302
    303     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     303    InstanceInvalidationGuard guard(*this);
    304304
    305305    if (updateRelativeLengthsOrViewBox
  • trunk/Source/WebCore/svg/SVGScriptElement.cpp

    r179555 r179695  
    9999    }
    100100
    101     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     101    InstanceInvalidationGuard guard(*this);
    102102
    103103    if (attrName == SVGNames::typeAttr || attrName == HTMLNames::onerrorAttr)
  • trunk/Source/WebCore/svg/SVGStopElement.cpp

    r179555 r179695  
    8787    }
    8888
    89     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     89    InstanceInvalidationGuard guard(*this);
    9090
    9191    if (attrName == SVGNames::offsetAttr) {
  • trunk/Source/WebCore/svg/SVGSymbolElement.cpp

    r179555 r179695  
    8989    }
    9090
    91     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     91    InstanceInvalidationGuard guard(*this);
    9292
    9393    // Every other property change is ignored.
  • trunk/Source/WebCore/svg/SVGTRefElement.cpp

    r179555 r179695  
    207207    }
    208208
    209     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     209    InstanceInvalidationGuard guard(*this);
    210210
    211211    if (SVGURIReference::isKnownAttribute(attrName)) {
  • trunk/Source/WebCore/svg/SVGTextContentElement.cpp

    r179555 r179695  
    269269    }
    270270
    271     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     271    InstanceInvalidationGuard guard(*this);
    272272
    273273    if (attrName == SVGNames::textLengthAttr)
  • trunk/Source/WebCore/svg/SVGTextPathElement.cpp

    r179555 r179695  
    113113    }
    114114
    115     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     115    InstanceInvalidationGuard guard(*this);
    116116
    117117    if (SVGURIReference::isKnownAttribute(attrName)) {
  • trunk/Source/WebCore/svg/SVGTextPositioningElement.cpp

    r179555 r179695  
    142142    }
    143143
    144     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     144    InstanceInvalidationGuard guard(*this);
    145145
    146146    bool updateRelativeLengths = attrName == SVGNames::xAttr
  • trunk/Source/WebCore/svg/SVGUseElement.cpp

    r179555 r179695  
    224224    }
    225225
    226     SVGElementInstance::InvalidationGuard invalidationGuard(this);
     226    InstanceInvalidationGuard guard(*this);
    227227
    228228    if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr || attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr) {
  • trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp

    r179555 r179695  
    500500        setAttributeName(constructQualifiedName(this, fastGetAttribute(SVGNames::attributeNameAttr)));
    501501    else if (attrName.matches(XLinkNames::hrefAttr)) {
    502         SVGElementInstance::InvalidationGuard invalidationGuard(this);
     502        InstanceInvalidationGuard guard(*this);
    503503        buildPendingResource();
    504504    } else if (inDocument()) {
Note: See TracChangeset for help on using the changeset viewer.