1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef LegacyStyleInterpolation_h 6 #define LegacyStyleInterpolation_h 7 8 #include "core/animation/interpolation/StyleInterpolation.h" 9 #include "core/css/resolver/AnimatedStyleBuilder.h" 10 11 namespace WebCore { 12 13 class LegacyStyleInterpolation : public StyleInterpolation { 14 public: 15 static PassRefPtrWillBeRawPtr<LegacyStyleInterpolation> create(PassRefPtrWillBeRawPtr<AnimatableValue> start, PassRefPtrWillBeRawPtr<AnimatableValue> end, CSSPropertyID id) 16 { 17 return adoptRefWillBeNoop(new LegacyStyleInterpolation(InterpolableAnimatableValue::create(start), InterpolableAnimatableValue::create(end), id)); 18 } 19 20 virtual void apply(StyleResolverState& state) const OVERRIDE 21 { 22 AnimatedStyleBuilder::applyProperty(m_id, state, currentValue().get()); 23 } 24 25 virtual bool isLegacyStyleInterpolation() const OVERRIDE FINAL { return true; } 26 PassRefPtrWillBeRawPtr<AnimatableValue> currentValue() const 27 { 28 InterpolableAnimatableValue* value = static_cast<InterpolableAnimatableValue*>(m_cachedValue.get()); 29 return value->value(); 30 } 31 32 virtual void trace(Visitor* visitor) OVERRIDE 33 { 34 StyleInterpolation::trace(visitor); 35 } 36 37 private: 38 LegacyStyleInterpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> start, PassOwnPtrWillBeRawPtr<InterpolableValue> end, CSSPropertyID id) 39 : StyleInterpolation(start, end, id) 40 { 41 } 42 }; 43 44 DEFINE_TYPE_CASTS(LegacyStyleInterpolation, Interpolation, value, value->isLegacyStyleInterpolation(), value.isLegacyStyleInterpolation()); 45 46 } 47 48 #endif 49