Chromium Code Reviews| 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 "wtf/HashMap.h" | 10 #include "wtf/HashMap.h" |
| 10 #include "wtf/Vector.h" | 11 #include "wtf/Vector.h" |
| 11 #include "wtf/text/AtomicString.h" | 12 #include "wtf/text/AtomicString.h" |
| 12 | 13 |
| 13 namespace blink { | 14 namespace blink { |
| 14 | 15 |
| 15 class AnimationPlayer; | 16 class AnimationPlayer; |
| 16 class InertAnimation; | 17 class InertAnimation; |
| 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: |
| 22 void startAnimation(const AtomicString& animationName, PassRefPtrWillBeRawPt r<InertAnimation> animation) | 23 void startAnimation(const AtomicString& animationName, PassRefPtrWillBeRawPt r<InertAnimation> animation, const Timing& timing, PassRefPtrWillBeRawPtr<StyleR uleKeyframes> styleRule) |
| 23 { | 24 { |
| 24 animation->setName(animationName); | 25 animation->setName(animationName); |
| 25 NewAnimation newAnimation; | 26 NewAnimation newAnimation; |
| 26 newAnimation.name = animationName; | 27 newAnimation.name = animationName; |
| 27 newAnimation.animation = animation; | 28 newAnimation.animation = animation; |
| 29 newAnimation.timing = timing; | |
| 30 newAnimation.styleChangeCounter = styleRule->styleChangeCounter(); | |
| 31 newAnimation.styleRule = styleRule; | |
| 28 m_newAnimations.append(newAnimation); | 32 m_newAnimations.append(newAnimation); |
| 29 } | 33 } |
| 30 // Returns whether player has been suppressed and should be filtered during style application. | 34 // 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); } | 35 bool isSuppressedAnimation(const AnimationPlayer* player) const { return m_s uppressedAnimationPlayers.contains(player); } |
| 32 void cancelAnimation(const AtomicString& name, AnimationPlayer& player) | 36 void cancelAnimation(const AtomicString& name, AnimationPlayer& player) |
| 33 { | 37 { |
| 34 m_cancelledAnimationNames.append(name); | 38 m_cancelledAnimationNames.append(name); |
| 35 m_suppressedAnimationPlayers.add(&player); | 39 m_suppressedAnimationPlayers.add(&player); |
| 36 } | 40 } |
| 37 void toggleAnimationPaused(const AtomicString& name) | 41 void toggleAnimationPaused(const AtomicString& name) |
| 38 { | 42 { |
| 39 m_animationsWithPauseToggled.append(name); | 43 m_animationsWithPauseToggled.append(name); |
| 40 } | 44 } |
| 41 void updateAnimationTiming(AnimationPlayer* player, PassRefPtrWillBeRawPtr<I nertAnimation> animation, const Timing& timing) | 45 void updateAnimation(const AtomicString& name, AnimationPlayer* player, Pass RefPtrWillBeRawPtr<InertAnimation> animation, const Timing& specifiedTiming, |
| 46 PassRefPtrWillBeRawPtr<StyleRuleKeyframes> styleRule) | |
| 42 { | 47 { |
| 43 UpdatedAnimationTiming updatedAnimation; | 48 UpdatedAnimation updatedAnimation; |
| 49 updatedAnimation.name = name; | |
| 44 updatedAnimation.player = player; | 50 updatedAnimation.player = player; |
| 45 updatedAnimation.animation = animation; | 51 updatedAnimation.animation = animation; |
| 46 updatedAnimation.newTiming = timing; | 52 updatedAnimation.specifiedTiming = specifiedTiming; |
| 47 m_animationsWithTimingUpdates.append(updatedAnimation); | 53 updatedAnimation.styleChangeCounter = styleRule->styleChangeCounter(); |
| 54 updatedAnimation.styleRule = styleRule; | |
| 55 m_animationsWithUpdates.append(updatedAnimation); | |
| 48 m_suppressedAnimationPlayers.add(player); | 56 m_suppressedAnimationPlayers.add(player); |
| 49 } | 57 } |
| 50 | 58 |
| 51 void startTransition(CSSPropertyID id, CSSPropertyID eventId, const Animatab leValue* from, const AnimatableValue* to, PassRefPtrWillBeRawPtr<InertAnimation> animation) | 59 void startTransition(CSSPropertyID id, CSSPropertyID eventId, const Animatab leValue* from, const AnimatableValue* to, PassRefPtrWillBeRawPtr<InertAnimation> animation) |
| 52 { | 60 { |
| 53 animation->setName(getPropertyName(id)); | 61 animation->setName(getPropertyName(id)); |
| 54 NewTransition newTransition; | 62 NewTransition newTransition; |
| 55 newTransition.id = id; | 63 newTransition.id = id; |
| 56 newTransition.eventId = eventId; | 64 newTransition.eventId = eventId; |
| 57 newTransition.from = from; | 65 newTransition.from = from; |
| 58 newTransition.to = to; | 66 newTransition.to = to; |
| 59 newTransition.animation = animation; | 67 newTransition.animation = animation; |
| 60 m_newTransitions.set(id, newTransition); | 68 m_newTransitions.set(id, newTransition); |
| 61 } | 69 } |
| 62 bool isCancelledTransition(CSSPropertyID id) const { return m_cancelledTrans itions.contains(id); } | 70 bool isCancelledTransition(CSSPropertyID id) const { return m_cancelledTrans itions.contains(id); } |
| 63 void cancelTransition(CSSPropertyID id) { m_cancelledTransitions.add(id); } | 71 void cancelTransition(CSSPropertyID id) { m_cancelledTransitions.add(id); } |
| 64 | 72 |
| 65 struct NewAnimation { | 73 struct NewAnimation { |
| 66 ALLOW_ONLY_INLINE_ALLOCATION(); | 74 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 67 public: | 75 public: |
| 68 void trace(Visitor* visitor) | 76 void trace(Visitor* visitor) |
| 69 { | 77 { |
| 70 visitor->trace(animation); | 78 visitor->trace(animation); |
| 71 } | 79 } |
| 72 | 80 |
| 73 AtomicString name; | 81 AtomicString name; |
| 74 RefPtrWillBeMember<InertAnimation> animation; | 82 RefPtrWillBeMember<InertAnimation> animation; |
| 83 Timing timing; | |
| 84 RefPtrWillBeMember<StyleRuleKeyframes> styleRule; | |
| 85 unsigned styleChangeCounter; | |
|
esprehn
2015/01/29 04:23:19
zero init.
shend
2015/01/30 00:03:10
Done.
| |
| 75 }; | 86 }; |
| 76 | 87 |
| 77 struct UpdatedAnimationTiming { | 88 struct UpdatedAnimation { |
| 78 ALLOW_ONLY_INLINE_ALLOCATION(); | 89 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 79 public: | 90 public: |
| 80 void trace(Visitor* visitor) | 91 void trace(Visitor* visitor) |
| 81 { | 92 { |
| 82 visitor->trace(player); | 93 visitor->trace(player); |
| 83 visitor->trace(animation); | 94 visitor->trace(animation); |
| 95 visitor->trace(styleRule); | |
| 84 } | 96 } |
| 85 | 97 |
| 98 AtomicString name; | |
| 86 RawPtrWillBeMember<AnimationPlayer> player; | 99 RawPtrWillBeMember<AnimationPlayer> player; |
| 87 RefPtrWillBeMember<InertAnimation> animation; | 100 RefPtrWillBeMember<InertAnimation> animation; |
| 88 Timing newTiming; | 101 Timing specifiedTiming; |
| 102 RefPtrWillBeMember<StyleRuleKeyframes> styleRule; | |
| 103 unsigned styleChangeCounter; | |
|
esprehn
2015/01/29 04:23:19
zero init.
shend
2015/01/30 00:03:10
Done.
| |
| 89 }; | 104 }; |
| 90 | 105 |
| 91 const WillBeHeapVector<NewAnimation>& newAnimations() const { return m_newAn imations; } | 106 const WillBeHeapVector<NewAnimation>& newAnimations() const { return m_newAn imations; } |
| 92 const Vector<AtomicString>& cancelledAnimationNames() const { return m_cance lledAnimationNames; } | 107 const Vector<AtomicString>& cancelledAnimationNames() const { return m_cance lledAnimationNames; } |
| 93 const WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>>& suppress edAnimationAnimationPlayers() const { return m_suppressedAnimationPlayers; } | 108 const WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>>& suppress edAnimationAnimationPlayers() const { return m_suppressedAnimationPlayers; } |
| 94 const Vector<AtomicString>& animationsWithPauseToggled() const { return m_an imationsWithPauseToggled; } | 109 const Vector<AtomicString>& animationsWithPauseToggled() const { return m_an imationsWithPauseToggled; } |
| 95 const WillBeHeapVector<UpdatedAnimationTiming>& animationsWithTimingUpdates( ) const { return m_animationsWithTimingUpdates; } | 110 const WillBeHeapVector<UpdatedAnimation>& animationsWithUpdates() const { re turn m_animationsWithUpdates; } |
| 96 | 111 |
| 97 struct NewTransition { | 112 struct NewTransition { |
| 98 ALLOW_ONLY_INLINE_ALLOCATION(); | 113 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 99 public: | 114 public: |
| 100 void trace(Visitor* visitor) | 115 void trace(Visitor* visitor) |
| 101 { | 116 { |
| 102 visitor->trace(from); | 117 visitor->trace(from); |
| 103 visitor->trace(to); | 118 visitor->trace(to); |
| 104 visitor->trace(animation); | 119 visitor->trace(animation); |
| 105 } | 120 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 119 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& a ctiveInterpolationsForAnimations() const { return m_activeInterpolationsForAnima tions; } | 134 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& a ctiveInterpolationsForAnimations() const { return m_activeInterpolationsForAnima tions; } |
| 120 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& a ctiveInterpolationsForTransitions() const { return m_activeInterpolationsForTran sitions; } | 135 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& a ctiveInterpolationsForTransitions() const { return m_activeInterpolationsForTran sitions; } |
| 121 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& activeI nterpolationsForAnimations() { return m_activeInterpolationsForAnimations; } | 136 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>>& activeI nterpolationsForAnimations() { return m_activeInterpolationsForAnimations; } |
| 122 | 137 |
| 123 bool isEmpty() const | 138 bool isEmpty() const |
| 124 { | 139 { |
| 125 return m_newAnimations.isEmpty() | 140 return m_newAnimations.isEmpty() |
| 126 && m_cancelledAnimationNames.isEmpty() | 141 && m_cancelledAnimationNames.isEmpty() |
| 127 && m_suppressedAnimationPlayers.isEmpty() | 142 && m_suppressedAnimationPlayers.isEmpty() |
| 128 && m_animationsWithPauseToggled.isEmpty() | 143 && m_animationsWithPauseToggled.isEmpty() |
| 129 && m_animationsWithTimingUpdates.isEmpty() | 144 && m_animationsWithUpdates.isEmpty() |
| 130 && m_newTransitions.isEmpty() | 145 && m_newTransitions.isEmpty() |
| 131 && m_cancelledTransitions.isEmpty() | 146 && m_cancelledTransitions.isEmpty() |
| 132 && m_activeInterpolationsForAnimations.isEmpty() | 147 && m_activeInterpolationsForAnimations.isEmpty() |
| 133 && m_activeInterpolationsForTransitions.isEmpty(); | 148 && m_activeInterpolationsForTransitions.isEmpty(); |
| 134 } | 149 } |
| 135 | 150 |
| 136 void trace(Visitor*); | 151 void trace(Visitor*); |
| 137 | 152 |
| 138 private: | 153 private: |
| 139 // Order is significant since it defines the order in which new animations | 154 // Order is significant since it defines the order in which new animations |
| 140 // will be started. Note that there may be multiple animations present | 155 // 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 | 156 // with the same name, due to the way in which we split up animations with |
| 142 // incomplete keyframes. | 157 // incomplete keyframes. |
| 143 WillBeHeapVector<NewAnimation> m_newAnimations; | 158 WillBeHeapVector<NewAnimation> m_newAnimations; |
| 144 Vector<AtomicString> m_cancelledAnimationNames; | 159 Vector<AtomicString> m_cancelledAnimationNames; |
| 145 WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>> m_suppressedAni mationPlayers; | 160 WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>> m_suppressedAni mationPlayers; |
| 146 Vector<AtomicString> m_animationsWithPauseToggled; | 161 Vector<AtomicString> m_animationsWithPauseToggled; |
| 147 WillBeHeapVector<UpdatedAnimationTiming> m_animationsWithTimingUpdates; | 162 WillBeHeapVector<UpdatedAnimation> m_animationsWithUpdates; |
| 148 | 163 |
| 149 NewTransitionMap m_newTransitions; | 164 NewTransitionMap m_newTransitions; |
| 150 HashSet<CSSPropertyID> m_cancelledTransitions; | 165 HashSet<CSSPropertyID> m_cancelledTransitions; |
| 151 | 166 |
| 152 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active InterpolationsForAnimations; | 167 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active InterpolationsForAnimations; |
| 153 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active InterpolationsForTransitions; | 168 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_active InterpolationsForTransitions; |
| 154 }; | 169 }; |
| 155 | 170 |
| 156 } // namespace blink | 171 } // namespace blink |
| 157 | 172 |
| 158 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation); | 173 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation); |
| 159 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimationTim ing); | 174 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimation); |
| 160 | 175 |
| 161 #endif | 176 #endif |
| OLD | NEW |