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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 friend class AnimationPlayer; // Calls attach/detach, updateInheritedTime. | 63 friend class AnimationPlayer; // Calls attach/detach, updateInheritedTime. |
64 public: | 64 public: |
65 // Note that logic in CSSAnimations depends on the order of these values. | 65 // Note that logic in CSSAnimations depends on the order of these values. |
66 enum Phase { | 66 enum Phase { |
67 PhaseBefore, | 67 PhaseBefore, |
68 PhaseActive, | 68 PhaseActive, |
69 PhaseAfter, | 69 PhaseAfter, |
70 PhaseNone, | 70 PhaseNone, |
71 }; | 71 }; |
72 | 72 |
73 class EventDelegate { | 73 class EventDelegate : public NoBaseWillBeGarbageCollectedFinalized<EventDele
gate> { |
74 public: | 74 public: |
75 virtual ~EventDelegate() { }; | 75 virtual ~EventDelegate() { } |
76 virtual void onEventCondition(const AnimationNode*) = 0; | 76 virtual void onEventCondition(const AnimationNode*) = 0; |
| 77 virtual void trace(Visitor*) { } |
77 }; | 78 }; |
78 | 79 |
79 virtual ~AnimationNode() { } | 80 virtual ~AnimationNode() { } |
80 | 81 |
81 virtual bool isAnimation() const { return false; } | 82 virtual bool isAnimation() const { return false; } |
82 | 83 |
83 Phase phase() const { return ensureCalculated().phase; } | 84 Phase phase() const { return ensureCalculated().phase; } |
84 bool isCurrent() const { return ensureCalculated().isCurrent; } | 85 bool isCurrent() const { return ensureCalculated().isCurrent; } |
85 bool isInEffect() const { return ensureCalculated().isInEffect; } | 86 bool isInEffect() const { return ensureCalculated().isInEffect; } |
86 bool isInPlay() const { return ensureCalculated().isInPlay; } | 87 bool isInPlay() const { return ensureCalculated().isInPlay; } |
(...skipping 20 matching lines...) Expand all Loading... |
107 PassRefPtrWillBeRawPtr<AnimationNodeTiming> timing(); | 108 PassRefPtrWillBeRawPtr<AnimationNodeTiming> timing(); |
108 void updateSpecifiedTiming(const Timing&); | 109 void updateSpecifiedTiming(const Timing&); |
109 | 110 |
110 // This method returns time in ms as it is unused except via the API. | 111 // This method returns time in ms as it is unused except via the API. |
111 double localTime(bool& isNull) const { isNull = !m_player; return ensureCalc
ulated().localTime * 1000; } | 112 double localTime(bool& isNull) const { isNull = !m_player; return ensureCalc
ulated().localTime * 1000; } |
112 double currentIteration(bool& isNull) const { isNull = !ensureCalculated().i
sInEffect; return ensureCalculated().currentIteration; } | 113 double currentIteration(bool& isNull) const { isNull = !ensureCalculated().i
sInEffect; return ensureCalculated().currentIteration; } |
113 | 114 |
114 virtual void trace(Visitor*); | 115 virtual void trace(Visitor*); |
115 | 116 |
116 protected: | 117 protected: |
117 explicit AnimationNode(const Timing&, PassOwnPtr<EventDelegate> = nullptr); | 118 explicit AnimationNode(const Timing&, PassOwnPtrWillBeRawPtr<EventDelegate>
= nullptr); |
118 | 119 |
119 // When AnimationNode receives a new inherited time via updateInheritedTime | 120 // When AnimationNode receives a new inherited time via updateInheritedTime |
120 // it will (if necessary) recalculate timings and (if necessary) call | 121 // it will (if necessary) recalculate timings and (if necessary) call |
121 // updateChildrenAndEffects. | 122 // updateChildrenAndEffects. |
122 void updateInheritedTime(double inheritedTime, TimingUpdateReason) const; | 123 void updateInheritedTime(double inheritedTime, TimingUpdateReason) const; |
123 void invalidate() const { m_needsUpdate = true; }; | 124 void invalidate() const { m_needsUpdate = true; }; |
124 bool hasEvents() const { return m_eventDelegate; } | 125 bool hasEvents() const { return m_eventDelegate; } |
125 void clearEventDelegate() { m_eventDelegate = nullptr; } | 126 void clearEventDelegate() { m_eventDelegate = nullptr; } |
126 | 127 |
127 virtual void attach(AnimationPlayer* player) | 128 virtual void attach(AnimationPlayer* player) |
(...skipping 12 matching lines...) Expand all Loading... |
140 virtual void updateChildrenAndEffects() const = 0; | 141 virtual void updateChildrenAndEffects() const = 0; |
141 virtual double intrinsicIterationDuration() const { return 0; }; | 142 virtual double intrinsicIterationDuration() const { return 0; }; |
142 virtual double calculateTimeToEffectChange(bool forwards, double localTime,
double timeToNextIteration) const = 0; | 143 virtual double calculateTimeToEffectChange(bool forwards, double localTime,
double timeToNextIteration) const = 0; |
143 virtual void specifiedTimingChanged() { } | 144 virtual void specifiedTimingChanged() { } |
144 | 145 |
145 // FIXME: m_parent and m_startTime are placeholders, they depend on timing g
roups. | 146 // FIXME: m_parent and m_startTime are placeholders, they depend on timing g
roups. |
146 RawPtrWillBeMember<AnimationNode> m_parent; | 147 RawPtrWillBeMember<AnimationNode> m_parent; |
147 const double m_startTime; | 148 const double m_startTime; |
148 RawPtrWillBeMember<AnimationPlayer> m_player; | 149 RawPtrWillBeMember<AnimationPlayer> m_player; |
149 Timing m_timing; | 150 Timing m_timing; |
150 OwnPtr<EventDelegate> m_eventDelegate; | 151 OwnPtrWillBeMember<EventDelegate> m_eventDelegate; |
151 | 152 |
152 mutable struct CalculatedTiming { | 153 mutable struct CalculatedTiming { |
153 Phase phase; | 154 Phase phase; |
154 double currentIteration; | 155 double currentIteration; |
155 double timeFraction; | 156 double timeFraction; |
156 bool isCurrent; | 157 bool isCurrent; |
157 bool isInEffect; | 158 bool isInEffect; |
158 bool isInPlay; | 159 bool isInPlay; |
159 double localTime; | 160 double localTime; |
160 double timeToForwardsEffectChange; | 161 double timeToForwardsEffectChange; |
161 double timeToReverseEffectChange; | 162 double timeToReverseEffectChange; |
162 } m_calculated; | 163 } m_calculated; |
163 mutable bool m_needsUpdate; | 164 mutable bool m_needsUpdate; |
164 mutable double m_lastUpdateTime; | 165 mutable double m_lastUpdateTime; |
165 | 166 |
166 const CalculatedTiming& ensureCalculated() const; | 167 const CalculatedTiming& ensureCalculated() const; |
167 }; | 168 }; |
168 | 169 |
169 } // namespace blink | 170 } // namespace blink |
170 | 171 |
171 #endif | 172 #endif |
OLD | NEW |