| Index: third_party/WebKit/Source/core/svg/SVGAnimatedTypeAnimator.cpp
|
| diff --git a/third_party/WebKit/Source/core/svg/SVGAnimatedTypeAnimator.cpp b/third_party/WebKit/Source/core/svg/SVGAnimatedTypeAnimator.cpp
|
| index 10f2e1fd33e3eee2e2f1d22c4037213fc8e3c985..bfb5e3c118bd884c7a669f7922e1371fe1d81225 100644
|
| --- a/third_party/WebKit/Source/core/svg/SVGAnimatedTypeAnimator.cpp
|
| +++ b/third_party/WebKit/Source/core/svg/SVGAnimatedTypeAnimator.cpp
|
| @@ -26,6 +26,7 @@
|
| #include "core/svg/SVGLength.h"
|
| #include "core/svg/SVGLengthList.h"
|
| #include "core/svg/SVGNumber.h"
|
| +#include "core/svg/SVGPointList.h"
|
| #include "core/svg/SVGString.h"
|
| #include "core/svg/SVGTransformList.h"
|
| #include "core/svg/properties/SVGAnimatedProperty.h"
|
| @@ -37,7 +38,7 @@
|
| , m_contextElement(nullptr)
|
| , m_type(AnimatedUnknown)
|
| {
|
| - DCHECK(m_animationElement);
|
| + ASSERT(m_animationElement);
|
| }
|
|
|
| void SVGAnimatedTypeAnimator::clear()
|
| @@ -49,7 +50,7 @@
|
|
|
| void SVGAnimatedTypeAnimator::reset(SVGElement* contextElement)
|
| {
|
| - DCHECK(contextElement);
|
| + ASSERT(contextElement);
|
| m_contextElement = contextElement;
|
|
|
| const QualifiedName& attributeName = m_animationElement->attributeName();
|
| @@ -62,31 +63,37 @@
|
| if (m_type == AnimatedTransformList && !isSVGAnimateTransformElement(*m_animationElement))
|
| m_type = AnimatedUnknown;
|
|
|
| - DCHECK(m_type != AnimatedPoint
|
| + ASSERT(m_type != AnimatedPoint
|
| && m_type != AnimatedStringList
|
| && m_type != AnimatedTransform);
|
| }
|
|
|
| -SVGPropertyBase* SVGAnimatedTypeAnimator::createPropertyForAttributeAnimation(const String& value) const
|
| -{
|
| - // SVG DOM animVal animation code-path.
|
| - if (m_type == AnimatedTransformList) {
|
| - // TransformList must be animated via <animateTransform>,
|
| - // and its {from,by,to} attribute values needs to be parsed w.r.t. its "type" attribute.
|
| - // Spec: http://www.w3.org/TR/SVG/single-page.html#animate-AnimateTransformElement
|
| - DCHECK(m_animationElement);
|
| - SVGTransformType transformType = toSVGAnimateTransformElement(m_animationElement)->transformType();
|
| - return SVGTransformList::create(transformType, value);
|
| - }
|
| - DCHECK(m_animatedProperty);
|
| - return m_animatedProperty->currentValueBase()->cloneForAnimation(value);
|
| -}
|
| -
|
| -SVGPropertyBase* SVGAnimatedTypeAnimator::createPropertyForCSSAnimation(const String& value) const
|
| -{
|
| +SVGPropertyBase* SVGAnimatedTypeAnimator::createPropertyForAnimation(const String& value)
|
| +{
|
| + ASSERT(m_contextElement);
|
| +
|
| + if (isAnimatingSVGDom()) {
|
| + // SVG DOM animVal animation code-path.
|
| +
|
| + if (m_type == AnimatedTransformList) {
|
| + // TransformList must be animated via <animateTransform>,
|
| + // and its {from,by,to} attribute values needs to be parsed w.r.t. its "type" attribute.
|
| + // Spec: http://www.w3.org/TR/SVG/single-page.html#animate-AnimateTransformElement
|
| + ASSERT(m_animationElement);
|
| + SVGTransformType transformType = toSVGAnimateTransformElement(m_animationElement)->transformType();
|
| + return SVGTransformList::create(transformType, value);
|
| + }
|
| +
|
| + ASSERT(m_animatedProperty);
|
| + return m_animatedProperty->currentValueBase()->cloneForAnimation(value);
|
| + }
|
| +
|
| + ASSERT(isAnimatingCSSProperty());
|
| +
|
| // CSS properties animation code-path.
|
| // Create a basic instance of the corresponding SVG property.
|
| // The instance will not have full context info. (e.g. SVGLengthMode)
|
| +
|
| switch (m_type) {
|
| case AnimatedColor:
|
| return SVGColorProperty::create(value);
|
| @@ -110,9 +117,8 @@
|
| property->setValueAsString(value);
|
| return property;
|
| }
|
| - // These types don't appear in the table in
|
| - // SVGElement::animatedPropertyTypeForCSSAttribute() and thus don't need
|
| - // support.
|
| +
|
| + // These types don't appear in the table in SVGElement::animatedPropertyTypeForCSSAttribute() and thus don't need support.
|
| case AnimatedAngle:
|
| case AnimatedBoolean:
|
| case AnimatedEnumeration:
|
| @@ -128,23 +134,35 @@
|
| case AnimatedStringList:
|
| case AnimatedTransform:
|
| case AnimatedTransformList:
|
| + ASSERT_NOT_REACHED();
|
| +
|
| case AnimatedUnknown:
|
| - break;
|
| - }
|
| - NOTREACHED();
|
| + ASSERT_NOT_REACHED();
|
| + };
|
| +
|
| + ASSERT_NOT_REACHED();
|
| return nullptr;
|
| }
|
|
|
| -SVGPropertyBase* SVGAnimatedTypeAnimator::createPropertyForAnimation(const String& value) const
|
| -{
|
| - DCHECK(m_contextElement);
|
| - if (isAnimatingSVGDom())
|
| - return createPropertyForAttributeAnimation(value);
|
| - DCHECK(isAnimatingCSSProperty());
|
| - return createPropertyForCSSAnimation(value);
|
| -}
|
| -
|
| -SVGPropertyBase* SVGAnimatedTypeAnimator::createAnimatedValue() const
|
| +SVGPropertyBase* SVGAnimatedTypeAnimator::createAnimatedValueFromString(const String& value)
|
| +{
|
| + return createPropertyForAnimation(value);
|
| +}
|
| +
|
| +void SVGAnimatedTypeAnimator::calculateFromAndToValues(Member<SVGPropertyBase>& from, Member<SVGPropertyBase>& to, const String& fromString, const String& toString)
|
| +{
|
| + from = createAnimatedValueFromString(fromString);
|
| + to = createAnimatedValueFromString(toString);
|
| +}
|
| +
|
| +void SVGAnimatedTypeAnimator::calculateFromAndByValues(Member<SVGPropertyBase>& from, Member<SVGPropertyBase>& to, const String& fromString, const String& byString)
|
| +{
|
| + from = createAnimatedValueFromString(fromString);
|
| + to = createAnimatedValueFromString(byString);
|
| + to->add(from, m_contextElement);
|
| +}
|
| +
|
| +SVGPropertyBase* SVGAnimatedTypeAnimator::createAnimatedValue()
|
| {
|
| DCHECK(isAnimatingSVGDom());
|
| SVGPropertyBase* animatedValue = m_animatedProperty->createAnimatedValue();
|
| @@ -152,6 +170,49 @@
|
| return animatedValue;
|
| }
|
|
|
| +class ParsePropertyFromString {
|
| + STACK_ALLOCATED();
|
| +public:
|
| + explicit ParsePropertyFromString(SVGAnimatedTypeAnimator* animator)
|
| + : m_animator(animator)
|
| + {
|
| + }
|
| +
|
| + SVGPropertyBase* operator()(SVGAnimationElement*, const String& value)
|
| + {
|
| + return m_animator->createPropertyForAnimation(value);
|
| + }
|
| +
|
| +private:
|
| + SVGAnimatedTypeAnimator* m_animator;
|
| +};
|
| +
|
| +void SVGAnimatedTypeAnimator::calculateAnimatedValue(float percentage, unsigned repeatCount, SVGPropertyBase* from, SVGPropertyBase* to, SVGPropertyBase* toAtEndOfDuration, SVGPropertyBase* animated)
|
| +{
|
| + ASSERT(m_animationElement);
|
| + ASSERT(m_contextElement);
|
| +
|
| + SVGPropertyBase* fromValue = m_animationElement->getAnimationMode() == ToAnimation ? animated : from;
|
| + SVGPropertyBase* toValue = to;
|
| + SVGPropertyBase* toAtEndOfDurationValue = toAtEndOfDuration;
|
| + SVGPropertyBase* animatedValue = animated;
|
| +
|
| + // Apply CSS inheritance rules.
|
| + ParsePropertyFromString parsePropertyFromString(this);
|
| + m_animationElement->adjustForInheritance<SVGPropertyBase*, ParsePropertyFromString>(parsePropertyFromString, m_animationElement->fromPropertyValueType(), fromValue, m_contextElement);
|
| + m_animationElement->adjustForInheritance<SVGPropertyBase*, ParsePropertyFromString>(parsePropertyFromString, m_animationElement->toPropertyValueType(), toValue, m_contextElement);
|
| +
|
| + animatedValue->calculateAnimatedValue(m_animationElement, percentage, repeatCount, fromValue, toValue, toAtEndOfDurationValue, m_contextElement);
|
| +}
|
| +
|
| +float SVGAnimatedTypeAnimator::calculateDistance(const String& fromString, const String& toString)
|
| +{
|
| + ASSERT(m_contextElement);
|
| + SVGPropertyBase* fromValue = createPropertyForAnimation(fromString);
|
| + SVGPropertyBase* toValue = createPropertyForAnimation(toString);
|
| + return fromValue->calculateDistance(toValue, m_contextElement);
|
| +}
|
| +
|
| DEFINE_TRACE(SVGAnimatedTypeAnimator)
|
| {
|
| visitor->trace(m_animationElement);
|
|
|