| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 class Element; | 48 class Element; |
| 49 class StylePropertyShorthand; | 49 class StylePropertyShorthand; |
| 50 class StyleResolver; | 50 class StyleResolver; |
| 51 class StyleRuleKeyframes; | 51 class StyleRuleKeyframes; |
| 52 | 52 |
| 53 // This class stores the CSS Animations/Transitions information we use during a
style recalc. | 53 // This class stores the CSS Animations/Transitions information we use during a
style recalc. |
| 54 // This includes updates to animations/transitions as well as the Interpolations
to be applied. | 54 // This includes updates to animations/transitions as well as the Interpolations
to be applied. |
| 55 class CSSAnimationUpdate FINAL : public NoBaseWillBeGarbageCollectedFinalized<CS
SAnimationUpdate> { | 55 class CSSAnimationUpdate FINAL : public NoBaseWillBeGarbageCollectedFinalized<CS
SAnimationUpdate> { |
| 56 public: | 56 public: |
| 57 void startAnimation(AtomicString& animationName, PassRefPtr<InertAnimation>
animation) | 57 void startAnimation(AtomicString& animationName, PassRefPtrWillBeRawPtr<Iner
tAnimation> animation) |
| 58 { | 58 { |
| 59 NewAnimation newAnimation; | 59 NewAnimation newAnimation; |
| 60 newAnimation.name = animationName; | 60 newAnimation.name = animationName; |
| 61 newAnimation.animation = animation; | 61 newAnimation.animation = animation; |
| 62 m_newAnimations.append(newAnimation); | 62 m_newAnimations.append(newAnimation); |
| 63 } | 63 } |
| 64 // Returns whether player has been cancelled and should be filtered during s
tyle application. | 64 // Returns whether player has been cancelled and should be filtered during s
tyle application. |
| 65 bool isCancelledAnimation(const AnimationPlayer* player) const { return m_ca
ncelledAnimationPlayers.contains(player); } | 65 bool isCancelledAnimation(const AnimationPlayer* player) const { return m_ca
ncelledAnimationPlayers.contains(player); } |
| 66 void cancelAnimation(const AtomicString& name, AnimationPlayer& player) | 66 void cancelAnimation(const AtomicString& name, AnimationPlayer& player) |
| 67 { | 67 { |
| 68 m_cancelledAnimationNames.append(name); | 68 m_cancelledAnimationNames.append(name); |
| 69 m_cancelledAnimationPlayers.add(&player); | 69 m_cancelledAnimationPlayers.add(&player); |
| 70 } | 70 } |
| 71 void toggleAnimationPaused(const AtomicString& name) | 71 void toggleAnimationPaused(const AtomicString& name) |
| 72 { | 72 { |
| 73 m_animationsWithPauseToggled.append(name); | 73 m_animationsWithPauseToggled.append(name); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void startTransition(CSSPropertyID id, CSSPropertyID eventId, const Animatab
leValue* from, const AnimatableValue* to, PassRefPtr<InertAnimation> animation) | 76 void startTransition(CSSPropertyID id, CSSPropertyID eventId, const Animatab
leValue* from, const AnimatableValue* to, PassRefPtrWillBeRawPtr<InertAnimation>
animation) |
| 77 { | 77 { |
| 78 NewTransition newTransition; | 78 NewTransition newTransition; |
| 79 newTransition.id = id; | 79 newTransition.id = id; |
| 80 newTransition.eventId = eventId; | 80 newTransition.eventId = eventId; |
| 81 newTransition.from = from; | 81 newTransition.from = from; |
| 82 newTransition.to = to; | 82 newTransition.to = to; |
| 83 newTransition.animation = animation; | 83 newTransition.animation = animation; |
| 84 m_newTransitions.set(id, newTransition); | 84 m_newTransitions.set(id, newTransition); |
| 85 } | 85 } |
| 86 bool isCancelledTransition(CSSPropertyID id) const { return m_cancelledTrans
itions.contains(id); } | 86 bool isCancelledTransition(CSSPropertyID id) const { return m_cancelledTrans
itions.contains(id); } |
| 87 void cancelTransition(CSSPropertyID id) { m_cancelledTransitions.add(id); } | 87 void cancelTransition(CSSPropertyID id) { m_cancelledTransitions.add(id); } |
| 88 | 88 |
| 89 struct NewAnimation { | 89 struct NewAnimation { |
| 90 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 91 public: |
| 92 void trace(Visitor* visitor) |
| 93 { |
| 94 visitor->trace(animation); |
| 95 } |
| 96 |
| 90 AtomicString name; | 97 AtomicString name; |
| 91 RefPtr<InertAnimation> animation; | 98 RefPtrWillBeMember<InertAnimation> animation; |
| 92 }; | 99 }; |
| 93 const Vector<NewAnimation>& newAnimations() const { return m_newAnimations;
} | 100 const WillBeHeapVector<NewAnimation>& newAnimations() const { return m_newAn
imations; } |
| 94 const Vector<AtomicString>& cancelledAnimationNames() const { return m_cance
lledAnimationNames; } | 101 const Vector<AtomicString>& cancelledAnimationNames() const { return m_cance
lledAnimationNames; } |
| 95 const HashSet<const AnimationPlayer*>& cancelledAnimationAnimationPlayers()
const { return m_cancelledAnimationPlayers; } | 102 const WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer> >& cancell
edAnimationAnimationPlayers() const { return m_cancelledAnimationPlayers; } |
| 96 const Vector<AtomicString>& animationsWithPauseToggled() const { return m_an
imationsWithPauseToggled; } | 103 const Vector<AtomicString>& animationsWithPauseToggled() const { return m_an
imationsWithPauseToggled; } |
| 97 | 104 |
| 98 struct NewTransition { | 105 struct NewTransition { |
| 99 ALLOW_ONLY_INLINE_ALLOCATION(); | 106 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 100 public: | 107 public: |
| 101 void trace(Visitor* visitor) | 108 void trace(Visitor* visitor) |
| 102 { | 109 { |
| 103 visitor->trace(from); | 110 visitor->trace(from); |
| 104 visitor->trace(to); | 111 visitor->trace(to); |
| 112 visitor->trace(animation); |
| 105 } | 113 } |
| 106 | 114 |
| 107 CSSPropertyID id; | 115 CSSPropertyID id; |
| 108 CSSPropertyID eventId; | 116 CSSPropertyID eventId; |
| 109 RawPtrWillBeMember<const AnimatableValue> from; | 117 RawPtrWillBeMember<const AnimatableValue> from; |
| 110 RawPtrWillBeMember<const AnimatableValue> to; | 118 RawPtrWillBeMember<const AnimatableValue> to; |
| 111 RefPtr<InertAnimation> animation; | 119 RefPtrWillBeMember<InertAnimation> animation; |
| 112 }; | 120 }; |
| 113 typedef WillBeHeapHashMap<CSSPropertyID, NewTransition> NewTransitionMap; | 121 typedef WillBeHeapHashMap<CSSPropertyID, NewTransition> NewTransitionMap; |
| 114 const NewTransitionMap& newTransitions() const { return m_newTransitions; } | 122 const NewTransitionMap& newTransitions() const { return m_newTransitions; } |
| 115 const HashSet<CSSPropertyID>& cancelledTransitions() const { return m_cancel
ledTransitions; } | 123 const HashSet<CSSPropertyID>& cancelledTransitions() const { return m_cancel
ledTransitions; } |
| 116 | 124 |
| 117 void adoptActiveInterpolationsForAnimations(WillBeHeapHashMap<CSSPropertyID,
RefPtrWillBeMember<Interpolation> >& newMap) { newMap.swap(m_activeInterpolatio
nsForAnimations); } | 125 void adoptActiveInterpolationsForAnimations(WillBeHeapHashMap<CSSPropertyID,
RefPtrWillBeMember<Interpolation> >& newMap) { newMap.swap(m_activeInterpolatio
nsForAnimations); } |
| 118 void adoptActiveInterpolationsForTransitions(WillBeHeapHashMap<CSSPropertyID
, RefPtrWillBeMember<Interpolation> >& newMap) { newMap.swap(m_activeInterpolati
onsForTransitions); } | 126 void adoptActiveInterpolationsForTransitions(WillBeHeapHashMap<CSSPropertyID
, RefPtrWillBeMember<Interpolation> >& newMap) { newMap.swap(m_activeInterpolati
onsForTransitions); } |
| 119 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >&
activeInterpolationsForAnimations() const { return m_activeInterpolationsForAnim
ations; } | 127 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >&
activeInterpolationsForAnimations() const { return m_activeInterpolationsForAnim
ations; } |
| 120 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >&
activeInterpolationsForTransitions() const { return m_activeInterpolationsForTra
nsitions; } | 128 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >&
activeInterpolationsForTransitions() const { return m_activeInterpolationsForTra
nsitions; } |
| 121 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& active
InterpolationsForAnimations() { return m_activeInterpolationsForAnimations; } | 129 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& active
InterpolationsForAnimations() { return m_activeInterpolationsForAnimations; } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 132 && m_activeInterpolationsForTransitions.isEmpty(); | 140 && m_activeInterpolationsForTransitions.isEmpty(); |
| 133 } | 141 } |
| 134 | 142 |
| 135 void trace(Visitor*); | 143 void trace(Visitor*); |
| 136 | 144 |
| 137 private: | 145 private: |
| 138 // Order is significant since it defines the order in which new animations | 146 // Order is significant since it defines the order in which new animations |
| 139 // will be started. Note that there may be multiple animations present | 147 // will be started. Note that there may be multiple animations present |
| 140 // with the same name, due to the way in which we split up animations with | 148 // with the same name, due to the way in which we split up animations with |
| 141 // incomplete keyframes. | 149 // incomplete keyframes. |
| 142 Vector<NewAnimation> m_newAnimations; | 150 WillBeHeapVector<NewAnimation> m_newAnimations; |
| 143 Vector<AtomicString> m_cancelledAnimationNames; | 151 Vector<AtomicString> m_cancelledAnimationNames; |
| 144 HashSet<const AnimationPlayer*> m_cancelledAnimationPlayers; | 152 WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer> > m_cancelledAni
mationPlayers; |
| 145 Vector<AtomicString> m_animationsWithPauseToggled; | 153 Vector<AtomicString> m_animationsWithPauseToggled; |
| 146 | 154 |
| 147 NewTransitionMap m_newTransitions; | 155 NewTransitionMap m_newTransitions; |
| 148 HashSet<CSSPropertyID> m_cancelledTransitions; | 156 HashSet<CSSPropertyID> m_cancelledTransitions; |
| 149 | 157 |
| 150 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > m_activ
eInterpolationsForAnimations; | 158 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > m_activ
eInterpolationsForAnimations; |
| 151 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > m_activ
eInterpolationsForTransitions; | 159 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > m_activ
eInterpolationsForTransitions; |
| 152 }; | 160 }; |
| 153 | 161 |
| 154 class CSSAnimations FINAL : public NoBaseWillBeGarbageCollectedFinalized<CSSAnim
ations> { | 162 class CSSAnimations FINAL : public NoBaseWillBeGarbageCollectedFinalized<CSSAnim
ations> { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 176 void trace(Visitor*); | 184 void trace(Visitor*); |
| 177 | 185 |
| 178 private: | 186 private: |
| 179 struct RunningTransition { | 187 struct RunningTransition { |
| 180 ALLOW_ONLY_INLINE_ALLOCATION(); | 188 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 181 public: | 189 public: |
| 182 void trace(Visitor* visitor) | 190 void trace(Visitor* visitor) |
| 183 { | 191 { |
| 184 visitor->trace(from); | 192 visitor->trace(from); |
| 185 visitor->trace(to); | 193 visitor->trace(to); |
| 194 visitor->trace(player); |
| 186 } | 195 } |
| 187 | 196 |
| 188 RefPtr<AnimationPlayer> player; | 197 RefPtrWillBeMember<AnimationPlayer> player; |
| 189 RawPtrWillBeMember<const AnimatableValue> from; | 198 RawPtrWillBeMember<const AnimatableValue> from; |
| 190 RawPtrWillBeMember<const AnimatableValue> to; | 199 RawPtrWillBeMember<const AnimatableValue> to; |
| 191 }; | 200 }; |
| 192 | 201 |
| 193 typedef HashMap<AtomicString, RefPtr<AnimationPlayer> > AnimationMap; | 202 typedef WillBeHeapHashMap<AtomicString, RefPtrWillBeMember<AnimationPlayer>
> AnimationMap; |
| 194 AnimationMap m_animations; | 203 AnimationMap m_animations; |
| 195 | 204 |
| 196 typedef WillBeHeapHashMap<CSSPropertyID, RunningTransition> TransitionMap; | 205 typedef WillBeHeapHashMap<CSSPropertyID, RunningTransition> TransitionMap; |
| 197 TransitionMap m_transitions; | 206 TransitionMap m_transitions; |
| 198 | 207 |
| 199 OwnPtrWillBeMember<CSSAnimationUpdate> m_pendingUpdate; | 208 OwnPtrWillBeMember<CSSAnimationUpdate> m_pendingUpdate; |
| 200 | 209 |
| 201 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > m_previ
ousActiveInterpolationsForAnimations; | 210 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > m_previ
ousActiveInterpolationsForAnimations; |
| 202 | 211 |
| 203 static void calculateAnimationUpdate(CSSAnimationUpdate*, Element*, const El
ement& parentElement, const RenderStyle&, RenderStyle* parentStyle, StyleResolve
r*); | 212 static void calculateAnimationUpdate(CSSAnimationUpdate*, Element*, const El
ement& parentElement, const RenderStyle&, RenderStyle* parentStyle, StyleResolve
r*); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 virtual void onEventCondition(const TimedItem*) OVERRIDE; | 245 virtual void onEventCondition(const TimedItem*) OVERRIDE; |
| 237 private: | 246 private: |
| 238 Element* m_target; | 247 Element* m_target; |
| 239 const CSSPropertyID m_property; | 248 const CSSPropertyID m_property; |
| 240 TimedItem::Phase m_previousPhase; | 249 TimedItem::Phase m_previousPhase; |
| 241 }; | 250 }; |
| 242 }; | 251 }; |
| 243 | 252 |
| 244 } // namespace WebCore | 253 } // namespace WebCore |
| 245 | 254 |
| 255 namespace WTF { |
| 256 template<> struct VectorTraits<WebCore::CSSAnimationUpdate::NewAnimation> : Vect
orTraitsBase<WebCore::CSSAnimationUpdate::NewAnimation> { |
| 257 static const bool canInitializeWithMemset = true; |
| 258 }; |
| 259 } |
| 260 |
| 246 #endif | 261 #endif |
| OLD | NEW |