| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 class CSSAnimationUpdateScope FINAL { | 53 class CSSAnimationUpdateScope FINAL { |
| 54 public: | 54 public: |
| 55 CSSAnimationUpdateScope(Element*); | 55 CSSAnimationUpdateScope(Element*); |
| 56 ~CSSAnimationUpdateScope(); | 56 ~CSSAnimationUpdateScope(); |
| 57 private: | 57 private: |
| 58 Element* m_target; | 58 Element* m_target; |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 class CSSAnimationUpdate FINAL { | 61 class CSSAnimationUpdate FINAL { |
| 62 public: | 62 public: |
| 63 void startAnimation(AtomicString& animationName, PassRefPtr<InertAnimation>
animation) | 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.animation = animation; | 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 isCancelled(const Player* player) const { return m_cancelledAnimationPl
ayers.contains(player); } |
| 72 void cancelAnimation(const AtomicString& name, const Player* player) | 72 void cancelAnimation(const AtomicString& name, const HashSet<RefPtr<Player>
>& players) |
| 73 { | 73 { |
| 74 m_cancelledAnimationNames.append(name); | 74 m_cancelledAnimationNames.append(name); |
| 75 m_cancelledAnimationPlayers.add(player); | 75 for (HashSet<RefPtr<Player> >::const_iterator iter = players.begin(); it
er != players.end(); ++iter) |
| 76 m_cancelledAnimationPlayers.add(iter->get()); |
| 76 } | 77 } |
| 77 struct NewAnimation { | 78 struct NewAnimation { |
| 78 AtomicString name; | 79 AtomicString name; |
| 79 RefPtr<InertAnimation> animation; | 80 HashSet<RefPtr<InertAnimation> > animations; |
| 80 }; | 81 }; |
| 81 const Vector<NewAnimation>& newAnimations() const { return m_newAnimations;
} | 82 const Vector<NewAnimation>& newAnimations() const { return m_newAnimations;
} |
| 82 const Vector<AtomicString>& cancelledAnimationNames() const { return m_cance
lledAnimationNames; } | 83 const Vector<AtomicString>& cancelledAnimationNames() const { return m_cance
lledAnimationNames; } |
| 83 private: | 84 private: |
| 84 // Order is significant since it defines the order in which new animations w
ill be started. | 85 // Order is significant since it defines the order in which new animations |
| 86 // 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 |
| 88 // incomplete keyframes. |
| 85 Vector<NewAnimation> m_newAnimations; | 89 Vector<NewAnimation> m_newAnimations; |
| 86 Vector<AtomicString> m_cancelledAnimationNames; | 90 Vector<AtomicString> m_cancelledAnimationNames; |
| 87 HashSet<const Player*> m_cancelledAnimationPlayers; | 91 HashSet<const Player*> m_cancelledAnimationPlayers; |
| 88 }; | 92 }; |
| 89 | 93 |
| 90 class CSSAnimations FINAL { | 94 class CSSAnimations FINAL { |
| 91 public: | 95 public: |
| 92 static bool isAnimatableProperty(CSSPropertyID); | 96 static bool isAnimatableProperty(CSSPropertyID); |
| 93 static bool needsUpdate(const Element*, const RenderStyle*); | 97 static bool needsUpdate(const Element*, const RenderStyle*); |
| 94 static PassOwnPtr<CSSAnimationUpdate> calculateUpdate(const Element*, const
RenderStyle*, const CSSAnimations*, const CSSAnimationDataList*, StyleResolver*)
; | 98 static PassOwnPtr<CSSAnimationUpdate> calculateUpdate(const Element*, const
RenderStyle*, const CSSAnimations*, const CSSAnimationDataList*, StyleResolver*)
; |
| 95 void setPendingUpdate(PassOwnPtr<CSSAnimationUpdate> update) { m_pendingUpda
te = update; } | 99 void setPendingUpdate(PassOwnPtr<CSSAnimationUpdate> update) { m_pendingUpda
te = update; } |
| 96 void maybeApplyPendingUpdate(Element*); | 100 void maybeApplyPendingUpdate(Element*); |
| 97 bool isEmpty() const { return m_animations.isEmpty() && !m_pendingUpdate; } | 101 bool isEmpty() const { return m_animations.isEmpty() && !m_pendingUpdate; } |
| 98 void cancel(); | 102 void cancel(); |
| 99 private: | 103 private: |
| 100 typedef HashMap<AtomicString, RefPtr<Player> > AnimationMap; | 104 // 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. |
| 106 // FIXME: Once the Web Animations model supports groups, we could use a |
| 107 // ParGroup to drive multiple animations from a single Player. |
| 108 typedef HashMap<AtomicString, HashSet<RefPtr<Player> > > AnimationMap; |
| 101 AnimationMap m_animations; | 109 AnimationMap m_animations; |
| 102 OwnPtr<CSSAnimationUpdate> m_pendingUpdate; | 110 OwnPtr<CSSAnimationUpdate> m_pendingUpdate; |
| 103 class EventDelegate FINAL : public TimedItem::EventDelegate { | 111 class EventDelegate FINAL : public TimedItem::EventDelegate { |
| 104 public: | 112 public: |
| 105 EventDelegate(Element* target, const AtomicString& name) | 113 EventDelegate(Element* target, const AtomicString& name) |
| 106 : m_target(target) | 114 : m_target(target) |
| 107 , m_name(name) | 115 , m_name(name) |
| 108 { | 116 { |
| 109 } | 117 } |
| 110 virtual void onEventCondition(const TimedItem*, bool isFirstSample, Time
dItem::Phase previousPhase, double previousIteration) OVERRIDE; | 118 virtual void onEventCondition(const TimedItem*, bool isFirstSample, Time
dItem::Phase previousPhase, double previousIteration) OVERRIDE; |
| 111 private: | 119 private: |
| 112 void maybeDispatch(Document::ListenerType, AtomicString& eventName, doub
le elapsedTime); | 120 void maybeDispatch(Document::ListenerType, AtomicString& eventName, doub
le elapsedTime); |
| 113 Element* m_target; | 121 Element* m_target; |
| 114 const AtomicString m_name; | 122 const AtomicString m_name; |
| 115 }; | 123 }; |
| 116 }; | 124 }; |
| 117 | 125 |
| 118 } // namespace WebCore | 126 } // namespace WebCore |
| 119 | 127 |
| 120 #endif | 128 #endif |
| OLD | NEW |