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 "wtf/RefCounted.h" | 11 #include "wtf/RefCounted.h" |
11 | 12 |
12 namespace WebCore { | 13 namespace WebCore { |
13 | 14 |
14 class StyleResolverState; | 15 class StyleResolverState; |
15 | 16 |
16 class Interpolation : public RefCounted<Interpolation> { | 17 class Interpolation : public RefCountedWillBeGarbageCollectedFinalized<Interpola
tion> { |
17 public: | 18 public: |
18 static PassRefPtr<Interpolation> create(PassOwnPtr<InterpolableValue> start,
PassOwnPtr<InterpolableValue> end) | 19 static PassRefPtrWillBeRawPtr<Interpolation> create(PassOwnPtr<InterpolableV
alue> start, PassOwnPtr<InterpolableValue> end) |
19 { | 20 { |
20 return adoptRef(new Interpolation(start, end)); | 21 return adoptRefWillBeNoop(new Interpolation(start, end)); |
21 } | 22 } |
22 | 23 |
23 void interpolate(int iteration, double fraction) const; | 24 void interpolate(int iteration, double fraction) const; |
24 | 25 |
25 virtual bool isStyleInterpolation() const { return false; } | 26 virtual bool isStyleInterpolation() const { return false; } |
26 virtual bool isLegacyStyleInterpolation() const { return false; } | 27 virtual bool isLegacyStyleInterpolation() const { return false; } |
27 | 28 |
28 virtual ~Interpolation() | 29 virtual ~Interpolation() { } |
29 { } | 30 |
| 31 virtual void trace(Visitor*) { } |
30 | 32 |
31 protected: | 33 protected: |
32 const OwnPtr<InterpolableValue> m_start; | 34 const OwnPtr<InterpolableValue> m_start; |
33 const OwnPtr<InterpolableValue> m_end; | 35 const OwnPtr<InterpolableValue> m_end; |
34 | 36 |
35 mutable double m_cachedFraction; | 37 mutable double m_cachedFraction; |
36 mutable int m_cachedIteration; | 38 mutable int m_cachedIteration; |
37 mutable OwnPtr<InterpolableValue> m_cachedValue; | 39 mutable OwnPtr<InterpolableValue> m_cachedValue; |
38 | 40 |
39 Interpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<InterpolableVa
lue> end); | 41 Interpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<InterpolableVa
lue> end); |
(...skipping 13 matching lines...) Expand all Loading... |
53 // X can be: | 55 // X can be: |
54 // (1) a CSSValue (and applied via StyleBuilder::applyProperty) | 56 // (1) a CSSValue (and applied via StyleBuilder::applyProperty) |
55 // (2) an AnimatableValue (and applied via // AnimatedStyleBuilder::applyPro
perty) | 57 // (2) an AnimatableValue (and applied via // AnimatedStyleBuilder::applyPro
perty) |
56 // (3) a custom value that is inserted directly into the StyleResolverState. | 58 // (3) a custom value that is inserted directly into the StyleResolverState. |
57 virtual void apply(StyleResolverState&) const = 0; | 59 virtual void apply(StyleResolverState&) const = 0; |
58 | 60 |
59 virtual bool isStyleInterpolation() const OVERRIDE FINAL { return true; } | 61 virtual bool isStyleInterpolation() const OVERRIDE FINAL { return true; } |
60 | 62 |
61 CSSPropertyID id() const { return m_id; } | 63 CSSPropertyID id() const { return m_id; } |
62 | 64 |
| 65 virtual void trace(Visitor*) OVERRIDE; |
| 66 |
63 protected: | 67 protected: |
64 CSSPropertyID m_id; | 68 CSSPropertyID m_id; |
65 | 69 |
66 StyleInterpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<Interpola
bleValue> end, CSSPropertyID id) | 70 StyleInterpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<Interpola
bleValue> end, CSSPropertyID id) |
67 : Interpolation(start, end) | 71 : Interpolation(start, end) |
68 , m_id(id) | 72 , m_id(id) |
69 { } | 73 { |
| 74 } |
70 }; | 75 }; |
71 | 76 |
72 class LegacyStyleInterpolation : public StyleInterpolation { | 77 class LegacyStyleInterpolation : public StyleInterpolation { |
73 public: | 78 public: |
74 static PassRefPtr<LegacyStyleInterpolation> create(PassRefPtrWillBeRawPtr<An
imatableValue> start, PassRefPtrWillBeRawPtr<AnimatableValue> end, CSSPropertyID
id) | 79 static PassRefPtrWillBeRawPtr<LegacyStyleInterpolation> create(PassRefPtrWil
lBeRawPtr<AnimatableValue> start, PassRefPtrWillBeRawPtr<AnimatableValue> end, C
SSPropertyID id) |
75 { | 80 { |
76 return adoptRef(new LegacyStyleInterpolation(InterpolableAnimatableValue
::create(start), InterpolableAnimatableValue::create(end), id)); | 81 return adoptRefWillBeNoop(new LegacyStyleInterpolation(InterpolableAnima
tableValue::create(start), InterpolableAnimatableValue::create(end), id)); |
77 } | 82 } |
78 | 83 |
79 virtual void apply(StyleResolverState&) const; | 84 virtual void apply(StyleResolverState&) const; |
80 | 85 |
81 virtual bool isLegacyStyleInterpolation() const OVERRIDE FINAL { return true
; } | 86 virtual bool isLegacyStyleInterpolation() const OVERRIDE FINAL { return true
; } |
82 AnimatableValue* currentValue() const | 87 AnimatableValue* currentValue() const |
83 { | 88 { |
84 InterpolableAnimatableValue* value = static_cast<InterpolableAnimatableV
alue*>(m_cachedValue.get()); | 89 InterpolableAnimatableValue* value = static_cast<InterpolableAnimatableV
alue*>(m_cachedValue.get()); |
85 return value->value(); | 90 return value->value(); |
86 } | 91 } |
87 | 92 |
| 93 virtual void trace(Visitor*) OVERRIDE; |
| 94 |
88 private: | 95 private: |
89 LegacyStyleInterpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<Int
erpolableValue> end, CSSPropertyID id) | 96 LegacyStyleInterpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<Int
erpolableValue> end, CSSPropertyID id) |
90 : StyleInterpolation(start, end, id) | 97 : StyleInterpolation(start, end, id) |
91 { } | 98 { |
| 99 } |
92 }; | 100 }; |
93 | 101 |
94 DEFINE_TYPE_CASTS(StyleInterpolation, Interpolation, value, value->isStyleInterp
olation(), value.isStyleInterpolation()); | 102 DEFINE_TYPE_CASTS(StyleInterpolation, Interpolation, value, value->isStyleInterp
olation(), value.isStyleInterpolation()); |
95 DEFINE_TYPE_CASTS(LegacyStyleInterpolation, Interpolation, value, value->isLegac
yStyleInterpolation(), value.isLegacyStyleInterpolation()); | 103 DEFINE_TYPE_CASTS(LegacyStyleInterpolation, Interpolation, value, value->isLegac
yStyleInterpolation(), value.isLegacyStyleInterpolation()); |
96 | 104 |
97 } | 105 } |
98 #endif | 106 #endif |
OLD | NEW |