OLD | NEW |
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 17 matching lines...) Expand all Loading... |
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 #include "config.h" | 31 #include "config.h" |
32 #include "core/animation/AnimationTimeline.h" | 32 #include "core/animation/AnimationTimeline.h" |
33 | 33 |
34 #include "core/animation/ActiveAnimations.h" | 34 #include "core/animation/ActiveAnimations.h" |
35 #include "core/animation/AnimationClock.h" | 35 #include "core/animation/AnimationClock.h" |
36 #include "core/dom/Document.h" | 36 #include "core/dom/Document.h" |
37 #include "core/frame/FrameView.h" | 37 #include "core/frame/FrameView.h" |
| 38 #include "core/loader/DocumentLoader.h" |
38 #include "core/page/Page.h" | 39 #include "core/page/Page.h" |
39 #include "platform/TraceEvent.h" | 40 #include "platform/TraceEvent.h" |
40 | 41 |
41 namespace blink { | 42 namespace blink { |
42 | 43 |
43 namespace { | 44 namespace { |
44 | 45 |
45 bool compareAnimationPlayers(const RefPtrWillBeMember<blink::AnimationPlayer>& l
eft, const RefPtrWillBeMember<blink::AnimationPlayer>& right) | 46 bool compareAnimationPlayers(const RefPtrWillBeMember<blink::AnimationPlayer>& l
eft, const RefPtrWillBeMember<blink::AnimationPlayer>& right) |
46 { | 47 { |
47 return AnimationPlayer::hasLowerPriority(left.get(), right.get()); | 48 return AnimationPlayer::hasLowerPriority(left.get(), right.get()); |
48 } | 49 } |
49 | 50 |
50 } | 51 } |
51 | 52 |
52 // This value represents 1 frame at 30Hz plus a little bit of wiggle room. | 53 // This value represents 1 frame at 30Hz plus a little bit of wiggle room. |
53 // TODO: Plumb a nominal framerate through and derive this value from that. | 54 // TODO: Plumb a nominal framerate through and derive this value from that. |
54 const double AnimationTimeline::s_minimumDelay = 0.04; | 55 const double AnimationTimeline::s_minimumDelay = 0.04; |
55 | 56 |
56 | 57 |
57 PassRefPtrWillBeRawPtr<AnimationTimeline> AnimationTimeline::create(Document* do
cument, PassOwnPtrWillBeRawPtr<PlatformTiming> timing) | 58 PassRefPtrWillBeRawPtr<AnimationTimeline> AnimationTimeline::create(Document* do
cument, PassOwnPtrWillBeRawPtr<PlatformTiming> timing) |
58 { | 59 { |
59 return adoptRefWillBeNoop(new AnimationTimeline(document, timing)); | 60 return adoptRefWillBeNoop(new AnimationTimeline(document, timing)); |
60 } | 61 } |
61 | 62 |
62 AnimationTimeline::AnimationTimeline(Document* document, PassOwnPtrWillBeRawPtr<
PlatformTiming> timing) | 63 AnimationTimeline::AnimationTimeline(Document* document, PassOwnPtrWillBeRawPtr<
PlatformTiming> timing) |
63 : m_document(document) | 64 : m_document(document) |
| 65 , m_zeroTime(0) |
64 { | 66 { |
65 if (!timing) | 67 if (!timing) |
66 m_timing = adoptPtrWillBeNoop(new AnimationTimelineTiming(this)); | 68 m_timing = adoptPtrWillBeNoop(new AnimationTimelineTiming(this)); |
67 else | 69 else |
68 m_timing = timing; | 70 m_timing = timing; |
69 | 71 |
70 ASSERT(document); | 72 ASSERT(document); |
71 } | 73 } |
72 | 74 |
73 AnimationTimeline::~AnimationTimeline() | 75 AnimationTimeline::~AnimationTimeline() |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 if (m_timeline->m_document && m_timeline->m_document->view()) | 160 if (m_timeline->m_document && m_timeline->m_document->view()) |
159 m_timeline->m_document->view()->scheduleAnimation(); | 161 m_timeline->m_document->view()->scheduleAnimation(); |
160 } | 162 } |
161 | 163 |
162 void AnimationTimeline::AnimationTimelineTiming::trace(Visitor* visitor) | 164 void AnimationTimeline::AnimationTimelineTiming::trace(Visitor* visitor) |
163 { | 165 { |
164 visitor->trace(m_timeline); | 166 visitor->trace(m_timeline); |
165 AnimationTimeline::PlatformTiming::trace(visitor); | 167 AnimationTimeline::PlatformTiming::trace(visitor); |
166 } | 168 } |
167 | 169 |
| 170 double AnimationTimeline::zeroTime() |
| 171 { |
| 172 if (!m_zeroTime && m_document && m_document->loader()) { |
| 173 m_zeroTime = m_document->loader()->timing()->referenceMonotonicTime(); |
| 174 } |
| 175 return m_zeroTime; |
| 176 } |
| 177 |
168 double AnimationTimeline::currentTime(bool& isNull) | 178 double AnimationTimeline::currentTime(bool& isNull) |
169 { | 179 { |
170 return currentTimeInternal(isNull) * 1000; | 180 return currentTimeInternal(isNull) * 1000; |
171 } | 181 } |
172 | 182 |
173 double AnimationTimeline::currentTimeInternal(bool& isNull) | 183 double AnimationTimeline::currentTimeInternal(bool& isNull) |
174 { | 184 { |
175 if (!m_document) { | 185 if (!m_document) { |
176 isNull = true; | 186 isNull = true; |
177 return std::numeric_limits<double>::quiet_NaN(); | 187 return std::numeric_limits<double>::quiet_NaN(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 { | 244 { |
235 #if ENABLE(OILPAN) | 245 #if ENABLE(OILPAN) |
236 visitor->trace(m_document); | 246 visitor->trace(m_document); |
237 visitor->trace(m_timing); | 247 visitor->trace(m_timing); |
238 visitor->trace(m_playersNeedingUpdate); | 248 visitor->trace(m_playersNeedingUpdate); |
239 visitor->trace(m_players); | 249 visitor->trace(m_players); |
240 #endif | 250 #endif |
241 } | 251 } |
242 | 252 |
243 } // namespace | 253 } // namespace |
OLD | NEW |