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

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: Add tests for changing timing function Created 5 years, 11 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(AnimationPlayer* player, PassRefPtrWillBeRawPtr<InertAn imation> animation, const Timing& newTiming, unsigned styleChangeCounter)
78 { 79 {
79 UpdatedAnimationTiming updatedAnimation; 80 UpdatedAnimation updatedAnimation;
80 updatedAnimation.player = player; 81 updatedAnimation.player = player;
81 updatedAnimation.animation = animation; 82 updatedAnimation.animation = animation;
82 updatedAnimation.newTiming = timing; 83 updatedAnimation.newTiming = newTiming;
83 m_animationsWithTimingUpdates.append(updatedAnimation); 84 updatedAnimation.styleChangeCounter = styleChangeCounter;
85 m_animationsWithUpdates.append(updatedAnimation);
84 m_suppressedAnimationPlayers.add(player); 86 m_suppressedAnimationPlayers.add(player);
85 } 87 }
86 88
87 void startTransition(CSSPropertyID id, CSSPropertyID eventId, const Animatab leValue* from, const AnimatableValue* to, PassRefPtrWillBeRawPtr<InertAnimation> animation) 89 void startTransition(CSSPropertyID id, CSSPropertyID eventId, const Animatab leValue* from, const AnimatableValue* to, PassRefPtrWillBeRawPtr<InertAnimation> animation)
88 { 90 {
89 animation->setName(getPropertyName(id)); 91 animation->setName(getPropertyName(id));
90 NewTransition newTransition; 92 NewTransition newTransition;
91 newTransition.id = id; 93 newTransition.id = id;
92 newTransition.eventId = eventId; 94 newTransition.eventId = eventId;
93 newTransition.from = from; 95 newTransition.from = from;
94 newTransition.to = to; 96 newTransition.to = to;
95 newTransition.animation = animation; 97 newTransition.animation = animation;
96 m_newTransitions.set(id, newTransition); 98 m_newTransitions.set(id, newTransition);
97 } 99 }
98 bool isCancelledTransition(CSSPropertyID id) const { return m_cancelledTrans itions.contains(id); } 100 bool isCancelledTransition(CSSPropertyID id) const { return m_cancelledTrans itions.contains(id); }
99 void cancelTransition(CSSPropertyID id) { m_cancelledTransitions.add(id); } 101 void cancelTransition(CSSPropertyID id) { m_cancelledTransitions.add(id); }
100 102
101 struct NewAnimation { 103 struct NewAnimation {
102 ALLOW_ONLY_INLINE_ALLOCATION(); 104 ALLOW_ONLY_INLINE_ALLOCATION();
103 public: 105 public:
104 void trace(Visitor* visitor) 106 void trace(Visitor* visitor)
105 { 107 {
106 visitor->trace(animation); 108 visitor->trace(animation);
107 } 109 }
108 110
109 AtomicString name; 111 AtomicString name;
110 RefPtrWillBeMember<InertAnimation> animation; 112 RefPtrWillBeMember<InertAnimation> animation;
113 Timing newTiming;
111 }; 114 };
112 115
113 struct UpdatedAnimationTiming { 116 struct UpdatedAnimation {
114 ALLOW_ONLY_INLINE_ALLOCATION(); 117 ALLOW_ONLY_INLINE_ALLOCATION();
115 public: 118 public:
116 void trace(Visitor* visitor) 119 void trace(Visitor* visitor)
117 { 120 {
118 visitor->trace(player); 121 visitor->trace(player);
119 visitor->trace(animation); 122 visitor->trace(animation);
120 } 123 }
121 124
122 RawPtrWillBeMember<AnimationPlayer> player; 125 RawPtrWillBeMember<AnimationPlayer> player;
123 RefPtrWillBeMember<InertAnimation> animation; 126 RefPtrWillBeMember<InertAnimation> animation;
124 Timing newTiming; 127 Timing newTiming;
128 unsigned styleChangeCounter;
125 }; 129 };
126 130
127 const WillBeHeapVector<NewAnimation>& newAnimations() const { return m_newAn imations; } 131 const WillBeHeapVector<NewAnimation>& newAnimations() const { return m_newAn imations; }
128 const Vector<AtomicString>& cancelledAnimationNames() const { return m_cance lledAnimationNames; } 132 const Vector<AtomicString>& cancelledAnimationNames() const { return m_cance lledAnimationNames; }
129 const WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>>& suppress edAnimationAnimationPlayers() const { return m_suppressedAnimationPlayers; } 133 const WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>>& suppress edAnimationAnimationPlayers() const { return m_suppressedAnimationPlayers; }
130 const Vector<AtomicString>& animationsWithPauseToggled() const { return m_an imationsWithPauseToggled; } 134 const Vector<AtomicString>& animationsWithPauseToggled() const { return m_an imationsWithPauseToggled; }
131 const WillBeHeapVector<UpdatedAnimationTiming>& animationsWithTimingUpdates( ) const { return m_animationsWithTimingUpdates; } 135 const WillBeHeapVector<UpdatedAnimation>& animationsWithUpdates() const { re turn m_animationsWithUpdates; }
132 136
133 struct NewTransition { 137 struct NewTransition {
134 ALLOW_ONLY_INLINE_ALLOCATION(); 138 ALLOW_ONLY_INLINE_ALLOCATION();
135 public: 139 public:
136 void trace(Visitor* visitor) 140 void trace(Visitor* visitor)
137 { 141 {
138 visitor->trace(from); 142 visitor->trace(from);
139 visitor->trace(to); 143 visitor->trace(to);
140 visitor->trace(animation); 144 visitor->trace(animation);
141 } 145 }
(...skipping 13 matching lines...) Expand all
155 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& a ctiveInterpolationsForAnimations() const { return m_activeInterpolationsForAnima tions; } 159 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; } 160 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& a ctiveInterpolationsForTransitions() const { return m_activeInterpolationsForTran sitions; }
157 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& activeI nterpolationsForAnimations() { return m_activeInterpolationsForAnimations; } 161 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& activeI nterpolationsForAnimations() { return m_activeInterpolationsForAnimations; }
158 162
159 bool isEmpty() const 163 bool isEmpty() const
160 { 164 {
161 return m_newAnimations.isEmpty() 165 return m_newAnimations.isEmpty()
162 && m_cancelledAnimationNames.isEmpty() 166 && m_cancelledAnimationNames.isEmpty()
163 && m_suppressedAnimationPlayers.isEmpty() 167 && m_suppressedAnimationPlayers.isEmpty()
164 && m_animationsWithPauseToggled.isEmpty() 168 && m_animationsWithPauseToggled.isEmpty()
165 && m_animationsWithTimingUpdates.isEmpty() 169 && m_animationsWithUpdates.isEmpty()
166 && m_newTransitions.isEmpty() 170 && m_newTransitions.isEmpty()
167 && m_cancelledTransitions.isEmpty() 171 && m_cancelledTransitions.isEmpty()
168 && m_activeInterpolationsForAnimations.isEmpty() 172 && m_activeInterpolationsForAnimations.isEmpty()
169 && m_activeInterpolationsForTransitions.isEmpty(); 173 && m_activeInterpolationsForTransitions.isEmpty();
170 } 174 }
171 175
172 void trace(Visitor*); 176 void trace(Visitor*);
173 177
174 private: 178 private:
175 // Order is significant since it defines the order in which new animations 179 // Order is significant since it defines the order in which new animations
176 // will be started. Note that there may be multiple animations present 180 // 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 181 // with the same name, due to the way in which we split up animations with
178 // incomplete keyframes. 182 // incomplete keyframes.
179 WillBeHeapVector<NewAnimation> m_newAnimations; 183 WillBeHeapVector<NewAnimation> m_newAnimations;
180 Vector<AtomicString> m_cancelledAnimationNames; 184 Vector<AtomicString> m_cancelledAnimationNames;
181 WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>> m_suppressedAni mationPlayers; 185 WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>> m_suppressedAni mationPlayers;
182 Vector<AtomicString> m_animationsWithPauseToggled; 186 Vector<AtomicString> m_animationsWithPauseToggled;
183 WillBeHeapVector<UpdatedAnimationTiming> m_animationsWithTimingUpdates; 187 WillBeHeapVector<UpdatedAnimation> m_animationsWithUpdates;
184 188
185 NewTransitionMap m_newTransitions; 189 NewTransitionMap m_newTransitions;
186 HashSet<CSSPropertyID> m_cancelledTransitions; 190 HashSet<CSSPropertyID> m_cancelledTransitions;
187 191
188 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active InterpolationsForAnimations; 192 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active InterpolationsForAnimations;
189 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active InterpolationsForTransitions; 193 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active InterpolationsForTransitions;
190 }; 194 };
191 195
192 class CSSAnimations final { 196 class CSSAnimations final {
193 WTF_MAKE_NONCOPYABLE(CSSAnimations); 197 WTF_MAKE_NONCOPYABLE(CSSAnimations);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 RawPtrWillBeMember<const AnimatableValue> from; 233 RawPtrWillBeMember<const AnimatableValue> from;
230 RawPtrWillBeMember<const AnimatableValue> to; 234 RawPtrWillBeMember<const AnimatableValue> to;
231 }; 235 };
232 236
233 using AnimationMap = WillBeHeapHashMap<AtomicString, RefPtrWillBeMember<Anim ationPlayer>>; 237 using AnimationMap = WillBeHeapHashMap<AtomicString, RefPtrWillBeMember<Anim ationPlayer>>;
234 AnimationMap m_animations; 238 AnimationMap m_animations;
235 239
236 using TransitionMap = WillBeHeapHashMap<CSSPropertyID, RunningTransition>; 240 using TransitionMap = WillBeHeapHashMap<CSSPropertyID, RunningTransition>;
237 TransitionMap m_transitions; 241 TransitionMap m_transitions;
238 242
243 using TimingMap = WillBeHeapHashMap<AtomicString, Timing>;
244 TimingMap m_timings;
245
239 OwnPtrWillBeMember<CSSAnimationUpdate> m_pendingUpdate; 246 OwnPtrWillBeMember<CSSAnimationUpdate> m_pendingUpdate;
240 247
241 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_previo usActiveInterpolationsForAnimations; 248 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_previo usActiveInterpolationsForAnimations;
242 249
243 static void calculateAnimationUpdate(CSSAnimationUpdate*, const Element* ani matingElement, Element&, const RenderStyle&, RenderStyle* parentStyle, StyleReso lver*); 250 static void calculateAnimationUpdate(CSSAnimationUpdate*, const Element* ani matingElement, Element&, const RenderStyle&, RenderStyle* parentStyle, StyleReso lver*);
244 static void calculateTransitionUpdate(CSSAnimationUpdate*, const Element* an imatingElement, const RenderStyle&); 251 static void calculateTransitionUpdate(CSSAnimationUpdate*, const Element* an imatingElement, const RenderStyle&);
245 static void calculateTransitionUpdateForProperty(CSSPropertyID, CSSPropertyI D eventId, const CSSTransitionData&, size_t transitionIndex, const RenderStyle& oldStyle, const RenderStyle&, const TransitionMap* activeTransitions, CSSAnimati onUpdate*, const Element*); 252 static void calculateTransitionUpdateForProperty(CSSPropertyID, CSSPropertyI D eventId, const CSSTransitionData&, size_t transitionIndex, const RenderStyle& oldStyle, const RenderStyle&, const TransitionMap* activeTransitions, CSSAnimati onUpdate*, const Element*);
246 253
247 static void calculateAnimationActiveInterpolations(CSSAnimationUpdate*, cons t Element* animatingElement, double timelineCurrentTime); 254 static void calculateAnimationActiveInterpolations(CSSAnimationUpdate*, cons t Element* animatingElement, double timelineCurrentTime);
248 static void calculateTransitionActiveInterpolations(CSSAnimationUpdate*, con st Element* animatingElement, double timelineCurrentTime); 255 static void calculateTransitionActiveInterpolations(CSSAnimationUpdate*, con st Element* animatingElement, double timelineCurrentTime);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 private: 290 private:
284 RawPtrWillBeMember<Element> m_target; 291 RawPtrWillBeMember<Element> m_target;
285 const CSSPropertyID m_property; 292 const CSSPropertyID m_property;
286 AnimationNode::Phase m_previousPhase; 293 AnimationNode::Phase m_previousPhase;
287 }; 294 };
288 }; 295 };
289 296
290 } // namespace blink 297 } // namespace blink
291 298
292 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation); 299 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation);
293 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimationTim ing); 300 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimation);
294 301
295 #endif 302 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698