Chromium Code Reviews| Index: Source/core/animation/StringKeyframe.cpp |
| diff --git a/Source/core/animation/StringKeyframe.cpp b/Source/core/animation/StringKeyframe.cpp |
| index 76e4fcf7843944e1b8c7d0418a1923e5d4df1720..1be1989908f3778e5d6a2c1ee518c6a81ccdbce1 100644 |
| --- a/Source/core/animation/StringKeyframe.cpp |
| +++ b/Source/core/animation/StringKeyframe.cpp |
| @@ -6,9 +6,11 @@ |
| #include "core/animation/StringKeyframe.h" |
| #include "core/animation/AngleSVGInterpolation.h" |
| +#include "core/animation/AnimationType.h" |
| #include "core/animation/ColorStyleInterpolation.h" |
| #include "core/animation/CompositorAnimations.h" |
| #include "core/animation/ConstantStyleInterpolation.h" |
| +#include "core/animation/DefaultAnimationType.h" |
| #include "core/animation/DefaultSVGInterpolation.h" |
| #include "core/animation/DeferredLegacyStyleInterpolation.h" |
| #include "core/animation/DoubleStyleInterpolation.h" |
| @@ -17,6 +19,7 @@ |
| #include "core/animation/ImageStyleInterpolation.h" |
| #include "core/animation/IntegerOptionalIntegerSVGInterpolation.h" |
| #include "core/animation/IntegerSVGInterpolation.h" |
| +#include "core/animation/InvalidatableStyleInterpolation.h" |
| #include "core/animation/LegacyStyleInterpolation.h" |
| #include "core/animation/LengthBoxStyleInterpolation.h" |
| #include "core/animation/LengthPairStyleInterpolation.h" |
| @@ -88,13 +91,13 @@ PassRefPtrWillBeRawPtr<Keyframe> StringKeyframe::clone() const |
| return adoptRefWillBeNoop(new StringKeyframe(*this)); |
| } |
| -PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::createPropertySpecificKeyframe(PropertyHandle property) const |
| +PassRefPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::createPropertySpecificKeyframe(PropertyHandle property) const |
| { |
| if (property.isCSSProperty()) |
| - return adoptPtrWillBeNoop(new CSSPropertySpecificKeyframe(offset(), &easing(), cssPropertyValue(property.cssProperty()), composite())); |
| + return adoptRefWillBeNoop(new CSSPropertySpecificKeyframe(offset(), &easing(), cssPropertyValue(property.cssProperty()), composite())); |
| ASSERT(property.isSVGAttribute()); |
| - return adoptPtrWillBeNoop(new SVGPropertySpecificKeyframe(offset(), &easing(), svgPropertyValue(*property.svgAttribute()), composite())); |
| + return adoptRefWillBeNoop(new SVGPropertySpecificKeyframe(offset(), &easing(), svgPropertyValue(*property.svgAttribute()), composite())); |
| } |
| DEFINE_TRACE(StringKeyframe) |
| @@ -150,11 +153,33 @@ InterpolationRange setRange(CSSPropertyID id) |
| } |
| } |
| +const Vector<const AnimationType*>* applicableTypesForProperty(CSSPropertyID property) |
|
shans
2015/05/28 05:48:14
This can be deferred until we support anything tha
alancutter (OOO until 2018)
2015/06/01 07:35:29
This code serves the AnimationTypes as per propert
|
| +{ |
| + using ApplicableTypesMap = HashMap<CSSPropertyID, const Vector<const AnimationType*>*>; |
| + DEFINE_STATIC_LOCAL(ApplicableTypesMap, applicableTypesMap, ()); |
| + if (applicableTypesMap.contains(property)) |
| + return applicableTypesMap.get(property); |
| + |
| + // TODO(alancutter): Support all animatable CSS properties here so we can stop falling back to the old StyleInterpolation implementation. |
| + if (CSSPropertyMetadata::isAnimatableProperty(property)) |
| + return nullptr; |
| + |
| + auto applicableTypes = new Vector<const AnimationType*>(); |
| + applicableTypes->append(new DefaultAnimationType(property)); |
| + applicableTypesMap.add(property, applicableTypes); |
| + return applicableTypes; |
| +} |
| + |
| } // namespace |
| -PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::CSSPropertySpecificKeyframe::maybeCreateInterpolation(PropertyHandle propertyHandle, Keyframe::PropertySpecificKeyframe& end, Element* element, const ComputedStyle* baseStyle) const |
| +PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::CSSPropertySpecificKeyframe::maybeCreateInterpolation(PropertyHandle propertyHandle, Keyframe::PropertySpecificKeyframe& end, Element* element, const ComputedStyle* baseStyle) |
| { |
| CSSPropertyID property = propertyHandle.cssProperty(); |
| + const Vector<const AnimationType*>* applicableTypes = applicableTypesForProperty(property); |
| + if (applicableTypes) |
| + return InvalidatableStyleInterpolation::create(*applicableTypes, this, toCSSPropertySpecificKeyframe(&end)); |
| + |
| + // TODO(alancutter): Remove the remainder of this function. |
| // FIXME: Refactor this into a generic piece that lives in InterpolationEffect, and a template parameter specific converter. |
| CSSValue* fromCSSValue = m_value.get(); |
| @@ -178,7 +203,6 @@ PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::CSSPropertySpecificKeyfram |
| return nullptr; |
| } |
| - // FIXME: Generate this giant switch statement. |
| switch (property) { |
| case CSSPropertyLineHeight: |
| if (LengthStyleInterpolation::canCreateFrom(*fromCSSValue) && LengthStyleInterpolation::canCreateFrom(*toCSSValue)) |
| @@ -438,16 +462,16 @@ PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::CSSPropertySpecificKeyfram |
| } |
| -PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::CSSPropertySpecificKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const |
| +PassRefPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::CSSPropertySpecificKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const |
| { |
| - return adoptPtrWillBeNoop(new CSSPropertySpecificKeyframe(offset, easing, static_cast<CSSValue*>(0), EffectModel::CompositeAdd)); |
| + return adoptRefWillBeNoop(new CSSPropertySpecificKeyframe(offset, easing, static_cast<CSSValue*>(0), EffectModel::CompositeAdd)); |
| } |
| -PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::CSSPropertySpecificKeyframe::cloneWithOffset(double offset) const |
| +PassRefPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::CSSPropertySpecificKeyframe::cloneWithOffset(double offset) const |
| { |
| Keyframe::PropertySpecificKeyframe* theClone = new CSSPropertySpecificKeyframe(offset, m_easing, m_value.get()); |
| toCSSPropertySpecificKeyframe(theClone)->m_animatableValueCache = m_animatableValueCache; |
| - return adoptPtrWillBeNoop(theClone); |
| + return adoptRefWillBeNoop(theClone); |
| } |
| DEFINE_TRACE(StringKeyframe::CSSPropertySpecificKeyframe) |
| @@ -475,14 +499,14 @@ DEFINE_TRACE(StringKeyframe::SVGPropertySpecificKeyframe) |
| Keyframe::PropertySpecificKeyframe::trace(visitor); |
| } |
| -PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> SVGPropertySpecificKeyframe::cloneWithOffset(double offset) const |
| +PassRefPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> SVGPropertySpecificKeyframe::cloneWithOffset(double offset) const |
| { |
| - return adoptPtrWillBeNoop(new SVGPropertySpecificKeyframe(offset, m_easing, m_value)); |
| + return adoptRefWillBeNoop(new SVGPropertySpecificKeyframe(offset, m_easing, m_value)); |
| } |
| -PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> SVGPropertySpecificKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const |
| +PassRefPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> SVGPropertySpecificKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const |
| { |
| - return adoptPtrWillBeNoop(new SVGPropertySpecificKeyframe(offset, easing, "", EffectModel::CompositeAdd)); |
| + return adoptRefWillBeNoop(new SVGPropertySpecificKeyframe(offset, easing, "", EffectModel::CompositeAdd)); |
| } |
| namespace { |
| @@ -540,7 +564,7 @@ PassRefPtrWillBeRawPtr<Interpolation> createSVGInterpolation(SVGPropertyBase* fr |
| } // namespace |
| -PassRefPtrWillBeRawPtr<Interpolation> SVGPropertySpecificKeyframe::maybeCreateInterpolation(PropertyHandle propertyHandle, Keyframe::PropertySpecificKeyframe& end, Element* element, const ComputedStyle* baseStyle) const |
| +PassRefPtrWillBeRawPtr<Interpolation> SVGPropertySpecificKeyframe::maybeCreateInterpolation(PropertyHandle propertyHandle, Keyframe::PropertySpecificKeyframe& end, Element* element, const ComputedStyle* baseStyle) |
| { |
| ASSERT(element); |
| RefPtrWillBeRawPtr<SVGAnimatedPropertyBase> attribute = toSVGElement(element)->propertyFromAttribute(*propertyHandle.svgAttribute()); |