OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All Rights Reserved. | 2 * Copyright (C) 2011 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 visitor->trace(m_document); | 63 visitor->trace(m_document); |
64 visitor->trace(m_eventQueue); | 64 visitor->trace(m_eventQueue); |
65 visitor->trace(m_mediaQueryListListeners); | 65 visitor->trace(m_mediaQueryListListeners); |
66 visitor->trace(m_perFrameEvents); | 66 visitor->trace(m_perFrameEvents); |
67 #endif | 67 #endif |
68 } | 68 } |
69 | 69 |
70 void ScriptedAnimationController::suspend() | 70 void ScriptedAnimationController::suspend() |
71 { | 71 { |
72 ++m_suspendCount; | 72 ++m_suspendCount; |
73 WTF_LOG(ScriptedAnimationController, "suspend: count = %d", m_suspendCount); | |
74 } | 73 } |
75 | 74 |
76 void ScriptedAnimationController::resume() | 75 void ScriptedAnimationController::resume() |
77 { | 76 { |
78 // It would be nice to put an ASSERT(m_suspendCount > 0) here, but in WK1 re
sume() can be called | 77 // It would be nice to put an ASSERT(m_suspendCount > 0) here, but in WK1 re
sume() can be called |
79 // even when suspend hasn't (if a tab was created in the background). | 78 // even when suspend hasn't (if a tab was created in the background). |
80 if (m_suspendCount > 0) | 79 if (m_suspendCount > 0) |
81 --m_suspendCount; | 80 --m_suspendCount; |
82 WTF_LOG(ScriptedAnimationController, "resume: count = %d", m_suspendCount); | |
83 scheduleAnimationIfNeeded(); | 81 scheduleAnimationIfNeeded(); |
84 } | 82 } |
85 | 83 |
86 ScriptedAnimationController::CallbackId ScriptedAnimationController::registerCal
lback(PassOwnPtrWillBeRawPtr<RequestAnimationFrameCallback> callback) | 84 ScriptedAnimationController::CallbackId ScriptedAnimationController::registerCal
lback(PassOwnPtrWillBeRawPtr<RequestAnimationFrameCallback> callback) |
87 { | 85 { |
88 ScriptedAnimationController::CallbackId id = ++m_nextCallbackId; | 86 ScriptedAnimationController::CallbackId id = ++m_nextCallbackId; |
89 WTF_LOG(ScriptedAnimationController, "registerCallback: id = %d", id); | |
90 callback->m_cancelled = false; | 87 callback->m_cancelled = false; |
91 callback->m_id = id; | 88 callback->m_id = id; |
92 m_callbacks.append(callback); | 89 m_callbacks.append(callback); |
93 scheduleAnimationIfNeeded(); | 90 scheduleAnimationIfNeeded(); |
94 | 91 |
95 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Reques
tAnimationFrame", "data", InspectorAnimationFrameEvent::data(m_document, id)); | 92 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Reques
tAnimationFrame", "data", InspectorAnimationFrameEvent::data(m_document, id)); |
96 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), "
CallStack", "stack", InspectorCallStackEvent::currentCallStack()); | 93 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), "
CallStack", "stack", InspectorCallStackEvent::currentCallStack()); |
97 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli
ne migrates to tracing. | 94 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli
ne migrates to tracing. |
98 InspectorInstrumentation::didRequestAnimationFrame(m_document, id); | 95 InspectorInstrumentation::didRequestAnimationFrame(m_document, id); |
99 | 96 |
100 return id; | 97 return id; |
101 } | 98 } |
102 | 99 |
103 void ScriptedAnimationController::cancelCallback(CallbackId id) | 100 void ScriptedAnimationController::cancelCallback(CallbackId id) |
104 { | 101 { |
105 WTF_LOG(ScriptedAnimationController, "cancelCallback: id = %d", id); | |
106 for (size_t i = 0; i < m_callbacks.size(); ++i) { | 102 for (size_t i = 0; i < m_callbacks.size(); ++i) { |
107 if (m_callbacks[i]->m_id == id) { | 103 if (m_callbacks[i]->m_id == id) { |
108 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"),
"CancelAnimationFrame", "data", InspectorAnimationFrameEvent::data(m_document,
id)); | 104 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"),
"CancelAnimationFrame", "data", InspectorAnimationFrameEvent::data(m_document,
id)); |
109 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.st
ack"), "CallStack", "stack", InspectorCallStackEvent::currentCallStack()); | 105 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.st
ack"), "CallStack", "stack", InspectorCallStackEvent::currentCallStack()); |
110 // FIXME(361045): remove InspectorInstrumentation calls once DevTool
s Timeline migrates to tracing. | 106 // FIXME(361045): remove InspectorInstrumentation calls once DevTool
s Timeline migrates to tracing. |
111 InspectorInstrumentation::didCancelAnimationFrame(m_document, id); | 107 InspectorInstrumentation::didCancelAnimationFrame(m_document, id); |
112 m_callbacks.remove(i); | 108 m_callbacks.remove(i); |
113 return; | 109 return; |
114 } | 110 } |
115 } | 111 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 listeners.swap(m_mediaQueryListListeners); | 180 listeners.swap(m_mediaQueryListListeners); |
185 | 181 |
186 for (MediaQueryListListeners::const_iterator it = listeners.begin(), end = l
isteners.end(); | 182 for (MediaQueryListListeners::const_iterator it = listeners.begin(), end = l
isteners.end(); |
187 it != end; ++it) { | 183 it != end; ++it) { |
188 (*it)->notifyMediaQueryChanged(); | 184 (*it)->notifyMediaQueryChanged(); |
189 } | 185 } |
190 } | 186 } |
191 | 187 |
192 void ScriptedAnimationController::serviceScriptedAnimations(double monotonicTime
Now) | 188 void ScriptedAnimationController::serviceScriptedAnimations(double monotonicTime
Now) |
193 { | 189 { |
194 WTF_LOG(ScriptedAnimationController, "serviceScriptedAnimations: #callbacks
= %d, #events = %d, #mediaQueryListListeners = %d, count = %d", | |
195 static_cast<int>(m_callbacks.size()), | |
196 static_cast<int>(m_eventQueue.size()), | |
197 static_cast<int>(m_mediaQueryListListeners.size()), | |
198 m_suspendCount); | |
199 if (!m_callbacks.size() && !m_eventQueue.size() && !m_mediaQueryListListener
s.size()) | 190 if (!m_callbacks.size() && !m_eventQueue.size() && !m_mediaQueryListListener
s.size()) |
200 return; | 191 return; |
201 | 192 |
202 if (m_suspendCount) | 193 if (m_suspendCount) |
203 return; | 194 return; |
204 | 195 |
205 RefPtrWillBeRawPtr<ScriptedAnimationController> protect(this); | 196 RefPtrWillBeRawPtr<ScriptedAnimationController> protect(this); |
206 | 197 |
207 callMediaQueryListListeners(); | 198 callMediaQueryListListeners(); |
208 dispatchEvents(); | 199 dispatchEvents(); |
209 executeCallbacks(monotonicTimeNow); | 200 executeCallbacks(monotonicTimeNow); |
210 | 201 |
211 scheduleAnimationIfNeeded(); | 202 scheduleAnimationIfNeeded(); |
212 } | 203 } |
213 | 204 |
214 void ScriptedAnimationController::enqueueEvent(PassRefPtrWillBeRawPtr<Event> eve
nt) | 205 void ScriptedAnimationController::enqueueEvent(PassRefPtrWillBeRawPtr<Event> eve
nt) |
215 { | 206 { |
216 WTF_LOG(ScriptedAnimationController, "enqueueEvent"); | |
217 InspectorInstrumentation::didEnqueueEvent(event->target(), event.get()); | 207 InspectorInstrumentation::didEnqueueEvent(event->target(), event.get()); |
218 m_eventQueue.append(event); | 208 m_eventQueue.append(event); |
219 scheduleAnimationIfNeeded(); | 209 scheduleAnimationIfNeeded(); |
220 } | 210 } |
221 | 211 |
222 void ScriptedAnimationController::enqueuePerFrameEvent(PassRefPtrWillBeRawPtr<Ev
ent> event) | 212 void ScriptedAnimationController::enqueuePerFrameEvent(PassRefPtrWillBeRawPtr<Ev
ent> event) |
223 { | 213 { |
224 if (!m_perFrameEvents.add(eventTargetKey(event.get())).isNewEntry) | 214 if (!m_perFrameEvents.add(eventTargetKey(event.get())).isNewEntry) |
225 return; | 215 return; |
226 enqueueEvent(event); | 216 enqueueEvent(event); |
227 } | 217 } |
228 | 218 |
229 void ScriptedAnimationController::enqueueMediaQueryChangeListeners(WillBeHeapVec
tor<RefPtrWillBeMember<MediaQueryListListener> >& listeners) | 219 void ScriptedAnimationController::enqueueMediaQueryChangeListeners(WillBeHeapVec
tor<RefPtrWillBeMember<MediaQueryListListener> >& listeners) |
230 { | 220 { |
231 WTF_LOG(ScriptedAnimationController, "enqueueMediaQueryChangeListeners"); | |
232 for (size_t i = 0; i < listeners.size(); ++i) { | 221 for (size_t i = 0; i < listeners.size(); ++i) { |
233 m_mediaQueryListListeners.add(listeners[i]); | 222 m_mediaQueryListListeners.add(listeners[i]); |
234 } | 223 } |
235 scheduleAnimationIfNeeded(); | 224 scheduleAnimationIfNeeded(); |
236 } | 225 } |
237 | 226 |
238 void ScriptedAnimationController::scheduleAnimationIfNeeded() | 227 void ScriptedAnimationController::scheduleAnimationIfNeeded() |
239 { | 228 { |
240 WTF_LOG(ScriptedAnimationController, "scheduleAnimationIfNeeded: document =
%d, count = %d, #callbacks = %d, #events = %d, #mediaQueryListListeners =%d, fra
meView = %d", | |
241 m_document ? 1 : 0, m_suspendCount, | |
242 static_cast<int>(m_callbacks.size()), | |
243 static_cast<int>(m_eventQueue.size()), | |
244 static_cast<int>(m_mediaQueryListListeners.size()), | |
245 m_document && m_document->view() ? 1 : 0); | |
246 if (!m_document) | 229 if (!m_document) |
247 return; | 230 return; |
248 | 231 |
249 if (m_suspendCount) | 232 if (m_suspendCount) |
250 return; | 233 return; |
251 | 234 |
252 if (!m_callbacks.size() && !m_eventQueue.size() && !m_mediaQueryListListener
s.size()) | 235 if (!m_callbacks.size() && !m_eventQueue.size() && !m_mediaQueryListListener
s.size()) |
253 return; | 236 return; |
254 | 237 |
255 if (FrameView* frameView = m_document->view()) | 238 if (FrameView* frameView = m_document->view()) |
256 frameView->scheduleAnimation(); | 239 frameView->scheduleAnimation(); |
257 } | 240 } |
258 | 241 |
259 } | 242 } |
OLD | NEW |