| 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 29 matching lines...) Expand all Loading... |
| 40 #include "sky/engine/core/rendering/style/RenderStyleConstants.h" | 40 #include "sky/engine/core/rendering/style/RenderStyleConstants.h" |
| 41 #include "sky/engine/wtf/HashMap.h" | 41 #include "sky/engine/wtf/HashMap.h" |
| 42 #include "sky/engine/wtf/Vector.h" | 42 #include "sky/engine/wtf/Vector.h" |
| 43 #include "sky/engine/wtf/text/AtomicString.h" | 43 #include "sky/engine/wtf/text/AtomicString.h" |
| 44 | 44 |
| 45 namespace blink { | 45 namespace blink { |
| 46 | 46 |
| 47 class CSSTransitionData; | 47 class CSSTransitionData; |
| 48 class Element; | 48 class Element; |
| 49 class StylePropertyShorthand; | 49 class StylePropertyShorthand; |
| 50 class StyleResolver; | |
| 51 class StyleRuleKeyframes; | 50 class StyleRuleKeyframes; |
| 52 | 51 |
| 53 // This class stores the CSS Animations/Transitions information we use during a
style recalc. | 52 // 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. | 53 // This includes updates to animations/transitions as well as the Interpolations
to be applied. |
| 55 class CSSAnimationUpdate final { | 54 class CSSAnimationUpdate final { |
| 56 public: | 55 public: |
| 57 void startAnimation(AtomicString& animationName, PassRefPtr<InertAnimation>
animation) | 56 void startAnimation(AtomicString& animationName, PassRefPtr<InertAnimation>
animation) |
| 58 { | 57 { |
| 59 NewAnimation newAnimation; | 58 NewAnimation newAnimation; |
| 60 newAnimation.name = animationName; | 59 newAnimation.name = animationName; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 HashMap<CSSPropertyID, RefPtr<Interpolation> > m_activeInterpolationsForAnim
ations; | 143 HashMap<CSSPropertyID, RefPtr<Interpolation> > m_activeInterpolationsForAnim
ations; |
| 145 HashMap<CSSPropertyID, RefPtr<Interpolation> > m_activeInterpolationsForTran
sitions; | 144 HashMap<CSSPropertyID, RefPtr<Interpolation> > m_activeInterpolationsForTran
sitions; |
| 146 }; | 145 }; |
| 147 | 146 |
| 148 class CSSAnimations final { | 147 class CSSAnimations final { |
| 149 WTF_MAKE_NONCOPYABLE(CSSAnimations); | 148 WTF_MAKE_NONCOPYABLE(CSSAnimations); |
| 150 DISALLOW_ALLOCATION(); | 149 DISALLOW_ALLOCATION(); |
| 151 public: | 150 public: |
| 152 CSSAnimations(); | 151 CSSAnimations(); |
| 153 | 152 |
| 154 // FIXME: This method is only used here and in the legacy animations | |
| 155 // implementation. It should be made private or file-scope when the legacy | |
| 156 // engine is removed. | |
| 157 static const StyleRuleKeyframes* matchScopedKeyframesRule(StyleResolver*, co
nst Element*, String animationName); | |
| 158 | |
| 159 static const StylePropertyShorthand& animatableProperties(); | 153 static const StylePropertyShorthand& animatableProperties(); |
| 160 static bool isAllowedAnimation(CSSPropertyID); | 154 static bool isAllowedAnimation(CSSPropertyID); |
| 161 // FIXME: We should change the Element* to a const Element* | 155 // FIXME: We should change the Element* to a const Element* |
| 162 static PassOwnPtr<CSSAnimationUpdate> calculateUpdate(Element*, const Elemen
t& parentElement, const RenderStyle&, RenderStyle* parentStyle, StyleResolver*); | 156 static PassOwnPtr<CSSAnimationUpdate> calculateUpdate(Element*, const Elemen
t& parentElement, const RenderStyle&, RenderStyle* parentStyle); |
| 163 | 157 |
| 164 void setPendingUpdate(PassOwnPtr<CSSAnimationUpdate> update) { m_pendingUpda
te = update; } | 158 void setPendingUpdate(PassOwnPtr<CSSAnimationUpdate> update) { m_pendingUpda
te = update; } |
| 165 void maybeApplyPendingUpdate(Element*); | 159 void maybeApplyPendingUpdate(Element*); |
| 166 bool isEmpty() const { return m_animations.isEmpty() && m_transitions.isEmpt
y() && !m_pendingUpdate; } | 160 bool isEmpty() const { return m_animations.isEmpty() && m_transitions.isEmpt
y() && !m_pendingUpdate; } |
| 167 void cancel(); | 161 void cancel(); |
| 168 | 162 |
| 169 private: | 163 private: |
| 170 struct RunningTransition { | 164 struct RunningTransition { |
| 171 ALLOW_ONLY_INLINE_ALLOCATION(); | 165 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 172 public: | 166 public: |
| 173 RefPtr<AnimationPlayer> player; | 167 RefPtr<AnimationPlayer> player; |
| 174 RawPtr<const AnimatableValue> from; | 168 RawPtr<const AnimatableValue> from; |
| 175 RawPtr<const AnimatableValue> to; | 169 RawPtr<const AnimatableValue> to; |
| 176 }; | 170 }; |
| 177 | 171 |
| 178 typedef HashMap<AtomicString, RefPtr<AnimationPlayer> > AnimationMap; | 172 typedef HashMap<AtomicString, RefPtr<AnimationPlayer> > AnimationMap; |
| 179 AnimationMap m_animations; | 173 AnimationMap m_animations; |
| 180 | 174 |
| 181 typedef HashMap<CSSPropertyID, RunningTransition> TransitionMap; | 175 typedef HashMap<CSSPropertyID, RunningTransition> TransitionMap; |
| 182 TransitionMap m_transitions; | 176 TransitionMap m_transitions; |
| 183 | 177 |
| 184 OwnPtr<CSSAnimationUpdate> m_pendingUpdate; | 178 OwnPtr<CSSAnimationUpdate> m_pendingUpdate; |
| 185 | 179 |
| 186 HashMap<CSSPropertyID, RefPtr<Interpolation> > m_previousActiveInterpolation
sForAnimations; | 180 HashMap<CSSPropertyID, RefPtr<Interpolation> > m_previousActiveInterpolation
sForAnimations; |
| 187 | 181 |
| 188 static void calculateAnimationUpdate(CSSAnimationUpdate*, Element*, const El
ement& parentElement, const RenderStyle&, RenderStyle* parentStyle, StyleResolve
r*); | |
| 189 static void calculateTransitionUpdate(CSSAnimationUpdate*, const Element*, c
onst RenderStyle&); | 182 static void calculateTransitionUpdate(CSSAnimationUpdate*, const Element*, c
onst RenderStyle&); |
| 190 static void calculateTransitionUpdateForProperty(CSSPropertyID, CSSPropertyI
D eventId, const CSSTransitionData&, size_t transitionIndex, const RenderStyle&
oldStyle, const RenderStyle&, const TransitionMap* activeTransitions, CSSAnimati
onUpdate*, const Element*); | 183 static void calculateTransitionUpdateForProperty(CSSPropertyID, CSSPropertyI
D eventId, const CSSTransitionData&, size_t transitionIndex, const RenderStyle&
oldStyle, const RenderStyle&, const TransitionMap* activeTransitions, CSSAnimati
onUpdate*, const Element*); |
| 191 | 184 |
| 192 static void calculateAnimationActiveInterpolations(CSSAnimationUpdate*, cons
t Element*, double timelineCurrentTime); | 185 static void calculateAnimationActiveInterpolations(CSSAnimationUpdate*, cons
t Element*, double timelineCurrentTime); |
| 193 static void calculateTransitionActiveInterpolations(CSSAnimationUpdate*, con
st Element*, double timelineCurrentTime); | 186 static void calculateTransitionActiveInterpolations(CSSAnimationUpdate*, con
st Element*, double timelineCurrentTime); |
| 194 | 187 |
| 195 class AnimationEventDelegate final : public AnimationNode::EventDelegate { | 188 class AnimationEventDelegate final : public AnimationNode::EventDelegate { |
| 196 public: | 189 public: |
| 197 AnimationEventDelegate(Element* target, const AtomicString& name) | 190 AnimationEventDelegate(Element* target, const AtomicString& name) |
| 198 : m_target(target) | 191 : m_target(target) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 226 const CSSPropertyID m_property; | 219 const CSSPropertyID m_property; |
| 227 AnimationNode::Phase m_previousPhase; | 220 AnimationNode::Phase m_previousPhase; |
| 228 }; | 221 }; |
| 229 }; | 222 }; |
| 230 | 223 |
| 231 } // namespace blink | 224 } // namespace blink |
| 232 | 225 |
| 233 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation); | 226 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::CSSAnimationUpdate::NewAnimation); |
| 234 | 227 |
| 235 #endif // SKY_ENGINE_CORE_ANIMATION_CSS_CSSANIMATIONS_H_ | 228 #endif // SKY_ENGINE_CORE_ANIMATION_CSS_CSSANIMATIONS_H_ |
| OLD | NEW |