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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 class CSSAnimationUpdate FINAL { | 61 class CSSAnimationUpdate FINAL { |
| 62 public: | 62 public: |
| 63 void startAnimation(AtomicString& animationName, const HashSet<RefPtr<InertA nimation> >& animations) | 63 void startAnimation(AtomicString& animationName, const HashSet<RefPtr<InertA nimation> >& animations) |
| 64 { | 64 { |
| 65 NewAnimation newAnimation; | 65 NewAnimation newAnimation; |
| 66 newAnimation.name = animationName; | 66 newAnimation.name = animationName; |
| 67 newAnimation.animations = animations; | 67 newAnimation.animations = animations; |
| 68 m_newAnimations.append(newAnimation); | 68 m_newAnimations.append(newAnimation); |
| 69 } | 69 } |
| 70 // Returns whether player has been cancelled and should be filtered during s tyle application. | 70 // Returns whether player has been cancelled and should be filtered during s tyle application. |
| 71 bool isCancelled(const Player* player) const { return m_cancelledAnimationPl ayers.contains(player); } | 71 bool isCancelledAnimation(const Player* player) const { return m_cancelledAn imationPlayers.contains(player); } |
|
dstockwell
2013/10/08 21:02:59
Not sure why this was renamed. Shouldn't this also
Timothy Loh
2013/10/09 01:33:07
Transitions and animations are basically disjoint
| |
| 72 void cancelAnimation(const AtomicString& name, const HashSet<RefPtr<Player> >& players) | 72 void cancelAnimation(const AtomicString& name, const HashSet<RefPtr<Player> >& players) |
| 73 { | 73 { |
| 74 m_cancelledAnimationNames.append(name); | 74 m_cancelledAnimationNames.append(name); |
| 75 for (HashSet<RefPtr<Player> >::const_iterator iter = players.begin(); it er != players.end(); ++iter) | 75 for (HashSet<RefPtr<Player> >::const_iterator iter = players.begin(); it er != players.end(); ++iter) |
| 76 m_cancelledAnimationPlayers.add(iter->get()); | 76 m_cancelledAnimationPlayers.add(iter->get()); |
| 77 } | 77 } |
| 78 | |
| 79 void startTransition(CSSPropertyID id, PassRefPtr<InertAnimation> animation) { m_newTransitions.set(id, animation); } | |
| 80 void endTransition(CSSPropertyID id) { m_endedTransitions.add(id); } | |
|
dstockwell
2013/10/08 21:02:59
cancelTransition
Timothy Loh
2013/10/09 01:33:07
This is also used for transitions which finish nor
dstockwell
2013/10/09 21:03:51
I meant that this should just be called cancelTran
Timothy Loh
2013/10/10 02:10:19
Yeah, I see finishing transitions normally and fin
| |
| 81 | |
| 78 struct NewAnimation { | 82 struct NewAnimation { |
| 79 AtomicString name; | 83 AtomicString name; |
| 80 HashSet<RefPtr<InertAnimation> > animations; | 84 HashSet<RefPtr<InertAnimation> > animations; |
| 81 }; | 85 }; |
| 82 const Vector<NewAnimation>& newAnimations() const { return m_newAnimations; } | 86 const Vector<NewAnimation>& newAnimations() const { return m_newAnimations; } |
| 83 const Vector<AtomicString>& cancelledAnimationNames() const { return m_cance lledAnimationNames; } | 87 const Vector<AtomicString>& cancelledAnimationNames() const { return m_cance lledAnimationNames; } |
| 88 const HashMap<CSSPropertyID, RefPtr<InertAnimation> >& newTransitions() cons t { return m_newTransitions; } | |
| 89 const HashSet<CSSPropertyID>& endedTransitions() const { return m_endedTrans itions; } | |
| 90 | |
| 91 bool isEmpty() const | |
| 92 { | |
| 93 return m_newAnimations.isEmpty() | |
| 94 && m_cancelledAnimationNames.isEmpty() | |
| 95 && m_cancelledAnimationPlayers.isEmpty() | |
| 96 && m_newTransitions.isEmpty() | |
| 97 && m_endedTransitions.isEmpty(); | |
| 98 } | |
| 84 private: | 99 private: |
| 85 // Order is significant since it defines the order in which new animations | 100 // Order is significant since it defines the order in which new animations |
| 86 // will be started. Note that there may be multiple animations present | 101 // will be started. Note that there may be multiple animations present |
| 87 // with the same name, due to the way in which we split up animations with | 102 // with the same name, due to the way in which we split up animations with |
| 88 // incomplete keyframes. | 103 // incomplete keyframes. |
| 89 Vector<NewAnimation> m_newAnimations; | 104 Vector<NewAnimation> m_newAnimations; |
| 90 Vector<AtomicString> m_cancelledAnimationNames; | 105 Vector<AtomicString> m_cancelledAnimationNames; |
| 91 HashSet<const Player*> m_cancelledAnimationPlayers; | 106 HashSet<const Player*> m_cancelledAnimationPlayers; |
| 107 | |
| 108 HashMap<CSSPropertyID, RefPtr<InertAnimation> > m_newTransitions; | |
| 109 HashSet<CSSPropertyID> m_endedTransitions; | |
| 92 }; | 110 }; |
| 93 | 111 |
| 94 class CSSAnimations FINAL { | 112 class CSSAnimations FINAL { |
| 95 public: | 113 public: |
| 96 static bool isAnimatableProperty(CSSPropertyID); | 114 static bool isAnimatableProperty(CSSPropertyID); |
| 97 static bool needsUpdate(const Element*, const RenderStyle*); | 115 static const Vector<CSSPropertyID>& animatableProperties(); |
| 98 static PassOwnPtr<CSSAnimationUpdate> calculateUpdate(Element*, const Render Style*, const CSSAnimations*, const CSSAnimationDataList*, StyleResolver*); | 116 // FIXME: This should take a const ScopedStyleTree instead of a StyleResolve r. |
| 117 // We should also change the Element* to a const Element* | |
| 118 static PassOwnPtr<CSSAnimationUpdate> calculateUpdate(Element*, const Render Style*, StyleResolver*); | |
| 119 static AnimationEffect::CompositableValueMap compositableValuesForTransition s(const CSSAnimations*, const CSSAnimationUpdate*); | |
| 120 | |
| 99 void setPendingUpdate(PassOwnPtr<CSSAnimationUpdate> update) { m_pendingUpda te = update; } | 121 void setPendingUpdate(PassOwnPtr<CSSAnimationUpdate> update) { m_pendingUpda te = update; } |
| 100 void maybeApplyPendingUpdate(Element*); | 122 void maybeApplyPendingUpdate(Element*); |
| 101 bool isEmpty() const { return m_animations.isEmpty() && !m_pendingUpdate; } | 123 bool isEmpty() const { return m_animations.isEmpty() && m_transitions.isEmpt y() && !m_pendingUpdate; } |
| 102 void cancel(); | 124 void cancel(); |
| 103 private: | 125 private: |
| 104 // Note that a single animation name may map to multiple players due to | 126 // Note that a single animation name may map to multiple players due to |
| 105 // the way in which we split up animations with incomplete keyframes. | 127 // the way in which we split up animations with incomplete keyframes. |
| 106 // FIXME: Once the Web Animations model supports groups, we could use a | 128 // FIXME: Once the Web Animations model supports groups, we could use a |
| 107 // ParGroup to drive multiple animations from a single Player. | 129 // ParGroup to drive multiple animations from a single Player. |
| 108 typedef HashMap<AtomicString, HashSet<RefPtr<Player> > > AnimationMap; | 130 typedef HashMap<AtomicString, HashSet<RefPtr<Player> > > AnimationMap; |
| 131 typedef HashMap<CSSPropertyID, RefPtr<Player> > TransitionMap; | |
| 109 AnimationMap m_animations; | 132 AnimationMap m_animations; |
| 133 TransitionMap m_transitions; | |
| 110 OwnPtr<CSSAnimationUpdate> m_pendingUpdate; | 134 OwnPtr<CSSAnimationUpdate> m_pendingUpdate; |
| 111 class EventDelegate FINAL : public TimedItem::EventDelegate { | 135 |
| 136 static void updateAnimationUpdate(CSSAnimationUpdate*, Element*, const Rende rStyle*, StyleResolver*); | |
| 137 static void updateTransitionUpdate(CSSAnimationUpdate*, const Element*, cons t RenderStyle*); | |
| 138 static void updateTransitionUpdate(CSSAnimationUpdate*, CSSPropertyID, const AnimatableValue* from, const AnimatableValue* to, const CSSAnimationData*, cons t TransitionMap* transitions); | |
| 139 | |
| 140 class AnimationEventDelegate FINAL : public TimedItem::EventDelegate { | |
| 112 public: | 141 public: |
| 113 EventDelegate(Element* target, const AtomicString& name) | 142 AnimationEventDelegate(Element* target, const AtomicString& name) |
| 114 : m_target(target) | 143 : m_target(target) |
| 115 , m_name(name) | 144 , m_name(name) |
| 116 { | 145 { |
| 117 } | 146 } |
| 118 virtual void onEventCondition(const TimedItem*, bool isFirstSample, Time dItem::Phase previousPhase, double previousIteration) OVERRIDE; | 147 virtual void onEventCondition(const TimedItem*, bool isFirstSample, Time dItem::Phase previousPhase, double previousIteration) OVERRIDE; |
| 119 private: | 148 private: |
| 120 void maybeDispatch(Document::ListenerType, AtomicString& eventName, doub le elapsedTime); | 149 void maybeDispatch(Document::ListenerType, AtomicString& eventName, doub le elapsedTime); |
| 121 Element* m_target; | 150 Element* m_target; |
| 122 const AtomicString m_name; | 151 const AtomicString m_name; |
| 123 }; | 152 }; |
| 153 | |
| 154 class TransitionEventDelegate FINAL : public TimedItem::EventDelegate { | |
| 155 public: | |
| 156 TransitionEventDelegate(Element* target, CSSPropertyID id) | |
| 157 : m_target(target) | |
| 158 , m_id(id) | |
| 159 { | |
| 160 } | |
| 161 virtual void onEventCondition(const TimedItem*, bool isFirstSample, Time dItem::Phase previousPhase, double previousIteration) OVERRIDE; | |
| 162 private: | |
| 163 Element* m_target; | |
| 164 const CSSPropertyID m_id; | |
|
Steve Block
2013/10/09 00:57:12
Probably better to call this m_property or m_prope
Timothy Loh
2013/10/09 07:39:23
Done.
| |
| 165 }; | |
| 124 }; | 166 }; |
| 125 | 167 |
| 126 } // namespace WebCore | 168 } // namespace WebCore |
| 127 | 169 |
| 128 #endif | 170 #endif |
| OLD | NEW |