Chromium Code Reviews

Side by Side Diff: Source/core/dom/ScriptedAnimationController.cpp

Issue 488863004: Revert of Add logging for ScriptedAnimationController. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/platform/Logging.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17 matching lines...)
28 28
29 #include "core/css/MediaQueryListListener.h" 29 #include "core/css/MediaQueryListListener.h"
30 #include "core/dom/Document.h" 30 #include "core/dom/Document.h"
31 #include "core/dom/RequestAnimationFrameCallback.h" 31 #include "core/dom/RequestAnimationFrameCallback.h"
32 #include "core/events/Event.h" 32 #include "core/events/Event.h"
33 #include "core/frame/LocalDOMWindow.h" 33 #include "core/frame/LocalDOMWindow.h"
34 #include "core/frame/FrameView.h" 34 #include "core/frame/FrameView.h"
35 #include "core/inspector/InspectorInstrumentation.h" 35 #include "core/inspector/InspectorInstrumentation.h"
36 #include "core/inspector/InspectorTraceEvents.h" 36 #include "core/inspector/InspectorTraceEvents.h"
37 #include "core/loader/DocumentLoader.h" 37 #include "core/loader/DocumentLoader.h"
38 #include "platform/Logging.h"
39 38
40 namespace blink { 39 namespace blink {
41 40
42 std::pair<EventTarget*, StringImpl*> eventTargetKey(const Event* event) 41 std::pair<EventTarget*, StringImpl*> eventTargetKey(const Event* event)
43 { 42 {
44 return std::make_pair(event->target(), event->type().impl()); 43 return std::make_pair(event->target(), event->type().impl());
45 } 44 }
46 45
47 ScriptedAnimationController::ScriptedAnimationController(Document* document) 46 ScriptedAnimationController::ScriptedAnimationController(Document* document)
48 : m_document(document) 47 : m_document(document)
(...skipping 12 matching lines...)
61 visitor->trace(m_document); 60 visitor->trace(m_document);
62 visitor->trace(m_eventQueue); 61 visitor->trace(m_eventQueue);
63 visitor->trace(m_mediaQueryListListeners); 62 visitor->trace(m_mediaQueryListListeners);
64 visitor->trace(m_perFrameEvents); 63 visitor->trace(m_perFrameEvents);
65 #endif 64 #endif
66 } 65 }
67 66
68 void ScriptedAnimationController::suspend() 67 void ScriptedAnimationController::suspend()
69 { 68 {
70 ++m_suspendCount; 69 ++m_suspendCount;
71 WTF_LOG(ScriptedAnimationController, "suspend: count = %d", m_suspendCount);
72 } 70 }
73 71
74 void ScriptedAnimationController::resume() 72 void ScriptedAnimationController::resume()
75 { 73 {
76 // It would be nice to put an ASSERT(m_suspendCount > 0) here, but in WK1 re sume() can be called 74 // It would be nice to put an ASSERT(m_suspendCount > 0) here, but in WK1 re sume() can be called
77 // even when suspend hasn't (if a tab was created in the background). 75 // even when suspend hasn't (if a tab was created in the background).
78 if (m_suspendCount > 0) 76 if (m_suspendCount > 0)
79 --m_suspendCount; 77 --m_suspendCount;
80 WTF_LOG(ScriptedAnimationController, "resume: count = %d", m_suspendCount);
81 scheduleAnimationIfNeeded(); 78 scheduleAnimationIfNeeded();
82 } 79 }
83 80
84 ScriptedAnimationController::CallbackId ScriptedAnimationController::registerCal lback(PassOwnPtr<RequestAnimationFrameCallback> callback) 81 ScriptedAnimationController::CallbackId ScriptedAnimationController::registerCal lback(PassOwnPtr<RequestAnimationFrameCallback> callback)
85 { 82 {
86 ScriptedAnimationController::CallbackId id = ++m_nextCallbackId; 83 ScriptedAnimationController::CallbackId id = ++m_nextCallbackId;
87 WTF_LOG(ScriptedAnimationController, "registerCallback: id = %d", id);
88 callback->m_cancelled = false; 84 callback->m_cancelled = false;
89 callback->m_id = id; 85 callback->m_id = id;
90 m_callbacks.append(callback); 86 m_callbacks.append(callback);
91 scheduleAnimationIfNeeded(); 87 scheduleAnimationIfNeeded();
92 88
93 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Reques tAnimationFrame", "data", InspectorAnimationFrameEvent::data(m_document, id)); 89 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Reques tAnimationFrame", "data", InspectorAnimationFrameEvent::data(m_document, id));
94 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), " CallStack", "stack", InspectorCallStackEvent::currentCallStack()); 90 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), " CallStack", "stack", InspectorCallStackEvent::currentCallStack());
95 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli ne migrates to tracing. 91 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli ne migrates to tracing.
96 InspectorInstrumentation::didRequestAnimationFrame(m_document, id); 92 InspectorInstrumentation::didRequestAnimationFrame(m_document, id);
97 93
98 return id; 94 return id;
99 } 95 }
100 96
101 void ScriptedAnimationController::cancelCallback(CallbackId id) 97 void ScriptedAnimationController::cancelCallback(CallbackId id)
102 { 98 {
103 WTF_LOG(ScriptedAnimationController, "cancelCallback: id = %d", id);
104 for (size_t i = 0; i < m_callbacks.size(); ++i) { 99 for (size_t i = 0; i < m_callbacks.size(); ++i) {
105 if (m_callbacks[i]->m_id == id) { 100 if (m_callbacks[i]->m_id == id) {
106 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "CancelAnimationFrame", "data", InspectorAnimationFrameEvent::data(m_document, id)); 101 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "CancelAnimationFrame", "data", InspectorAnimationFrameEvent::data(m_document, id));
107 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.st ack"), "CallStack", "stack", InspectorCallStackEvent::currentCallStack()); 102 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.st ack"), "CallStack", "stack", InspectorCallStackEvent::currentCallStack());
108 // FIXME(361045): remove InspectorInstrumentation calls once DevTool s Timeline migrates to tracing. 103 // FIXME(361045): remove InspectorInstrumentation calls once DevTool s Timeline migrates to tracing.
109 InspectorInstrumentation::didCancelAnimationFrame(m_document, id); 104 InspectorInstrumentation::didCancelAnimationFrame(m_document, id);
110 m_callbacks.remove(i); 105 m_callbacks.remove(i);
111 return; 106 return;
112 } 107 }
113 } 108 }
(...skipping 68 matching lines...)
182 listeners.swap(m_mediaQueryListListeners); 177 listeners.swap(m_mediaQueryListListeners);
183 178
184 for (MediaQueryListListeners::const_iterator it = listeners.begin(), end = l isteners.end(); 179 for (MediaQueryListListeners::const_iterator it = listeners.begin(), end = l isteners.end();
185 it != end; ++it) { 180 it != end; ++it) {
186 (*it)->call(); 181 (*it)->call();
187 } 182 }
188 } 183 }
189 184
190 void ScriptedAnimationController::serviceScriptedAnimations(double monotonicTime Now) 185 void ScriptedAnimationController::serviceScriptedAnimations(double monotonicTime Now)
191 { 186 {
192 WTF_LOG(ScriptedAnimationController, "serviceScriptedAnimations: #callbacks = %lu, #events = %lu, #mediaQueryListListeners =%u, count = %d",
193 m_callbacks.size(), m_eventQueue.size(), m_mediaQueryListListeners.size( ), m_suspendCount);
194 if (!m_callbacks.size() && !m_eventQueue.size() && !m_mediaQueryListListener s.size()) 187 if (!m_callbacks.size() && !m_eventQueue.size() && !m_mediaQueryListListener s.size())
195 return; 188 return;
196 189
197 if (m_suspendCount) 190 if (m_suspendCount)
198 return; 191 return;
199 192
200 RefPtrWillBeRawPtr<ScriptedAnimationController> protect(this); 193 RefPtrWillBeRawPtr<ScriptedAnimationController> protect(this);
201 194
202 callMediaQueryListListeners(); 195 callMediaQueryListListeners();
203 dispatchEvents(); 196 dispatchEvents();
204 executeCallbacks(monotonicTimeNow); 197 executeCallbacks(monotonicTimeNow);
205 198
206 scheduleAnimationIfNeeded(); 199 scheduleAnimationIfNeeded();
207 } 200 }
208 201
209 void ScriptedAnimationController::enqueueEvent(PassRefPtrWillBeRawPtr<Event> eve nt) 202 void ScriptedAnimationController::enqueueEvent(PassRefPtrWillBeRawPtr<Event> eve nt)
210 { 203 {
211 WTF_LOG(ScriptedAnimationController, "enqueueEvent");
212 InspectorInstrumentation::didEnqueueEvent(event->target(), event.get()); 204 InspectorInstrumentation::didEnqueueEvent(event->target(), event.get());
213 m_eventQueue.append(event); 205 m_eventQueue.append(event);
214 scheduleAnimationIfNeeded(); 206 scheduleAnimationIfNeeded();
215 } 207 }
216 208
217 void ScriptedAnimationController::enqueuePerFrameEvent(PassRefPtrWillBeRawPtr<Ev ent> event) 209 void ScriptedAnimationController::enqueuePerFrameEvent(PassRefPtrWillBeRawPtr<Ev ent> event)
218 { 210 {
219 if (!m_perFrameEvents.add(eventTargetKey(event.get())).isNewEntry) 211 if (!m_perFrameEvents.add(eventTargetKey(event.get())).isNewEntry)
220 return; 212 return;
221 enqueueEvent(event); 213 enqueueEvent(event);
222 } 214 }
223 215
224 void ScriptedAnimationController::enqueueMediaQueryChangeListeners(WillBeHeapVec tor<RefPtrWillBeMember<MediaQueryListListener> >& listeners) 216 void ScriptedAnimationController::enqueueMediaQueryChangeListeners(WillBeHeapVec tor<RefPtrWillBeMember<MediaQueryListListener> >& listeners)
225 { 217 {
226 WTF_LOG(ScriptedAnimationController, "enqueueMediaQueryChangeListeners");
227 for (size_t i = 0; i < listeners.size(); ++i) { 218 for (size_t i = 0; i < listeners.size(); ++i) {
228 m_mediaQueryListListeners.add(listeners[i]); 219 m_mediaQueryListListeners.add(listeners[i]);
229 } 220 }
230 scheduleAnimationIfNeeded(); 221 scheduleAnimationIfNeeded();
231 } 222 }
232 223
233 void ScriptedAnimationController::scheduleAnimationIfNeeded() 224 void ScriptedAnimationController::scheduleAnimationIfNeeded()
234 { 225 {
235 WTF_LOG(ScriptedAnimationController, "scheduleAnimationIfNeeded: document = %d, count = %d, #callbacks = %lu, #events = %lu, #mediaQueryListListeners =%u, f rameView = %d",
236 m_document ? 1 : 0, m_suspendCount, m_callbacks.size(), m_eventQueue.siz e(), m_mediaQueryListListeners.size(), m_document && m_document->view() ? 1 : 0) ;
237 if (!m_document) 226 if (!m_document)
238 return; 227 return;
239 228
240 if (m_suspendCount) 229 if (m_suspendCount)
241 return; 230 return;
242 231
243 if (!m_callbacks.size() && !m_eventQueue.size() && !m_mediaQueryListListener s.size()) 232 if (!m_callbacks.size() && !m_eventQueue.size() && !m_mediaQueryListListener s.size())
244 return; 233 return;
245 234
246 if (FrameView* frameView = m_document->view()) 235 if (FrameView* frameView = m_document->view())
247 frameView->scheduleAnimation(); 236 frameView->scheduleAnimation();
248 } 237 }
249 238
250 } 239 }
OLDNEW
« no previous file with comments | « no previous file | Source/platform/Logging.h » ('j') | no next file with comments »

Powered by Google App Engine