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

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

Issue 2944423003: Implement new AnimationTimeline superclass (Closed)
Patch Set: Created 3 years, 6 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 void setCurrentTime(double, bool is_null); 92 void setCurrentTime(double, bool is_null);
91 void SetCurrentTimeInternal(double); 93 void SetCurrentTimeInternal(double);
92 double EffectiveTime(); 94 double EffectiveTime();
93 void PauseAnimationsForTesting(double); 95 void PauseAnimationsForTesting(double);
94 96
95 void SetAllCompositorPending(bool source_changed = false); 97 void SetAllCompositorPending(bool source_changed = false);
96 void SetOutdatedAnimation(Animation*); 98 void SetOutdatedAnimation(Animation*);
97 void ClearOutdatedAnimation(Animation*); 99 void ClearOutdatedAnimation(Animation*);
98 bool HasOutdatedAnimation() const { return outdated_animation_count_ > 0; } 100 bool HasOutdatedAnimation() const { return outdated_animation_count_ > 0; }
99 bool NeedsAnimationTimingUpdate(); 101 bool NeedsAnimationTimingUpdate();
100 void InvalidateKeyframeEffects(const TreeScope&); 102 void InvalidateKeyframeEffects(const TreeScope&);
101 103
102 void SetPlaybackRate(double); 104 void SetPlaybackRate(double);
103 double PlaybackRate() const; 105 double PlaybackRate() const;
104 106
105 CompositorAnimationTimeline* CompositorTimeline() const { 107 CompositorAnimationTimeline* CompositorTimeline() const {
106 return compositor_timeline_.get(); 108 return compositor_timeline_.get();
107 } 109 }
108 110
109 Document* GetDocument() { return document_.Get(); } 111 Document* GetDocument() { return document_.Get(); }
110 void Wake(); 112 void Wake();
111 void ResetForTesting(); 113 void ResetForTesting();
112 114
113 DECLARE_TRACE(); 115 DECLARE_VIRTUAL_TRACE();
114 116
115 protected: 117 protected:
116 AnimationTimeline(Document*, PlatformTiming*); 118 AnimationTimeline(Document*, PlatformTiming*);
117 119
118 private: 120 private:
119 Member<Document> document_; 121 Member<Document> document_;
120 double zero_time_; 122 double zero_time_;
121 bool zero_time_initialized_; 123 bool zero_time_initialized_;
122 unsigned outdated_animation_count_; 124 unsigned outdated_animation_count_;
123 // Animations which will be updated on the next frame 125 // Animations which will be updated on the next frame
(...skipping 30 matching lines...) Expand all
154 DECLARE_VIRTUAL_TRACE(); 156 DECLARE_VIRTUAL_TRACE();
155 157
156 private: 158 private:
157 Member<AnimationTimeline> timeline_; 159 Member<AnimationTimeline> timeline_;
158 TaskRunnerTimer<AnimationTimelineTiming> timer_; 160 TaskRunnerTimer<AnimationTimelineTiming> timer_;
159 }; 161 };
160 162
161 friend class AnimationAnimationTimelineTest; 163 friend class AnimationAnimationTimelineTest;
162 }; 164 };
163 165
166 DEFINE_TYPE_CASTS(AnimationTimeline,
167 SuperAnimationTimeline,
168 timeline,
169 timeline->IsAnimationTimeline(),
170 timeline.IsAnimationTimeline());
171
164 } // namespace blink 172 } // namespace blink
165 173
166 #endif 174 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698