Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: Source/core/animation/css/CSSAnimations.h

Issue 814083003: Update animation when changes in animation keyframes are detected. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Move change counters to CSSAnimations Created 5 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 class CSSTransitionData; 48 class CSSTransitionData;
49 class Element; 49 class Element;
50 class StylePropertyShorthand; 50 class StylePropertyShorthand;
51 class StyleResolver; 51 class StyleResolver;
52 class StyleRuleKeyframes; 52 class StyleRuleKeyframes;
53 53
54 // This class stores the CSS Animations/Transitions information we use during a style recalc. 54 // This class stores the CSS Animations/Transitions information we use during a style recalc.
55 // This includes updates to animations/transitions as well as the Interpolations to be applied. 55 // This includes updates to animations/transitions as well as the Interpolations to be applied.
56 class CSSAnimationUpdate final : public NoBaseWillBeGarbageCollectedFinalized<CS SAnimationUpdate> { 56 class CSSAnimationUpdate final : public NoBaseWillBeGarbageCollectedFinalized<CS SAnimationUpdate> {
57 public: 57 public:
58 void startAnimation(const AtomicString& animationName, PassRefPtrWillBeRawPt r<InertAnimation> animation) 58 void startAnimation(const AtomicString& animationName, PassRefPtrWillBeRawPt r<InertAnimation> animation, const Timing& newTiming)
59 { 59 {
60 animation->setName(animationName); 60 animation->setName(animationName);
61 NewAnimation newAnimation; 61 NewAnimation newAnimation;
62 newAnimation.name = animationName; 62 newAnimation.name = animationName;
63 newAnimation.animation = animation; 63 newAnimation.animation = animation;
64 newAnimation.newTiming = newTiming;
64 m_newAnimations.append(newAnimation); 65 m_newAnimations.append(newAnimation);
65 } 66 }
66 // Returns whether player has been suppressed and should be filtered during style application. 67 // Returns whether player has been suppressed and should be filtered during style application.
67 bool isSuppressedAnimation(const AnimationPlayer* player) const { return m_s uppressedAnimationPlayers.contains(player); } 68 bool isSuppressedAnimation(const AnimationPlayer* player) const { return m_s uppressedAnimationPlayers.contains(player); }
68 void cancelAnimation(const AtomicString& name, AnimationPlayer& player) 69 void cancelAnimation(const AtomicString& name, AnimationPlayer& player)
69 { 70 {
70 m_cancelledAnimationNames.append(name); 71 m_cancelledAnimationNames.append(name);
71 m_suppressedAnimationPlayers.add(&player); 72 m_suppressedAnimationPlayers.add(&player);
72 } 73 }
73 void toggleAnimationPaused(const AtomicString& name) 74 void toggleAnimationPaused(const AtomicString& name)
74 { 75 {
75 m_animationsWithPauseToggled.append(name); 76 m_animationsWithPauseToggled.append(name);
76 } 77 }
77 void updateAnimationTiming(AnimationPlayer* player, PassRefPtrWillBeRawPtr<I nertAnimation> animation, const Timing& timing) 78 void updateAnimation(const AtomicString& name, AnimationPlayer* player, Pass RefPtrWillBeRawPtr<InertAnimation> animation, const Timing& newTiming, unsigned styleChangeCounter)
78 { 79 {
79 UpdatedAnimationTiming updatedAnimation; 80 UpdatedAnimation updatedAnimation;
81 updatedAnimation.name = name;
80 updatedAnimation.player = player; 82 updatedAnimation.player = player;
81 updatedAnimation.animation = animation; 83 updatedAnimation.animation = animation;
82 updatedAnimation.newTiming = timing; 84 updatedAnimation.newTiming = newTiming;
83 m_animationsWithTimingUpdates.append(updatedAnimation); 85 updatedAnimation.styleChangeCounter = styleChangeCounter;
86 m_animationsWithUpdates.append(updatedAnimation);
84 m_suppressedAnimationPlayers.add(player); 87 m_suppressedAnimationPlayers.add(player);
85 } 88 }
86 89
87 void startTransition(CSSPropertyID id, CSSPropertyID eventId, const Animatab leValue* from, const AnimatableValue* to, PassRefPtrWillBeRawPtr<InertAnimation> animation) 90 void startTransition(CSSPropertyID id, CSSPropertyID eventId, const Animatab leValue* from, const AnimatableValue* to, PassRefPtrWillBeRawPtr<InertAnimation> animation)
88 { 91 {
89 animation->setName(getPropertyName(id)); 92 animation->setName(getPropertyName(id));
90 NewTransition newTransition; 93 NewTransition newTransition;
91 newTransition.id = id; 94 newTransition.id = id;
92 newTransition.eventId = eventId; 95 newTransition.eventId = eventId;
93 newTransition.from = from; 96 newTransition.from = from;
94 newTransition.to = to; 97 newTransition.to = to;
95 newTransition.animation = animation; 98 newTransition.animation = animation;
96 m_newTransitions.set(id, newTransition); 99 m_newTransitions.set(id, newTransition);
97 } 100 }
98 bool isCancelledTransition(CSSPropertyID id) const { return m_cancelledTrans itions.contains(id); } 101 bool isCancelledTransition(CSSPropertyID id) const { return m_cancelledTrans itions.contains(id); }
99 void cancelTransition(CSSPropertyID id) { m_cancelledTransitions.add(id); } 102 void cancelTransition(CSSPropertyID id) { m_cancelledTransitions.add(id); }
100 103
101 struct NewAnimation { 104 struct NewAnimation {
102 ALLOW_ONLY_INLINE_ALLOCATION(); 105 ALLOW_ONLY_INLINE_ALLOCATION();
103 public: 106 public:
104 void trace(Visitor* visitor) 107 void trace(Visitor* visitor)
105 { 108 {
106 visitor->trace(animation); 109 visitor->trace(animation);
107 } 110 }
108 111
109 AtomicString name; 112 AtomicString name;
110 RefPtrWillBeMember<InertAnimation> animation; 113 RefPtrWillBeMember<InertAnimation> animation;
114 Timing newTiming;
dstockwell 2014/12/29 23:16:33 Why newTiming rather than just timing?
shend 2014/12/30 00:03:40 Changed to just 'timing'. It was meant to differen
111 }; 115 };
112 116
113 struct UpdatedAnimationTiming { 117 struct UpdatedAnimation {
114 ALLOW_ONLY_INLINE_ALLOCATION(); 118 ALLOW_ONLY_INLINE_ALLOCATION();
115 public: 119 public:
116 void trace(Visitor* visitor) 120 void trace(Visitor* visitor)
117 { 121 {
118 visitor->trace(player); 122 visitor->trace(player);
119 visitor->trace(animation); 123 visitor->trace(animation);
120 } 124 }
121 125
126 AtomicString name;
122 RawPtrWillBeMember<AnimationPlayer> player; 127 RawPtrWillBeMember<AnimationPlayer> player;
123 RefPtrWillBeMember<InertAnimation> animation; 128 RefPtrWillBeMember<InertAnimation> animation;
124 Timing newTiming; 129 Timing newTiming;
130 unsigned styleChangeCounter;
125 }; 131 };
126 132
127 const WillBeHeapVector<NewAnimation>& newAnimations() const { return m_newAn imations; } 133 const WillBeHeapVector<NewAnimation>& newAnimations() const { return m_newAn imations; }
128 const Vector<AtomicString>& cancelledAnimationNames() const { return m_cance lledAnimationNames; } 134 const Vector<AtomicString>& cancelledAnimationNames() const { return m_cance lledAnimationNames; }
129 const WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>>& suppress edAnimationAnimationPlayers() const { return m_suppressedAnimationPlayers; } 135 const WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>>& suppress edAnimationAnimationPlayers() const { return m_suppressedAnimationPlayers; }
130 const Vector<AtomicString>& animationsWithPauseToggled() const { return m_an imationsWithPauseToggled; } 136 const Vector<AtomicString>& animationsWithPauseToggled() const { return m_an imationsWithPauseToggled; }
131 const WillBeHeapVector<UpdatedAnimationTiming>& animationsWithTimingUpdates( ) const { return m_animationsWithTimingUpdates; } 137 const WillBeHeapVector<UpdatedAnimation>& animationsWithUpdates() const { re turn m_animationsWithUpdates; }
132 138
133 struct NewTransition { 139 struct NewTransition {
134 ALLOW_ONLY_INLINE_ALLOCATION(); 140 ALLOW_ONLY_INLINE_ALLOCATION();
135 public: 141 public:
136 void trace(Visitor* visitor) 142 void trace(Visitor* visitor)
137 { 143 {
138 visitor->trace(from); 144 visitor->trace(from);
139 visitor->trace(to); 145 visitor->trace(to);
140 visitor->trace(animation); 146 visitor->trace(animation);
141 } 147 }
(...skipping 13 matching lines...) Expand all
155 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& a ctiveInterpolationsForAnimations() const { return m_activeInterpolationsForAnima tions; } 161 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& a ctiveInterpolationsForAnimations() const { return m_activeInterpolationsForAnima tions; }
156 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& a ctiveInterpolationsForTransitions() const { return m_activeInterpolationsForTran sitions; } 162 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& a ctiveInterpolationsForTransitions() const { return m_activeInterpolationsForTran sitions; }
157 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& activeI nterpolationsForAnimations() { return m_activeInterpolationsForAnimations; } 163 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& activeI nterpolationsForAnimations() { return m_activeInterpolationsForAnimations; }
158 164
159 bool isEmpty() const 165 bool isEmpty() const
160 { 166 {
161 return m_newAnimations.isEmpty() 167 return m_newAnimations.isEmpty()
162 && m_cancelledAnimationNames.isEmpty() 168 && m_cancelledAnimationNames.isEmpty()
163 && m_suppressedAnimationPlayers.isEmpty() 169 && m_suppressedAnimationPlayers.isEmpty()
164 && m_animationsWithPauseToggled.isEmpty() 170 && m_animationsWithPauseToggled.isEmpty()
165 && m_animationsWithTimingUpdates.isEmpty() 171 && m_animationsWithUpdates.isEmpty()
166 && m_newTransitions.isEmpty() 172 && m_newTransitions.isEmpty()
167 && m_cancelledTransitions.isEmpty() 173 && m_cancelledTransitions.isEmpty()
168 && m_activeInterpolationsForAnimations.isEmpty() 174 && m_activeInterpolationsForAnimations.isEmpty()
169 && m_activeInterpolationsForTransitions.isEmpty(); 175 && m_activeInterpolationsForTransitions.isEmpty();
170 } 176 }
171 177
172 void trace(Visitor*); 178 void trace(Visitor*);
173 179
174 private: 180 private:
175 // Order is significant since it defines the order in which new animations 181 // Order is significant since it defines the order in which new animations
176 // will be started. Note that there may be multiple animations present 182 // will be started. Note that there may be multiple animations present
177 // with the same name, due to the way in which we split up animations with 183 // with the same name, due to the way in which we split up animations with
178 // incomplete keyframes. 184 // incomplete keyframes.
179 WillBeHeapVector<NewAnimation> m_newAnimations; 185 WillBeHeapVector<NewAnimation> m_newAnimations;
180 Vector<AtomicString> m_cancelledAnimationNames; 186 Vector<AtomicString> m_cancelledAnimationNames;
181 WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>> m_suppressedAni mationPlayers; 187 WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>> m_suppressedAni mationPlayers;
182 Vector<AtomicString> m_animationsWithPauseToggled; 188 Vector<AtomicString> m_animationsWithPauseToggled;
183 WillBeHeapVector<UpdatedAnimationTiming> m_animationsWithTimingUpdates; 189 WillBeHeapVector<UpdatedAnimation> m_animationsWithUpdates;
184 190
185 NewTransitionMap m_newTransitions; 191 NewTransitionMap m_newTransitions;
186 HashSet<CSSPropertyID> m_cancelledTransitions; 192 HashSet<CSSPropertyID> m_cancelledTransitions;
187 193
188 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active InterpolationsForAnimations; 194 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active InterpolationsForAnimations;
189 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active InterpolationsForTransitions; 195 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active InterpolationsForTransitions;
190 }; 196 };
191 197
192 class CSSAnimations final { 198 class CSSAnimations final {
193 WTF_MAKE_NONCOPYABLE(CSSAnimations); 199 WTF_MAKE_NONCOPYABLE(CSSAnimations);
(...skipping 14 matching lines...) Expand all
208 static PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> calculateUpdate(const Elem ent* animatingElement, Element&, const RenderStyle&, RenderStyle* parentStyle, S tyleResolver*); 214 static PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> calculateUpdate(const Elem ent* animatingElement, Element&, const RenderStyle&, RenderStyle* parentStyle, S tyleResolver*);
209 215
210 void setPendingUpdate(PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> update) { m _pendingUpdate = update; } 216 void setPendingUpdate(PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> update) { m _pendingUpdate = update; }
211 void maybeApplyPendingUpdate(Element*); 217 void maybeApplyPendingUpdate(Element*);
212 bool isEmpty() const { return m_animations.isEmpty() && m_transitions.isEmpt y() && !m_pendingUpdate; } 218 bool isEmpty() const { return m_animations.isEmpty() && m_transitions.isEmpt y() && !m_pendingUpdate; }
213 void cancel(); 219 void cancel();
214 220
215 void trace(Visitor*); 221 void trace(Visitor*);
216 222
217 private: 223 private:
224 struct RunningAnimation {
225 ALLOW_ONLY_INLINE_ALLOCATION();
226 public:
227 void trace(Visitor* visitor)
228 {
229 visitor->trace(player);
230 }
231
232 RefPtrWillBeMember<AnimationPlayer> player;
233 Timing specifiedTiming;
234 unsigned styleChangeCounter;
235 };
236
218 struct RunningTransition { 237 struct RunningTransition {
219 ALLOW_ONLY_INLINE_ALLOCATION(); 238 ALLOW_ONLY_INLINE_ALLOCATION();
220 public: 239 public:
221 void trace(Visitor* visitor) 240 void trace(Visitor* visitor)
222 { 241 {
223 visitor->trace(player); 242 visitor->trace(player);
224 visitor->trace(from); 243 visitor->trace(from);
225 visitor->trace(to); 244 visitor->trace(to);
226 } 245 }
227 246
228 RefPtrWillBeMember<AnimationPlayer> player; 247 RefPtrWillBeMember<AnimationPlayer> player;
229 RawPtrWillBeMember<const AnimatableValue> from; 248 RawPtrWillBeMember<const AnimatableValue> from;
230 RawPtrWillBeMember<const AnimatableValue> to; 249 RawPtrWillBeMember<const AnimatableValue> to;
231 }; 250 };
232 251
233 using AnimationMap = WillBeHeapHashMap<AtomicString, RefPtrWillBeMember<Anim ationPlayer>>; 252 using AnimationMap = WillBeHeapHashMap<AtomicString, RunningAnimation>;
234 AnimationMap m_animations; 253 AnimationMap m_animations;
235 254
236 using TransitionMap = WillBeHeapHashMap<CSSPropertyID, RunningTransition>; 255 using TransitionMap = WillBeHeapHashMap<CSSPropertyID, RunningTransition>;
237 TransitionMap m_transitions; 256 TransitionMap m_transitions;
238 257
239 OwnPtrWillBeMember<CSSAnimationUpdate> m_pendingUpdate; 258 OwnPtrWillBeMember<CSSAnimationUpdate> m_pendingUpdate;
240 259
241 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_previo usActiveInterpolationsForAnimations; 260 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_previo usActiveInterpolationsForAnimations;
242 261
243 static void calculateAnimationUpdate(CSSAnimationUpdate*, const Element* ani matingElement, Element&, const RenderStyle&, RenderStyle* parentStyle, StyleReso lver*); 262 static void calculateAnimationUpdate(CSSAnimationUpdate*, const Element* ani matingElement, Element&, const RenderStyle&, RenderStyle* parentStyle, StyleReso lver*);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 private: 302 private:
284 RawPtrWillBeMember<Element> m_target; 303 RawPtrWillBeMember<Element> m_target;
285 const CSSPropertyID m_property; 304 const CSSPropertyID m_property;
286 AnimationNode::Phase m_previousPhase; 305 AnimationNode::Phase m_previousPhase;
287 }; 306 };
288 }; 307 };
289 308
290 } // namespace blink 309 } // namespace blink
291 310
292 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation); 311 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation);
293 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimationTim ing); 312 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimation);
294 313
295 #endif 314 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698