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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 static inline bool isNull(double value) | 54 static inline bool isNull(double value) |
55 { | 55 { |
56 return std::isnan(value); | 56 return std::isnan(value); |
57 } | 57 } |
58 | 58 |
59 static inline double nullValue() | 59 static inline double nullValue() |
60 { | 60 { |
61 return std::numeric_limits<double>::quiet_NaN(); | 61 return std::numeric_limits<double>::quiet_NaN(); |
62 } | 62 } |
63 | 63 |
64 class CORE_EXPORT AnimationEffect : public RefCountedWillBeGarbageCollectedFinal
ized<AnimationEffect>, public ScriptWrappable { | 64 class CORE_EXPORT AnimationEffect : public GarbageCollectedFinalized<AnimationEf
fect>, public ScriptWrappable { |
65 DEFINE_WRAPPERTYPEINFO(); | 65 DEFINE_WRAPPERTYPEINFO(); |
66 friend class Animation; // Calls attach/detach, updateInheritedTime. | 66 friend class Animation; // Calls attach/detach, updateInheritedTime. |
67 public: | 67 public: |
68 // Note that logic in CSSAnimations depends on the order of these values. | 68 // Note that logic in CSSAnimations depends on the order of these values. |
69 enum Phase { | 69 enum Phase { |
70 PhaseBefore, | 70 PhaseBefore, |
71 PhaseActive, | 71 PhaseActive, |
72 PhaseAfter, | 72 PhaseAfter, |
73 PhaseNone, | 73 PhaseNone, |
74 }; | 74 }; |
75 | 75 |
76 class EventDelegate : public NoBaseWillBeGarbageCollectedFinalized<EventDele
gate> { | 76 class EventDelegate : public GarbageCollectedFinalized<EventDelegate> { |
77 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(EventDelegate); | |
78 public: | 77 public: |
79 virtual ~EventDelegate() { } | 78 virtual ~EventDelegate() { } |
80 virtual bool requiresIterationEvents(const AnimationEffect&) = 0; | 79 virtual bool requiresIterationEvents(const AnimationEffect&) = 0; |
81 virtual void onEventCondition(const AnimationEffect&) = 0; | 80 virtual void onEventCondition(const AnimationEffect&) = 0; |
82 DEFINE_INLINE_VIRTUAL_TRACE() { } | 81 DEFINE_INLINE_VIRTUAL_TRACE() { } |
83 }; | 82 }; |
84 | 83 |
85 virtual ~AnimationEffect() { } | 84 virtual ~AnimationEffect() { } |
86 | 85 |
87 virtual bool isAnimation() const { return false; } | 86 virtual bool isAnimation() const { return false; } |
88 | 87 |
89 Phase phase() const { return ensureCalculated().phase; } | 88 Phase phase() const { return ensureCalculated().phase; } |
90 bool isCurrent() const { return ensureCalculated().isCurrent; } | 89 bool isCurrent() const { return ensureCalculated().isCurrent; } |
91 bool isInEffect() const { return ensureCalculated().isInEffect; } | 90 bool isInEffect() const { return ensureCalculated().isInEffect; } |
92 bool isInPlay() const { return ensureCalculated().isInPlay; } | 91 bool isInPlay() const { return ensureCalculated().isInPlay; } |
93 double currentIteration() const { return ensureCalculated().currentIteration
; } | 92 double currentIteration() const { return ensureCalculated().currentIteration
; } |
94 double timeFraction() const { return ensureCalculated().timeFraction; } | 93 double timeFraction() const { return ensureCalculated().timeFraction; } |
95 double timeToForwardsEffectChange() const { return ensureCalculated().timeTo
ForwardsEffectChange; } | 94 double timeToForwardsEffectChange() const { return ensureCalculated().timeTo
ForwardsEffectChange; } |
96 double timeToReverseEffectChange() const { return ensureCalculated().timeToR
everseEffectChange; } | 95 double timeToReverseEffectChange() const { return ensureCalculated().timeToR
everseEffectChange; } |
97 | 96 |
98 double iterationDuration() const; | 97 double iterationDuration() const; |
99 double activeDurationInternal() const; | 98 double activeDurationInternal() const; |
100 double startTimeInternal() const { return m_startTime; } | 99 double startTimeInternal() const { return m_startTime; } |
101 double endTimeInternal() const { return std::max(startTimeInternal(), startT
imeInternal() + specifiedTiming().startDelay + activeDurationInternal() + specif
iedTiming().endDelay); } | 100 double endTimeInternal() const { return std::max(startTimeInternal(), startT
imeInternal() + specifiedTiming().startDelay + activeDurationInternal() + specif
iedTiming().endDelay); } |
102 | 101 |
103 const Animation* animation() const { return m_animation; } | 102 const Animation* animation() const { return m_animation; } |
104 Animation* animation() { return m_animation; } | 103 Animation* animation() { return m_animation; } |
105 const Timing& specifiedTiming() const { return m_timing; } | 104 const Timing& specifiedTiming() const { return m_timing; } |
106 PassRefPtrWillBeRawPtr<AnimationEffectTiming> timing(); | 105 AnimationEffectTiming* timing(); |
107 void updateSpecifiedTiming(const Timing&); | 106 void updateSpecifiedTiming(const Timing&); |
108 | 107 |
109 void computedTiming(ComputedTimingProperties&); | 108 void computedTiming(ComputedTimingProperties&); |
110 ComputedTimingProperties computedTiming(); | 109 ComputedTimingProperties computedTiming(); |
111 | 110 |
112 void setName(const String& name) { m_name = name; } | 111 void setName(const String& name) { m_name = name; } |
113 const String& name() const { return m_name; } | 112 const String& name() const { return m_name; } |
114 | 113 |
115 DECLARE_VIRTUAL_TRACE(); | 114 DECLARE_VIRTUAL_TRACE(); |
116 | 115 |
117 protected: | 116 protected: |
118 explicit AnimationEffect(const Timing&, PassOwnPtrWillBeRawPtr<EventDelegate
> = nullptr); | 117 explicit AnimationEffect(const Timing&, EventDelegate* = nullptr); |
119 | 118 |
120 // When AnimationEffect receives a new inherited time via updateInheritedTim
e | 119 // When AnimationEffect receives a new inherited time via updateInheritedTim
e |
121 // it will (if necessary) recalculate timings and (if necessary) call | 120 // it will (if necessary) recalculate timings and (if necessary) call |
122 // updateChildrenAndEffects. | 121 // updateChildrenAndEffects. |
123 void updateInheritedTime(double inheritedTime, TimingUpdateReason) const; | 122 void updateInheritedTime(double inheritedTime, TimingUpdateReason) const; |
124 void invalidate() const { m_needsUpdate = true; } | 123 void invalidate() const { m_needsUpdate = true; } |
125 bool requiresIterationEvents() const { return m_eventDelegate && m_eventDele
gate->requiresIterationEvents(*this); } | 124 bool requiresIterationEvents() const { return m_eventDelegate && m_eventDele
gate->requiresIterationEvents(*this); } |
126 void clearEventDelegate() { m_eventDelegate = nullptr; } | 125 void clearEventDelegate() { m_eventDelegate = nullptr; } |
127 | 126 |
128 virtual void attach(Animation* animation) | 127 virtual void attach(Animation* animation) |
129 { | 128 { |
130 m_animation = animation; | 129 m_animation = animation; |
131 } | 130 } |
132 | 131 |
133 virtual void detach() | 132 virtual void detach() |
134 { | 133 { |
135 ASSERT(m_animation); | 134 ASSERT(m_animation); |
136 m_animation = nullptr; | 135 m_animation = nullptr; |
137 } | 136 } |
138 | 137 |
139 double repeatedDuration() const; | 138 double repeatedDuration() const; |
140 | 139 |
141 virtual void updateChildrenAndEffects() const = 0; | 140 virtual void updateChildrenAndEffects() const = 0; |
142 virtual double intrinsicIterationDuration() const { return 0; } | 141 virtual double intrinsicIterationDuration() const { return 0; } |
143 virtual double calculateTimeToEffectChange(bool forwards, double localTime,
double timeToNextIteration) const = 0; | 142 virtual double calculateTimeToEffectChange(bool forwards, double localTime,
double timeToNextIteration) const = 0; |
144 virtual void specifiedTimingChanged() { } | 143 virtual void specifiedTimingChanged() { } |
145 | 144 |
146 // FIXME: m_parent and m_startTime are placeholders, they depend on timing g
roups. | 145 // FIXME: m_parent and m_startTime are placeholders, they depend on timing g
roups. |
147 RawPtrWillBeMember<AnimationEffect> m_parent; | 146 Member<AnimationEffect> m_parent; |
148 const double m_startTime; | 147 const double m_startTime; |
149 RawPtrWillBeMember<Animation> m_animation; | 148 Member<Animation> m_animation; |
150 Timing m_timing; | 149 Timing m_timing; |
151 OwnPtrWillBeMember<EventDelegate> m_eventDelegate; | 150 Member<EventDelegate> m_eventDelegate; |
152 | 151 |
153 mutable struct CalculatedTiming { | 152 mutable struct CalculatedTiming { |
154 DISALLOW_ALLOCATION(); | 153 DISALLOW_ALLOCATION(); |
155 Phase phase; | 154 Phase phase; |
156 double currentIteration; | 155 double currentIteration; |
157 double timeFraction; | 156 double timeFraction; |
158 bool isCurrent; | 157 bool isCurrent; |
159 bool isInEffect; | 158 bool isInEffect; |
160 bool isInPlay; | 159 bool isInPlay; |
161 double localTime; | 160 double localTime; |
162 double timeToForwardsEffectChange; | 161 double timeToForwardsEffectChange; |
163 double timeToReverseEffectChange; | 162 double timeToReverseEffectChange; |
164 } m_calculated; | 163 } m_calculated; |
165 mutable bool m_needsUpdate; | 164 mutable bool m_needsUpdate; |
166 mutable double m_lastUpdateTime; | 165 mutable double m_lastUpdateTime; |
167 String m_name; | 166 String m_name; |
168 | 167 |
169 const CalculatedTiming& ensureCalculated() const; | 168 const CalculatedTiming& ensureCalculated() const; |
170 }; | 169 }; |
171 | 170 |
172 } // namespace blink | 171 } // namespace blink |
173 | 172 |
174 #endif // AnimationEffect_h | 173 #endif // AnimationEffect_h |
OLD | NEW |