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/AnimationStack.h" | 8 #include "core/animation/AnimationStack.h" |
| 9 #include "core/animation/InertEffect.h" | |
| 9 #include "core/animation/Interpolation.h" | 10 #include "core/animation/Interpolation.h" |
| 10 #include "core/animation/KeyframeEffectModel.h" | 11 #include "core/animation/KeyframeEffectModel.h" |
| 11 #include "core/animation/css/CSSAnimatableValueFactory.h" | 12 #include "core/animation/css/CSSAnimatableValueFactory.h" |
| 12 #include "core/animation/css/CSSPropertyEquality.h" | 13 #include "core/animation/css/CSSPropertyEquality.h" |
| 13 #include "core/css/CSSKeyframesRule.h" | 14 #include "core/css/CSSKeyframesRule.h" |
| 14 #include "core/layout/LayoutObject.h" | 15 #include "core/layout/LayoutObject.h" |
| 15 #include "wtf/HashMap.h" | 16 #include "wtf/HashMap.h" |
| 16 #include "wtf/Vector.h" | 17 #include "wtf/Vector.h" |
| 17 #include "wtf/text/AtomicString.h" | 18 #include "wtf/text/AtomicString.h" |
| 18 | 19 |
| 19 namespace blink { | 20 namespace blink { |
| 20 | 21 |
| 21 class Animation; | 22 class Animation; |
| 22 class InertEffect; | |
| 23 | 23 |
| 24 // This class stores the CSS Animations/Transitions information we use during a style recalc. | 24 // This class stores the CSS Animations/Transitions information we use during a style recalc. |
| 25 // This includes updates to animations/transitions as well as the Interpolations to be applied. | 25 // This includes updates to animations/transitions as well as the Interpolations to be applied. |
| 26 class CSSAnimationUpdate final : public NoBaseWillBeGarbageCollectedFinalized<CS SAnimationUpdate> { | 26 class CSSAnimationUpdate final { |
| 27 STACK_ALLOCATED(); | |
| 27 public: | 28 public: |
| 28 class NewAnimation { | 29 class NewAnimation { |
| 29 ALLOW_ONLY_INLINE_ALLOCATION(); | 30 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 30 public: | 31 public: |
| 31 NewAnimation() | 32 NewAnimation() |
| 32 : styleRuleVersion(0) | 33 : styleRuleVersion(0) |
| 33 { | 34 { |
| 34 } | 35 } |
| 35 | 36 |
| 36 NewAnimation(AtomicString name, PassRefPtrWillBeRawPtr<InertEffect> effe ct, Timing timing, PassRefPtrWillBeRawPtr<StyleRuleKeyframes> styleRule) | 37 NewAnimation(AtomicString name, PassRefPtrWillBeRawPtr<InertEffect> effe ct, Timing timing, PassRefPtrWillBeRawPtr<StyleRuleKeyframes> styleRule) |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 visitor->trace(animation); | 124 visitor->trace(animation); |
| 124 visitor->trace(model); | 125 visitor->trace(model); |
| 125 visitor->trace(snapshot); | 126 visitor->trace(snapshot); |
| 126 } | 127 } |
| 127 | 128 |
| 128 RawPtrWillBeMember<Animation> animation; | 129 RawPtrWillBeMember<Animation> animation; |
| 129 RawPtrWillBeMember<KeyframeEffectModelBase> model; | 130 RawPtrWillBeMember<KeyframeEffectModelBase> model; |
| 130 CompositableStyleSnapshot snapshot; | 131 CompositableStyleSnapshot snapshot; |
| 131 }; | 132 }; |
| 132 | 133 |
| 134 ~CSSAnimationUpdate() | |
| 135 { | |
| 136 #if ENABLE(OILPAN) | |
| 137 // For performance reasons, explicitly clear HeapVectors and | |
| 138 // HeapHashMaps to avoid giving a pressure on Oilpan's GC. | |
| 139 m_newAnimations.clear(); | |
| 140 m_suppressedAnimations.clear(); | |
| 141 m_animationsWithUpdates.clear(); | |
| 142 m_animationsWithStyleUpdates.clear(); | |
| 143 m_newTransitions.clear(); | |
| 144 m_activeInterpolationsForAnimations.clear(); | |
| 145 m_activeInterpolationsForTransitions.clear(); | |
| 146 #endif | |
| 147 } | |
| 148 | |
| 133 void startAnimation(const AtomicString& animationName, PassRefPtrWillBeRawPt r<InertEffect> effect, const Timing& timing, PassRefPtrWillBeRawPtr<StyleRuleKey frames> styleRule) | 149 void startAnimation(const AtomicString& animationName, PassRefPtrWillBeRawPt r<InertEffect> effect, const Timing& timing, PassRefPtrWillBeRawPtr<StyleRuleKey frames> styleRule) |
| 134 { | 150 { |
| 135 effect->setName(animationName); | 151 effect->setName(animationName); |
| 136 m_newAnimations.append(NewAnimation(animationName, effect, timing, style Rule)); | 152 m_newAnimations.append(NewAnimation(animationName, effect, timing, style Rule)); |
| 137 } | 153 } |
| 138 // Returns whether animation has been suppressed and should be filtered duri ng style application. | 154 // Returns whether animation has been suppressed and should be filtered duri ng style application. |
| 139 bool isSuppressedAnimation(const Animation* animation) const { return m_supp ressedAnimations.contains(animation); } | 155 bool isSuppressedAnimation(const Animation* animation) const { return m_supp ressedAnimations.contains(animation); } |
| 140 void cancelAnimation(const AtomicString& name, Animation& animation) | 156 void cancelAnimation(const AtomicString& name, Animation& animation) |
| 141 { | 157 { |
| 142 m_cancelledAnimationNames.append(name); | 158 m_cancelledAnimationNames.append(name); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 && m_animationsWithPauseToggled.isEmpty() | 239 && m_animationsWithPauseToggled.isEmpty() |
| 224 && m_animationsWithUpdates.isEmpty() | 240 && m_animationsWithUpdates.isEmpty() |
| 225 && m_animationsWithStyleUpdates.isEmpty() | 241 && m_animationsWithStyleUpdates.isEmpty() |
| 226 && m_newTransitions.isEmpty() | 242 && m_newTransitions.isEmpty() |
| 227 && m_cancelledTransitions.isEmpty() | 243 && m_cancelledTransitions.isEmpty() |
| 228 && m_finishedTransitions.isEmpty() | 244 && m_finishedTransitions.isEmpty() |
| 229 && m_activeInterpolationsForAnimations.isEmpty() | 245 && m_activeInterpolationsForAnimations.isEmpty() |
| 230 && m_activeInterpolationsForTransitions.isEmpty(); | 246 && m_activeInterpolationsForTransitions.isEmpty(); |
| 231 } | 247 } |
| 232 | 248 |
| 233 DECLARE_TRACE(); | |
| 234 | |
| 235 private: | 249 private: |
| 236 // Order is significant since it defines the order in which new animations | 250 // Order is significant since it defines the order in which new animations |
| 237 // will be started. Note that there may be multiple animations present | 251 // will be started. Note that there may be multiple animations present |
| 238 // with the same name, due to the way in which we split up animations with | 252 // with the same name, due to the way in which we split up animations with |
| 239 // incomplete keyframes. | 253 // incomplete keyframes. |
| 240 WillBeHeapVector<NewAnimation> m_newAnimations; | 254 WillBeHeapVector<NewAnimation> m_newAnimations; |
| 241 Vector<AtomicString> m_cancelledAnimationNames; | 255 Vector<AtomicString> m_cancelledAnimationNames; |
| 242 WillBeHeapHashSet<RawPtrWillBeMember<const Animation>> m_suppressedAnimation s; | 256 WillBeHeapHashSet<RawPtrWillBeMember<const Animation>> m_suppressedAnimation s; |
| 243 Vector<AtomicString> m_animationsWithPauseToggled; | 257 Vector<AtomicString> m_animationsWithPauseToggled; |
| 244 WillBeHeapVector<UpdatedAnimation> m_animationsWithUpdates; | 258 WillBeHeapVector<UpdatedAnimation> m_animationsWithUpdates; |
| 245 WillBeHeapVector<UpdatedAnimationStyle> m_animationsWithStyleUpdates; | 259 WillBeHeapVector<UpdatedAnimationStyle> m_animationsWithStyleUpdates; |
| 246 | 260 |
| 247 NewTransitionMap m_newTransitions; | 261 NewTransitionMap m_newTransitions; |
| 248 HashSet<CSSPropertyID> m_cancelledTransitions; | 262 HashSet<CSSPropertyID> m_cancelledTransitions; |
| 249 HashSet<CSSPropertyID> m_finishedTransitions; | 263 HashSet<CSSPropertyID> m_finishedTransitions; |
| 250 | 264 |
| 251 ActiveInterpolationMap m_activeInterpolationsForAnimations; | 265 ActiveInterpolationMap m_activeInterpolationsForAnimations; |
| 252 ActiveInterpolationMap m_activeInterpolationsForTransitions; | 266 ActiveInterpolationMap m_activeInterpolationsForTransitions; |
| 267 | |
| 268 friend class PendingAnimationUpdate; | |
| 269 }; | |
| 270 | |
| 271 class PendingAnimationUpdate final { | |
| 272 DISALLOW_ALLOCATION(); | |
|
alancutter (OOO until 2018)
2015/08/19 02:46:30
Can we make CSSAnimationUpdate DISALLOW_ALLOCATION
haraken
2015/08/19 05:46:08
That is a great suggestion :) Done.
| |
| 273 WTF_MAKE_NONCOPYABLE(PendingAnimationUpdate); | |
| 274 public: | |
| 275 PendingAnimationUpdate() | |
| 276 : m_isEmpty(true) | |
| 277 { | |
| 278 } | |
| 279 | |
| 280 void setPendingUpdate(const CSSAnimationUpdate& update) | |
| 281 { | |
| 282 ASSERT(m_isEmpty); | |
| 283 m_isEmpty = false; | |
| 284 m_newAnimations = update.newAnimations(); | |
| 285 m_animationsWithUpdates = update.animationsWithUpdates(); | |
| 286 m_animationsWithStyleUpdates = update.animationsWithStyleUpdates(); | |
| 287 m_newTransitions = update.newTransitions(); | |
| 288 m_activeInterpolationsForAnimations = update.activeInterpolationsForAnim ations(); | |
| 289 m_activeInterpolationsForTransitions = update.activeInterpolationsForTra nsitions(); | |
| 290 m_cancelledAnimationNames = update.cancelledAnimationNames(); | |
| 291 m_animationsWithPauseToggled = update.animationsWithPauseToggled(); | |
| 292 m_cancelledTransitions = update.cancelledTransitions(); | |
| 293 m_finishedTransitions = update.finishedTransitions(); | |
| 294 } | |
| 295 | |
| 296 bool isEmpty() const { return m_isEmpty; } | |
| 297 const WillBeHeapVector<CSSAnimationUpdate::NewAnimation>& newAnimations() co nst { return m_newAnimations; } | |
| 298 const Vector<AtomicString>& cancelledAnimationNames() const { return m_cance lledAnimationNames; } | |
| 299 const Vector<AtomicString>& animationsWithPauseToggled() const { return m_an imationsWithPauseToggled; } | |
| 300 const WillBeHeapVector<CSSAnimationUpdate::UpdatedAnimation>& animationsWith Updates() const { return m_animationsWithUpdates; } | |
| 301 const WillBeHeapVector<CSSAnimationUpdate::UpdatedAnimationStyle>& animation sWithStyleUpdates() const { return m_animationsWithStyleUpdates; } | |
| 302 const CSSAnimationUpdate::NewTransitionMap& newTransitions() const { return m_newTransitions; } | |
| 303 const HashSet<CSSPropertyID>& cancelledTransitions() const { return m_cancel ledTransitions; } | |
| 304 const HashSet<CSSPropertyID>& finishedTransitions() const { return m_finishe dTransitions; } | |
| 305 | |
| 306 const ActiveInterpolationMap& activeInterpolationsForAnimations() const { re turn m_activeInterpolationsForAnimations; } | |
| 307 const ActiveInterpolationMap& activeInterpolationsForTransitions() const { r eturn m_activeInterpolationsForTransitions; } | |
| 308 ActiveInterpolationMap& activeInterpolationsForAnimations() { return m_activ eInterpolationsForAnimations; } | |
| 309 | |
| 310 DEFINE_INLINE_TRACE() | |
| 311 { | |
| 312 #if ENABLE(OILPAN) | |
|
alancutter (OOO until 2018)
2015/08/19 02:46:30
Is it necessary to #if here?
haraken
2015/08/19 05:46:08
Unfortunately yes. The current oilpan cannot handl
| |
| 313 visitor->trace(m_newAnimations); | |
| 314 visitor->trace(m_animationsWithUpdates); | |
| 315 visitor->trace(m_animationsWithStyleUpdates); | |
| 316 visitor->trace(m_newTransitions); | |
| 317 visitor->trace(m_activeInterpolationsForAnimations); | |
| 318 visitor->trace(m_activeInterpolationsForTransitions); | |
| 319 #endif | |
| 320 } | |
| 321 | |
| 322 void clear() | |
| 323 { | |
| 324 m_newAnimations.clear(); | |
| 325 m_animationsWithUpdates.clear(); | |
| 326 m_animationsWithStyleUpdates.clear(); | |
| 327 m_newTransitions.clear(); | |
| 328 m_activeInterpolationsForAnimations.clear(); | |
| 329 m_activeInterpolationsForTransitions.clear(); | |
| 330 m_cancelledAnimationNames.clear(); | |
| 331 m_animationsWithPauseToggled.clear(); | |
| 332 m_cancelledTransitions.clear(); | |
| 333 m_finishedTransitions.clear(); | |
| 334 m_isEmpty = true; | |
| 335 } | |
| 336 | |
| 337 private: | |
| 338 WillBeHeapVector<CSSAnimationUpdate::NewAnimation> m_newAnimations; | |
| 339 WillBeHeapVector<CSSAnimationUpdate::UpdatedAnimation> m_animationsWithUpdat es; | |
| 340 WillBeHeapVector<CSSAnimationUpdate::UpdatedAnimationStyle> m_animationsWith StyleUpdates; | |
| 341 CSSAnimationUpdate::NewTransitionMap m_newTransitions; | |
| 342 ActiveInterpolationMap m_activeInterpolationsForAnimations; | |
| 343 ActiveInterpolationMap m_activeInterpolationsForTransitions; | |
| 344 Vector<AtomicString> m_cancelledAnimationNames; | |
| 345 Vector<AtomicString> m_animationsWithPauseToggled; | |
| 346 HashSet<CSSPropertyID> m_cancelledTransitions; | |
| 347 HashSet<CSSPropertyID> m_finishedTransitions; | |
| 348 bool m_isEmpty; | |
| 253 }; | 349 }; |
| 254 | 350 |
| 255 } // namespace blink | 351 } // namespace blink |
| 256 | 352 |
| 257 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation); | 353 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation); |
| 258 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimation); | 354 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimation); |
| 259 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimationSty le); | 355 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimationSty le); |
| 260 | 356 |
| 261 #endif | 357 #endif |
| OLD | NEW |