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

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

Issue 832713004: Web Animations: Implement the AnimationPlayer finished promise (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 11 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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
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 AnimationPlayer_h 31 #ifndef AnimationPlayer_h
32 #define AnimationPlayer_h 32 #define AnimationPlayer_h
33 33
34 #include "bindings/core/v8/ScriptPromise.h"
35 #include "bindings/core/v8/ScriptPromiseProperty.h"
34 #include "core/animation/AnimationNode.h" 36 #include "core/animation/AnimationNode.h"
35 #include "core/dom/ActiveDOMObject.h" 37 #include "core/dom/ActiveDOMObject.h"
38 #include "core/dom/DOMException.h"
36 #include "core/events/EventTarget.h" 39 #include "core/events/EventTarget.h"
37 #include "platform/heap/Handle.h" 40 #include "platform/heap/Handle.h"
38 #include "wtf/RefPtr.h" 41 #include "wtf/RefPtr.h"
39 42
40 namespace blink { 43 namespace blink {
41 44
42 class AnimationTimeline; 45 class AnimationTimeline;
43 class ExceptionState; 46 class ExceptionState;
44 47
45 class AnimationPlayer final 48 class AnimationPlayer final
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 bool paused() const { return m_paused && !m_isPausedForTesting; } 85 bool paused() const { return m_paused && !m_isPausedForTesting; }
83 static const char* playStateString(AnimationPlayState); 86 static const char* playStateString(AnimationPlayState);
84 String playState() { return playStateString(playStateInternal()); } 87 String playState() { return playStateString(playStateInternal()); }
85 AnimationPlayState playStateInternal() const; 88 AnimationPlayState playStateInternal() const;
86 89
87 void pause(); 90 void pause();
88 void play(); 91 void play();
89 void reverse(); 92 void reverse();
90 void finish(ExceptionState&); 93 void finish(ExceptionState&);
91 94
95 ScriptPromise finished(ScriptState*);
96
92 bool playing() const { return !(playStateInternal() == Idle || limited() || m_paused || m_isPausedForTesting); } 97 bool playing() const { return !(playStateInternal() == Idle || limited() || m_paused || m_isPausedForTesting); }
93 bool limited() const { return limited(currentTimeInternal()); } 98 bool limited() const { return limited(currentTimeInternal()); }
94 99
95 DEFINE_ATTRIBUTE_EVENT_LISTENER(finish); 100 DEFINE_ATTRIBUTE_EVENT_LISTENER(finish);
96 101
97 virtual const AtomicString& interfaceName() const override; 102 virtual const AtomicString& interfaceName() const override;
98 virtual ExecutionContext* executionContext() const override; 103 virtual ExecutionContext* executionContext() const override;
99 virtual bool hasPendingActivity() const override; 104 virtual bool hasPendingActivity() const override;
100 virtual void stop() override; 105 virtual void stop() override;
101 virtual bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>) override; 106 virtual bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>) override;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 void beginUpdatingState(); 181 void beginUpdatingState();
177 void endUpdatingState(); 182 void endUpdatingState();
178 183
179 AnimationPlayState m_playState; 184 AnimationPlayState m_playState;
180 double m_playbackRate; 185 double m_playbackRate;
181 double m_startTime; 186 double m_startTime;
182 double m_holdTime; 187 double m_holdTime;
183 188
184 unsigned m_sequenceNumber; 189 unsigned m_sequenceNumber;
185 190
191 typedef ScriptPromiseProperty<RawPtrWillBeMember<AnimationPlayer>, RawPtrWil lBeMember<AnimationPlayer>, RefPtrWillBeMember<DOMException> > AnimationPlayerPr omise;
192 PersistentWillBeMember<AnimationPlayerPromise> m_finishedPromise;
193
186 RefPtrWillBeMember<AnimationNode> m_content; 194 RefPtrWillBeMember<AnimationNode> m_content;
187 RawPtrWillBeMember<AnimationTimeline> m_timeline; 195 RawPtrWillBeMember<AnimationTimeline> m_timeline;
188 // Reflects all pausing, including via pauseForTesting(). 196 // Reflects all pausing, including via pauseForTesting().
189 bool m_paused; 197 bool m_paused;
190 bool m_held; 198 bool m_held;
191 bool m_isPausedForTesting; 199 bool m_isPausedForTesting;
192 200
193 // This indicates timing information relevant to the player's effect 201 // This indicates timing information relevant to the player's effect
194 // has changed by means other than the ordinary progression of time 202 // has changed by means other than the ordinary progression of time
195 bool m_outdated; 203 bool m_outdated;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 DoNotSetCompositorPending, 237 DoNotSetCompositorPending,
230 }; 238 };
231 239
232 class PlayStateUpdateScope { 240 class PlayStateUpdateScope {
233 STACK_ALLOCATED(); 241 STACK_ALLOCATED();
234 public: 242 public:
235 PlayStateUpdateScope(AnimationPlayer&, TimingUpdateReason, CompositorPen dingChange = SetCompositorPending); 243 PlayStateUpdateScope(AnimationPlayer&, TimingUpdateReason, CompositorPen dingChange = SetCompositorPending);
236 ~PlayStateUpdateScope(); 244 ~PlayStateUpdateScope();
237 private: 245 private:
238 RawPtrWillBeMember<AnimationPlayer> m_player; 246 RawPtrWillBeMember<AnimationPlayer> m_player;
239 AnimationPlayState m_initial; 247 AnimationPlayState m_initialPlayState;
240 CompositorPendingChange m_compositorPendingChange; 248 CompositorPendingChange m_compositorPendingChange;
241 }; 249 };
242 250
243 // This mirrors the known compositor state. It is created when a compositor 251 // This mirrors the known compositor state. It is created when a compositor
244 // animation is started. Updated once the start time is known and each time 252 // animation is started. Updated once the start time is known and each time
245 // modifications are pushed to the compositor. 253 // modifications are pushed to the compositor.
246 OwnPtr<CompositorState> m_compositorState; 254 OwnPtr<CompositorState> m_compositorState;
247 bool m_compositorPending; 255 bool m_compositorPending;
248 int m_compositorGroup; 256 int m_compositorGroup;
249 257
250 bool m_currentTimePending; 258 bool m_currentTimePending;
251 bool m_stateIsBeingUpdated; 259 bool m_stateIsBeingUpdated;
252 260
253 }; 261 };
254 262
255 } // namespace blink 263 } // namespace blink
256 264
257 #endif // AnimationPlayer_h 265 #endif // AnimationPlayer_h
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/ScriptPromiseProperties.h ('k') | Source/core/animation/AnimationPlayer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698