Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: Source/core/animation/TimedItem.h

Issue 225073004: Oilpan: Completely move core/animations/ to oilpan's heap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef TimedItem_h 31 #ifndef TimedItem_h
32 #define TimedItem_h 32 #define TimedItem_h
33 33
34 #include "core/animation/Timing.h" 34 #include "core/animation/Timing.h"
35 #include "platform/heap/Handle.h"
35 #include "wtf/OwnPtr.h" 36 #include "wtf/OwnPtr.h"
36 #include "wtf/PassOwnPtr.h" 37 #include "wtf/PassOwnPtr.h"
37 #include "wtf/RefCounted.h" 38 #include "wtf/RefCounted.h"
38 39
39 namespace WebCore { 40 namespace WebCore {
40 41
41 class AnimationPlayer; 42 class AnimationPlayer;
42 class TimedItem; 43 class TimedItem;
43 class TimedItemTiming; 44 class TimedItemTiming;
44 45
45 enum TimingUpdateReason { 46 enum TimingUpdateReason {
46 TimingUpdateOnDemand, 47 TimingUpdateOnDemand,
47 TimingUpdateForAnimationFrame 48 TimingUpdateForAnimationFrame
48 }; 49 };
49 50
50 static inline bool isNull(double value) 51 static inline bool isNull(double value)
51 { 52 {
52 return std::isnan(value); 53 return std::isnan(value);
53 } 54 }
54 55
55 static inline double nullValue() 56 static inline double nullValue()
56 { 57 {
57 return std::numeric_limits<double>::quiet_NaN(); 58 return std::numeric_limits<double>::quiet_NaN();
58 } 59 }
59 60
60 class TimedItem : public RefCounted<TimedItem> { 61 class TimedItem : public RefCountedWillBeGarbageCollectedFinalized<TimedItem> {
61 friend class AnimationPlayer; // Calls attach/detach, updateInheritedTime. 62 friend class AnimationPlayer; // Calls attach/detach, updateInheritedTime.
62 public: 63 public:
63 // Note that logic in CSSAnimations depends on the order of these values. 64 // Note that logic in CSSAnimations depends on the order of these values.
64 enum Phase { 65 enum Phase {
65 PhaseBefore, 66 PhaseBefore,
66 PhaseActive, 67 PhaseActive,
67 PhaseAfter, 68 PhaseAfter,
68 PhaseNone, 69 PhaseNone,
69 }; 70 };
70 71
(...skipping 25 matching lines...) Expand all
96 double timeFraction() const { return ensureCalculated().timeFraction; } 97 double timeFraction() const { return ensureCalculated().timeFraction; }
97 double startTime() const { return m_startTime * 1000; } 98 double startTime() const { return m_startTime * 1000; }
98 double startTimeInternal() const { return m_startTime; } 99 double startTimeInternal() const { return m_startTime; }
99 double endTime() const { return endTimeInternal() * 1000; } 100 double endTime() const { return endTimeInternal() * 1000; }
100 double endTimeInternal() const { return startTime() + specifiedTiming().star tDelay + activeDurationInternal() + specifiedTiming().endDelay; } 101 double endTimeInternal() const { return startTime() + specifiedTiming().star tDelay + activeDurationInternal() + specifiedTiming().endDelay; }
101 102
102 const AnimationPlayer* player() const { return m_player; } 103 const AnimationPlayer* player() const { return m_player; }
103 AnimationPlayer* player() { return m_player; } 104 AnimationPlayer* player() { return m_player; }
104 AnimationPlayer* player(bool& isNull) { isNull = !m_player; return m_player; } 105 AnimationPlayer* player(bool& isNull) { isNull = !m_player; return m_player; }
105 const Timing& specifiedTiming() const { return m_timing; } 106 const Timing& specifiedTiming() const { return m_timing; }
106 PassRefPtr<TimedItemTiming> timing(); 107 PassRefPtrWillBeRawPtr<TimedItemTiming> timing();
107 void updateSpecifiedTiming(const Timing&); 108 void updateSpecifiedTiming(const Timing&);
108 109
109 // This method returns time in ms as it is unused except via the API. 110 // This method returns time in ms as it is unused except via the API.
110 double localTime(bool& isNull) const { isNull = !m_player; return ensureCalc ulated().localTime * 1000; } 111 double localTime(bool& isNull) const { isNull = !m_player; return ensureCalc ulated().localTime * 1000; }
111 double currentIteration(bool& isNull) const { isNull = !ensureCalculated().i sInEffect; return ensureCalculated().currentIteration; } 112 double currentIteration(bool& isNull) const { isNull = !ensureCalculated().i sInEffect; return ensureCalculated().currentIteration; }
112 113
114 virtual void trace(Visitor*);
115
113 protected: 116 protected:
114 TimedItem(const Timing&, PassOwnPtr<EventDelegate> = nullptr); 117 explicit TimedItem(const Timing&, PassOwnPtr<EventDelegate> = nullptr);
115 118
116 // When TimedItem receives a new inherited time via updateInheritedTime 119 // When TimedItem receives a new inherited time via updateInheritedTime
117 // it will (if necessary) recalculate timings and (if necessary) call 120 // it will (if necessary) recalculate timings and (if necessary) call
118 // updateChildrenAndEffects. 121 // updateChildrenAndEffects.
119 void updateInheritedTime(double inheritedTime, TimingUpdateReason) const; 122 void updateInheritedTime(double inheritedTime, TimingUpdateReason) const;
120 void invalidate() const { m_needsUpdate = true; }; 123 void invalidate() const { m_needsUpdate = true; };
121 bool hasEvents() const { return m_eventDelegate; } 124 bool hasEvents() const { return m_eventDelegate; }
122 void clearEventDelegate() { m_eventDelegate = nullptr; } 125 void clearEventDelegate() { m_eventDelegate = nullptr; }
123 126
124 private: 127 virtual void attach(AnimationPlayer* player)
128 {
129 m_player = player;
130 }
131
132 virtual void detach()
133 {
134 ASSERT(m_player);
135 m_player = nullptr;
136 }
125 137
126 double repeatedDuration() const; 138 double repeatedDuration() const;
127 139
128 virtual void updateChildrenAndEffects() const = 0; 140 virtual void updateChildrenAndEffects() const = 0;
129 virtual double intrinsicIterationDuration() const { return 0; }; 141 virtual double intrinsicIterationDuration() const { return 0; };
130 virtual double calculateTimeToEffectChange(bool forwards, double localTime, double timeToNextIteration) const = 0; 142 virtual double calculateTimeToEffectChange(bool forwards, double localTime, double timeToNextIteration) const = 0;
131 virtual void didAttach() { }; 143 virtual void specifiedTimingChanged() { }
132 virtual void willDetach() { };
133 virtual void specifiedTimingChanged() { };
134
135 void attach(AnimationPlayer* player)
136 {
137 m_player = player;
138 didAttach();
139 };
140
141 void detach()
142 {
143 ASSERT(m_player);
144 willDetach();
145 m_player = 0;
146 };
147 144
148 // 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.
149 TimedItem* const m_parent; 146 RawPtrWillBeMember<TimedItem> m_parent;
150 const double m_startTime; 147 const double m_startTime;
151 AnimationPlayer* m_player; 148 RawPtrWillBeMember<AnimationPlayer> m_player;
152 Timing m_timing; 149 Timing m_timing;
153 OwnPtr<EventDelegate> m_eventDelegate; 150 OwnPtr<EventDelegate> m_eventDelegate;
154 151
155 mutable struct CalculatedTiming { 152 mutable struct CalculatedTiming {
156 Phase phase; 153 Phase phase;
157 double currentIteration; 154 double currentIteration;
158 double timeFraction; 155 double timeFraction;
159 bool isCurrent; 156 bool isCurrent;
160 bool isInEffect; 157 bool isInEffect;
161 bool isInPlay; 158 bool isInPlay;
162 double localTime; 159 double localTime;
163 double timeToForwardsEffectChange; 160 double timeToForwardsEffectChange;
164 double timeToReverseEffectChange; 161 double timeToReverseEffectChange;
165 } m_calculated; 162 } m_calculated;
166 mutable bool m_needsUpdate; 163 mutable bool m_needsUpdate;
167 mutable double m_lastUpdateTime; 164 mutable double m_lastUpdateTime;
168 165
169 const CalculatedTiming& ensureCalculated() const; 166 const CalculatedTiming& ensureCalculated() const;
170 }; 167 };
171 168
172 } // namespace WebCore 169 } // namespace WebCore
173 170
174 #endif 171 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698