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 Keyframe_h | 5 #ifndef Keyframe_h |
6 #define Keyframe_h | 6 #define Keyframe_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "core/animation/AnimationEffect.h" | 9 #include "core/animation/AnimationEffect.h" |
10 #include "core/animation/AnimationNode.h" | 10 #include "core/animation/EffectModel.h" |
11 #include "core/animation/PropertyHandle.h" | 11 #include "core/animation/PropertyHandle.h" |
12 #include "core/animation/animatable/AnimatableValue.h" | 12 #include "core/animation/animatable/AnimatableValue.h" |
13 | 13 |
14 namespace blink { | 14 namespace blink { |
15 | 15 |
16 using PropertyHandleSet = HashSet<PropertyHandle>; | 16 using PropertyHandleSet = HashSet<PropertyHandle>; |
17 | 17 |
18 class Element; | 18 class Element; |
19 class ComputedStyle; | 19 class ComputedStyle; |
20 | 20 |
21 // FIXME: Make Keyframe immutable | 21 // FIXME: Make Keyframe immutable |
22 class CORE_EXPORT Keyframe : public RefCountedWillBeGarbageCollectedFinalized<Ke
yframe> { | 22 class CORE_EXPORT Keyframe : public RefCountedWillBeGarbageCollectedFinalized<Ke
yframe> { |
23 public: | 23 public: |
24 virtual ~Keyframe() { } | 24 virtual ~Keyframe() { } |
25 | 25 |
26 void setOffset(double offset) { m_offset = offset; } | 26 void setOffset(double offset) { m_offset = offset; } |
27 double offset() const { return m_offset; } | 27 double offset() const { return m_offset; } |
28 | 28 |
29 void setComposite(AnimationEffect::CompositeOperation composite) { m_composi
te = composite; } | 29 void setComposite(EffectModel::CompositeOperation composite) { m_composite =
composite; } |
30 AnimationEffect::CompositeOperation composite() const { return m_composite;
} | 30 EffectModel::CompositeOperation composite() const { return m_composite; } |
31 | 31 |
32 void setEasing(PassRefPtr<TimingFunction> easing) { m_easing = easing; } | 32 void setEasing(PassRefPtr<TimingFunction> easing) { m_easing = easing; } |
33 TimingFunction& easing() const { return *m_easing; } | 33 TimingFunction& easing() const { return *m_easing; } |
34 | 34 |
35 static bool compareOffsets(const RefPtrWillBeMember<Keyframe>& a, const RefP
trWillBeMember<Keyframe>& b) | 35 static bool compareOffsets(const RefPtrWillBeMember<Keyframe>& a, const RefP
trWillBeMember<Keyframe>& b) |
36 { | 36 { |
37 return a->offset() < b->offset(); | 37 return a->offset() < b->offset(); |
38 } | 38 } |
39 | 39 |
40 virtual PropertyHandleSet properties() const = 0; | 40 virtual PropertyHandleSet properties() const = 0; |
41 | 41 |
42 virtual PassRefPtrWillBeRawPtr<Keyframe> clone() const = 0; | 42 virtual PassRefPtrWillBeRawPtr<Keyframe> clone() const = 0; |
43 PassRefPtrWillBeRawPtr<Keyframe> cloneWithOffset(double offset) const | 43 PassRefPtrWillBeRawPtr<Keyframe> cloneWithOffset(double offset) const |
44 { | 44 { |
45 RefPtrWillBeRawPtr<Keyframe> theClone = clone(); | 45 RefPtrWillBeRawPtr<Keyframe> theClone = clone(); |
46 theClone->setOffset(offset); | 46 theClone->setOffset(offset); |
47 return theClone.release(); | 47 return theClone.release(); |
48 } | 48 } |
49 | 49 |
50 virtual bool isAnimatableValueKeyframe() const { return false; } | 50 virtual bool isAnimatableValueKeyframe() const { return false; } |
51 virtual bool isStringKeyframe() const { return false; } | 51 virtual bool isStringKeyframe() const { return false; } |
52 | 52 |
53 DEFINE_INLINE_VIRTUAL_TRACE() { } | 53 DEFINE_INLINE_VIRTUAL_TRACE() { } |
54 | 54 |
55 class PropertySpecificKeyframe : public NoBaseWillBeGarbageCollectedFinalize
d<PropertySpecificKeyframe> { | 55 class PropertySpecificKeyframe : public NoBaseWillBeGarbageCollectedFinalize
d<PropertySpecificKeyframe> { |
56 public: | 56 public: |
57 virtual ~PropertySpecificKeyframe() { } | 57 virtual ~PropertySpecificKeyframe() { } |
58 double offset() const { return m_offset; } | 58 double offset() const { return m_offset; } |
59 TimingFunction& easing() const { return *m_easing; } | 59 TimingFunction& easing() const { return *m_easing; } |
60 AnimationEffect::CompositeOperation composite() const { return m_composi
te; } | 60 EffectModel::CompositeOperation composite() const { return m_composite;
} |
61 virtual PassOwnPtrWillBeRawPtr<PropertySpecificKeyframe> cloneWithOffset
(double offset) const = 0; | 61 virtual PassOwnPtrWillBeRawPtr<PropertySpecificKeyframe> cloneWithOffset
(double offset) const = 0; |
62 | 62 |
63 // FIXME: Remove this once CompositorAnimations no longer depends on Ani
matableValues | 63 // FIXME: Remove this once CompositorAnimations no longer depends on Ani
matableValues |
64 virtual void populateAnimatableValue(CSSPropertyID, Element&, const Comp
utedStyle* baseStyle) const { } | 64 virtual void populateAnimatableValue(CSSPropertyID, Element&, const Comp
utedStyle* baseStyle) const { } |
65 virtual const PassRefPtrWillBeRawPtr<AnimatableValue> getAnimatableValue
() const = 0; | 65 virtual const PassRefPtrWillBeRawPtr<AnimatableValue> getAnimatableValue
() const = 0; |
66 | 66 |
67 virtual bool isAnimatableValuePropertySpecificKeyframe() const { return
false; } | 67 virtual bool isAnimatableValuePropertySpecificKeyframe() const { return
false; } |
68 virtual bool isCSSPropertySpecificKeyframe() const { return false; } | 68 virtual bool isCSSPropertySpecificKeyframe() const { return false; } |
69 virtual bool isSVGPropertySpecificKeyframe() const { return false; } | 69 virtual bool isSVGPropertySpecificKeyframe() const { return false; } |
70 | 70 |
71 virtual PassOwnPtrWillBeRawPtr<PropertySpecificKeyframe> neutralKeyframe
(double offset, PassRefPtr<TimingFunction> easing) const = 0; | 71 virtual PassOwnPtrWillBeRawPtr<PropertySpecificKeyframe> neutralKeyframe
(double offset, PassRefPtr<TimingFunction> easing) const = 0; |
72 virtual PassRefPtrWillBeRawPtr<Interpolation> maybeCreateInterpolation(P
ropertyHandle, Keyframe::PropertySpecificKeyframe& end, Element*, const Computed
Style* baseStyle) const = 0; | 72 virtual PassRefPtrWillBeRawPtr<Interpolation> maybeCreateInterpolation(P
ropertyHandle, Keyframe::PropertySpecificKeyframe& end, Element*, const Computed
Style* baseStyle) const = 0; |
73 | 73 |
74 DEFINE_INLINE_VIRTUAL_TRACE() { } | 74 DEFINE_INLINE_VIRTUAL_TRACE() { } |
75 | 75 |
76 protected: | 76 protected: |
77 PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easin
g, AnimationEffect::CompositeOperation); | 77 PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easin
g, EffectModel::CompositeOperation); |
78 | 78 |
79 double m_offset; | 79 double m_offset; |
80 RefPtr<TimingFunction> m_easing; | 80 RefPtr<TimingFunction> m_easing; |
81 AnimationEffect::CompositeOperation m_composite; | 81 EffectModel::CompositeOperation m_composite; |
82 }; | 82 }; |
83 | 83 |
84 virtual PassOwnPtrWillBeRawPtr<PropertySpecificKeyframe> createPropertySpeci
ficKeyframe(PropertyHandle) const = 0; | 84 virtual PassOwnPtrWillBeRawPtr<PropertySpecificKeyframe> createPropertySpeci
ficKeyframe(PropertyHandle) const = 0; |
85 | 85 |
86 protected: | 86 protected: |
87 Keyframe() | 87 Keyframe() |
88 : m_offset(nullValue()) | 88 : m_offset(nullValue()) |
89 , m_composite(AnimationEffect::CompositeReplace) | 89 , m_composite(EffectModel::CompositeReplace) |
90 , m_easing(LinearTimingFunction::shared()) | 90 , m_easing(LinearTimingFunction::shared()) |
91 { | 91 { |
92 } | 92 } |
93 Keyframe(double offset, AnimationEffect::CompositeOperation composite, PassR
efPtr<TimingFunction> easing) | 93 Keyframe(double offset, EffectModel::CompositeOperation composite, PassRefPt
r<TimingFunction> easing) |
94 : m_offset(offset) | 94 : m_offset(offset) |
95 , m_composite(composite) | 95 , m_composite(composite) |
96 , m_easing(easing) | 96 , m_easing(easing) |
97 { | 97 { |
98 } | 98 } |
99 | 99 |
100 double m_offset; | 100 double m_offset; |
101 AnimationEffect::CompositeOperation m_composite; | 101 EffectModel::CompositeOperation m_composite; |
102 RefPtr<TimingFunction> m_easing; | 102 RefPtr<TimingFunction> m_easing; |
103 }; | 103 }; |
104 | 104 |
105 } // namespace blink | 105 } // namespace blink |
106 | 106 |
107 #endif // Keyframe_h | 107 #endif // Keyframe_h |
OLD | NEW |