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 RefCountedWillBeGarbageCollectedFinalized<Interpola tion> { |
Mads Ager (chromium)
2014/03/26 13:28:31
Looks like this hierarchy doesn't need to be final
haraken
2014/03/26 13:42:30
Done.
| |
18 public: | 18 public: |
19 static PassRefPtrWillBeRawPtr<Interpolation> create(PassOwnPtr<InterpolableV alue> start, PassOwnPtr<InterpolableValue> end) | 19 static PassRefPtrWillBeRawPtr<Interpolation> create(PassOwnPtrWillBeRawPtr<I nterpolableValue> start, PassOwnPtrWillBeRawPtr<InterpolableValue> end) |
20 { | 20 { |
21 return adoptRefWillBeNoop(new Interpolation(start, end)); | 21 return adoptRefWillBeNoop(new Interpolation(start, end)); |
22 } | 22 } |
23 | 23 |
24 void interpolate(int iteration, double fraction) const; | 24 void interpolate(int iteration, double fraction) const; |
25 | 25 |
26 virtual bool isStyleInterpolation() const { return false; } | 26 virtual bool isStyleInterpolation() const { return false; } |
27 virtual bool isLegacyStyleInterpolation() const { return false; } | 27 virtual bool isLegacyStyleInterpolation() const { return false; } |
28 | 28 |
29 virtual ~Interpolation() { } | 29 virtual ~Interpolation() { } |
30 | 30 |
31 virtual void trace(Visitor*) { } | 31 virtual void trace(Visitor*); |
32 | 32 |
33 protected: | 33 protected: |
34 const OwnPtr<InterpolableValue> m_start; | 34 const OwnPtrWillBeMember<InterpolableValue> m_start; |
35 const OwnPtr<InterpolableValue> m_end; | 35 const OwnPtrWillBeMember<InterpolableValue> m_end; |
36 | 36 |
37 mutable double m_cachedFraction; | 37 mutable double m_cachedFraction; |
38 mutable int m_cachedIteration; | 38 mutable int m_cachedIteration; |
39 mutable OwnPtr<InterpolableValue> m_cachedValue; | 39 mutable OwnPtrWillBeMember<InterpolableValue> m_cachedValue; |
40 | 40 |
41 Interpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<InterpolableVa lue> end); | 41 Interpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> start, PassOwnPtrWil lBeRawPtr<InterpolableValue> end); |
42 | 42 |
43 private: | 43 private: |
44 InterpolableValue* getCachedValueForTesting() const { return m_cachedValue.g et(); } | 44 InterpolableValue* getCachedValueForTesting() const { return m_cachedValue.g et(); } |
45 | 45 |
46 friend class AnimationInterpolableValueTest; | 46 friend class AnimationInterpolableValueTest; |
47 friend class AnimationInterpolationEffectTest; | 47 friend class AnimationInterpolationEffectTest; |
48 | 48 |
49 }; | 49 }; |
50 | 50 |
51 class StyleInterpolation : public Interpolation { | 51 class StyleInterpolation : public Interpolation { |
52 public: | 52 public: |
53 // 1) convert m_cachedValue into an X | 53 // 1) convert m_cachedValue into an X |
54 // 2) shove X into StyleResolverState | 54 // 2) shove X into StyleResolverState |
55 // X can be: | 55 // X can be: |
56 // (1) a CSSValue (and applied via StyleBuilder::applyProperty) | 56 // (1) a CSSValue (and applied via StyleBuilder::applyProperty) |
57 // (2) an AnimatableValue (and applied via // AnimatedStyleBuilder::applyPro perty) | 57 // (2) an AnimatableValue (and applied via // AnimatedStyleBuilder::applyPro perty) |
58 // (3) a custom value that is inserted directly into the StyleResolverState. | 58 // (3) a custom value that is inserted directly into the StyleResolverState. |
59 virtual void apply(StyleResolverState&) const = 0; | 59 virtual void apply(StyleResolverState&) const = 0; |
60 | 60 |
61 virtual bool isStyleInterpolation() const OVERRIDE FINAL { return true; } | 61 virtual bool isStyleInterpolation() const OVERRIDE FINAL { return true; } |
62 | 62 |
63 CSSPropertyID id() const { return m_id; } | 63 CSSPropertyID id() const { return m_id; } |
64 | 64 |
65 virtual void trace(Visitor*) OVERRIDE; | 65 virtual void trace(Visitor*) OVERRIDE; |
66 | 66 |
67 protected: | 67 protected: |
68 CSSPropertyID m_id; | 68 CSSPropertyID m_id; |
69 | 69 |
70 StyleInterpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<Interpola bleValue> end, CSSPropertyID id) | 70 StyleInterpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> start, PassOwnP trWillBeRawPtr<InterpolableValue> end, CSSPropertyID id) |
71 : Interpolation(start, end) | 71 : Interpolation(start, end) |
72 , m_id(id) | 72 , m_id(id) |
73 { | 73 { |
74 } | 74 } |
75 }; | 75 }; |
76 | 76 |
77 class LegacyStyleInterpolation : public StyleInterpolation { | 77 class LegacyStyleInterpolation : public StyleInterpolation { |
78 public: | 78 public: |
79 static PassRefPtrWillBeRawPtr<LegacyStyleInterpolation> create(PassRefPtrWil lBeRawPtr<AnimatableValue> start, PassRefPtrWillBeRawPtr<AnimatableValue> end, C SSPropertyID id) | 79 static PassRefPtrWillBeRawPtr<LegacyStyleInterpolation> create(PassRefPtrWil lBeRawPtr<AnimatableValue> start, PassRefPtrWillBeRawPtr<AnimatableValue> end, C SSPropertyID id) |
80 { | 80 { |
81 return adoptRefWillBeNoop(new LegacyStyleInterpolation(InterpolableAnima tableValue::create(start), InterpolableAnimatableValue::create(end), id)); | 81 return adoptRefWillBeNoop(new LegacyStyleInterpolation(InterpolableAnima tableValue::create(start), InterpolableAnimatableValue::create(end), id)); |
82 } | 82 } |
83 | 83 |
84 virtual void apply(StyleResolverState&) const; | 84 virtual void apply(StyleResolverState&) const; |
85 | 85 |
86 virtual bool isLegacyStyleInterpolation() const OVERRIDE FINAL { return true ; } | 86 virtual bool isLegacyStyleInterpolation() const OVERRIDE FINAL { return true ; } |
87 AnimatableValue* currentValue() const | 87 AnimatableValue* currentValue() const |
88 { | 88 { |
89 InterpolableAnimatableValue* value = static_cast<InterpolableAnimatableV alue*>(m_cachedValue.get()); | 89 InterpolableAnimatableValue* value = static_cast<InterpolableAnimatableV alue*>(m_cachedValue.get()); |
90 return value->value(); | 90 return value->value(); |
91 } | 91 } |
92 | 92 |
93 virtual void trace(Visitor*) OVERRIDE; | 93 virtual void trace(Visitor*) OVERRIDE; |
94 | 94 |
95 private: | 95 private: |
96 LegacyStyleInterpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<Int erpolableValue> end, CSSPropertyID id) | 96 LegacyStyleInterpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> start, Pa ssOwnPtrWillBeRawPtr<InterpolableValue> end, CSSPropertyID id) |
97 : StyleInterpolation(start, end, id) | 97 : StyleInterpolation(start, end, id) |
98 { | 98 { |
99 } | 99 } |
100 }; | 100 }; |
101 | 101 |
102 DEFINE_TYPE_CASTS(StyleInterpolation, Interpolation, value, value->isStyleInterp olation(), value.isStyleInterpolation()); | 102 DEFINE_TYPE_CASTS(StyleInterpolation, Interpolation, value, value->isStyleInterp olation(), value.isStyleInterpolation()); |
103 DEFINE_TYPE_CASTS(LegacyStyleInterpolation, Interpolation, value, value->isLegac yStyleInterpolation(), value.isLegacyStyleInterpolation()); | 103 DEFINE_TYPE_CASTS(LegacyStyleInterpolation, Interpolation, value, value->isLegac yStyleInterpolation(), value.isLegacyStyleInterpolation()); |
104 | 104 |
105 } | 105 } |
106 #endif | 106 #endif |
OLD | NEW |