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

Side by Side Diff: third_party/WebKit/Source/core/animation/AnimationTimeline.h

Issue 2944423003: Implement new AnimationTimeline superclass (Closed)
Patch Set: Rebase Created 3 years, 5 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
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 15 matching lines...) Expand all
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 AnimationTimeline_h 31 #ifndef AnimationTimeline_h
32 #define AnimationTimeline_h 32 #define AnimationTimeline_h
33 33
34 #include <memory> 34 #include <memory>
35 #include "core/CoreExport.h" 35 #include "core/CoreExport.h"
36 #include "core/animation/Animation.h" 36 #include "core/animation/AnimationEffectReadOnly.h"
37 #include "core/animation/EffectModel.h" 37 #include "core/animation/EffectModel.h"
38 #include "core/animation/SuperAnimationTimeline.h"
38 #include "core/dom/Element.h" 39 #include "core/dom/Element.h"
39 #include "core/dom/TaskRunnerHelper.h" 40 #include "core/dom/TaskRunnerHelper.h"
40 #include "platform/Timer.h" 41 #include "platform/Timer.h"
41 #include "platform/animation/CompositorAnimationTimeline.h" 42 #include "platform/animation/CompositorAnimationTimeline.h"
42 #include "platform/bindings/ScriptWrappable.h" 43 #include "platform/bindings/ScriptWrappable.h"
43 #include "platform/heap/Handle.h" 44 #include "platform/heap/Handle.h"
44 #include "platform/wtf/RefPtr.h" 45 #include "platform/wtf/RefPtr.h"
45 #include "platform/wtf/Vector.h" 46 #include "platform/wtf/Vector.h"
46 47
47 namespace blink { 48 namespace blink {
48 49
50 class Animation;
51 class AnimationEffectReadOnly;
49 class Document; 52 class Document;
50 class AnimationEffectReadOnly;
51 53
52 // AnimationTimeline is constructed and owned by Document, and tied to its 54 // AnimationTimeline is constructed and owned by Document, and tied to its
53 // lifecycle. 55 // lifecycle.
54 class CORE_EXPORT AnimationTimeline 56 class CORE_EXPORT AnimationTimeline : public SuperAnimationTimeline {
55 : public GarbageCollectedFinalized<AnimationTimeline>,
56 public ScriptWrappable {
57 DEFINE_WRAPPERTYPEINFO(); 57 DEFINE_WRAPPERTYPEINFO();
58 58
59 public: 59 public:
60 class PlatformTiming : public GarbageCollectedFinalized<PlatformTiming> { 60 class PlatformTiming : public GarbageCollectedFinalized<PlatformTiming> {
61 public: 61 public:
62 // Calls AnimationTimeline's wake() method after duration seconds. 62 // Calls AnimationTimeline's wake() method after duration seconds.
63 virtual void WakeAfter(double duration) = 0; 63 virtual void WakeAfter(double duration) = 0;
64 virtual void ServiceOnNextFrame() = 0; 64 virtual void ServiceOnNextFrame() = 0;
65 virtual ~PlatformTiming() {} 65 virtual ~PlatformTiming() {}
66 DEFINE_INLINE_VIRTUAL_TRACE() {} 66 DEFINE_INLINE_VIRTUAL_TRACE() {}
67 }; 67 };
68 68
69 static AnimationTimeline* Create(Document*, PlatformTiming* = nullptr); 69 static AnimationTimeline* Create(Document*, PlatformTiming* = nullptr);
70 70
71 virtual ~AnimationTimeline() {} 71 virtual ~AnimationTimeline() {}
72 72
73 bool IsAnimationTimeline() const final { return true; }
74
73 void ServiceAnimations(TimingUpdateReason); 75 void ServiceAnimations(TimingUpdateReason);
74 void ScheduleNextService(); 76 void ScheduleNextService();
75 77
76 Animation* Play(AnimationEffectReadOnly*); 78 Animation* Play(AnimationEffectReadOnly*);
77 HeapVector<Member<Animation>> getAnimations(); 79 HeapVector<Member<Animation>> getAnimations();
78 80
79 void AnimationAttached(Animation&); 81 void AnimationAttached(Animation&);
80 82
81 bool IsActive(); 83 bool IsActive();
82 bool HasPendingUpdates() const { 84 bool HasPendingUpdates() const {
83 return !animations_needing_update_.IsEmpty(); 85 return !animations_needing_update_.IsEmpty();
84 } 86 }
85 double ZeroTime(); 87 double ZeroTime();
86 double currentTime(bool& is_null); 88 double currentTime(bool& is_null) override;
87 double currentTime(); 89 double currentTime();
88 double CurrentTimeInternal(bool& is_null); 90 double CurrentTimeInternal(bool& is_null);
89 double CurrentTimeInternal(); 91 double CurrentTimeInternal();
90 double EffectiveTime(); 92 double EffectiveTime();
91 void PauseAnimationsForTesting(double); 93 void PauseAnimationsForTesting(double);
92 94
93 void SetAllCompositorPending(bool source_changed = false); 95 void SetAllCompositorPending(bool source_changed = false);
94 void SetOutdatedAnimation(Animation*); 96 void SetOutdatedAnimation(Animation*);
95 void ClearOutdatedAnimation(Animation*); 97 void ClearOutdatedAnimation(Animation*);
96 bool HasOutdatedAnimation() const { return outdated_animation_count_ > 0; } 98 bool HasOutdatedAnimation() const { return outdated_animation_count_ > 0; }
97 bool NeedsAnimationTimingUpdate(); 99 bool NeedsAnimationTimingUpdate();
98 void InvalidateKeyframeEffects(const TreeScope&); 100 void InvalidateKeyframeEffects(const TreeScope&);
99 101
100 void SetPlaybackRate(double); 102 void SetPlaybackRate(double);
101 double PlaybackRate() const; 103 double PlaybackRate() const;
102 104
103 CompositorAnimationTimeline* CompositorTimeline() const { 105 CompositorAnimationTimeline* CompositorTimeline() const {
104 return compositor_timeline_.get(); 106 return compositor_timeline_.get();
105 } 107 }
106 108
107 Document* GetDocument() { return document_.Get(); } 109 Document* GetDocument() { return document_.Get(); }
108 void Wake(); 110 void Wake();
109 void ResetForTesting(); 111 void ResetForTesting();
110 112
111 DECLARE_TRACE(); 113 DECLARE_VIRTUAL_TRACE();
112 114
113 protected: 115 protected:
114 AnimationTimeline(Document*, PlatformTiming*); 116 AnimationTimeline(Document*, PlatformTiming*);
115 117
116 private: 118 private:
117 Member<Document> document_; 119 Member<Document> document_;
118 double zero_time_; 120 double zero_time_;
119 bool zero_time_initialized_; 121 bool zero_time_initialized_;
120 unsigned outdated_animation_count_; 122 unsigned outdated_animation_count_;
121 // Animations which will be updated on the next frame 123 // Animations which will be updated on the next frame
(...skipping 30 matching lines...) Expand all
152 DECLARE_VIRTUAL_TRACE(); 154 DECLARE_VIRTUAL_TRACE();
153 155
154 private: 156 private:
155 Member<AnimationTimeline> timeline_; 157 Member<AnimationTimeline> timeline_;
156 TaskRunnerTimer<AnimationTimelineTiming> timer_; 158 TaskRunnerTimer<AnimationTimelineTiming> timer_;
157 }; 159 };
158 160
159 friend class AnimationAnimationTimelineTest; 161 friend class AnimationAnimationTimelineTest;
160 }; 162 };
161 163
164 DEFINE_TYPE_CASTS(AnimationTimeline,
165 SuperAnimationTimeline,
166 timeline,
167 timeline->IsAnimationTimeline(),
168 timeline.IsAnimationTimeline());
169
162 } // namespace blink 170 } // namespace blink
163 171
164 #endif 172 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/animation/Animation.cpp ('k') | third_party/WebKit/Source/core/animation/AnimationTimeline.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698