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

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

Issue 2746013007: Rework SMIL animation target invalidation (Closed)
Patch Set: Created 3 years, 9 months 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/SVGAnimateElement.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGAnimateElement.cpp b/third_party/WebKit/Source/core/svg/SVGAnimateElement.cpp
index 9e1233aae880c4d28337adc9bf1ecc31dc79e12c..9b4a99e79a77b75bbf03336a31846a68f7a22794 100644
--- a/third_party/WebKit/Source/core/svg/SVGAnimateElement.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGAnimateElement.cpp
@@ -105,8 +105,7 @@ SVGAnimateElement::SVGAnimateElement(const QualifiedName& tagName,
m_cssPropertyId(CSSPropertyInvalid),
m_fromPropertyValueType(RegularPropertyValue),
m_toPropertyValueType(RegularPropertyValue),
- m_attributeType(AttributeTypeAuto),
- m_hasInvalidCSSAttributeType(false) {}
+ m_attributeType(AttributeTypeAuto) {}
SVGAnimateElement* SVGAnimateElement::create(Document& document) {
return new SVGAnimateElement(SVGNames::animateTag, document);
@@ -214,30 +213,23 @@ AnimatedPropertyType SVGAnimateElement::animatedPropertyType() {
bool SVGAnimateElement::hasValidTarget() {
if (!SVGAnimationElement::hasValidTarget())
return false;
- if (!hasValidAttributeName())
+ if (attributeName() == anyQName())
return false;
resolveTargetProperty();
- return m_type != AnimatedUnknown && !m_hasInvalidCSSAttributeType;
-}
-
-bool SVGAnimateElement::hasValidAttributeName() const {
- return attributeName() != anyQName();
-}
-
-bool SVGAnimateElement::shouldApplyAnimation(
- const SVGElement& targetElement,
- const QualifiedName& attributeName) {
- if (!hasValidTarget() || !targetElement.parentNode())
+ if (m_type == AnimatedUnknown)
return false;
-
// Always animate CSS properties using the ApplyCSSAnimation code path,
// regardless of the attributeType value.
- if (isTargetAttributeCSSProperty(targetElement, attributeName))
- return true;
-
// If attributeType="CSS" and attributeName doesn't point to a CSS property,
// ignore the animation.
- return getAttributeType() != AttributeTypeCSS;
+ return isTargetAttributeCSSProperty(*targetElement(), attributeName()) ||
+ getAttributeType() != AttributeTypeCSS;
+}
+
+bool SVGAnimateElement::shouldApplyAnimation(
+ const SVGElement& targetElement,
+ const QualifiedName& attributeName) {
+ return targetElement.parentNode() && hasValidTarget();
}
SVGPropertyBase* SVGAnimateElement::createPropertyForAttributeAnimation(
@@ -557,51 +549,32 @@ float SVGAnimateElement::calculateDistance(const String& fromString,
return fromValue->calculateDistance(toValue, targetElement());
}
-void SVGAnimateElement::setTargetElement(SVGElement* target) {
- SVGAnimationElement::setTargetElement(target);
- checkInvalidCSSAttributeType();
+void SVGAnimateElement::willChangeAnimationTarget() {
+ SVGAnimationElement::willChangeAnimationTarget();
+ if (targetElement())
+ clearAnimatedType();
+}
+
+void SVGAnimateElement::didChangeAnimationTarget() {
+ SVGAnimationElement::didChangeAnimationTarget();
resetAnimatedPropertyType();
}
void SVGAnimateElement::setAttributeName(const QualifiedName& attributeName) {
- unscheduleIfScheduled();
- if (targetElement())
- clearAnimatedType();
+ willChangeAnimationTarget();
m_attributeName = attributeName;
- schedule();
- checkInvalidCSSAttributeType();
- resetAnimatedPropertyType();
+ didChangeAnimationTarget();
}
void SVGAnimateElement::setAttributeType(const AtomicString& attributeType) {
+ willChangeAnimationTarget();
if (attributeType == "CSS")
m_attributeType = AttributeTypeCSS;
else if (attributeType == "XML")
m_attributeType = AttributeTypeXML;
else
m_attributeType = AttributeTypeAuto;
- checkInvalidCSSAttributeType();
-}
-
-void SVGAnimateElement::checkInvalidCSSAttributeType() {
- bool hasInvalidCSSAttributeType =
- targetElement() && hasValidAttributeName() &&
- getAttributeType() == AttributeTypeCSS &&
- !isTargetAttributeCSSProperty(*targetElement(), attributeName());
-
- if (hasInvalidCSSAttributeType != m_hasInvalidCSSAttributeType) {
- if (hasInvalidCSSAttributeType)
- unscheduleIfScheduled();
-
- m_hasInvalidCSSAttributeType = hasInvalidCSSAttributeType;
-
- if (!hasInvalidCSSAttributeType)
- schedule();
- }
-
- // Clear values that may depend on the previous target.
- if (targetElement())
- clearAnimatedType();
+ didChangeAnimationTarget();
}
void SVGAnimateElement::resetAnimatedPropertyType() {
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGAnimateElement.h ('k') | third_party/WebKit/Source/core/svg/animation/SVGSMILElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698