Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(832)

Unified Diff: third_party/WebKit/Source/core/svg/SVGElement.cpp

Issue 1474263002: Clear SVG Web Animation effects when animations exit their fill phase (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@_svgPathInterpolationType
Patch Set: Add test Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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)

Powered by Google App Engine
This is Rietveld 408576698