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