Chromium Code Reviews| 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 15 matching lines...) Expand all Loading... | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef CSSAnimations_h | 31 #ifndef CSSAnimations_h |
| 32 #define CSSAnimations_h | 32 #define CSSAnimations_h |
| 33 | 33 |
| 34 #include "core/animation/Animation.h" | 34 #include "core/animation/Animation.h" |
| 35 #include "core/animation/InertAnimation.h" | 35 #include "core/animation/InertAnimation.h" |
| 36 #include "core/animation/Interpolation.h" | |
| 36 #include "core/animation/Player.h" | 37 #include "core/animation/Player.h" |
| 37 #include "core/animation/css/CSSAnimationData.h" | 38 #include "core/animation/css/CSSAnimationData.h" |
| 38 #include "core/css/StylePropertySet.h" | 39 #include "core/css/StylePropertySet.h" |
| 39 #include "core/dom/Document.h" | 40 #include "core/dom/Document.h" |
| 40 #include "core/rendering/style/RenderStyleConstants.h" | 41 #include "core/rendering/style/RenderStyleConstants.h" |
| 41 #include "wtf/HashMap.h" | 42 #include "wtf/HashMap.h" |
| 42 #include "wtf/Vector.h" | 43 #include "wtf/Vector.h" |
| 43 #include "wtf/text/AtomicString.h" | 44 #include "wtf/text/AtomicString.h" |
| 44 | 45 |
| 45 namespace WebCore { | 46 namespace WebCore { |
| 46 | 47 |
| 47 class Element; | 48 class Element; |
| 48 class StylePropertyShorthand; | 49 class StylePropertyShorthand; |
| 49 class StyleResolver; | 50 class StyleResolver; |
| 50 class StyleRuleKeyframes; | 51 class StyleRuleKeyframes; |
| 51 | 52 |
| 52 // 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. |
| 53 // This includes updates to animations/transitions as well as the CompositableVa lueMaps to be applied. | 54 // This includes updates to animations/transitions as well as the CompositableVa lueMaps to be applied. |
|
alancutter (OOO until 2018)
2014/03/12 03:34:07
Comment needs updating, CompositableValueMaps are
shans
2014/03/14 06:19:58
Done.
| |
| 54 class CSSAnimationUpdate FINAL { | 55 class CSSAnimationUpdate FINAL { |
| 55 public: | 56 public: |
| 56 void startAnimation(AtomicString& animationName, const HashSet<RefPtr<InertA nimation> >& animations) | 57 void startAnimation(AtomicString& animationName, const HashSet<RefPtr<InertA nimation> >& animations) |
| 57 { | 58 { |
| 58 NewAnimation newAnimation; | 59 NewAnimation newAnimation; |
| 59 newAnimation.name = animationName; | 60 newAnimation.name = animationName; |
| 60 newAnimation.animations = animations; | 61 newAnimation.animations = animations; |
| 61 m_newAnimations.append(newAnimation); | 62 m_newAnimations.append(newAnimation); |
| 62 } | 63 } |
| 63 // 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. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 struct NewTransition { | 98 struct NewTransition { |
| 98 CSSPropertyID id; | 99 CSSPropertyID id; |
| 99 const AnimatableValue* from; | 100 const AnimatableValue* from; |
| 100 const AnimatableValue* to; | 101 const AnimatableValue* to; |
| 101 RefPtr<InertAnimation> animation; | 102 RefPtr<InertAnimation> animation; |
| 102 }; | 103 }; |
| 103 typedef HashMap<CSSPropertyID, NewTransition> NewTransitionMap; | 104 typedef HashMap<CSSPropertyID, NewTransition> NewTransitionMap; |
| 104 const NewTransitionMap& newTransitions() const { return m_newTransitions; } | 105 const NewTransitionMap& newTransitions() const { return m_newTransitions; } |
| 105 const HashSet<CSSPropertyID>& cancelledTransitions() const { return m_cancel ledTransitions; } | 106 const HashSet<CSSPropertyID>& cancelledTransitions() const { return m_cancel ledTransitions; } |
| 106 | 107 |
| 107 void adoptCompositableValuesForAnimations(AnimationEffect::CompositableValue Map& newMap) { newMap.swap(m_compositableValuesForAnimations); } | 108 void adoptActiveInterpolationsForAnimations(HashMap<CSSPropertyID, RefPtr<In terpolation> >& newMap) { newMap.swap(m_activeInterpolationsForAnimations); } |
| 108 void adoptCompositableValuesForTransitions(AnimationEffect::CompositableValu eMap& newMap) { newMap.swap(m_compositableValuesForTransitions); } | 109 void adoptActiveInterpolationsForTransitions(HashMap<CSSPropertyID, RefPtr<I nterpolation> >& newMap) { newMap.swap(m_activeInterpolationsForTransitions); } |
| 109 const AnimationEffect::CompositableValueMap& compositableValuesForAnimations () const { return m_compositableValuesForAnimations; } | 110 const HashMap<CSSPropertyID, RefPtr<Interpolation> >& activeInterpolationsFo rAnimations() const { return m_activeInterpolationsForAnimations; } |
| 110 const AnimationEffect::CompositableValueMap& compositableValuesForTransition s() const { return m_compositableValuesForTransitions; } | 111 const HashMap<CSSPropertyID, RefPtr<Interpolation> >& activeInterpolationsFo rTransitions() const { return m_activeInterpolationsForTransitions; } |
| 111 AnimationEffect::CompositableValueMap& compositableValuesForAnimations() { r eturn m_compositableValuesForAnimations; } | 112 HashMap<CSSPropertyID, RefPtr<Interpolation> >& activeInterpolationsForAnima tions() { return m_activeInterpolationsForAnimations; } |
| 112 | 113 |
| 113 bool isEmpty() const | 114 bool isEmpty() const |
| 114 { | 115 { |
| 115 return m_newAnimations.isEmpty() | 116 return m_newAnimations.isEmpty() |
| 116 && m_cancelledAnimationNames.isEmpty() | 117 && m_cancelledAnimationNames.isEmpty() |
| 117 && m_cancelledAnimationPlayers.isEmpty() | 118 && m_cancelledAnimationPlayers.isEmpty() |
| 118 && m_animationsWithPauseToggled.isEmpty() | 119 && m_animationsWithPauseToggled.isEmpty() |
| 119 && m_newTransitions.isEmpty() | 120 && m_newTransitions.isEmpty() |
| 120 && m_cancelledTransitions.isEmpty() | 121 && m_cancelledTransitions.isEmpty() |
| 121 && m_compositableValuesForAnimations.isEmpty() | 122 && m_activeInterpolationsForAnimations.isEmpty() |
| 122 && m_compositableValuesForTransitions.isEmpty(); | 123 && m_activeInterpolationsForTransitions.isEmpty(); |
| 123 } | 124 } |
| 124 private: | 125 private: |
| 125 // Order is significant since it defines the order in which new animations | 126 // Order is significant since it defines the order in which new animations |
| 126 // will be started. Note that there may be multiple animations present | 127 // will be started. Note that there may be multiple animations present |
| 127 // with the same name, due to the way in which we split up animations with | 128 // with the same name, due to the way in which we split up animations with |
| 128 // incomplete keyframes. | 129 // incomplete keyframes. |
| 129 Vector<NewAnimation> m_newAnimations; | 130 Vector<NewAnimation> m_newAnimations; |
| 130 Vector<AtomicString> m_cancelledAnimationNames; | 131 Vector<AtomicString> m_cancelledAnimationNames; |
| 131 HashSet<const Player*> m_cancelledAnimationPlayers; | 132 HashSet<const Player*> m_cancelledAnimationPlayers; |
| 132 Vector<AtomicString> m_animationsWithPauseToggled; | 133 Vector<AtomicString> m_animationsWithPauseToggled; |
| 133 | 134 |
| 134 NewTransitionMap m_newTransitions; | 135 NewTransitionMap m_newTransitions; |
| 135 HashSet<CSSPropertyID> m_cancelledTransitions; | 136 HashSet<CSSPropertyID> m_cancelledTransitions; |
| 136 | 137 |
| 137 AnimationEffect::CompositableValueMap m_compositableValuesForAnimations; | 138 HashMap<CSSPropertyID, RefPtr<Interpolation> > m_activeInterpolationsForAnim ations; |
| 138 AnimationEffect::CompositableValueMap m_compositableValuesForTransitions; | 139 HashMap<CSSPropertyID, RefPtr<Interpolation> > m_activeInterpolationsForTran sitions; |
| 139 }; | 140 }; |
| 140 | 141 |
| 141 class CSSAnimations FINAL { | 142 class CSSAnimations FINAL { |
| 142 public: | 143 public: |
| 143 // FIXME: This method is only used here and in the legacy animations | 144 // FIXME: This method is only used here and in the legacy animations |
| 144 // implementation. It should be made private or file-scope when the legacy | 145 // implementation. It should be made private or file-scope when the legacy |
| 145 // engine is removed. | 146 // engine is removed. |
| 146 static const StyleRuleKeyframes* matchScopedKeyframesRule(StyleResolver*, co nst Element*, const StringImpl*); | 147 static const StyleRuleKeyframes* matchScopedKeyframesRule(StyleResolver*, co nst Element*, const StringImpl*); |
| 147 | 148 |
| 148 static bool isAnimatableProperty(CSSPropertyID); | 149 static bool isAnimatableProperty(CSSPropertyID); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 165 struct RunningTransition { | 166 struct RunningTransition { |
| 166 Animation* transition; // The TransitionTimeline keeps the Players alive | 167 Animation* transition; // The TransitionTimeline keeps the Players alive |
| 167 const AnimatableValue* from; | 168 const AnimatableValue* from; |
| 168 const AnimatableValue* to; | 169 const AnimatableValue* to; |
| 169 }; | 170 }; |
| 170 typedef HashMap<CSSPropertyID, RunningTransition > TransitionMap; | 171 typedef HashMap<CSSPropertyID, RunningTransition > TransitionMap; |
| 171 AnimationMap m_animations; | 172 AnimationMap m_animations; |
| 172 TransitionMap m_transitions; | 173 TransitionMap m_transitions; |
| 173 OwnPtr<CSSAnimationUpdate> m_pendingUpdate; | 174 OwnPtr<CSSAnimationUpdate> m_pendingUpdate; |
| 174 | 175 |
| 175 AnimationEffect::CompositableValueMap m_previousCompositableValuesForAnimati ons; | 176 HashMap<CSSPropertyID, RefPtr<Interpolation> > m_previousActiveInterpolation sForAnimations; |
| 176 | 177 |
| 177 static void calculateAnimationUpdate(CSSAnimationUpdate*, Element*, const El ement& parentElement, const RenderStyle&, RenderStyle* parentStyle, StyleResolve r*); | 178 static void calculateAnimationUpdate(CSSAnimationUpdate*, Element*, const El ement& parentElement, const RenderStyle&, RenderStyle* parentStyle, StyleResolve r*); |
| 178 static void calculateTransitionUpdate(CSSAnimationUpdate*, const Element*, c onst RenderStyle&); | 179 static void calculateTransitionUpdate(CSSAnimationUpdate*, const Element*, c onst RenderStyle&); |
| 179 static void calculateTransitionUpdateForProperty(CSSPropertyID, const CSSAni mationData*, const RenderStyle& oldStyle, const RenderStyle&, const TransitionMa p* activeTransitions, CSSAnimationUpdate*, const Element*); | 180 static void calculateTransitionUpdateForProperty(CSSPropertyID, const CSSAni mationData*, const RenderStyle& oldStyle, const RenderStyle&, const TransitionMa p* activeTransitions, CSSAnimationUpdate*, const Element*); |
| 180 | 181 |
| 181 static void calculateAnimationCompositableValues(CSSAnimationUpdate*, const Element*); | 182 static void calculateAnimationActiveInterpolations(CSSAnimationUpdate*, cons t Element*); |
| 182 static void calculateTransitionCompositableValues(CSSAnimationUpdate*, const Element*); | 183 static void calculateTransitionActiveInterpolations(CSSAnimationUpdate*, con st Element*); |
| 183 | 184 |
| 184 class AnimationEventDelegate FINAL : public TimedItem::EventDelegate { | 185 class AnimationEventDelegate FINAL : public TimedItem::EventDelegate { |
| 185 public: | 186 public: |
| 186 AnimationEventDelegate(Element* target, const AtomicString& name) | 187 AnimationEventDelegate(Element* target, const AtomicString& name) |
| 187 : m_target(target) | 188 : m_target(target) |
| 188 , m_name(name) | 189 , m_name(name) |
| 189 { | 190 { |
| 190 } | 191 } |
| 191 virtual void onEventCondition(const TimedItem*, bool isFirstSample, Time dItem::Phase previousPhase, double previousIteration) OVERRIDE; | 192 virtual void onEventCondition(const TimedItem*, bool isFirstSample, Time dItem::Phase previousPhase, double previousIteration) OVERRIDE; |
| 192 private: | 193 private: |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 205 virtual void onEventCondition(const TimedItem*, bool isFirstSample, Time dItem::Phase previousPhase, double previousIteration) OVERRIDE; | 206 virtual void onEventCondition(const TimedItem*, bool isFirstSample, Time dItem::Phase previousPhase, double previousIteration) OVERRIDE; |
| 206 private: | 207 private: |
| 207 Element* m_target; | 208 Element* m_target; |
| 208 const CSSPropertyID m_property; | 209 const CSSPropertyID m_property; |
| 209 }; | 210 }; |
| 210 }; | 211 }; |
| 211 | 212 |
| 212 } // namespace WebCore | 213 } // namespace WebCore |
| 213 | 214 |
| 214 #endif | 215 #endif |
| OLD | NEW |