| 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 "core/css/CSSKeyframesRule.h" |
| 10 #include "wtf/HashMap.h" | 10 #include "wtf/HashMap.h" |
| 11 #include "wtf/Vector.h" | 11 #include "wtf/Vector.h" |
| 12 #include "wtf/text/AtomicString.h" | 12 #include "wtf/text/AtomicString.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 class AnimationPlayer; | 16 class AnimationPlayer; |
| 17 class InertAnimation; | 17 class InertAnimation; |
| 18 class KeyframeEffectModelBase; |
| 18 | 19 |
| 19 // This class stores the CSS Animations/Transitions information we use during a
style recalc. | 20 // This class stores the CSS Animations/Transitions information we use during a
style recalc. |
| 20 // This includes updates to animations/transitions as well as the Interpolations
to be applied. | 21 // This includes updates to animations/transitions as well as the Interpolations
to be applied. |
| 21 class CSSAnimationUpdate final : public NoBaseWillBeGarbageCollectedFinalized<CS
SAnimationUpdate> { | 22 class CSSAnimationUpdate final : public NoBaseWillBeGarbageCollectedFinalized<CS
SAnimationUpdate> { |
| 22 public: | 23 public: |
| 23 class NewAnimation { | 24 class NewAnimation { |
| 24 ALLOW_ONLY_INLINE_ALLOCATION(); | 25 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 25 public: | 26 public: |
| 26 NewAnimation() | 27 NewAnimation() |
| 27 : styleRuleVersion(0) | 28 : styleRuleVersion(0) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 } | 77 } |
| 77 | 78 |
| 78 AtomicString name; | 79 AtomicString name; |
| 79 RawPtrWillBeMember<AnimationPlayer> player; | 80 RawPtrWillBeMember<AnimationPlayer> player; |
| 80 RefPtrWillBeMember<InertAnimation> animation; | 81 RefPtrWillBeMember<InertAnimation> animation; |
| 81 Timing specifiedTiming; | 82 Timing specifiedTiming; |
| 82 RefPtrWillBeMember<StyleRuleKeyframes> styleRule; | 83 RefPtrWillBeMember<StyleRuleKeyframes> styleRule; |
| 83 unsigned styleRuleVersion; | 84 unsigned styleRuleVersion; |
| 84 }; | 85 }; |
| 85 | 86 |
| 87 class UpdatedAnimationStyle { |
| 88 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 89 public: |
| 90 struct CompositableStyleSnapshot { |
| 91 RefPtrWillBeMember<AnimatableValue> opacity; |
| 92 RefPtrWillBeMember<AnimatableValue> transform; |
| 93 RefPtrWillBeMember<AnimatableValue> webkitFilter; |
| 94 }; |
| 95 |
| 96 UpdatedAnimationStyle() |
| 97 { |
| 98 } |
| 99 |
| 100 UpdatedAnimationStyle(AnimationPlayer* player, KeyframeEffectModelBase*
effect, const UpdatedAnimationStyle::CompositableStyleSnapshot& snapshot) |
| 101 : player(player) |
| 102 , effect(effect) |
| 103 , snapshot(snapshot) |
| 104 { |
| 105 } |
| 106 |
| 107 void trace(Visitor* visitor) |
| 108 { |
| 109 visitor->trace(player); |
| 110 visitor->trace(effect); |
| 111 } |
| 112 |
| 113 RawPtrWillBeMember<AnimationPlayer> player; |
| 114 RawPtrWillBeMember<KeyframeEffectModelBase> effect; |
| 115 CompositableStyleSnapshot snapshot; |
| 116 }; |
| 117 |
| 86 void startAnimation(const AtomicString& animationName, PassRefPtrWillBeRawPt
r<InertAnimation> animation, const Timing& timing, PassRefPtrWillBeRawPtr<StyleR
uleKeyframes> styleRule) | 118 void startAnimation(const AtomicString& animationName, PassRefPtrWillBeRawPt
r<InertAnimation> animation, const Timing& timing, PassRefPtrWillBeRawPtr<StyleR
uleKeyframes> styleRule) |
| 87 { | 119 { |
| 88 animation->setName(animationName); | 120 animation->setName(animationName); |
| 89 m_newAnimations.append(NewAnimation(animationName, animation, timing, st
yleRule)); | 121 m_newAnimations.append(NewAnimation(animationName, animation, timing, st
yleRule)); |
| 90 } | 122 } |
| 91 // Returns whether player has been suppressed and should be filtered during
style application. | 123 // Returns whether player has been suppressed and should be filtered during
style application. |
| 92 bool isSuppressedAnimation(const AnimationPlayer* player) const { return m_s
uppressedAnimationPlayers.contains(player); } | 124 bool isSuppressedAnimation(const AnimationPlayer* player) const { return m_s
uppressedAnimationPlayers.contains(player); } |
| 93 void cancelAnimation(const AtomicString& name, AnimationPlayer& player) | 125 void cancelAnimation(const AtomicString& name, AnimationPlayer& player) |
| 94 { | 126 { |
| 95 m_cancelledAnimationNames.append(name); | 127 m_cancelledAnimationNames.append(name); |
| 96 m_suppressedAnimationPlayers.add(&player); | 128 m_suppressedAnimationPlayers.add(&player); |
| 97 } | 129 } |
| 98 void toggleAnimationPaused(const AtomicString& name) | 130 void toggleAnimationPaused(const AtomicString& name) |
| 99 { | 131 { |
| 100 m_animationsWithPauseToggled.append(name); | 132 m_animationsWithPauseToggled.append(name); |
| 101 } | 133 } |
| 102 void updateAnimation(const AtomicString& name, AnimationPlayer* player, Pass
RefPtrWillBeRawPtr<InertAnimation> animation, const Timing& specifiedTiming, | 134 void updateAnimation(const AtomicString& name, AnimationPlayer* player, Pass
RefPtrWillBeRawPtr<InertAnimation> animation, const Timing& specifiedTiming, |
| 103 PassRefPtrWillBeRawPtr<StyleRuleKeyframes> styleRule) | 135 PassRefPtrWillBeRawPtr<StyleRuleKeyframes> styleRule) |
| 104 { | 136 { |
| 105 m_animationsWithUpdates.append(UpdatedAnimation(name, player, animation,
specifiedTiming, styleRule)); | 137 m_animationsWithUpdates.append(UpdatedAnimation(name, player, animation,
specifiedTiming, styleRule)); |
| 106 m_suppressedAnimationPlayers.add(player); | 138 m_suppressedAnimationPlayers.add(player); |
| 107 } | 139 } |
| 140 void updateAnimationStyle(AnimationPlayer* player, KeyframeEffectModelBase*
effect, const UpdatedAnimationStyle::CompositableStyleSnapshot& snapshot) |
| 141 { |
| 142 m_animationsWithStyleUpdates.append(UpdatedAnimationStyle(player, effect
, snapshot)); |
| 143 } |
| 108 | 144 |
| 109 void startTransition(CSSPropertyID id, CSSPropertyID eventId, const Animatab
leValue* from, const AnimatableValue* to, PassRefPtrWillBeRawPtr<InertAnimation>
animation) | 145 void startTransition(CSSPropertyID id, CSSPropertyID eventId, const Animatab
leValue* from, const AnimatableValue* to, PassRefPtrWillBeRawPtr<InertAnimation>
animation) |
| 110 { | 146 { |
| 111 animation->setName(getPropertyName(id)); | 147 animation->setName(getPropertyName(id)); |
| 112 NewTransition newTransition; | 148 NewTransition newTransition; |
| 113 newTransition.id = id; | 149 newTransition.id = id; |
| 114 newTransition.eventId = eventId; | 150 newTransition.eventId = eventId; |
| 115 newTransition.from = from; | 151 newTransition.from = from; |
| 116 newTransition.to = to; | 152 newTransition.to = to; |
| 117 newTransition.animation = animation; | 153 newTransition.animation = animation; |
| 118 m_newTransitions.set(id, newTransition); | 154 m_newTransitions.set(id, newTransition); |
| 119 } | 155 } |
| 120 bool isCancelledTransition(CSSPropertyID id) const { return m_cancelledTrans
itions.contains(id); } | 156 bool isCancelledTransition(CSSPropertyID id) const { return m_cancelledTrans
itions.contains(id); } |
| 121 void cancelTransition(CSSPropertyID id) { m_cancelledTransitions.add(id); } | 157 void cancelTransition(CSSPropertyID id) { m_cancelledTransitions.add(id); } |
| 122 | 158 |
| 123 const WillBeHeapVector<NewAnimation>& newAnimations() const { return m_newAn
imations; } | 159 const WillBeHeapVector<NewAnimation>& newAnimations() const { return m_newAn
imations; } |
| 124 const Vector<AtomicString>& cancelledAnimationNames() const { return m_cance
lledAnimationNames; } | 160 const Vector<AtomicString>& cancelledAnimationNames() const { return m_cance
lledAnimationNames; } |
| 125 const WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>>& suppress
edAnimationAnimationPlayers() const { return m_suppressedAnimationPlayers; } | 161 const WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>>& suppress
edAnimationAnimationPlayers() const { return m_suppressedAnimationPlayers; } |
| 126 const Vector<AtomicString>& animationsWithPauseToggled() const { return m_an
imationsWithPauseToggled; } | 162 const Vector<AtomicString>& animationsWithPauseToggled() const { return m_an
imationsWithPauseToggled; } |
| 127 const WillBeHeapVector<UpdatedAnimation>& animationsWithUpdates() const { re
turn m_animationsWithUpdates; } | 163 const WillBeHeapVector<UpdatedAnimation>& animationsWithUpdates() const { re
turn m_animationsWithUpdates; } |
| 164 const WillBeHeapVector<UpdatedAnimationStyle>& animationsWithStyleUpdates()
const { return m_animationsWithStyleUpdates; } |
| 128 | 165 |
| 129 struct NewTransition { | 166 struct NewTransition { |
| 130 ALLOW_ONLY_INLINE_ALLOCATION(); | 167 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 131 public: | 168 public: |
| 132 void trace(Visitor* visitor) | 169 void trace(Visitor* visitor) |
| 133 { | 170 { |
| 134 visitor->trace(from); | 171 visitor->trace(from); |
| 135 visitor->trace(to); | 172 visitor->trace(to); |
| 136 visitor->trace(animation); | 173 visitor->trace(animation); |
| 137 } | 174 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 152 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& a
ctiveInterpolationsForTransitions() const { return m_activeInterpolationsForTran
sitions; } | 189 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& a
ctiveInterpolationsForTransitions() const { return m_activeInterpolationsForTran
sitions; } |
| 153 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& activeI
nterpolationsForAnimations() { return m_activeInterpolationsForAnimations; } | 190 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& activeI
nterpolationsForAnimations() { return m_activeInterpolationsForAnimations; } |
| 154 | 191 |
| 155 bool isEmpty() const | 192 bool isEmpty() const |
| 156 { | 193 { |
| 157 return m_newAnimations.isEmpty() | 194 return m_newAnimations.isEmpty() |
| 158 && m_cancelledAnimationNames.isEmpty() | 195 && m_cancelledAnimationNames.isEmpty() |
| 159 && m_suppressedAnimationPlayers.isEmpty() | 196 && m_suppressedAnimationPlayers.isEmpty() |
| 160 && m_animationsWithPauseToggled.isEmpty() | 197 && m_animationsWithPauseToggled.isEmpty() |
| 161 && m_animationsWithUpdates.isEmpty() | 198 && m_animationsWithUpdates.isEmpty() |
| 199 && m_animationsWithStyleUpdates.isEmpty() |
| 162 && m_newTransitions.isEmpty() | 200 && m_newTransitions.isEmpty() |
| 163 && m_cancelledTransitions.isEmpty() | 201 && m_cancelledTransitions.isEmpty() |
| 164 && m_activeInterpolationsForAnimations.isEmpty() | 202 && m_activeInterpolationsForAnimations.isEmpty() |
| 165 && m_activeInterpolationsForTransitions.isEmpty(); | 203 && m_activeInterpolationsForTransitions.isEmpty(); |
| 166 } | 204 } |
| 167 | 205 |
| 168 void trace(Visitor*); | 206 void trace(Visitor*); |
| 169 | 207 |
| 170 private: | 208 private: |
| 171 // Order is significant since it defines the order in which new animations | 209 // Order is significant since it defines the order in which new animations |
| 172 // will be started. Note that there may be multiple animations present | 210 // will be started. Note that there may be multiple animations present |
| 173 // with the same name, due to the way in which we split up animations with | 211 // with the same name, due to the way in which we split up animations with |
| 174 // incomplete keyframes. | 212 // incomplete keyframes. |
| 175 WillBeHeapVector<NewAnimation> m_newAnimations; | 213 WillBeHeapVector<NewAnimation> m_newAnimations; |
| 176 Vector<AtomicString> m_cancelledAnimationNames; | 214 Vector<AtomicString> m_cancelledAnimationNames; |
| 177 WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>> m_suppressedAni
mationPlayers; | 215 WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>> m_suppressedAni
mationPlayers; |
| 178 Vector<AtomicString> m_animationsWithPauseToggled; | 216 Vector<AtomicString> m_animationsWithPauseToggled; |
| 179 WillBeHeapVector<UpdatedAnimation> m_animationsWithUpdates; | 217 WillBeHeapVector<UpdatedAnimation> m_animationsWithUpdates; |
| 218 WillBeHeapVector<UpdatedAnimationStyle> m_animationsWithStyleUpdates; |
| 180 | 219 |
| 181 NewTransitionMap m_newTransitions; | 220 NewTransitionMap m_newTransitions; |
| 182 HashSet<CSSPropertyID> m_cancelledTransitions; | 221 HashSet<CSSPropertyID> m_cancelledTransitions; |
| 183 | 222 |
| 184 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active
InterpolationsForAnimations; | 223 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active
InterpolationsForAnimations; |
| 185 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active
InterpolationsForTransitions; | 224 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active
InterpolationsForTransitions; |
| 186 }; | 225 }; |
| 187 | 226 |
| 188 } // namespace blink | 227 } // namespace blink |
| 189 | 228 |
| 190 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation); | 229 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation); |
| 191 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimation); | 230 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimation); |
| 192 | 231 |
| 193 #endif | 232 #endif |
| OLD | NEW |