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

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

Issue 851693007: Prepare for responsive CSS animations. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix timing function layout tests Created 5 years, 10 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 // 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 "wtf/HashMap.h" 9 #include "wtf/HashMap.h"
10 #include "wtf/Vector.h" 10 #include "wtf/Vector.h"
11 #include "wtf/text/AtomicString.h" 11 #include "wtf/text/AtomicString.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 class AnimationPlayer; 15 class AnimationPlayer;
16 class InertAnimation; 16 class InertAnimation;
17 class KeyframeEffectModelBase;
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:
23 struct NewAnimation {
24 ALLOW_ONLY_INLINE_ALLOCATION();
25 public:
26 void trace(Visitor* visitor)
27 {
28 visitor->trace(animation);
29 }
30
31 AtomicString name;
32 RefPtrWillBeMember<InertAnimation> animation;
33 };
34
35 struct UpdatedAnimationTiming {
36 ALLOW_ONLY_INLINE_ALLOCATION();
37 public:
38 void trace(Visitor* visitor)
39 {
40 visitor->trace(player);
41 visitor->trace(animation);
42 }
43
44 RawPtrWillBeMember<AnimationPlayer> player;
45 RefPtrWillBeMember<InertAnimation> animation;
46 Timing newTiming;
47 };
48
49 struct UpdatedAnimationStyle {
50 ALLOW_ONLY_INLINE_ALLOCATION();
51 public:
52 void trace(Visitor* visitor)
53 {
54 visitor->trace(player);
55 visitor->trace(effect);
56 }
57
58 struct CompositableStyleSnapshot {
59 RefPtrWillBeMember<AnimatableValue> opacity;
60 RefPtrWillBeMember<AnimatableValue> transform;
61 RefPtrWillBeMember<AnimatableValue> webkitFilter;
62 };
63
64 RawPtrWillBeMember<AnimationPlayer> player;
65 RawPtrWillBeMember<KeyframeEffectModelBase> effect;
66 CompositableStyleSnapshot snapshot;
67 };
68
22 void startAnimation(const AtomicString& animationName, PassRefPtrWillBeRawPt r<InertAnimation> animation) 69 void startAnimation(const AtomicString& animationName, PassRefPtrWillBeRawPt r<InertAnimation> animation)
23 { 70 {
24 animation->setName(animationName); 71 animation->setName(animationName);
25 NewAnimation newAnimation; 72 NewAnimation newAnimation;
26 newAnimation.name = animationName; 73 newAnimation.name = animationName;
27 newAnimation.animation = animation; 74 newAnimation.animation = animation;
28 m_newAnimations.append(newAnimation); 75 m_newAnimations.append(newAnimation);
29 } 76 }
30 // Returns whether player has been suppressed and should be filtered during style application. 77 // 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); } 78 bool isSuppressedAnimation(const AnimationPlayer* player) const { return m_s uppressedAnimationPlayers.contains(player); }
32 void cancelAnimation(const AtomicString& name, AnimationPlayer& player) 79 void cancelAnimation(const AtomicString& name, AnimationPlayer& player)
33 { 80 {
34 m_cancelledAnimationNames.append(name); 81 m_cancelledAnimationNames.append(name);
35 m_suppressedAnimationPlayers.add(&player); 82 m_suppressedAnimationPlayers.add(&player);
36 } 83 }
37 void toggleAnimationPaused(const AtomicString& name) 84 void toggleAnimationPaused(const AtomicString& name)
38 { 85 {
39 m_animationsWithPauseToggled.append(name); 86 m_animationsWithPauseToggled.append(name);
40 } 87 }
41 void updateAnimationTiming(AnimationPlayer* player, PassRefPtrWillBeRawPtr<I nertAnimation> animation, const Timing& timing) 88 void updateAnimationTiming(AnimationPlayer* player, PassRefPtrWillBeRawPtr<I nertAnimation> animation, const Timing& timing)
42 { 89 {
43 UpdatedAnimationTiming updatedAnimation; 90 UpdatedAnimationTiming updatedAnimation;
44 updatedAnimation.player = player; 91 updatedAnimation.player = player;
45 updatedAnimation.animation = animation; 92 updatedAnimation.animation = animation;
46 updatedAnimation.newTiming = timing; 93 updatedAnimation.newTiming = timing;
47 m_animationsWithTimingUpdates.append(updatedAnimation); 94 m_animationsWithTimingUpdates.append(updatedAnimation);
48 m_suppressedAnimationPlayers.add(player); 95 m_suppressedAnimationPlayers.add(player);
49 } 96 }
97 void updateAnimationStyle(AnimationPlayer* player, KeyframeEffectModelBase* effect, const UpdatedAnimationStyle::CompositableStyleSnapshot& snapshot)
98 {
99 UpdatedAnimationStyle updatedAnimation;
100 updatedAnimation.player = player;
101 updatedAnimation.effect = effect;
102 updatedAnimation.snapshot = snapshot;
103 m_animationsWithStyleUpdates.append(updatedAnimation);
104 }
50 105
51 void startTransition(CSSPropertyID id, CSSPropertyID eventId, const Animatab leValue* from, const AnimatableValue* to, PassRefPtrWillBeRawPtr<InertAnimation> animation) 106 void startTransition(CSSPropertyID id, CSSPropertyID eventId, const Animatab leValue* from, const AnimatableValue* to, PassRefPtrWillBeRawPtr<InertAnimation> animation)
52 { 107 {
53 animation->setName(getPropertyName(id)); 108 animation->setName(getPropertyName(id));
54 NewTransition newTransition; 109 NewTransition newTransition;
55 newTransition.id = id; 110 newTransition.id = id;
56 newTransition.eventId = eventId; 111 newTransition.eventId = eventId;
57 newTransition.from = from; 112 newTransition.from = from;
58 newTransition.to = to; 113 newTransition.to = to;
59 newTransition.animation = animation; 114 newTransition.animation = animation;
60 m_newTransitions.set(id, newTransition); 115 m_newTransitions.set(id, newTransition);
61 } 116 }
62 bool isCancelledTransition(CSSPropertyID id) const { return m_cancelledTrans itions.contains(id); } 117 bool isCancelledTransition(CSSPropertyID id) const { return m_cancelledTrans itions.contains(id); }
63 void cancelTransition(CSSPropertyID id) { m_cancelledTransitions.add(id); } 118 void cancelTransition(CSSPropertyID id) { m_cancelledTransitions.add(id); }
64 119
65 struct NewAnimation {
66 ALLOW_ONLY_INLINE_ALLOCATION();
67 public:
68 void trace(Visitor* visitor)
69 {
70 visitor->trace(animation);
71 }
72
73 AtomicString name;
74 RefPtrWillBeMember<InertAnimation> animation;
75 };
76
77 struct UpdatedAnimationTiming {
78 ALLOW_ONLY_INLINE_ALLOCATION();
79 public:
80 void trace(Visitor* visitor)
81 {
82 visitor->trace(player);
83 visitor->trace(animation);
84 }
85
86 RawPtrWillBeMember<AnimationPlayer> player;
87 RefPtrWillBeMember<InertAnimation> animation;
88 Timing newTiming;
89 };
90
91 const WillBeHeapVector<NewAnimation>& newAnimations() const { return m_newAn imations; } 120 const WillBeHeapVector<NewAnimation>& newAnimations() const { return m_newAn imations; }
92 const Vector<AtomicString>& cancelledAnimationNames() const { return m_cance lledAnimationNames; } 121 const Vector<AtomicString>& cancelledAnimationNames() const { return m_cance lledAnimationNames; }
93 const WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>>& suppress edAnimationAnimationPlayers() const { return m_suppressedAnimationPlayers; } 122 const WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>>& suppress edAnimationAnimationPlayers() const { return m_suppressedAnimationPlayers; }
94 const Vector<AtomicString>& animationsWithPauseToggled() const { return m_an imationsWithPauseToggled; } 123 const Vector<AtomicString>& animationsWithPauseToggled() const { return m_an imationsWithPauseToggled; }
95 const WillBeHeapVector<UpdatedAnimationTiming>& animationsWithTimingUpdates( ) const { return m_animationsWithTimingUpdates; } 124 const WillBeHeapVector<UpdatedAnimationTiming>& animationsWithTimingUpdates( ) const { return m_animationsWithTimingUpdates; }
125 const WillBeHeapVector<UpdatedAnimationStyle>& animationsWithStyleUpdates() const { return m_animationsWithStyleUpdates; }
96 126
97 struct NewTransition { 127 struct NewTransition {
98 ALLOW_ONLY_INLINE_ALLOCATION(); 128 ALLOW_ONLY_INLINE_ALLOCATION();
99 public: 129 public:
100 void trace(Visitor* visitor) 130 void trace(Visitor* visitor)
101 { 131 {
102 visitor->trace(from); 132 visitor->trace(from);
103 visitor->trace(to); 133 visitor->trace(to);
104 visitor->trace(animation); 134 visitor->trace(animation);
105 } 135 }
(...skipping 14 matching lines...) Expand all
120 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& a ctiveInterpolationsForTransitions() const { return m_activeInterpolationsForTran sitions; } 150 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& a ctiveInterpolationsForTransitions() const { return m_activeInterpolationsForTran sitions; }
121 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& activeI nterpolationsForAnimations() { return m_activeInterpolationsForAnimations; } 151 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& activeI nterpolationsForAnimations() { return m_activeInterpolationsForAnimations; }
122 152
123 bool isEmpty() const 153 bool isEmpty() const
124 { 154 {
125 return m_newAnimations.isEmpty() 155 return m_newAnimations.isEmpty()
126 && m_cancelledAnimationNames.isEmpty() 156 && m_cancelledAnimationNames.isEmpty()
127 && m_suppressedAnimationPlayers.isEmpty() 157 && m_suppressedAnimationPlayers.isEmpty()
128 && m_animationsWithPauseToggled.isEmpty() 158 && m_animationsWithPauseToggled.isEmpty()
129 && m_animationsWithTimingUpdates.isEmpty() 159 && m_animationsWithTimingUpdates.isEmpty()
160 && m_animationsWithStyleUpdates.isEmpty()
130 && m_newTransitions.isEmpty() 161 && m_newTransitions.isEmpty()
131 && m_cancelledTransitions.isEmpty() 162 && m_cancelledTransitions.isEmpty()
132 && m_activeInterpolationsForAnimations.isEmpty() 163 && m_activeInterpolationsForAnimations.isEmpty()
133 && m_activeInterpolationsForTransitions.isEmpty(); 164 && m_activeInterpolationsForTransitions.isEmpty();
134 } 165 }
135 166
136 void trace(Visitor*); 167 void trace(Visitor*);
137 168
138 private: 169 private:
139 // Order is significant since it defines the order in which new animations 170 // Order is significant since it defines the order in which new animations
140 // will be started. Note that there may be multiple animations present 171 // 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 172 // with the same name, due to the way in which we split up animations with
142 // incomplete keyframes. 173 // incomplete keyframes.
143 WillBeHeapVector<NewAnimation> m_newAnimations; 174 WillBeHeapVector<NewAnimation> m_newAnimations;
144 Vector<AtomicString> m_cancelledAnimationNames; 175 Vector<AtomicString> m_cancelledAnimationNames;
145 WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>> m_suppressedAni mationPlayers; 176 WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>> m_suppressedAni mationPlayers;
146 Vector<AtomicString> m_animationsWithPauseToggled; 177 Vector<AtomicString> m_animationsWithPauseToggled;
147 WillBeHeapVector<UpdatedAnimationTiming> m_animationsWithTimingUpdates; 178 WillBeHeapVector<UpdatedAnimationTiming> m_animationsWithTimingUpdates;
179 WillBeHeapVector<UpdatedAnimationStyle> m_animationsWithStyleUpdates;
148 180
149 NewTransitionMap m_newTransitions; 181 NewTransitionMap m_newTransitions;
150 HashSet<CSSPropertyID> m_cancelledTransitions; 182 HashSet<CSSPropertyID> m_cancelledTransitions;
151 183
152 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active InterpolationsForAnimations; 184 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active InterpolationsForAnimations;
153 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active InterpolationsForTransitions; 185 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active InterpolationsForTransitions;
154 }; 186 };
155 187
156 } // namespace blink 188 } // namespace blink
157 189
158 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation); 190 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation);
159 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimationTim ing); 191 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimationTim ing);
160 192
161 #endif 193 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698