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 |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND A
NY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND A
NY |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR A
NY | 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR A
NY |
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON | 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON |
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THI
S | 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THI
S |
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
23 * | 23 * |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "core/dom/ScriptedAnimationController.h" | 27 #include "core/dom/ScriptedAnimationController.h" |
28 | 28 |
29 #include "core/css/MediaQueryListListener.h" | |
30 #include "core/dom/Document.h" | 29 #include "core/dom/Document.h" |
31 #include "core/dom/RequestAnimationFrameCallback.h" | 30 #include "core/dom/RequestAnimationFrameCallback.h" |
32 #include "core/events/Event.h" | 31 #include "core/events/Event.h" |
33 #include "core/frame/LocalDOMWindow.h" | 32 #include "core/frame/LocalDOMWindow.h" |
34 #include "core/frame/FrameView.h" | 33 #include "core/frame/FrameView.h" |
35 #include "core/inspector/InspectorInstrumentation.h" | 34 #include "core/inspector/InspectorInstrumentation.h" |
36 #include "core/inspector/InspectorTraceEvents.h" | 35 #include "core/inspector/InspectorTraceEvents.h" |
37 #include "core/loader/DocumentLoader.h" | 36 #include "core/loader/DocumentLoader.h" |
38 | 37 |
39 namespace WebCore { | 38 namespace WebCore { |
(...skipping 11 matching lines...) Expand all Loading... |
51 } | 50 } |
52 | 51 |
53 ScriptedAnimationController::~ScriptedAnimationController() | 52 ScriptedAnimationController::~ScriptedAnimationController() |
54 { | 53 { |
55 } | 54 } |
56 | 55 |
57 void ScriptedAnimationController::trace(Visitor* visitor) | 56 void ScriptedAnimationController::trace(Visitor* visitor) |
58 { | 57 { |
59 visitor->trace(m_document); | 58 visitor->trace(m_document); |
60 visitor->trace(m_eventQueue); | 59 visitor->trace(m_eventQueue); |
61 visitor->trace(m_mediaQueryListListeners); | |
62 #if ENABLE(OILPAN) | 60 #if ENABLE(OILPAN) |
63 visitor->trace(m_perFrameEvents); | 61 visitor->trace(m_perFrameEvents); |
64 #endif | 62 #endif |
65 } | 63 } |
66 | 64 |
67 void ScriptedAnimationController::suspend() | 65 void ScriptedAnimationController::suspend() |
68 { | 66 { |
69 ++m_suspendCount; | 67 ++m_suspendCount; |
70 } | 68 } |
71 | 69 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 else | 162 else |
165 callback->handleEvent(highResNowMs); | 163 callback->handleEvent(highResNowMs); |
166 InspectorInstrumentation::didFireAnimationFrame(cookie); | 164 InspectorInstrumentation::didFireAnimationFrame(cookie); |
167 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"),
"UpdateCounters", "data", InspectorUpdateCountersEvent::data()); | 165 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"),
"UpdateCounters", "data", InspectorUpdateCountersEvent::data()); |
168 } | 166 } |
169 } | 167 } |
170 | 168 |
171 m_callbacksToInvoke.clear(); | 169 m_callbacksToInvoke.clear(); |
172 } | 170 } |
173 | 171 |
174 void ScriptedAnimationController::callMediaQueryListListeners() | |
175 { | |
176 MediaQueryListListeners listeners; | |
177 listeners.swap(m_mediaQueryListListeners); | |
178 | |
179 for (MediaQueryListListeners::const_iterator it = listeners.begin(), end = l
isteners.end(); | |
180 it != end; ++it) { | |
181 (*it)->call(); | |
182 } | |
183 } | |
184 | |
185 void ScriptedAnimationController::serviceScriptedAnimations(double monotonicTime
Now) | 172 void ScriptedAnimationController::serviceScriptedAnimations(double monotonicTime
Now) |
186 { | 173 { |
187 if (!m_callbacks.size() && !m_eventQueue.size() && !m_mediaQueryListListener
s.size()) | 174 if (!m_callbacks.size() && !m_eventQueue.size()) |
188 return; | 175 return; |
189 | 176 |
190 if (m_suspendCount) | 177 if (m_suspendCount) |
191 return; | 178 return; |
192 | 179 |
193 RefPtrWillBeRawPtr<ScriptedAnimationController> protect(this); | 180 RefPtrWillBeRawPtr<ScriptedAnimationController> protect(this); |
194 | 181 |
195 callMediaQueryListListeners(); | |
196 dispatchEvents(); | 182 dispatchEvents(); |
197 executeCallbacks(monotonicTimeNow); | 183 executeCallbacks(monotonicTimeNow); |
198 | 184 |
199 scheduleAnimationIfNeeded(); | 185 scheduleAnimationIfNeeded(); |
200 } | 186 } |
201 | 187 |
202 void ScriptedAnimationController::enqueueEvent(PassRefPtrWillBeRawPtr<Event> eve
nt) | 188 void ScriptedAnimationController::enqueueEvent(PassRefPtrWillBeRawPtr<Event> eve
nt) |
203 { | 189 { |
204 InspectorInstrumentation::didEnqueueEvent(event->target(), event.get()); | 190 InspectorInstrumentation::didEnqueueEvent(event->target(), event.get()); |
205 m_eventQueue.append(event); | 191 m_eventQueue.append(event); |
206 scheduleAnimationIfNeeded(); | 192 scheduleAnimationIfNeeded(); |
207 } | 193 } |
208 | 194 |
209 void ScriptedAnimationController::enqueuePerFrameEvent(PassRefPtrWillBeRawPtr<Ev
ent> event) | 195 void ScriptedAnimationController::enqueuePerFrameEvent(PassRefPtrWillBeRawPtr<Ev
ent> event) |
210 { | 196 { |
211 if (!m_perFrameEvents.add(eventTargetKey(event.get())).isNewEntry) | 197 if (!m_perFrameEvents.add(eventTargetKey(event.get())).isNewEntry) |
212 return; | 198 return; |
213 enqueueEvent(event); | 199 enqueueEvent(event); |
214 } | 200 } |
215 | 201 |
216 void ScriptedAnimationController::enqueueMediaQueryChangeListeners(WillBeHeapVec
tor<RefPtrWillBeMember<MediaQueryListListener> >& listeners) | |
217 { | |
218 for (size_t i = 0; i < listeners.size(); ++i) { | |
219 m_mediaQueryListListeners.add(listeners[i]); | |
220 } | |
221 scheduleAnimationIfNeeded(); | |
222 } | |
223 | |
224 void ScriptedAnimationController::scheduleAnimationIfNeeded() | 202 void ScriptedAnimationController::scheduleAnimationIfNeeded() |
225 { | 203 { |
226 if (!m_document) | 204 if (!m_document) |
227 return; | 205 return; |
228 | 206 |
229 if (m_suspendCount) | 207 if (m_suspendCount) |
230 return; | 208 return; |
231 | 209 |
232 if (!m_callbacks.size() && !m_eventQueue.size() && !m_mediaQueryListListener
s.size()) | 210 if (!m_callbacks.size() && !m_eventQueue.size()) |
233 return; | 211 return; |
234 | 212 |
235 if (FrameView* frameView = m_document->view()) | 213 if (FrameView* frameView = m_document->view()) |
236 frameView->scheduleAnimation(); | 214 frameView->scheduleAnimation(); |
237 } | 215 } |
238 | 216 |
239 } | 217 } |
OLD | NEW |