| 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" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 WTF_MAKE_NONCOPYABLE(CSSAnimationUpdate); | 29 WTF_MAKE_NONCOPYABLE(CSSAnimationUpdate); |
| 30 public: | 30 public: |
| 31 class NewAnimation { | 31 class NewAnimation { |
| 32 ALLOW_ONLY_INLINE_ALLOCATION(); | 32 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 33 public: | 33 public: |
| 34 NewAnimation() | 34 NewAnimation() |
| 35 : styleRuleVersion(0) | 35 : styleRuleVersion(0) |
| 36 { | 36 { |
| 37 } | 37 } |
| 38 | 38 |
| 39 NewAnimation(AtomicString name, InertEffect* effect, Timing timing, Pass
RefPtrWillBeRawPtr<StyleRuleKeyframes> styleRule) | 39 NewAnimation(AtomicString name, size_t nameIndex, InertEffect* effect, T
iming timing, PassRefPtrWillBeRawPtr<StyleRuleKeyframes> styleRule) |
| 40 : name(name) | 40 : name(name) |
| 41 , nameIndex(nameIndex) |
| 41 , effect(effect) | 42 , effect(effect) |
| 42 , timing(timing) | 43 , timing(timing) |
| 43 , styleRule(styleRule) | 44 , styleRule(styleRule) |
| 44 , styleRuleVersion(this->styleRule->version()) | 45 , styleRuleVersion(this->styleRule->version()) |
| 45 { | 46 { |
| 46 } | 47 } |
| 47 | 48 |
| 48 DEFINE_INLINE_TRACE() | 49 DEFINE_INLINE_TRACE() |
| 49 { | 50 { |
| 50 visitor->trace(effect); | 51 visitor->trace(effect); |
| 51 visitor->trace(styleRule); | 52 visitor->trace(styleRule); |
| 52 } | 53 } |
| 53 | 54 |
| 54 AtomicString name; | 55 AtomicString name; |
| 56 size_t nameIndex; |
| 55 Member<InertEffect> effect; | 57 Member<InertEffect> effect; |
| 56 Timing timing; | 58 Timing timing; |
| 57 RefPtrWillBeMember<StyleRuleKeyframes> styleRule; | 59 RefPtrWillBeMember<StyleRuleKeyframes> styleRule; |
| 58 unsigned styleRuleVersion; | 60 unsigned styleRuleVersion; |
| 59 }; | 61 }; |
| 60 | 62 |
| 61 class UpdatedAnimation { | 63 class UpdatedAnimation { |
| 62 ALLOW_ONLY_INLINE_ALLOCATION(); | 64 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 63 public: | 65 public: |
| 64 UpdatedAnimation() | 66 UpdatedAnimation() |
| 65 : styleRuleVersion(0) | 67 : styleRuleVersion(0) |
| 66 { | 68 { |
| 67 } | 69 } |
| 68 | 70 |
| 69 UpdatedAnimation(AtomicString name, Animation* animation, InertEffect* e
ffect, Timing specifiedTiming, PassRefPtrWillBeRawPtr<StyleRuleKeyframes> styleR
ule) | 71 UpdatedAnimation(size_t index, Animation* animation, InertEffect* effect
, Timing specifiedTiming, PassRefPtrWillBeRawPtr<StyleRuleKeyframes> styleRule) |
| 70 : name(name) | 72 : index(index) |
| 71 , animation(animation) | 73 , animation(animation) |
| 72 , effect(effect) | 74 , effect(effect) |
| 73 , specifiedTiming(specifiedTiming) | 75 , specifiedTiming(specifiedTiming) |
| 74 , styleRule(styleRule) | 76 , styleRule(styleRule) |
| 75 , styleRuleVersion(this->styleRule->version()) | 77 , styleRuleVersion(this->styleRule->version()) |
| 76 { | 78 { |
| 77 } | 79 } |
| 78 | 80 |
| 79 DEFINE_INLINE_TRACE() | 81 DEFINE_INLINE_TRACE() |
| 80 { | 82 { |
| 81 visitor->trace(animation); | 83 visitor->trace(animation); |
| 82 visitor->trace(effect); | 84 visitor->trace(effect); |
| 83 visitor->trace(styleRule); | 85 visitor->trace(styleRule); |
| 84 } | 86 } |
| 85 | 87 |
| 86 AtomicString name; | 88 size_t index; |
| 87 Member<Animation> animation; | 89 Member<Animation> animation; |
| 88 Member<InertEffect> effect; | 90 Member<InertEffect> effect; |
| 89 Timing specifiedTiming; | 91 Timing specifiedTiming; |
| 90 RefPtrWillBeMember<StyleRuleKeyframes> styleRule; | 92 RefPtrWillBeMember<StyleRuleKeyframes> styleRule; |
| 91 unsigned styleRuleVersion; | 93 unsigned styleRuleVersion; |
| 92 }; | 94 }; |
| 93 | 95 |
| 94 CSSAnimationUpdate() | 96 CSSAnimationUpdate() |
| 95 { | 97 { |
| 96 } | 98 } |
| 97 | 99 |
| 98 ~CSSAnimationUpdate() | 100 ~CSSAnimationUpdate() |
| 99 { | 101 { |
| 100 // For performance reasons, explicitly clear HeapVectors and | 102 // For performance reasons, explicitly clear HeapVectors and |
| 101 // HeapHashMaps to avoid giving a pressure on Oilpan's GC. | 103 // HeapHashMaps to avoid giving a pressure on Oilpan's GC. |
| 102 clear(); | 104 clear(); |
| 103 } | 105 } |
| 104 | 106 |
| 105 void copy(const CSSAnimationUpdate& update) | 107 void copy(const CSSAnimationUpdate& update) |
| 106 { | 108 { |
| 107 ASSERT(isEmpty()); | 109 ASSERT(isEmpty()); |
| 108 m_newAnimations = update.newAnimations(); | 110 m_newAnimations = update.newAnimations(); |
| 109 m_animationsWithUpdates = update.animationsWithUpdates(); | 111 m_animationsWithUpdates = update.animationsWithUpdates(); |
| 110 m_newTransitions = update.newTransitions(); | 112 m_newTransitions = update.newTransitions(); |
| 111 m_activeInterpolationsForAnimations = update.activeInterpolationsForAnim
ations(); | 113 m_activeInterpolationsForAnimations = update.activeInterpolationsForAnim
ations(); |
| 112 m_activeInterpolationsForTransitions = update.activeInterpolationsForTra
nsitions(); | 114 m_activeInterpolationsForTransitions = update.activeInterpolationsForTra
nsitions(); |
| 113 m_cancelledAnimationNames = update.cancelledAnimationNames(); | 115 m_cancelledAnimationIndices = update.cancelledAnimationIndices(); |
| 114 m_animationsWithPauseToggled = update.animationsWithPauseToggled(); | 116 m_animationIndicesWithPauseToggled = update.animationIndicesWithPauseTog
gled(); |
| 115 m_cancelledTransitions = update.cancelledTransitions(); | 117 m_cancelledTransitions = update.cancelledTransitions(); |
| 116 m_finishedTransitions = update.finishedTransitions(); | 118 m_finishedTransitions = update.finishedTransitions(); |
| 117 m_updatedCompositorKeyframes = update.updatedCompositorKeyframes(); | 119 m_updatedCompositorKeyframes = update.updatedCompositorKeyframes(); |
| 118 } | 120 } |
| 119 | 121 |
| 120 void clear() | 122 void clear() |
| 121 { | 123 { |
| 122 m_newAnimations.clear(); | 124 m_newAnimations.clear(); |
| 123 m_animationsWithUpdates.clear(); | 125 m_animationsWithUpdates.clear(); |
| 124 m_newTransitions.clear(); | 126 m_newTransitions.clear(); |
| 125 m_activeInterpolationsForAnimations.clear(); | 127 m_activeInterpolationsForAnimations.clear(); |
| 126 m_activeInterpolationsForTransitions.clear(); | 128 m_activeInterpolationsForTransitions.clear(); |
| 127 m_cancelledAnimationNames.clear(); | 129 m_cancelledAnimationIndices.clear(); |
| 128 m_animationsWithPauseToggled.clear(); | 130 m_animationIndicesWithPauseToggled.clear(); |
| 129 m_cancelledTransitions.clear(); | 131 m_cancelledTransitions.clear(); |
| 130 m_finishedTransitions.clear(); | 132 m_finishedTransitions.clear(); |
| 131 m_updatedCompositorKeyframes.clear(); | 133 m_updatedCompositorKeyframes.clear(); |
| 132 } | 134 } |
| 133 | 135 |
| 134 void startAnimation(const AtomicString& animationName, InertEffect* effect,
const Timing& timing, PassRefPtrWillBeRawPtr<StyleRuleKeyframes> styleRule) | 136 void startAnimation(const AtomicString& animationName, size_t nameIndex, Ine
rtEffect* effect, const Timing& timing, PassRefPtrWillBeRawPtr<StyleRuleKeyframe
s> styleRule) |
| 135 { | 137 { |
| 136 effect->setName(animationName); | 138 effect->setName(animationName); |
| 137 m_newAnimations.append(NewAnimation(animationName, effect, timing, style
Rule)); | 139 m_newAnimations.append(NewAnimation(animationName, nameIndex, effect, ti
ming, styleRule)); |
| 138 } | 140 } |
| 139 // Returns whether animation has been suppressed and should be filtered duri
ng style application. | 141 // Returns whether animation has been suppressed and should be filtered duri
ng style application. |
| 140 bool isSuppressedAnimation(const Animation* animation) const { return m_supp
ressedAnimations.contains(animation); } | 142 bool isSuppressedAnimation(const Animation* animation) const { return m_supp
ressedAnimations.contains(animation); } |
| 141 void cancelAnimation(const AtomicString& name, Animation& animation) | 143 void cancelAnimation(size_t index, const Animation& animation) |
| 142 { | 144 { |
| 143 m_cancelledAnimationNames.append(name); | 145 m_cancelledAnimationIndices.append(index); |
| 144 m_suppressedAnimations.add(&animation); | 146 m_suppressedAnimations.add(&animation); |
| 145 } | 147 } |
| 146 void toggleAnimationPaused(const AtomicString& name) | 148 void toggleAnimationIndexPaused(size_t index) |
| 147 { | 149 { |
| 148 m_animationsWithPauseToggled.append(name); | 150 m_animationIndicesWithPauseToggled.append(index); |
| 149 } | 151 } |
| 150 void updateAnimation(const AtomicString& name, Animation* animation, InertEf
fect* effect, const Timing& specifiedTiming, | 152 void updateAnimation(size_t index, Animation* animation, InertEffect* effect
, const Timing& specifiedTiming, |
| 151 PassRefPtrWillBeRawPtr<StyleRuleKeyframes> styleRule) | 153 PassRefPtrWillBeRawPtr<StyleRuleKeyframes> styleRule) |
| 152 { | 154 { |
| 153 m_animationsWithUpdates.append(UpdatedAnimation(name, animation, effect,
specifiedTiming, styleRule)); | 155 m_animationsWithUpdates.append(UpdatedAnimation(index, animation, effect
, specifiedTiming, styleRule)); |
| 154 m_suppressedAnimations.add(animation); | 156 m_suppressedAnimations.add(animation); |
| 155 } | 157 } |
| 156 void updateCompositorKeyframes(Animation* animation) | 158 void updateCompositorKeyframes(Animation* animation) |
| 157 { | 159 { |
| 158 m_updatedCompositorKeyframes.append(animation); | 160 m_updatedCompositorKeyframes.append(animation); |
| 159 } | 161 } |
| 160 | 162 |
| 161 void startTransition(CSSPropertyID id, const AnimatableValue* from, const An
imatableValue* to, InertEffect* effect) | 163 void startTransition(CSSPropertyID id, const AnimatableValue* from, const An
imatableValue* to, InertEffect* effect) |
| 162 { | 164 { |
| 163 effect->setName(getPropertyName(id)); | 165 effect->setName(getPropertyName(id)); |
| 164 NewTransition newTransition; | 166 NewTransition newTransition; |
| 165 newTransition.id = id; | 167 newTransition.id = id; |
| 166 newTransition.from = from; | 168 newTransition.from = from; |
| 167 newTransition.to = to; | 169 newTransition.to = to; |
| 168 newTransition.effect = effect; | 170 newTransition.effect = effect; |
| 169 m_newTransitions.set(id, newTransition); | 171 m_newTransitions.set(id, newTransition); |
| 170 } | 172 } |
| 171 bool isCancelledTransition(CSSPropertyID id) const { return m_cancelledTrans
itions.contains(id); } | 173 bool isCancelledTransition(CSSPropertyID id) const { return m_cancelledTrans
itions.contains(id); } |
| 172 void cancelTransition(CSSPropertyID id) { m_cancelledTransitions.add(id); } | 174 void cancelTransition(CSSPropertyID id) { m_cancelledTransitions.add(id); } |
| 173 void finishTransition(CSSPropertyID id) { m_finishedTransitions.add(id); } | 175 void finishTransition(CSSPropertyID id) { m_finishedTransitions.add(id); } |
| 174 | 176 |
| 175 const HeapVector<NewAnimation>& newAnimations() const { return m_newAnimatio
ns; } | 177 const HeapVector<NewAnimation>& newAnimations() const { return m_newAnimatio
ns; } |
| 176 const Vector<AtomicString>& cancelledAnimationNames() const { return m_cance
lledAnimationNames; } | 178 const Vector<size_t>& cancelledAnimationIndices() const { return m_cancelled
AnimationIndices; } |
| 177 const HeapHashSet<Member<const Animation>>& suppressedAnimations() const { r
eturn m_suppressedAnimations; } | 179 const HeapHashSet<Member<const Animation>>& suppressedAnimations() const { r
eturn m_suppressedAnimations; } |
| 178 const Vector<AtomicString>& animationsWithPauseToggled() const { return m_an
imationsWithPauseToggled; } | 180 const Vector<size_t>& animationIndicesWithPauseToggled() const { return m_an
imationIndicesWithPauseToggled; } |
| 179 const HeapVector<UpdatedAnimation>& animationsWithUpdates() const { return m
_animationsWithUpdates; } | 181 const HeapVector<UpdatedAnimation>& animationsWithUpdates() const { return m
_animationsWithUpdates; } |
| 180 const HeapVector<Member<Animation>>& updatedCompositorKeyframes() const { re
turn m_updatedCompositorKeyframes; } | 182 const HeapVector<Member<Animation>>& updatedCompositorKeyframes() const { re
turn m_updatedCompositorKeyframes; } |
| 181 | 183 |
| 182 struct NewTransition { | 184 struct NewTransition { |
| 183 ALLOW_ONLY_INLINE_ALLOCATION(); | 185 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 184 public: | 186 public: |
| 185 DEFINE_INLINE_TRACE() | 187 DEFINE_INLINE_TRACE() |
| 186 { | 188 { |
| 187 visitor->trace(effect); | 189 visitor->trace(effect); |
| 188 } | 190 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 199 | 201 |
| 200 void adoptActiveInterpolationsForAnimations(ActiveInterpolationsMap& newMap)
{ newMap.swap(m_activeInterpolationsForAnimations); } | 202 void adoptActiveInterpolationsForAnimations(ActiveInterpolationsMap& newMap)
{ newMap.swap(m_activeInterpolationsForAnimations); } |
| 201 void adoptActiveInterpolationsForTransitions(ActiveInterpolationsMap& newMap
) { newMap.swap(m_activeInterpolationsForTransitions); } | 203 void adoptActiveInterpolationsForTransitions(ActiveInterpolationsMap& newMap
) { newMap.swap(m_activeInterpolationsForTransitions); } |
| 202 const ActiveInterpolationsMap& activeInterpolationsForAnimations() const { r
eturn m_activeInterpolationsForAnimations; } | 204 const ActiveInterpolationsMap& activeInterpolationsForAnimations() const { r
eturn m_activeInterpolationsForAnimations; } |
| 203 const ActiveInterpolationsMap& activeInterpolationsForTransitions() const {
return m_activeInterpolationsForTransitions; } | 205 const ActiveInterpolationsMap& activeInterpolationsForTransitions() const {
return m_activeInterpolationsForTransitions; } |
| 204 ActiveInterpolationsMap& activeInterpolationsForAnimations() { return m_acti
veInterpolationsForAnimations; } | 206 ActiveInterpolationsMap& activeInterpolationsForAnimations() { return m_acti
veInterpolationsForAnimations; } |
| 205 | 207 |
| 206 bool isEmpty() const | 208 bool isEmpty() const |
| 207 { | 209 { |
| 208 return m_newAnimations.isEmpty() | 210 return m_newAnimations.isEmpty() |
| 209 && m_cancelledAnimationNames.isEmpty() | 211 && m_cancelledAnimationIndices.isEmpty() |
| 210 && m_suppressedAnimations.isEmpty() | 212 && m_suppressedAnimations.isEmpty() |
| 211 && m_animationsWithPauseToggled.isEmpty() | 213 && m_animationIndicesWithPauseToggled.isEmpty() |
| 212 && m_animationsWithUpdates.isEmpty() | 214 && m_animationsWithUpdates.isEmpty() |
| 213 && m_newTransitions.isEmpty() | 215 && m_newTransitions.isEmpty() |
| 214 && m_cancelledTransitions.isEmpty() | 216 && m_cancelledTransitions.isEmpty() |
| 215 && m_finishedTransitions.isEmpty() | 217 && m_finishedTransitions.isEmpty() |
| 216 && m_activeInterpolationsForAnimations.isEmpty() | 218 && m_activeInterpolationsForAnimations.isEmpty() |
| 217 && m_activeInterpolationsForTransitions.isEmpty() | 219 && m_activeInterpolationsForTransitions.isEmpty() |
| 218 && m_updatedCompositorKeyframes.isEmpty(); | 220 && m_updatedCompositorKeyframes.isEmpty(); |
| 219 } | 221 } |
| 220 | 222 |
| 221 DEFINE_INLINE_TRACE() | 223 DEFINE_INLINE_TRACE() |
| 222 { | 224 { |
| 223 visitor->trace(m_newTransitions); | 225 visitor->trace(m_newTransitions); |
| 224 visitor->trace(m_newAnimations); | 226 visitor->trace(m_newAnimations); |
| 225 visitor->trace(m_suppressedAnimations); | 227 visitor->trace(m_suppressedAnimations); |
| 226 visitor->trace(m_animationsWithUpdates); | 228 visitor->trace(m_animationsWithUpdates); |
| 227 visitor->trace(m_updatedCompositorKeyframes); | 229 visitor->trace(m_updatedCompositorKeyframes); |
| 228 } | 230 } |
| 229 | 231 |
| 230 private: | 232 private: |
| 231 // Order is significant since it defines the order in which new animations | 233 // Order is significant since it defines the order in which new animations |
| 232 // will be started. Note that there may be multiple animations present | 234 // will be started. Note that there may be multiple animations present |
| 233 // with the same name, due to the way in which we split up animations with | 235 // with the same name, due to the way in which we split up animations with |
| 234 // incomplete keyframes. | 236 // incomplete keyframes. |
| 235 HeapVector<NewAnimation> m_newAnimations; | 237 HeapVector<NewAnimation> m_newAnimations; |
| 236 Vector<AtomicString> m_cancelledAnimationNames; | 238 Vector<size_t> m_cancelledAnimationIndices; |
| 237 HeapHashSet<Member<const Animation>> m_suppressedAnimations; | 239 HeapHashSet<Member<const Animation>> m_suppressedAnimations; |
| 238 Vector<AtomicString> m_animationsWithPauseToggled; | 240 Vector<size_t> m_animationIndicesWithPauseToggled; |
| 239 HeapVector<UpdatedAnimation> m_animationsWithUpdates; | 241 HeapVector<UpdatedAnimation> m_animationsWithUpdates; |
| 240 HeapVector<Member<Animation>> m_updatedCompositorKeyframes; | 242 HeapVector<Member<Animation>> m_updatedCompositorKeyframes; |
| 241 | 243 |
| 242 NewTransitionMap m_newTransitions; | 244 NewTransitionMap m_newTransitions; |
| 243 HashSet<CSSPropertyID> m_cancelledTransitions; | 245 HashSet<CSSPropertyID> m_cancelledTransitions; |
| 244 HashSet<CSSPropertyID> m_finishedTransitions; | 246 HashSet<CSSPropertyID> m_finishedTransitions; |
| 245 | 247 |
| 246 ActiveInterpolationsMap m_activeInterpolationsForAnimations; | 248 ActiveInterpolationsMap m_activeInterpolationsForAnimations; |
| 247 ActiveInterpolationsMap m_activeInterpolationsForTransitions; | 249 ActiveInterpolationsMap m_activeInterpolationsForTransitions; |
| 248 | 250 |
| 249 friend class PendingAnimationUpdate; | 251 friend class PendingAnimationUpdate; |
| 250 }; | 252 }; |
| 251 | 253 |
| 252 } // namespace blink | 254 } // namespace blink |
| 253 | 255 |
| 254 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation); | 256 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation); |
| 255 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimation); | 257 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimation); |
| 256 | 258 |
| 257 #endif | 259 #endif |
| OLD | NEW |