| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef Interpolation_h | 5 #ifndef Interpolation_h |
| 6 #define Interpolation_h | 6 #define Interpolation_h |
| 7 | 7 |
| 8 #include "CSSPropertyNames.h" | 8 #include "CSSPropertyNames.h" |
| 9 #include "core/animation/InterpolableValue.h" | 9 #include "core/animation/InterpolableValue.h" |
| 10 #include "heap/Handle.h" | 10 #include "heap/Handle.h" |
| 11 #include "wtf/RefCounted.h" | 11 #include "wtf/RefCounted.h" |
| 12 | 12 |
| 13 namespace WebCore { | 13 namespace WebCore { |
| 14 | 14 |
| 15 class StyleResolverState; | 15 class StyleResolverState; |
| 16 | 16 |
| 17 class Interpolation : public RefCountedWillBeGarbageCollectedFinalized<Interpola
tion> { | 17 class Interpolation : public RefCountedWillBeGarbageCollected<Interpolation> { |
| 18 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(Interpolation); |
| 18 public: | 19 public: |
| 19 static PassRefPtrWillBeRawPtr<Interpolation> create(PassOwnPtr<InterpolableV
alue> start, PassOwnPtr<InterpolableValue> end) | 20 static PassRefPtrWillBeRawPtr<Interpolation> create(PassOwnPtrWillBeRawPtr<I
nterpolableValue> start, PassOwnPtrWillBeRawPtr<InterpolableValue> end) |
| 20 { | 21 { |
| 21 return adoptRefWillBeNoop(new Interpolation(start, end)); | 22 return adoptRefWillBeNoop(new Interpolation(start, end)); |
| 22 } | 23 } |
| 23 | 24 |
| 24 void interpolate(int iteration, double fraction) const; | 25 void interpolate(int iteration, double fraction) const; |
| 25 | 26 |
| 26 virtual bool isStyleInterpolation() const { return false; } | 27 virtual bool isStyleInterpolation() const { return false; } |
| 27 virtual bool isLegacyStyleInterpolation() const { return false; } | 28 virtual bool isLegacyStyleInterpolation() const { return false; } |
| 28 | 29 |
| 29 virtual ~Interpolation() { } | 30 virtual void trace(Visitor*); |
| 30 | |
| 31 virtual void trace(Visitor*) { } | |
| 32 | 31 |
| 33 protected: | 32 protected: |
| 34 const OwnPtr<InterpolableValue> m_start; | 33 const OwnPtrWillBeMember<InterpolableValue> m_start; |
| 35 const OwnPtr<InterpolableValue> m_end; | 34 const OwnPtrWillBeMember<InterpolableValue> m_end; |
| 36 | 35 |
| 37 mutable double m_cachedFraction; | 36 mutable double m_cachedFraction; |
| 38 mutable int m_cachedIteration; | 37 mutable int m_cachedIteration; |
| 39 mutable OwnPtr<InterpolableValue> m_cachedValue; | 38 mutable OwnPtrWillBeMember<InterpolableValue> m_cachedValue; |
| 40 | 39 |
| 41 Interpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<InterpolableVa
lue> end); | 40 Interpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> start, PassOwnPtrWil
lBeRawPtr<InterpolableValue> end); |
| 42 | 41 |
| 43 private: | 42 private: |
| 44 InterpolableValue* getCachedValueForTesting() const { return m_cachedValue.g
et(); } | 43 InterpolableValue* getCachedValueForTesting() const { return m_cachedValue.g
et(); } |
| 45 | 44 |
| 46 friend class AnimationInterpolableValueTest; | 45 friend class AnimationInterpolableValueTest; |
| 47 friend class AnimationInterpolationEffectTest; | 46 friend class AnimationInterpolationEffectTest; |
| 48 | 47 |
| 49 }; | 48 }; |
| 50 | 49 |
| 51 class StyleInterpolation : public Interpolation { | 50 class StyleInterpolation : public Interpolation { |
| 52 public: | 51 public: |
| 53 // 1) convert m_cachedValue into an X | 52 // 1) convert m_cachedValue into an X |
| 54 // 2) shove X into StyleResolverState | 53 // 2) shove X into StyleResolverState |
| 55 // X can be: | 54 // X can be: |
| 56 // (1) a CSSValue (and applied via StyleBuilder::applyProperty) | 55 // (1) a CSSValue (and applied via StyleBuilder::applyProperty) |
| 57 // (2) an AnimatableValue (and applied via // AnimatedStyleBuilder::applyPro
perty) | 56 // (2) an AnimatableValue (and applied via // AnimatedStyleBuilder::applyPro
perty) |
| 58 // (3) a custom value that is inserted directly into the StyleResolverState. | 57 // (3) a custom value that is inserted directly into the StyleResolverState. |
| 59 virtual void apply(StyleResolverState&) const = 0; | 58 virtual void apply(StyleResolverState&) const = 0; |
| 60 | 59 |
| 61 virtual bool isStyleInterpolation() const OVERRIDE FINAL { return true; } | 60 virtual bool isStyleInterpolation() const OVERRIDE FINAL { return true; } |
| 62 | 61 |
| 63 CSSPropertyID id() const { return m_id; } | 62 CSSPropertyID id() const { return m_id; } |
| 64 | 63 |
| 65 virtual void trace(Visitor*) OVERRIDE; | 64 virtual void trace(Visitor*) OVERRIDE; |
| 66 | 65 |
| 67 protected: | 66 protected: |
| 68 CSSPropertyID m_id; | 67 CSSPropertyID m_id; |
| 69 | 68 |
| 70 StyleInterpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<Interpola
bleValue> end, CSSPropertyID id) | 69 StyleInterpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> start, PassOwnP
trWillBeRawPtr<InterpolableValue> end, CSSPropertyID id) |
| 71 : Interpolation(start, end) | 70 : Interpolation(start, end) |
| 72 , m_id(id) | 71 , m_id(id) |
| 73 { | 72 { |
| 74 } | 73 } |
| 75 }; | 74 }; |
| 76 | 75 |
| 77 class LegacyStyleInterpolation : public StyleInterpolation { | 76 class LegacyStyleInterpolation : public StyleInterpolation { |
| 78 public: | 77 public: |
| 79 static PassRefPtrWillBeRawPtr<LegacyStyleInterpolation> create(PassRefPtrWil
lBeRawPtr<AnimatableValue> start, PassRefPtrWillBeRawPtr<AnimatableValue> end, C
SSPropertyID id) | 78 static PassRefPtrWillBeRawPtr<LegacyStyleInterpolation> create(PassRefPtrWil
lBeRawPtr<AnimatableValue> start, PassRefPtrWillBeRawPtr<AnimatableValue> end, C
SSPropertyID id) |
| 80 { | 79 { |
| 81 return adoptRefWillBeNoop(new LegacyStyleInterpolation(InterpolableAnima
tableValue::create(start), InterpolableAnimatableValue::create(end), id)); | 80 return adoptRefWillBeNoop(new LegacyStyleInterpolation(InterpolableAnima
tableValue::create(start), InterpolableAnimatableValue::create(end), id)); |
| 82 } | 81 } |
| 83 | 82 |
| 84 virtual void apply(StyleResolverState&) const; | 83 virtual void apply(StyleResolverState&) const; |
| 85 | 84 |
| 86 virtual bool isLegacyStyleInterpolation() const OVERRIDE FINAL { return true
; } | 85 virtual bool isLegacyStyleInterpolation() const OVERRIDE FINAL { return true
; } |
| 87 AnimatableValue* currentValue() const | 86 AnimatableValue* currentValue() const |
| 88 { | 87 { |
| 89 InterpolableAnimatableValue* value = static_cast<InterpolableAnimatableV
alue*>(m_cachedValue.get()); | 88 InterpolableAnimatableValue* value = static_cast<InterpolableAnimatableV
alue*>(m_cachedValue.get()); |
| 90 return value->value(); | 89 return value->value(); |
| 91 } | 90 } |
| 92 | 91 |
| 93 virtual void trace(Visitor*) OVERRIDE; | 92 virtual void trace(Visitor*) OVERRIDE; |
| 94 | 93 |
| 95 private: | 94 private: |
| 96 LegacyStyleInterpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<Int
erpolableValue> end, CSSPropertyID id) | 95 LegacyStyleInterpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> start, Pa
ssOwnPtrWillBeRawPtr<InterpolableValue> end, CSSPropertyID id) |
| 97 : StyleInterpolation(start, end, id) | 96 : StyleInterpolation(start, end, id) |
| 98 { | 97 { |
| 99 } | 98 } |
| 100 }; | 99 }; |
| 101 | 100 |
| 102 DEFINE_TYPE_CASTS(StyleInterpolation, Interpolation, value, value->isStyleInterp
olation(), value.isStyleInterpolation()); | 101 DEFINE_TYPE_CASTS(StyleInterpolation, Interpolation, value, value->isStyleInterp
olation(), value.isStyleInterpolation()); |
| 103 DEFINE_TYPE_CASTS(LegacyStyleInterpolation, Interpolation, value, value->isLegac
yStyleInterpolation(), value.isLegacyStyleInterpolation()); | 102 DEFINE_TYPE_CASTS(LegacyStyleInterpolation, Interpolation, value, value->isLegac
yStyleInterpolation(), value.isLegacyStyleInterpolation()); |
| 104 | 103 |
| 105 } | 104 } |
| 106 #endif | 105 #endif |
| OLD | NEW |