Chromium Code Reviews| Index: third_party/WebKit/Source/core/svg/SVGElement.cpp |
| diff --git a/third_party/WebKit/Source/core/svg/SVGElement.cpp b/third_party/WebKit/Source/core/svg/SVGElement.cpp |
| index 5024d320e456a34ab3ac57681c10f25116eb4054..6ef3f1c5259ff2712e9d0e3cda6e6bcb28759b46 100644 |
| --- a/third_party/WebKit/Source/core/svg/SVGElement.cpp |
| +++ b/third_party/WebKit/Source/core/svg/SVGElement.cpp |
| @@ -40,6 +40,7 @@ |
| #include "core/html/HTMLElement.h" |
| #include "core/layout/LayoutObject.h" |
| #include "core/layout/svg/LayoutSVGResourceContainer.h" |
| +#include "core/svg/SVGAnimateElement.h" |
| #include "core/svg/SVGCursorElement.h" |
| #include "core/svg/SVGDocumentExtensions.h" |
| #include "core/svg/SVGElementRareData.h" |
| @@ -47,6 +48,7 @@ |
| #include "core/svg/SVGSVGElement.h" |
| #include "core/svg/SVGTitleElement.h" |
| #include "core/svg/SVGUseElement.h" |
| +#include "core/svg/properties/SVGProperty.h" |
| #include "platform/JSONValues.h" |
| #include "wtf/TemporaryChange.h" |
| @@ -240,6 +242,38 @@ void SVGElement::setWebAnimationsPending() |
| document().accessSVGExtensions().addWebAnimationsPendingSVGElement(*this); |
| } |
| +template<typename T> |
| +static void updateInstancesAnimatedAttribute(SVGElement* element, const QualifiedName& attribute, T callback) |
| +{ |
| + SVGElement::InstanceUpdateBlocker blocker(element); |
| + for (SVGElement* instance : SVGAnimateElement::findElementInstances(element)) { |
| + RefPtrWillBeRawPtr<SVGAnimatedPropertyBase> animatedProperty = instance->propertyFromAttribute(attribute); |
| + if (animatedProperty) { |
| + callback(*animatedProperty); |
| + instance->invalidateSVGAttributes(); |
| + instance->svgAttributeChanged(attribute); |
| + } |
| + } |
| +} |
| + |
| +void SVGElement::setWebAnimatedAttribute(const QualifiedName& attribute, PassRefPtrWillBeRawPtr<SVGPropertyBase> value) |
| +{ |
| + updateInstancesAnimatedAttribute(this, attribute, [&value](SVGAnimatedPropertyBase& animatedProperty) { |
| + animatedProperty.setAnimatedValue(value.get()); |
| + }); |
| + ensureSVGRareData()->webAnimatedAttributes().add(&attribute); |
| +} |
| + |
| +void SVGElement::clearWebAnimatedAttributes() |
| +{ |
| + for (const QualifiedName* attribute : ensureSVGRareData()->webAnimatedAttributes()) { |
|
fs
2015/11/27 09:34:36
Use svgRareData (+assert/check) here (and below) i
alancutter (OOO until 2018)
2015/11/30 00:43:30
Done.
|
| + updateInstancesAnimatedAttribute(this, *attribute, [](SVGAnimatedPropertyBase& animatedProperty) { |
| + animatedProperty.animationEnded(); |
| + }); |
| + } |
| + ensureSVGRareData()->webAnimatedAttributes().clear(); |
| +} |
| + |
| AffineTransform SVGElement::localCoordinateSpaceTransform(CTMScope) const |
| { |
| // To be overriden by SVGGraphicsElement (or as special case SVGTextElement and SVGPatternElement) |