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

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: Check rare data 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..4df0776a7f6f47e431acff2c63eb4f0e5ded8023 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,40 @@ 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()
+{
+ if (!hasSVGRareData())
+ return;
+ for (const QualifiedName* attribute : svgRareData()->webAnimatedAttributes()) {
+ updateInstancesAnimatedAttribute(this, *attribute, [](SVGAnimatedPropertyBase& animatedProperty) {
+ animatedProperty.animationEnded();
+ });
+ }
+ svgRareData()->webAnimatedAttributes().clear();
+}
+
AffineTransform SVGElement::localCoordinateSpaceTransform(CTMScope) const
{
// To be overriden by SVGGraphicsElement (or as special case SVGTextElement and SVGPatternElement)
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGElement.h ('k') | third_party/WebKit/Source/core/svg/SVGElementRareData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698