| 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 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 #include "sky/engine/config.h" | 26 #include "sky/engine/config.h" |
| 27 #include "sky/engine/core/dom/ScriptedAnimationController.h" | 27 #include "sky/engine/core/dom/ScriptedAnimationController.h" |
| 28 | 28 |
| 29 #include "sky/engine/core/css/MediaQueryListListener.h" | 29 #include "sky/engine/core/css/MediaQueryListListener.h" |
| 30 #include "sky/engine/core/dom/Document.h" | 30 #include "sky/engine/core/dom/Document.h" |
| 31 #include "sky/engine/core/dom/RequestAnimationFrameCallback.h" | 31 #include "sky/engine/core/dom/RequestAnimationFrameCallback.h" |
| 32 #include "sky/engine/core/events/Event.h" | 32 #include "sky/engine/core/events/Event.h" |
| 33 #include "sky/engine/core/frame/FrameView.h" | 33 #include "sky/engine/core/frame/FrameView.h" |
| 34 #include "sky/engine/core/frame/LocalDOMWindow.h" | 34 #include "sky/engine/core/frame/LocalDOMWindow.h" |
| 35 #include "sky/engine/core/inspector/InspectorTraceEvents.h" | |
| 36 #include "sky/engine/core/page/Page.h" | 35 #include "sky/engine/core/page/Page.h" |
| 37 #include "sky/engine/platform/Logging.h" | 36 #include "sky/engine/platform/Logging.h" |
| 38 | 37 |
| 39 namespace blink { | 38 namespace blink { |
| 40 | 39 |
| 41 std::pair<EventTarget*, StringImpl*> eventTargetKey(const Event* event) | 40 std::pair<EventTarget*, StringImpl*> eventTargetKey(const Event* event) |
| 42 { | 41 { |
| 43 return std::make_pair(event->target(), event->type().impl()); | 42 return std::make_pair(event->target(), event->type().impl()); |
| 44 } | 43 } |
| 45 | 44 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 71 } | 70 } |
| 72 | 71 |
| 73 ScriptedAnimationController::CallbackId ScriptedAnimationController::registerCal
lback(PassOwnPtr<RequestAnimationFrameCallback> callback) | 72 ScriptedAnimationController::CallbackId ScriptedAnimationController::registerCal
lback(PassOwnPtr<RequestAnimationFrameCallback> callback) |
| 74 { | 73 { |
| 75 ScriptedAnimationController::CallbackId id = ++m_nextCallbackId; | 74 ScriptedAnimationController::CallbackId id = ++m_nextCallbackId; |
| 76 WTF_LOG(ScriptedAnimationController, "registerCallback: id = %d", id); | 75 WTF_LOG(ScriptedAnimationController, "registerCallback: id = %d", id); |
| 77 callback->m_cancelled = false; | 76 callback->m_cancelled = false; |
| 78 callback->m_id = id; | 77 callback->m_id = id; |
| 79 m_callbacks.append(callback); | 78 m_callbacks.append(callback); |
| 80 scheduleAnimationIfNeeded(); | 79 scheduleAnimationIfNeeded(); |
| 81 | |
| 82 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Reques
tAnimationFrame", TRACE_EVENT_SCOPE_PROCESS, "data", InspectorAnimationFrameEven
t::data(m_document, id)); | |
| 83 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), "
CallStack", TRACE_EVENT_SCOPE_PROCESS, "stack", InspectorCallStackEvent::current
CallStack()); | |
| 84 | |
| 85 return id; | 80 return id; |
| 86 } | 81 } |
| 87 | 82 |
| 88 void ScriptedAnimationController::cancelCallback(CallbackId id) | 83 void ScriptedAnimationController::cancelCallback(CallbackId id) |
| 89 { | 84 { |
| 90 WTF_LOG(ScriptedAnimationController, "cancelCallback: id = %d", id); | 85 WTF_LOG(ScriptedAnimationController, "cancelCallback: id = %d", id); |
| 91 for (size_t i = 0; i < m_callbacks.size(); ++i) { | 86 for (size_t i = 0; i < m_callbacks.size(); ++i) { |
| 92 if (m_callbacks[i]->m_id == id) { | 87 if (m_callbacks[i]->m_id == id) { |
| 93 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"),
"CancelAnimationFrame", TRACE_EVENT_SCOPE_PROCESS, "data", InspectorAnimationFr
ameEvent::data(m_document, id)); | |
| 94 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.st
ack"), "CallStack", TRACE_EVENT_SCOPE_PROCESS, "stack", InspectorCallStackEvent:
:currentCallStack()); | |
| 95 m_callbacks.remove(i); | 88 m_callbacks.remove(i); |
| 96 return; | 89 return; |
| 97 } | 90 } |
| 98 } | 91 } |
| 99 for (size_t i = 0; i < m_callbacksToInvoke.size(); ++i) { | 92 for (size_t i = 0; i < m_callbacksToInvoke.size(); ++i) { |
| 100 if (m_callbacksToInvoke[i]->m_id == id) { | 93 if (m_callbacksToInvoke[i]->m_id == id) { |
| 101 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"),
"CancelAnimationFrame", TRACE_EVENT_SCOPE_PROCESS, "data", InspectorAnimationFr
ameEvent::data(m_document, id)); | |
| 102 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.st
ack"), "CallStack", TRACE_EVENT_SCOPE_PROCESS, "stack", InspectorCallStackEvent:
:currentCallStack()); | |
| 103 m_callbacksToInvoke[i]->m_cancelled = true; | 94 m_callbacksToInvoke[i]->m_cancelled = true; |
| 104 // will be removed at the end of executeCallbacks() | 95 // will be removed at the end of executeCallbacks() |
| 105 return; | 96 return; |
| 106 } | 97 } |
| 107 } | 98 } |
| 108 } | 99 } |
| 109 | 100 |
| 110 void ScriptedAnimationController::dispatchEvents() | 101 void ScriptedAnimationController::dispatchEvents() |
| 111 { | 102 { |
| 112 Vector<RefPtr<Event> > events; | 103 Vector<RefPtr<Event> > events; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 return; | 209 return; |
| 219 | 210 |
| 220 if (!m_callbacks.size() && !m_eventQueue.size() && !m_mediaQueryListListener
s.size()) | 211 if (!m_callbacks.size() && !m_eventQueue.size() && !m_mediaQueryListListener
s.size()) |
| 221 return; | 212 return; |
| 222 | 213 |
| 223 // TODO(esprehn): This causes a full raster on every raf even if nothing cha
nged. | 214 // TODO(esprehn): This causes a full raster on every raf even if nothing cha
nged. |
| 224 m_document->page()->scheduleVisualUpdate(); | 215 m_document->page()->scheduleVisualUpdate(); |
| 225 } | 216 } |
| 226 | 217 |
| 227 } | 218 } |
| OLD | NEW |