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/Allocator.h" | 16 #include "wtf/Allocator.h" |
16 #include "wtf/HashMap.h" | 17 #include "wtf/HashMap.h" |
17 #include "wtf/Vector.h" | 18 #include "wtf/Vector.h" |
18 #include "wtf/text/AtomicString.h" | 19 #include "wtf/text/AtomicString.h" |
19 | 20 |
20 namespace blink { | 21 namespace blink { |
21 | 22 |
22 class Animation; | 23 class Animation; |
23 class InertEffect; | |
24 | 24 |
25 // This class stores the CSS Animations/Transitions information we use during a
style recalc. | 25 // 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. | 26 // This includes updates to animations/transitions as well as the Interpolations
to be applied. |
27 class CSSAnimationUpdate final : public NoBaseWillBeGarbageCollectedFinalized<CS
SAnimationUpdate> { | 27 class CSSAnimationUpdate final { |
28 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(CSSAnimationUpdate); | 28 DISALLOW_ALLOCATION(); |
29 WTF_MAKE_NONCOPYABLE(CSSAnimationUpdate); | 29 WTF_MAKE_NONCOPYABLE(CSSAnimationUpdate); |
30 public: | 30 public: |
31 CSSAnimationUpdate() { } | |
32 | |
33 class NewAnimation { | 31 class NewAnimation { |
34 ALLOW_ONLY_INLINE_ALLOCATION(); | 32 ALLOW_ONLY_INLINE_ALLOCATION(); |
35 public: | 33 public: |
36 NewAnimation() | 34 NewAnimation() |
37 : styleRuleVersion(0) | 35 : styleRuleVersion(0) |
38 { | 36 { |
39 } | 37 } |
40 | 38 |
41 NewAnimation(AtomicString name, PassRefPtrWillBeRawPtr<InertEffect> effe
ct, Timing timing, PassRefPtrWillBeRawPtr<StyleRuleKeyframes> styleRule) | 39 NewAnimation(AtomicString name, PassRefPtrWillBeRawPtr<InertEffect> effe
ct, Timing timing, PassRefPtrWillBeRawPtr<StyleRuleKeyframes> styleRule) |
42 : name(name) | 40 : name(name) |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 visitor->trace(animation); | 126 visitor->trace(animation); |
129 visitor->trace(model); | 127 visitor->trace(model); |
130 visitor->trace(snapshot); | 128 visitor->trace(snapshot); |
131 } | 129 } |
132 | 130 |
133 RawPtrWillBeMember<Animation> animation; | 131 RawPtrWillBeMember<Animation> animation; |
134 RawPtrWillBeMember<KeyframeEffectModelBase> model; | 132 RawPtrWillBeMember<KeyframeEffectModelBase> model; |
135 CompositableStyleSnapshot snapshot; | 133 CompositableStyleSnapshot snapshot; |
136 }; | 134 }; |
137 | 135 |
| 136 CSSAnimationUpdate() |
| 137 { |
| 138 } |
| 139 |
| 140 ~CSSAnimationUpdate() |
| 141 { |
| 142 #if ENABLE(OILPAN) |
| 143 // For performance reasons, explicitly clear HeapVectors and |
| 144 // HeapHashMaps to avoid giving a pressure on Oilpan's GC. |
| 145 clear(); |
| 146 #endif |
| 147 } |
| 148 |
| 149 void copy(const CSSAnimationUpdate& update) |
| 150 { |
| 151 ASSERT(isEmpty()); |
| 152 m_newAnimations = update.newAnimations(); |
| 153 m_animationsWithUpdates = update.animationsWithUpdates(); |
| 154 m_animationsWithStyleUpdates = update.animationsWithStyleUpdates(); |
| 155 m_newTransitions = update.newTransitions(); |
| 156 m_activeInterpolationsForAnimations = update.activeInterpolationsForAnim
ations(); |
| 157 m_activeInterpolationsForTransitions = update.activeInterpolationsForTra
nsitions(); |
| 158 m_cancelledAnimationNames = update.cancelledAnimationNames(); |
| 159 m_animationsWithPauseToggled = update.animationsWithPauseToggled(); |
| 160 m_cancelledTransitions = update.cancelledTransitions(); |
| 161 m_finishedTransitions = update.finishedTransitions(); |
| 162 } |
| 163 |
| 164 void clear() |
| 165 { |
| 166 m_newAnimations.clear(); |
| 167 m_animationsWithUpdates.clear(); |
| 168 m_animationsWithStyleUpdates.clear(); |
| 169 m_newTransitions.clear(); |
| 170 m_activeInterpolationsForAnimations.clear(); |
| 171 m_activeInterpolationsForTransitions.clear(); |
| 172 m_cancelledAnimationNames.clear(); |
| 173 m_animationsWithPauseToggled.clear(); |
| 174 m_cancelledTransitions.clear(); |
| 175 m_finishedTransitions.clear(); |
| 176 } |
| 177 |
138 void startAnimation(const AtomicString& animationName, PassRefPtrWillBeRawPt
r<InertEffect> effect, const Timing& timing, PassRefPtrWillBeRawPtr<StyleRuleKey
frames> styleRule) | 178 void startAnimation(const AtomicString& animationName, PassRefPtrWillBeRawPt
r<InertEffect> effect, const Timing& timing, PassRefPtrWillBeRawPtr<StyleRuleKey
frames> styleRule) |
139 { | 179 { |
140 effect->setName(animationName); | 180 effect->setName(animationName); |
141 m_newAnimations.append(NewAnimation(animationName, effect, timing, style
Rule)); | 181 m_newAnimations.append(NewAnimation(animationName, effect, timing, style
Rule)); |
142 } | 182 } |
143 // Returns whether animation has been suppressed and should be filtered duri
ng style application. | 183 // Returns whether animation has been suppressed and should be filtered duri
ng style application. |
144 bool isSuppressedAnimation(const Animation* animation) const { return m_supp
ressedAnimations.contains(animation); } | 184 bool isSuppressedAnimation(const Animation* animation) const { return m_supp
ressedAnimations.contains(animation); } |
145 void cancelAnimation(const AtomicString& name, Animation& animation) | 185 void cancelAnimation(const AtomicString& name, Animation& animation) |
146 { | 186 { |
147 m_cancelledAnimationNames.append(name); | 187 m_cancelledAnimationNames.append(name); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 && m_animationsWithPauseToggled.isEmpty() | 268 && m_animationsWithPauseToggled.isEmpty() |
229 && m_animationsWithUpdates.isEmpty() | 269 && m_animationsWithUpdates.isEmpty() |
230 && m_animationsWithStyleUpdates.isEmpty() | 270 && m_animationsWithStyleUpdates.isEmpty() |
231 && m_newTransitions.isEmpty() | 271 && m_newTransitions.isEmpty() |
232 && m_cancelledTransitions.isEmpty() | 272 && m_cancelledTransitions.isEmpty() |
233 && m_finishedTransitions.isEmpty() | 273 && m_finishedTransitions.isEmpty() |
234 && m_activeInterpolationsForAnimations.isEmpty() | 274 && m_activeInterpolationsForAnimations.isEmpty() |
235 && m_activeInterpolationsForTransitions.isEmpty(); | 275 && m_activeInterpolationsForTransitions.isEmpty(); |
236 } | 276 } |
237 | 277 |
238 DECLARE_TRACE(); | 278 DEFINE_INLINE_TRACE() |
| 279 { |
| 280 #if ENABLE(OILPAN) |
| 281 visitor->trace(m_newTransitions); |
| 282 visitor->trace(m_activeInterpolationsForAnimations); |
| 283 visitor->trace(m_activeInterpolationsForTransitions); |
| 284 visitor->trace(m_newAnimations); |
| 285 visitor->trace(m_suppressedAnimations); |
| 286 visitor->trace(m_animationsWithUpdates); |
| 287 visitor->trace(m_animationsWithStyleUpdates); |
| 288 #endif |
| 289 } |
239 | 290 |
240 private: | 291 private: |
241 // Order is significant since it defines the order in which new animations | 292 // Order is significant since it defines the order in which new animations |
242 // will be started. Note that there may be multiple animations present | 293 // will be started. Note that there may be multiple animations present |
243 // with the same name, due to the way in which we split up animations with | 294 // with the same name, due to the way in which we split up animations with |
244 // incomplete keyframes. | 295 // incomplete keyframes. |
245 WillBeHeapVector<NewAnimation> m_newAnimations; | 296 WillBeHeapVector<NewAnimation> m_newAnimations; |
246 Vector<AtomicString> m_cancelledAnimationNames; | 297 Vector<AtomicString> m_cancelledAnimationNames; |
247 WillBeHeapHashSet<RawPtrWillBeMember<const Animation>> m_suppressedAnimation
s; | 298 WillBeHeapHashSet<RawPtrWillBeMember<const Animation>> m_suppressedAnimation
s; |
248 Vector<AtomicString> m_animationsWithPauseToggled; | 299 Vector<AtomicString> m_animationsWithPauseToggled; |
249 WillBeHeapVector<UpdatedAnimation> m_animationsWithUpdates; | 300 WillBeHeapVector<UpdatedAnimation> m_animationsWithUpdates; |
250 WillBeHeapVector<UpdatedAnimationStyle> m_animationsWithStyleUpdates; | 301 WillBeHeapVector<UpdatedAnimationStyle> m_animationsWithStyleUpdates; |
251 | 302 |
252 NewTransitionMap m_newTransitions; | 303 NewTransitionMap m_newTransitions; |
253 HashSet<CSSPropertyID> m_cancelledTransitions; | 304 HashSet<CSSPropertyID> m_cancelledTransitions; |
254 HashSet<CSSPropertyID> m_finishedTransitions; | 305 HashSet<CSSPropertyID> m_finishedTransitions; |
255 | 306 |
256 ActiveInterpolationMap m_activeInterpolationsForAnimations; | 307 ActiveInterpolationMap m_activeInterpolationsForAnimations; |
257 ActiveInterpolationMap m_activeInterpolationsForTransitions; | 308 ActiveInterpolationMap m_activeInterpolationsForTransitions; |
258 }; | 309 }; |
259 | 310 |
260 } // namespace blink | 311 } // namespace blink |
261 | 312 |
262 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation); | 313 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation); |
263 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimation); | 314 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimation); |
264 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimationSty
le); | 315 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::UpdatedAnimationSty
le); |
265 | 316 |
266 #endif | 317 #endif |
OLD | NEW |