| 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 HashSet<const AnimationPlayer*>& cancelledAnimationAnimationPlayers()
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 HashSet<const AnimationPlayer*> m_cancelledAnimationPlayers; |
| 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 }; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 175 void trace(Visitor*); | 183 void trace(Visitor*); |
| 176 | 184 |
| 177 private: | 185 private: |
| 178 struct RunningTransition { | 186 struct RunningTransition { |
| 179 ALLOW_ONLY_INLINE_ALLOCATION(); | 187 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 180 public: | 188 public: |
| 181 void trace(Visitor* visitor) | 189 void trace(Visitor* visitor) |
| 182 { | 190 { |
| 183 visitor->trace(from); | 191 visitor->trace(from); |
| 184 visitor->trace(to); | 192 visitor->trace(to); |
| 193 visitor->trace(player); |
| 185 } | 194 } |
| 186 | 195 |
| 187 RefPtr<AnimationPlayer> player; | 196 RefPtrWillBeMember<AnimationPlayer> player; |
| 188 RawPtrWillBeMember<const AnimatableValue> from; | 197 RawPtrWillBeMember<const AnimatableValue> from; |
| 189 RawPtrWillBeMember<const AnimatableValue> to; | 198 RawPtrWillBeMember<const AnimatableValue> to; |
| 190 }; | 199 }; |
| 191 | 200 |
| 192 typedef HashMap<AtomicString, RefPtr<AnimationPlayer> > AnimationMap; | 201 typedef WillBeHeapHashMap<AtomicString, RefPtrWillBeMember<AnimationPlayer>
> AnimationMap; |
| 193 AnimationMap m_animations; | 202 AnimationMap m_animations; |
| 194 | 203 |
| 195 typedef WillBeHeapHashMap<CSSPropertyID, RunningTransition> TransitionMap; | 204 typedef WillBeHeapHashMap<CSSPropertyID, RunningTransition> TransitionMap; |
| 196 TransitionMap m_transitions; | 205 TransitionMap m_transitions; |
| 197 | 206 |
| 198 OwnPtrWillBeMember<CSSAnimationUpdate> m_pendingUpdate; | 207 OwnPtrWillBeMember<CSSAnimationUpdate> m_pendingUpdate; |
| 199 | 208 |
| 200 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > m_previ
ousActiveInterpolationsForAnimations; | 209 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > m_previ
ousActiveInterpolationsForAnimations; |
| 201 | 210 |
| 202 static void calculateAnimationUpdate(CSSAnimationUpdate*, Element*, const El
ement& parentElement, const RenderStyle&, RenderStyle* parentStyle, StyleResolve
r*); | 211 static void calculateAnimationUpdate(CSSAnimationUpdate*, Element*, const El
ement& parentElement, const RenderStyle&, RenderStyle* parentStyle, StyleResolve
r*); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 229 } | 238 } |
| 230 virtual void onEventCondition(const TimedItem*, bool isFirstSample, Time
dItem::Phase previousPhase, double previousIteration) OVERRIDE; | 239 virtual void onEventCondition(const TimedItem*, bool isFirstSample, Time
dItem::Phase previousPhase, double previousIteration) OVERRIDE; |
| 231 private: | 240 private: |
| 232 Element* m_target; | 241 Element* m_target; |
| 233 const CSSPropertyID m_property; | 242 const CSSPropertyID m_property; |
| 234 }; | 243 }; |
| 235 }; | 244 }; |
| 236 | 245 |
| 237 } // namespace WebCore | 246 } // namespace WebCore |
| 238 | 247 |
| 248 namespace WTF { |
| 249 template<> struct VectorTraits<WebCore::CSSAnimationUpdate::NewAnimation> : Vect
orTraitsBase<WebCore::CSSAnimationUpdate::NewAnimation> { |
| 250 static const bool canInitializeWithMemset = true; |
| 251 }; |
| 252 } |
| 253 |
| 239 #endif | 254 #endif |
| OLD | NEW |