| 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/AnimationStack.h" | 8 #include "core/animation/AnimationStack.h" |
| 9 #include "core/animation/InertEffect.h" | 9 #include "core/animation/InertEffect.h" |
| 10 #include "core/animation/Interpolation.h" | 10 #include "core/animation/Interpolation.h" |
| 11 #include "core/animation/KeyframeEffectModel.h" | 11 #include "core/animation/KeyframeEffectModel.h" |
| 12 #include "core/animation/css/CSSAnimatableValueFactory.h" | 12 #include "core/animation/css/CSSAnimatableValueFactory.h" |
| 13 #include "core/css/CSSKeyframesRule.h" | 13 #include "core/css/CSSKeyframesRule.h" |
| 14 #include "core/css/CSSPropertyEquality.h" | 14 #include "core/css/CSSPropertyEquality.h" |
| 15 #include "core/layout/LayoutObject.h" | 15 #include "core/layout/LayoutObject.h" |
| 16 #include "wtf/Allocator.h" | 16 #include "wtf/Allocator.h" |
| 17 #include "wtf/HashMap.h" | 17 #include "wtf/HashMap.h" |
| 18 #include "wtf/Vector.h" | 18 #include "wtf/Vector.h" |
| 19 #include "wtf/text/AtomicString.h" | 19 #include "wtf/text/AtomicString.h" |
| 20 | 20 |
| 21 namespace blink { | 21 namespace blink { |
| 22 | 22 |
| 23 class Animation; | 23 class Animation; |
| 24 | 24 |
| 25 class NewCSSAnimation { |
| 26 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 27 public: |
| 28 NewCSSAnimation(AtomicString name, size_t nameIndex, const InertEffect& effe
ct, Timing timing, StyleRuleKeyframes* styleRule) |
| 29 : name(name) |
| 30 , nameIndex(nameIndex) |
| 31 , effect(effect) |
| 32 , timing(timing) |
| 33 , styleRule(styleRule) |
| 34 , styleRuleVersion(this->styleRule->version()) |
| 35 { |
| 36 } |
| 37 |
| 38 DEFINE_INLINE_TRACE() |
| 39 { |
| 40 visitor->trace(effect); |
| 41 visitor->trace(styleRule); |
| 42 } |
| 43 |
| 44 AtomicString name; |
| 45 size_t nameIndex; |
| 46 Member<const InertEffect> effect; |
| 47 Timing timing; |
| 48 Member<StyleRuleKeyframes> styleRule; |
| 49 unsigned styleRuleVersion; |
| 50 }; |
| 51 |
| 52 class UpdatedCSSAnimation { |
| 53 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 54 public: |
| 55 UpdatedCSSAnimation(size_t index, Animation* animation, const InertEffect& e
ffect, Timing specifiedTiming, StyleRuleKeyframes* styleRule) |
| 56 : index(index) |
| 57 , animation(animation) |
| 58 , effect(&effect) |
| 59 , specifiedTiming(specifiedTiming) |
| 60 , styleRule(styleRule) |
| 61 , styleRuleVersion(this->styleRule->version()) |
| 62 { |
| 63 } |
| 64 |
| 65 DEFINE_INLINE_TRACE() |
| 66 { |
| 67 visitor->trace(animation); |
| 68 visitor->trace(effect); |
| 69 visitor->trace(styleRule); |
| 70 } |
| 71 |
| 72 size_t index; |
| 73 Member<Animation> animation; |
| 74 Member<const InertEffect> effect; |
| 75 Timing specifiedTiming; |
| 76 Member<StyleRuleKeyframes> styleRule; |
| 77 unsigned styleRuleVersion; |
| 78 }; |
| 79 |
| 80 } // namespace blink |
| 81 |
| 82 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::NewCSSAnimation); |
| 83 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::UpdatedCSSAnimation); |
| 84 |
| 85 namespace blink { |
| 86 |
| 25 // This class stores the CSS Animations/Transitions information we use during a
style recalc. | 87 // This class stores the CSS Animations/Transitions information we use during a
style recalc. |
| 26 // This includes updates to animations/transitions as well as the Interpolations
to be applied. | 88 // This includes updates to animations/transitions as well as the Interpolations
to be applied. |
| 27 class CSSAnimationUpdate final { | 89 class CSSAnimationUpdate final { |
| 28 DISALLOW_NEW(); | 90 DISALLOW_NEW(); |
| 29 WTF_MAKE_NONCOPYABLE(CSSAnimationUpdate); | 91 WTF_MAKE_NONCOPYABLE(CSSAnimationUpdate); |
| 30 public: | 92 public: |
| 31 class NewAnimation { | |
| 32 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | |
| 33 public: | |
| 34 NewAnimation(AtomicString name, size_t nameIndex, const InertEffect& eff
ect, Timing timing, StyleRuleKeyframes* styleRule) | |
| 35 : name(name) | |
| 36 , nameIndex(nameIndex) | |
| 37 , effect(effect) | |
| 38 , timing(timing) | |
| 39 , styleRule(styleRule) | |
| 40 , styleRuleVersion(this->styleRule->version()) | |
| 41 { | |
| 42 } | |
| 43 | |
| 44 DEFINE_INLINE_TRACE() | |
| 45 { | |
| 46 visitor->trace(effect); | |
| 47 visitor->trace(styleRule); | |
| 48 } | |
| 49 | |
| 50 AtomicString name; | |
| 51 size_t nameIndex; | |
| 52 Member<const InertEffect> effect; | |
| 53 Timing timing; | |
| 54 Member<StyleRuleKeyframes> styleRule; | |
| 55 unsigned styleRuleVersion; | |
| 56 }; | |
| 57 | |
| 58 class UpdatedAnimation { | |
| 59 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | |
| 60 public: | |
| 61 UpdatedAnimation(size_t index, Animation* animation, const InertEffect&
effect, Timing specifiedTiming, StyleRuleKeyframes* styleRule) | |
| 62 : index(index) | |
| 63 , animation(animation) | |
| 64 , effect(&effect) | |
| 65 , specifiedTiming(specifiedTiming) | |
| 66 , styleRule(styleRule) | |
| 67 , styleRuleVersion(this->styleRule->version()) | |
| 68 { | |
| 69 } | |
| 70 | |
| 71 DEFINE_INLINE_TRACE() | |
| 72 { | |
| 73 visitor->trace(animation); | |
| 74 visitor->trace(effect); | |
| 75 visitor->trace(styleRule); | |
| 76 } | |
| 77 | |
| 78 size_t index; | |
| 79 Member<Animation> animation; | |
| 80 Member<const InertEffect> effect; | |
| 81 Timing specifiedTiming; | |
| 82 Member<StyleRuleKeyframes> styleRule; | |
| 83 unsigned styleRuleVersion; | |
| 84 }; | |
| 85 | |
| 86 CSSAnimationUpdate() | 93 CSSAnimationUpdate() |
| 87 { | 94 { |
| 88 } | 95 } |
| 89 | 96 |
| 90 ~CSSAnimationUpdate() | 97 ~CSSAnimationUpdate() |
| 91 { | 98 { |
| 92 } | 99 } |
| 93 | 100 |
| 94 void copy(const CSSAnimationUpdate& update) | 101 void copy(const CSSAnimationUpdate& update) |
| 95 { | 102 { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 115 m_activeInterpolationsForTransitions.clear(); | 122 m_activeInterpolationsForTransitions.clear(); |
| 116 m_cancelledAnimationIndices.clear(); | 123 m_cancelledAnimationIndices.clear(); |
| 117 m_animationIndicesWithPauseToggled.clear(); | 124 m_animationIndicesWithPauseToggled.clear(); |
| 118 m_cancelledTransitions.clear(); | 125 m_cancelledTransitions.clear(); |
| 119 m_finishedTransitions.clear(); | 126 m_finishedTransitions.clear(); |
| 120 m_updatedCompositorKeyframes.clear(); | 127 m_updatedCompositorKeyframes.clear(); |
| 121 } | 128 } |
| 122 | 129 |
| 123 void startAnimation(const AtomicString& animationName, size_t nameIndex, con
st InertEffect& effect, const Timing& timing, StyleRuleKeyframes* styleRule) | 130 void startAnimation(const AtomicString& animationName, size_t nameIndex, con
st InertEffect& effect, const Timing& timing, StyleRuleKeyframes* styleRule) |
| 124 { | 131 { |
| 125 m_newAnimations.append(NewAnimation(animationName, nameIndex, effect, ti
ming, styleRule)); | 132 m_newAnimations.append(NewCSSAnimation(animationName, nameIndex, effect,
timing, styleRule)); |
| 126 } | 133 } |
| 127 // Returns whether animation has been suppressed and should be filtered duri
ng style application. | 134 // Returns whether animation has been suppressed and should be filtered duri
ng style application. |
| 128 bool isSuppressedAnimation(const Animation* animation) const { return m_supp
ressedAnimations.contains(animation); } | 135 bool isSuppressedAnimation(const Animation* animation) const { return m_supp
ressedAnimations.contains(animation); } |
| 129 void cancelAnimation(size_t index, const Animation& animation) | 136 void cancelAnimation(size_t index, const Animation& animation) |
| 130 { | 137 { |
| 131 m_cancelledAnimationIndices.append(index); | 138 m_cancelledAnimationIndices.append(index); |
| 132 m_suppressedAnimations.add(&animation); | 139 m_suppressedAnimations.add(&animation); |
| 133 } | 140 } |
| 134 void toggleAnimationIndexPaused(size_t index) | 141 void toggleAnimationIndexPaused(size_t index) |
| 135 { | 142 { |
| 136 m_animationIndicesWithPauseToggled.append(index); | 143 m_animationIndicesWithPauseToggled.append(index); |
| 137 } | 144 } |
| 138 void updateAnimation(size_t index, Animation* animation, const InertEffect&
effect, const Timing& specifiedTiming, | 145 void updateAnimation(size_t index, Animation* animation, const InertEffect&
effect, const Timing& specifiedTiming, |
| 139 StyleRuleKeyframes* styleRule) | 146 StyleRuleKeyframes* styleRule) |
| 140 { | 147 { |
| 141 m_animationsWithUpdates.append(UpdatedAnimation(index, animation, effect
, specifiedTiming, styleRule)); | 148 m_animationsWithUpdates.append(UpdatedCSSAnimation(index, animation, eff
ect, specifiedTiming, styleRule)); |
| 142 m_suppressedAnimations.add(animation); | 149 m_suppressedAnimations.add(animation); |
| 143 } | 150 } |
| 144 void updateCompositorKeyframes(Animation* animation) | 151 void updateCompositorKeyframes(Animation* animation) |
| 145 { | 152 { |
| 146 m_updatedCompositorKeyframes.append(animation); | 153 m_updatedCompositorKeyframes.append(animation); |
| 147 } | 154 } |
| 148 | 155 |
| 149 void startTransition(CSSPropertyID id, const AnimatableValue* from, const An
imatableValue* to, PassRefPtr<AnimatableValue> reversingAdjustedStartValue, doub
le reversingShorteningFactor, const InertEffect& effect) | 156 void startTransition(CSSPropertyID id, const AnimatableValue* from, const An
imatableValue* to, PassRefPtr<AnimatableValue> reversingAdjustedStartValue, doub
le reversingShorteningFactor, const InertEffect& effect) |
| 150 { | 157 { |
| 151 NewTransition newTransition; | 158 NewTransition newTransition; |
| 152 newTransition.id = id; | 159 newTransition.id = id; |
| 153 newTransition.from = from; | 160 newTransition.from = from; |
| 154 newTransition.to = to; | 161 newTransition.to = to; |
| 155 newTransition.reversingAdjustedStartValue = reversingAdjustedStartValue; | 162 newTransition.reversingAdjustedStartValue = reversingAdjustedStartValue; |
| 156 newTransition.reversingShorteningFactor = reversingShorteningFactor; | 163 newTransition.reversingShorteningFactor = reversingShorteningFactor; |
| 157 newTransition.effect = &effect; | 164 newTransition.effect = &effect; |
| 158 m_newTransitions.set(id, newTransition); | 165 m_newTransitions.set(id, newTransition); |
| 159 } | 166 } |
| 160 bool isCancelledTransition(CSSPropertyID id) const { return m_cancelledTrans
itions.contains(id); } | 167 bool isCancelledTransition(CSSPropertyID id) const { return m_cancelledTrans
itions.contains(id); } |
| 161 void cancelTransition(CSSPropertyID id) { m_cancelledTransitions.add(id); } | 168 void cancelTransition(CSSPropertyID id) { m_cancelledTransitions.add(id); } |
| 162 void finishTransition(CSSPropertyID id) { m_finishedTransitions.add(id); } | 169 void finishTransition(CSSPropertyID id) { m_finishedTransitions.add(id); } |
| 163 | 170 |
| 164 const HeapVector<NewAnimation>& newAnimations() const { return m_newAnimatio
ns; } | 171 const HeapVector<NewCSSAnimation>& newAnimations() const { return m_newAnima
tions; } |
| 165 const Vector<size_t>& cancelledAnimationIndices() const { return m_cancelled
AnimationIndices; } | 172 const Vector<size_t>& cancelledAnimationIndices() const { return m_cancelled
AnimationIndices; } |
| 166 const HeapHashSet<Member<const Animation>>& suppressedAnimations() const { r
eturn m_suppressedAnimations; } | 173 const HeapHashSet<Member<const Animation>>& suppressedAnimations() const { r
eturn m_suppressedAnimations; } |
| 167 const Vector<size_t>& animationIndicesWithPauseToggled() const { return m_an
imationIndicesWithPauseToggled; } | 174 const Vector<size_t>& animationIndicesWithPauseToggled() const { return m_an
imationIndicesWithPauseToggled; } |
| 168 const HeapVector<UpdatedAnimation>& animationsWithUpdates() const { return m
_animationsWithUpdates; } | 175 const HeapVector<UpdatedCSSAnimation>& animationsWithUpdates() const { retur
n m_animationsWithUpdates; } |
| 169 const HeapVector<Member<Animation>>& updatedCompositorKeyframes() const { re
turn m_updatedCompositorKeyframes; } | 176 const HeapVector<Member<Animation>>& updatedCompositorKeyframes() const { re
turn m_updatedCompositorKeyframes; } |
| 170 | 177 |
| 171 struct NewTransition { | 178 struct NewTransition { |
| 172 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 179 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 173 public: | 180 public: |
| 174 DEFINE_INLINE_TRACE() | 181 DEFINE_INLINE_TRACE() |
| 175 { | 182 { |
| 176 visitor->trace(effect); | 183 visitor->trace(effect); |
| 177 } | 184 } |
| 178 | 185 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 visitor->trace(m_suppressedAnimations); | 223 visitor->trace(m_suppressedAnimations); |
| 217 visitor->trace(m_animationsWithUpdates); | 224 visitor->trace(m_animationsWithUpdates); |
| 218 visitor->trace(m_updatedCompositorKeyframes); | 225 visitor->trace(m_updatedCompositorKeyframes); |
| 219 } | 226 } |
| 220 | 227 |
| 221 private: | 228 private: |
| 222 // Order is significant since it defines the order in which new animations | 229 // Order is significant since it defines the order in which new animations |
| 223 // will be started. Note that there may be multiple animations present | 230 // will be started. Note that there may be multiple animations present |
| 224 // with the same name, due to the way in which we split up animations with | 231 // with the same name, due to the way in which we split up animations with |
| 225 // incomplete keyframes. | 232 // incomplete keyframes. |
| 226 HeapVector<NewAnimation> m_newAnimations; | 233 HeapVector<NewCSSAnimation> m_newAnimations; |
| 227 Vector<size_t> m_cancelledAnimationIndices; | 234 Vector<size_t> m_cancelledAnimationIndices; |
| 228 HeapHashSet<Member<const Animation>> m_suppressedAnimations; | 235 HeapHashSet<Member<const Animation>> m_suppressedAnimations; |
| 229 Vector<size_t> m_animationIndicesWithPauseToggled; | 236 Vector<size_t> m_animationIndicesWithPauseToggled; |
| 230 HeapVector<UpdatedAnimation> m_animationsWithUpdates; | 237 HeapVector<UpdatedCSSAnimation> m_animationsWithUpdates; |
| 231 HeapVector<Member<Animation>> m_updatedCompositorKeyframes; | 238 HeapVector<Member<Animation>> m_updatedCompositorKeyframes; |
| 232 | 239 |
| 233 NewTransitionMap m_newTransitions; | 240 NewTransitionMap m_newTransitions; |
| 234 HashSet<CSSPropertyID> m_cancelledTransitions; | 241 HashSet<CSSPropertyID> m_cancelledTransitions; |
| 235 HashSet<CSSPropertyID> m_finishedTransitions; | 242 HashSet<CSSPropertyID> m_finishedTransitions; |
| 236 | 243 |
| 237 ActiveInterpolationsMap m_activeInterpolationsForAnimations; | 244 ActiveInterpolationsMap m_activeInterpolationsForAnimations; |
| 238 ActiveInterpolationsMap m_activeInterpolationsForTransitions; | 245 ActiveInterpolationsMap m_activeInterpolationsForTransitions; |
| 239 | 246 |
| 240 friend class PendingAnimationUpdate; | 247 friend class PendingAnimationUpdate; |
| 241 }; | 248 }; |
| 242 | 249 |
| 243 } // namespace blink | 250 } // namespace blink |
| 244 | 251 |
| 245 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation); | |
| 246 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimation); | |
| 247 | |
| 248 #endif | 252 #endif |
| OLD | NEW |