| OLD | NEW |
| 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 Loading... |
| 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& timing, unsigned styleChangeCounter) |
| 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.timing = timing; |
| 65 newAnimation.styleChangeCounter = styleChangeCounter; |
| 64 m_newAnimations.append(newAnimation); | 66 m_newAnimations.append(newAnimation); |
| 65 } | 67 } |
| 66 // Returns whether player has been suppressed and should be filtered during
style application. | 68 // 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); } | 69 bool isSuppressedAnimation(const AnimationPlayer* player) const { return m_s
uppressedAnimationPlayers.contains(player); } |
| 68 void cancelAnimation(const AtomicString& name, AnimationPlayer& player) | 70 void cancelAnimation(const AtomicString& name, AnimationPlayer& player) |
| 69 { | 71 { |
| 70 m_cancelledAnimationNames.append(name); | 72 m_cancelledAnimationNames.append(name); |
| 71 m_suppressedAnimationPlayers.add(&player); | 73 m_suppressedAnimationPlayers.add(&player); |
| 72 } | 74 } |
| 73 void toggleAnimationPaused(const AtomicString& name) | 75 void toggleAnimationPaused(const AtomicString& name) |
| 74 { | 76 { |
| 75 m_animationsWithPauseToggled.append(name); | 77 m_animationsWithPauseToggled.append(name); |
| 76 } | 78 } |
| 77 void updateAnimationTiming(AnimationPlayer* player, PassRefPtrWillBeRawPtr<I
nertAnimation> animation, const Timing& timing) | 79 void updateAnimation(const AtomicString& name, AnimationPlayer* player, Pass
RefPtrWillBeRawPtr<InertAnimation> animation, const Timing& newTiming, unsigned
styleChangeCounter) |
| 78 { | 80 { |
| 79 UpdatedAnimationTiming updatedAnimation; | 81 UpdatedAnimation updatedAnimation; |
| 82 updatedAnimation.name = name; |
| 80 updatedAnimation.player = player; | 83 updatedAnimation.player = player; |
| 81 updatedAnimation.animation = animation; | 84 updatedAnimation.animation = animation; |
| 82 updatedAnimation.newTiming = timing; | 85 updatedAnimation.newTiming = newTiming; |
| 83 m_animationsWithTimingUpdates.append(updatedAnimation); | 86 updatedAnimation.styleChangeCounter = styleChangeCounter; |
| 87 m_animationsWithUpdates.append(updatedAnimation); |
| 84 m_suppressedAnimationPlayers.add(player); | 88 m_suppressedAnimationPlayers.add(player); |
| 85 } | 89 } |
| 86 | 90 |
| 87 void startTransition(CSSPropertyID id, CSSPropertyID eventId, const Animatab
leValue* from, const AnimatableValue* to, PassRefPtrWillBeRawPtr<InertAnimation>
animation) | 91 void startTransition(CSSPropertyID id, CSSPropertyID eventId, const Animatab
leValue* from, const AnimatableValue* to, PassRefPtrWillBeRawPtr<InertAnimation>
animation) |
| 88 { | 92 { |
| 89 animation->setName(getPropertyName(id)); | 93 animation->setName(getPropertyName(id)); |
| 90 NewTransition newTransition; | 94 NewTransition newTransition; |
| 91 newTransition.id = id; | 95 newTransition.id = id; |
| 92 newTransition.eventId = eventId; | 96 newTransition.eventId = eventId; |
| 93 newTransition.from = from; | 97 newTransition.from = from; |
| 94 newTransition.to = to; | 98 newTransition.to = to; |
| 95 newTransition.animation = animation; | 99 newTransition.animation = animation; |
| 96 m_newTransitions.set(id, newTransition); | 100 m_newTransitions.set(id, newTransition); |
| 97 } | 101 } |
| 98 bool isCancelledTransition(CSSPropertyID id) const { return m_cancelledTrans
itions.contains(id); } | 102 bool isCancelledTransition(CSSPropertyID id) const { return m_cancelledTrans
itions.contains(id); } |
| 99 void cancelTransition(CSSPropertyID id) { m_cancelledTransitions.add(id); } | 103 void cancelTransition(CSSPropertyID id) { m_cancelledTransitions.add(id); } |
| 100 | 104 |
| 101 struct NewAnimation { | 105 struct NewAnimation { |
| 102 ALLOW_ONLY_INLINE_ALLOCATION(); | 106 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 103 public: | 107 public: |
| 104 void trace(Visitor* visitor) | 108 void trace(Visitor* visitor) |
| 105 { | 109 { |
| 106 visitor->trace(animation); | 110 visitor->trace(animation); |
| 107 } | 111 } |
| 108 | 112 |
| 109 AtomicString name; | 113 AtomicString name; |
| 110 RefPtrWillBeMember<InertAnimation> animation; | 114 RefPtrWillBeMember<InertAnimation> animation; |
| 115 Timing timing; |
| 116 unsigned styleChangeCounter; |
| 111 }; | 117 }; |
| 112 | 118 |
| 113 struct UpdatedAnimationTiming { | 119 struct UpdatedAnimation { |
| 114 ALLOW_ONLY_INLINE_ALLOCATION(); | 120 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 115 public: | 121 public: |
| 116 void trace(Visitor* visitor) | 122 void trace(Visitor* visitor) |
| 117 { | 123 { |
| 118 visitor->trace(player); | 124 visitor->trace(player); |
| 119 visitor->trace(animation); | 125 visitor->trace(animation); |
| 120 } | 126 } |
| 121 | 127 |
| 128 AtomicString name; |
| 122 RawPtrWillBeMember<AnimationPlayer> player; | 129 RawPtrWillBeMember<AnimationPlayer> player; |
| 123 RefPtrWillBeMember<InertAnimation> animation; | 130 RefPtrWillBeMember<InertAnimation> animation; |
| 124 Timing newTiming; | 131 Timing newTiming; |
| 132 unsigned styleChangeCounter; |
| 125 }; | 133 }; |
| 126 | 134 |
| 127 const WillBeHeapVector<NewAnimation>& newAnimations() const { return m_newAn
imations; } | 135 const WillBeHeapVector<NewAnimation>& newAnimations() const { return m_newAn
imations; } |
| 128 const Vector<AtomicString>& cancelledAnimationNames() const { return m_cance
lledAnimationNames; } | 136 const Vector<AtomicString>& cancelledAnimationNames() const { return m_cance
lledAnimationNames; } |
| 129 const WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>>& suppress
edAnimationAnimationPlayers() const { return m_suppressedAnimationPlayers; } | 137 const WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>>& suppress
edAnimationAnimationPlayers() const { return m_suppressedAnimationPlayers; } |
| 130 const Vector<AtomicString>& animationsWithPauseToggled() const { return m_an
imationsWithPauseToggled; } | 138 const Vector<AtomicString>& animationsWithPauseToggled() const { return m_an
imationsWithPauseToggled; } |
| 131 const WillBeHeapVector<UpdatedAnimationTiming>& animationsWithTimingUpdates(
) const { return m_animationsWithTimingUpdates; } | 139 const WillBeHeapVector<UpdatedAnimation>& animationsWithUpdates() const { re
turn m_animationsWithUpdates; } |
| 132 | 140 |
| 133 struct NewTransition { | 141 struct NewTransition { |
| 134 ALLOW_ONLY_INLINE_ALLOCATION(); | 142 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 135 public: | 143 public: |
| 136 void trace(Visitor* visitor) | 144 void trace(Visitor* visitor) |
| 137 { | 145 { |
| 138 visitor->trace(from); | 146 visitor->trace(from); |
| 139 visitor->trace(to); | 147 visitor->trace(to); |
| 140 visitor->trace(animation); | 148 visitor->trace(animation); |
| 141 } | 149 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 155 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& a
ctiveInterpolationsForAnimations() const { return m_activeInterpolationsForAnima
tions; } | 163 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; } | 164 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& a
ctiveInterpolationsForTransitions() const { return m_activeInterpolationsForTran
sitions; } |
| 157 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& activeI
nterpolationsForAnimations() { return m_activeInterpolationsForAnimations; } | 165 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& activeI
nterpolationsForAnimations() { return m_activeInterpolationsForAnimations; } |
| 158 | 166 |
| 159 bool isEmpty() const | 167 bool isEmpty() const |
| 160 { | 168 { |
| 161 return m_newAnimations.isEmpty() | 169 return m_newAnimations.isEmpty() |
| 162 && m_cancelledAnimationNames.isEmpty() | 170 && m_cancelledAnimationNames.isEmpty() |
| 163 && m_suppressedAnimationPlayers.isEmpty() | 171 && m_suppressedAnimationPlayers.isEmpty() |
| 164 && m_animationsWithPauseToggled.isEmpty() | 172 && m_animationsWithPauseToggled.isEmpty() |
| 165 && m_animationsWithTimingUpdates.isEmpty() | 173 && m_animationsWithUpdates.isEmpty() |
| 166 && m_newTransitions.isEmpty() | 174 && m_newTransitions.isEmpty() |
| 167 && m_cancelledTransitions.isEmpty() | 175 && m_cancelledTransitions.isEmpty() |
| 168 && m_activeInterpolationsForAnimations.isEmpty() | 176 && m_activeInterpolationsForAnimations.isEmpty() |
| 169 && m_activeInterpolationsForTransitions.isEmpty(); | 177 && m_activeInterpolationsForTransitions.isEmpty(); |
| 170 } | 178 } |
| 171 | 179 |
| 172 void trace(Visitor*); | 180 void trace(Visitor*); |
| 173 | 181 |
| 174 private: | 182 private: |
| 175 // Order is significant since it defines the order in which new animations | 183 // Order is significant since it defines the order in which new animations |
| 176 // will be started. Note that there may be multiple animations present | 184 // 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 | 185 // with the same name, due to the way in which we split up animations with |
| 178 // incomplete keyframes. | 186 // incomplete keyframes. |
| 179 WillBeHeapVector<NewAnimation> m_newAnimations; | 187 WillBeHeapVector<NewAnimation> m_newAnimations; |
| 180 Vector<AtomicString> m_cancelledAnimationNames; | 188 Vector<AtomicString> m_cancelledAnimationNames; |
| 181 WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>> m_suppressedAni
mationPlayers; | 189 WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>> m_suppressedAni
mationPlayers; |
| 182 Vector<AtomicString> m_animationsWithPauseToggled; | 190 Vector<AtomicString> m_animationsWithPauseToggled; |
| 183 WillBeHeapVector<UpdatedAnimationTiming> m_animationsWithTimingUpdates; | 191 WillBeHeapVector<UpdatedAnimation> m_animationsWithUpdates; |
| 184 | 192 |
| 185 NewTransitionMap m_newTransitions; | 193 NewTransitionMap m_newTransitions; |
| 186 HashSet<CSSPropertyID> m_cancelledTransitions; | 194 HashSet<CSSPropertyID> m_cancelledTransitions; |
| 187 | 195 |
| 188 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active
InterpolationsForAnimations; | 196 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active
InterpolationsForAnimations; |
| 189 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active
InterpolationsForTransitions; | 197 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active
InterpolationsForTransitions; |
| 190 }; | 198 }; |
| 191 | 199 |
| 192 class CSSAnimations final { | 200 class CSSAnimations final { |
| 193 WTF_MAKE_NONCOPYABLE(CSSAnimations); | 201 WTF_MAKE_NONCOPYABLE(CSSAnimations); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 208 static PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> calculateUpdate(const Elem
ent* animatingElement, Element&, const RenderStyle&, RenderStyle* parentStyle, S
tyleResolver*); | 216 static PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> calculateUpdate(const Elem
ent* animatingElement, Element&, const RenderStyle&, RenderStyle* parentStyle, S
tyleResolver*); |
| 209 | 217 |
| 210 void setPendingUpdate(PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> update) { m
_pendingUpdate = update; } | 218 void setPendingUpdate(PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> update) { m
_pendingUpdate = update; } |
| 211 void maybeApplyPendingUpdate(Element*); | 219 void maybeApplyPendingUpdate(Element*); |
| 212 bool isEmpty() const { return m_animations.isEmpty() && m_transitions.isEmpt
y() && !m_pendingUpdate; } | 220 bool isEmpty() const { return m_animations.isEmpty() && m_transitions.isEmpt
y() && !m_pendingUpdate; } |
| 213 void cancel(); | 221 void cancel(); |
| 214 | 222 |
| 215 void trace(Visitor*); | 223 void trace(Visitor*); |
| 216 | 224 |
| 217 private: | 225 private: |
| 226 struct RunningAnimation { |
| 227 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 228 public: |
| 229 void trace(Visitor* visitor) |
| 230 { |
| 231 visitor->trace(player); |
| 232 } |
| 233 |
| 234 RefPtrWillBeMember<AnimationPlayer> player; |
| 235 Timing specifiedTiming; |
| 236 unsigned styleChangeCounter; |
| 237 }; |
| 238 |
| 218 struct RunningTransition { | 239 struct RunningTransition { |
| 219 ALLOW_ONLY_INLINE_ALLOCATION(); | 240 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 220 public: | 241 public: |
| 221 void trace(Visitor* visitor) | 242 void trace(Visitor* visitor) |
| 222 { | 243 { |
| 223 visitor->trace(player); | 244 visitor->trace(player); |
| 224 visitor->trace(from); | 245 visitor->trace(from); |
| 225 visitor->trace(to); | 246 visitor->trace(to); |
| 226 } | 247 } |
| 227 | 248 |
| 228 RefPtrWillBeMember<AnimationPlayer> player; | 249 RefPtrWillBeMember<AnimationPlayer> player; |
| 229 RawPtrWillBeMember<const AnimatableValue> from; | 250 RawPtrWillBeMember<const AnimatableValue> from; |
| 230 RawPtrWillBeMember<const AnimatableValue> to; | 251 RawPtrWillBeMember<const AnimatableValue> to; |
| 231 }; | 252 }; |
| 232 | 253 |
| 233 using AnimationMap = WillBeHeapHashMap<AtomicString, RefPtrWillBeMember<Anim
ationPlayer>>; | 254 using AnimationMap = WillBeHeapHashMap<AtomicString, RunningAnimation>; |
| 234 AnimationMap m_animations; | 255 AnimationMap m_animations; |
| 235 | 256 |
| 236 using TransitionMap = WillBeHeapHashMap<CSSPropertyID, RunningTransition>; | 257 using TransitionMap = WillBeHeapHashMap<CSSPropertyID, RunningTransition>; |
| 237 TransitionMap m_transitions; | 258 TransitionMap m_transitions; |
| 238 | 259 |
| 239 OwnPtrWillBeMember<CSSAnimationUpdate> m_pendingUpdate; | 260 OwnPtrWillBeMember<CSSAnimationUpdate> m_pendingUpdate; |
| 240 | 261 |
| 241 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_previo
usActiveInterpolationsForAnimations; | 262 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_previo
usActiveInterpolationsForAnimations; |
| 242 | 263 |
| 243 static void calculateAnimationUpdate(CSSAnimationUpdate*, const Element* ani
matingElement, Element&, const RenderStyle&, RenderStyle* parentStyle, StyleReso
lver*); | 264 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 Loading... |
| 283 private: | 304 private: |
| 284 RawPtrWillBeMember<Element> m_target; | 305 RawPtrWillBeMember<Element> m_target; |
| 285 const CSSPropertyID m_property; | 306 const CSSPropertyID m_property; |
| 286 AnimationNode::Phase m_previousPhase; | 307 AnimationNode::Phase m_previousPhase; |
| 287 }; | 308 }; |
| 288 }; | 309 }; |
| 289 | 310 |
| 290 } // namespace blink | 311 } // namespace blink |
| 291 | 312 |
| 292 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation); | 313 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation); |
| 293 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimationTim
ing); | 314 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimation); |
| 294 | 315 |
| 295 #endif | 316 #endif |
| OLD | NEW |