OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 CSSAnimationUpdate_h | 5 #ifndef CSSAnimationUpdate_h |
6 #define CSSAnimationUpdate_h | 6 #define CSSAnimationUpdate_h |
7 | 7 |
8 #include "core/animation/Interpolation.h" | 8 #include "core/animation/Interpolation.h" |
9 #include "core/css/CSSKeyframesRule.h" | |
9 #include "wtf/HashMap.h" | 10 #include "wtf/HashMap.h" |
10 #include "wtf/Vector.h" | 11 #include "wtf/Vector.h" |
11 #include "wtf/text/AtomicString.h" | 12 #include "wtf/text/AtomicString.h" |
12 | 13 |
13 namespace blink { | 14 namespace blink { |
14 | 15 |
15 class AnimationPlayer; | 16 class AnimationPlayer; |
16 class InertAnimation; | 17 class InertAnimation; |
17 | 18 |
18 // This class stores the CSS Animations/Transitions information we use during a style recalc. | 19 // This class stores the CSS Animations/Transitions information we use during a style recalc. |
19 // This includes updates to animations/transitions as well as the Interpolations to be applied. | 20 // This includes updates to animations/transitions as well as the Interpolations to be applied. |
20 class CSSAnimationUpdate final : public NoBaseWillBeGarbageCollectedFinalized<CS SAnimationUpdate> { | 21 class CSSAnimationUpdate final : public NoBaseWillBeGarbageCollectedFinalized<CS SAnimationUpdate> { |
21 public: | 22 public: |
22 void startAnimation(const AtomicString& animationName, PassRefPtrWillBeRawPt r<InertAnimation> animation) | 23 void startAnimation(const AtomicString& animationName, PassRefPtrWillBeRawPt r<InertAnimation> animation, const Timing& timing, PassRefPtrWillBeRawPtr<StyleR uleKeyframes> styleRule) |
23 { | 24 { |
24 animation->setName(animationName); | 25 animation->setName(animationName); |
25 NewAnimation newAnimation; | 26 NewAnimation newAnimation; |
esprehn
2015/01/30 02:50:28
Since you're adding a constructor you can just pas
shend
2015/02/01 23:49:13
Done.
| |
26 newAnimation.name = animationName; | 27 newAnimation.name = animationName; |
27 newAnimation.animation = animation; | 28 newAnimation.animation = animation; |
29 newAnimation.timing = timing; | |
30 newAnimation.styleRuleVersion = styleRule->version(); | |
31 newAnimation.styleRule = styleRule; | |
28 m_newAnimations.append(newAnimation); | 32 m_newAnimations.append(newAnimation); |
29 } | 33 } |
30 // Returns whether player has been suppressed and should be filtered during style application. | 34 // Returns whether player has been suppressed and should be filtered during style application. |
31 bool isSuppressedAnimation(const AnimationPlayer* player) const { return m_s uppressedAnimationPlayers.contains(player); } | 35 bool isSuppressedAnimation(const AnimationPlayer* player) const { return m_s uppressedAnimationPlayers.contains(player); } |
32 void cancelAnimation(const AtomicString& name, AnimationPlayer& player) | 36 void cancelAnimation(const AtomicString& name, AnimationPlayer& player) |
33 { | 37 { |
34 m_cancelledAnimationNames.append(name); | 38 m_cancelledAnimationNames.append(name); |
35 m_suppressedAnimationPlayers.add(&player); | 39 m_suppressedAnimationPlayers.add(&player); |
36 } | 40 } |
37 void toggleAnimationPaused(const AtomicString& name) | 41 void toggleAnimationPaused(const AtomicString& name) |
38 { | 42 { |
39 m_animationsWithPauseToggled.append(name); | 43 m_animationsWithPauseToggled.append(name); |
40 } | 44 } |
41 void updateAnimationTiming(AnimationPlayer* player, PassRefPtrWillBeRawPtr<I nertAnimation> animation, const Timing& timing) | 45 void updateAnimation(const AtomicString& name, AnimationPlayer* player, Pass RefPtrWillBeRawPtr<InertAnimation> animation, const Timing& specifiedTiming, |
46 PassRefPtrWillBeRawPtr<StyleRuleKeyframes> styleRule) | |
42 { | 47 { |
43 UpdatedAnimationTiming updatedAnimation; | 48 UpdatedAnimation updatedAnimation; |
esprehn
2015/01/30 02:50:28
ditto for the constructor.
shend
2015/02/01 23:49:13
Done.
| |
49 updatedAnimation.name = name; | |
44 updatedAnimation.player = player; | 50 updatedAnimation.player = player; |
45 updatedAnimation.animation = animation; | 51 updatedAnimation.animation = animation; |
46 updatedAnimation.newTiming = timing; | 52 updatedAnimation.specifiedTiming = specifiedTiming; |
47 m_animationsWithTimingUpdates.append(updatedAnimation); | 53 updatedAnimation.styleRuleVersion = styleRule->version(); |
54 updatedAnimation.styleRule = styleRule; | |
55 m_animationsWithUpdates.append(updatedAnimation); | |
48 m_suppressedAnimationPlayers.add(player); | 56 m_suppressedAnimationPlayers.add(player); |
49 } | 57 } |
50 | 58 |
51 void startTransition(CSSPropertyID id, CSSPropertyID eventId, const Animatab leValue* from, const AnimatableValue* to, PassRefPtrWillBeRawPtr<InertAnimation> animation) | 59 void startTransition(CSSPropertyID id, CSSPropertyID eventId, const Animatab leValue* from, const AnimatableValue* to, PassRefPtrWillBeRawPtr<InertAnimation> animation) |
52 { | 60 { |
53 animation->setName(getPropertyName(id)); | 61 animation->setName(getPropertyName(id)); |
54 NewTransition newTransition; | 62 NewTransition newTransition; |
55 newTransition.id = id; | 63 newTransition.id = id; |
56 newTransition.eventId = eventId; | 64 newTransition.eventId = eventId; |
57 newTransition.from = from; | 65 newTransition.from = from; |
58 newTransition.to = to; | 66 newTransition.to = to; |
59 newTransition.animation = animation; | 67 newTransition.animation = animation; |
60 m_newTransitions.set(id, newTransition); | 68 m_newTransitions.set(id, newTransition); |
61 } | 69 } |
62 bool isCancelledTransition(CSSPropertyID id) const { return m_cancelledTrans itions.contains(id); } | 70 bool isCancelledTransition(CSSPropertyID id) const { return m_cancelledTrans itions.contains(id); } |
63 void cancelTransition(CSSPropertyID id) { m_cancelledTransitions.add(id); } | 71 void cancelTransition(CSSPropertyID id) { m_cancelledTransitions.add(id); } |
64 | 72 |
65 struct NewAnimation { | 73 struct NewAnimation { |
66 ALLOW_ONLY_INLINE_ALLOCATION(); | 74 ALLOW_ONLY_INLINE_ALLOCATION(); |
67 public: | 75 public: |
76 NewAnimation() | |
77 : styleRuleVersion(0) | |
78 { | |
79 } | |
80 | |
68 void trace(Visitor* visitor) | 81 void trace(Visitor* visitor) |
69 { | 82 { |
70 visitor->trace(animation); | 83 visitor->trace(animation); |
71 } | 84 } |
72 | 85 |
73 AtomicString name; | 86 AtomicString name; |
74 RefPtrWillBeMember<InertAnimation> animation; | 87 RefPtrWillBeMember<InertAnimation> animation; |
88 Timing timing; | |
89 RefPtrWillBeMember<StyleRuleKeyframes> styleRule; | |
90 unsigned styleRuleVersion; | |
75 }; | 91 }; |
76 | 92 |
77 struct UpdatedAnimationTiming { | 93 struct UpdatedAnimation { |
78 ALLOW_ONLY_INLINE_ALLOCATION(); | 94 ALLOW_ONLY_INLINE_ALLOCATION(); |
79 public: | 95 public: |
96 UpdatedAnimation() | |
97 : styleRuleVersion(0) | |
98 { | |
99 } | |
100 | |
80 void trace(Visitor* visitor) | 101 void trace(Visitor* visitor) |
81 { | 102 { |
82 visitor->trace(player); | 103 visitor->trace(player); |
83 visitor->trace(animation); | 104 visitor->trace(animation); |
105 visitor->trace(styleRule); | |
84 } | 106 } |
85 | 107 |
108 AtomicString name; | |
86 RawPtrWillBeMember<AnimationPlayer> player; | 109 RawPtrWillBeMember<AnimationPlayer> player; |
87 RefPtrWillBeMember<InertAnimation> animation; | 110 RefPtrWillBeMember<InertAnimation> animation; |
88 Timing newTiming; | 111 Timing specifiedTiming; |
112 RefPtrWillBeMember<StyleRuleKeyframes> styleRule; | |
113 unsigned styleRuleVersion; | |
89 }; | 114 }; |
90 | 115 |
91 const WillBeHeapVector<NewAnimation>& newAnimations() const { return m_newAn imations; } | 116 const WillBeHeapVector<NewAnimation>& newAnimations() const { return m_newAn imations; } |
92 const Vector<AtomicString>& cancelledAnimationNames() const { return m_cance lledAnimationNames; } | 117 const Vector<AtomicString>& cancelledAnimationNames() const { return m_cance lledAnimationNames; } |
93 const WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>>& suppress edAnimationAnimationPlayers() const { return m_suppressedAnimationPlayers; } | 118 const WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>>& suppress edAnimationAnimationPlayers() const { return m_suppressedAnimationPlayers; } |
94 const Vector<AtomicString>& animationsWithPauseToggled() const { return m_an imationsWithPauseToggled; } | 119 const Vector<AtomicString>& animationsWithPauseToggled() const { return m_an imationsWithPauseToggled; } |
95 const WillBeHeapVector<UpdatedAnimationTiming>& animationsWithTimingUpdates( ) const { return m_animationsWithTimingUpdates; } | 120 const WillBeHeapVector<UpdatedAnimation>& animationsWithUpdates() const { re turn m_animationsWithUpdates; } |
96 | 121 |
97 struct NewTransition { | 122 struct NewTransition { |
98 ALLOW_ONLY_INLINE_ALLOCATION(); | 123 ALLOW_ONLY_INLINE_ALLOCATION(); |
99 public: | 124 public: |
100 void trace(Visitor* visitor) | 125 void trace(Visitor* visitor) |
101 { | 126 { |
102 visitor->trace(from); | 127 visitor->trace(from); |
103 visitor->trace(to); | 128 visitor->trace(to); |
104 visitor->trace(animation); | 129 visitor->trace(animation); |
105 } | 130 } |
(...skipping 13 matching lines...) Expand all Loading... | |
119 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& a ctiveInterpolationsForAnimations() const { return m_activeInterpolationsForAnima tions; } | 144 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& a ctiveInterpolationsForAnimations() const { return m_activeInterpolationsForAnima tions; } |
120 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& a ctiveInterpolationsForTransitions() const { return m_activeInterpolationsForTran sitions; } | 145 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& a ctiveInterpolationsForTransitions() const { return m_activeInterpolationsForTran sitions; } |
121 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& activeI nterpolationsForAnimations() { return m_activeInterpolationsForAnimations; } | 146 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& activeI nterpolationsForAnimations() { return m_activeInterpolationsForAnimations; } |
122 | 147 |
123 bool isEmpty() const | 148 bool isEmpty() const |
124 { | 149 { |
125 return m_newAnimations.isEmpty() | 150 return m_newAnimations.isEmpty() |
126 && m_cancelledAnimationNames.isEmpty() | 151 && m_cancelledAnimationNames.isEmpty() |
127 && m_suppressedAnimationPlayers.isEmpty() | 152 && m_suppressedAnimationPlayers.isEmpty() |
128 && m_animationsWithPauseToggled.isEmpty() | 153 && m_animationsWithPauseToggled.isEmpty() |
129 && m_animationsWithTimingUpdates.isEmpty() | 154 && m_animationsWithUpdates.isEmpty() |
130 && m_newTransitions.isEmpty() | 155 && m_newTransitions.isEmpty() |
131 && m_cancelledTransitions.isEmpty() | 156 && m_cancelledTransitions.isEmpty() |
132 && m_activeInterpolationsForAnimations.isEmpty() | 157 && m_activeInterpolationsForAnimations.isEmpty() |
133 && m_activeInterpolationsForTransitions.isEmpty(); | 158 && m_activeInterpolationsForTransitions.isEmpty(); |
134 } | 159 } |
135 | 160 |
136 void trace(Visitor*); | 161 void trace(Visitor*); |
137 | 162 |
138 private: | 163 private: |
139 // Order is significant since it defines the order in which new animations | 164 // Order is significant since it defines the order in which new animations |
140 // will be started. Note that there may be multiple animations present | 165 // will be started. Note that there may be multiple animations present |
141 // with the same name, due to the way in which we split up animations with | 166 // with the same name, due to the way in which we split up animations with |
142 // incomplete keyframes. | 167 // incomplete keyframes. |
143 WillBeHeapVector<NewAnimation> m_newAnimations; | 168 WillBeHeapVector<NewAnimation> m_newAnimations; |
144 Vector<AtomicString> m_cancelledAnimationNames; | 169 Vector<AtomicString> m_cancelledAnimationNames; |
145 WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>> m_suppressedAni mationPlayers; | 170 WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>> m_suppressedAni mationPlayers; |
146 Vector<AtomicString> m_animationsWithPauseToggled; | 171 Vector<AtomicString> m_animationsWithPauseToggled; |
147 WillBeHeapVector<UpdatedAnimationTiming> m_animationsWithTimingUpdates; | 172 WillBeHeapVector<UpdatedAnimation> m_animationsWithUpdates; |
148 | 173 |
149 NewTransitionMap m_newTransitions; | 174 NewTransitionMap m_newTransitions; |
150 HashSet<CSSPropertyID> m_cancelledTransitions; | 175 HashSet<CSSPropertyID> m_cancelledTransitions; |
151 | 176 |
152 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active InterpolationsForAnimations; | 177 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active InterpolationsForAnimations; |
153 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active InterpolationsForTransitions; | 178 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active InterpolationsForTransitions; |
154 }; | 179 }; |
155 | 180 |
156 } // namespace blink | 181 } // namespace blink |
157 | 182 |
158 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation); | 183 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation); |
159 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimationTim ing); | 184 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimation); |
160 | 185 |
161 #endif | 186 #endif |
OLD | NEW |