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

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

Issue 2948193002: Merge AnimationTimeline and DocumentTimeline (Closed)
Patch Set: Fix rebase error 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 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 DocumentTimeline_h 31 #ifndef DocumentTimeline_h
32 #define DocumentTimeline_h 32 #define DocumentTimeline_h
33 33
34 #include <memory>
34 #include "core/CoreExport.h" 35 #include "core/CoreExport.h"
35 #include "core/animation/AnimationTimeline.h" 36 #include "core/animation/AnimationEffectReadOnly.h"
37 #include "core/animation/EffectModel.h"
38 #include "core/animation/SuperAnimationTimeline.h"
39 #include "core/dom/Element.h"
40 #include "core/dom/TaskRunnerHelper.h"
41 #include "platform/Timer.h"
42 #include "platform/animation/CompositorAnimationTimeline.h"
36 #include "platform/bindings/ScriptWrappable.h" 43 #include "platform/bindings/ScriptWrappable.h"
44 #include "platform/heap/Handle.h"
45 #include "platform/wtf/RefPtr.h"
46 #include "platform/wtf/Vector.h"
37 47
38 namespace blink { 48 namespace blink {
39 49
50 class Animation;
51 class AnimationEffectReadOnly;
40 class Document; 52 class Document;
41 53
42 class CORE_EXPORT DocumentTimeline final : public AnimationTimeline { 54 // DocumentTimeline is constructed and owned by Document, and tied to its
55 // lifecycle.
56 class CORE_EXPORT DocumentTimeline : public SuperAnimationTimeline {
57 DEFINE_WRAPPERTYPEINFO();
58
43 public: 59 public:
44 static DocumentTimeline* Create(Document* document) { 60 class PlatformTiming : public GarbageCollectedFinalized<PlatformTiming> {
45 return new DocumentTimeline(document); 61 public:
62 // Calls DocumentTimeline's wake() method after duration seconds.
63 virtual void WakeAfter(double duration) = 0;
64 virtual void ServiceOnNextFrame() = 0;
65 virtual ~PlatformTiming() {}
66 DEFINE_INLINE_VIRTUAL_TRACE() {}
67 };
68
69 static DocumentTimeline* Create(Document*, PlatformTiming* = nullptr);
70
71 virtual ~DocumentTimeline() {}
72
73 bool IsDocumentTimeline() const final { return true; }
74
75 void ServiceAnimations(TimingUpdateReason);
76 void ScheduleNextService();
77
78 Animation* Play(AnimationEffectReadOnly*);
79 HeapVector<Member<Animation>> getAnimations();
80
81 void AnimationAttached(Animation&);
82
83 bool IsActive();
84 bool HasPendingUpdates() const {
85 return !animations_needing_update_.IsEmpty();
86 }
87 double ZeroTime();
88 double currentTime(bool& is_null) override;
89 double currentTime();
90 double CurrentTimeInternal(bool& is_null);
91 double CurrentTimeInternal();
92 double EffectiveTime();
93 void PauseAnimationsForTesting(double);
94
95 void SetAllCompositorPending(bool source_changed = false);
96 void SetOutdatedAnimation(Animation*);
97 void ClearOutdatedAnimation(Animation*);
98 bool HasOutdatedAnimation() const { return outdated_animation_count_ > 0; }
99 bool NeedsAnimationTimingUpdate();
100 void InvalidateKeyframeEffects(const TreeScope&);
101
102 void SetPlaybackRate(double);
103 double PlaybackRate() const;
104
105 CompositorAnimationTimeline* CompositorTimeline() const {
106 return compositor_timeline_.get();
46 } 107 }
47 108
109 Document* GetDocument() { return document_.Get(); }
110 void Wake();
111 void ResetForTesting();
112
113 DECLARE_VIRTUAL_TRACE();
114
115 protected:
116 DocumentTimeline(Document*, PlatformTiming*);
117
48 private: 118 private:
49 DocumentTimeline(Document* document) : AnimationTimeline(document, nullptr) {} 119 Member<Document> document_;
120 double zero_time_;
121 bool zero_time_initialized_;
122 unsigned outdated_animation_count_;
123 // Animations which will be updated on the next frame
124 // i.e. current, in effect, or had timing changed
125 HeapHashSet<Member<Animation>> animations_needing_update_;
126 HeapHashSet<WeakMember<Animation>> animations_;
127
128 double playback_rate_;
129
130 friend class SMILTimeContainer;
131 static const double kMinimumDelay;
132
133 Member<PlatformTiming> timing_;
134 double last_current_time_internal_;
135
136 std::unique_ptr<CompositorAnimationTimeline> compositor_timeline_;
137
138 class DocumentTimelineTiming final : public PlatformTiming {
139 public:
140 DocumentTimelineTiming(DocumentTimeline* timeline)
141 : timeline_(timeline),
142 timer_(TaskRunnerHelper::Get(TaskType::kUnspecedTimer,
143 timeline->GetDocument()),
144 this,
145 &DocumentTimelineTiming::TimerFired) {
146 DCHECK(timeline_);
147 }
148
149 void WakeAfter(double duration) override;
150 void ServiceOnNextFrame() override;
151
152 void TimerFired(TimerBase*) { timeline_->Wake(); }
153
154 DECLARE_VIRTUAL_TRACE();
155
156 private:
157 Member<DocumentTimeline> timeline_;
158 TaskRunnerTimer<DocumentTimelineTiming> timer_;
159 };
50 160
51 friend class AnimationDocumentTimelineTest; 161 friend class AnimationDocumentTimelineTest;
52 }; 162 };
53 163
164 DEFINE_TYPE_CASTS(DocumentTimeline,
165 SuperAnimationTimeline,
166 timeline,
167 timeline->IsDocumentTimeline(),
168 timeline.IsDocumentTimeline());
169
54 } // namespace blink 170 } // namespace blink
55 171
56 #endif 172 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698