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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 } | 107 } |
108 } | 108 } |
109 } | 109 } |
110 | 110 |
111 void ScriptedAnimationController::serviceScriptedAnimations(double monotonicTime
Now) | 111 void ScriptedAnimationController::serviceScriptedAnimations(double monotonicTime
Now) |
112 { | 112 { |
113 if (!m_callbacks.size() || m_suspendCount || (m_document->settings() && !m_d
ocument->settings()->requestAnimationFrameEnabled())) | 113 if (!m_callbacks.size() || m_suspendCount || (m_document->settings() && !m_d
ocument->settings()->requestAnimationFrameEnabled())) |
114 return; | 114 return; |
115 | 115 |
116 double highResNowMs = 1000.0 * m_document->loader()->timing()->monotonicTime
ToZeroBasedDocumentTime(monotonicTimeNow); | 116 double highResNowMs = 1000.0 * m_document->loader()->timing()->monotonicTime
ToZeroBasedDocumentTime(monotonicTimeNow); |
| 117 double legacyHighResNowMs = 1000.0 * m_document->loader()->timing()->monoton
icTimeToPseudoWallTime(monotonicTimeNow); |
117 | 118 |
118 // First, generate a list of callbacks to consider. Callbacks registered fr
om this point | 119 // First, generate a list of callbacks to consider. Callbacks registered fr
om this point |
119 // on are considered only for the "next" frame, not this one. | 120 // on are considered only for the "next" frame, not this one. |
120 CallbackList callbacks(m_callbacks); | 121 CallbackList callbacks(m_callbacks); |
121 | 122 |
122 // Invoking callbacks may detach elements from our document, which clears th
e document's | 123 // Invoking callbacks may detach elements from our document, which clears th
e document's |
123 // reference to us, so take a defensive reference. | 124 // reference to us, so take a defensive reference. |
124 RefPtr<ScriptedAnimationController> protector(this); | 125 RefPtr<ScriptedAnimationController> protector(this); |
125 | 126 |
126 for (size_t i = 0; i < callbacks.size(); ++i) { | 127 for (size_t i = 0; i < callbacks.size(); ++i) { |
127 RequestAnimationFrameCallback* callback = callbacks[i].get(); | 128 RequestAnimationFrameCallback* callback = callbacks[i].get(); |
128 if (!callback->m_firedOrCancelled) { | 129 if (!callback->m_firedOrCancelled) { |
129 callback->m_firedOrCancelled = true; | 130 callback->m_firedOrCancelled = true; |
130 InspectorInstrumentationCookie cookie = InspectorInstrumentation::wi
llFireAnimationFrame(m_document, callback->m_id); | 131 InspectorInstrumentationCookie cookie = InspectorInstrumentation::wi
llFireAnimationFrame(m_document, callback->m_id); |
131 callback->handleEvent(highResNowMs); | 132 if (callback->m_useLegacyTimeBase) |
| 133 callback->handleEvent(legacyHighResNowMs); |
| 134 else |
| 135 callback->handleEvent(highResNowMs); |
132 InspectorInstrumentation::didFireAnimationFrame(cookie); | 136 InspectorInstrumentation::didFireAnimationFrame(cookie); |
133 } | 137 } |
134 } | 138 } |
135 | 139 |
136 // Remove any callbacks we fired from the list of pending callbacks. | 140 // Remove any callbacks we fired from the list of pending callbacks. |
137 for (size_t i = 0; i < m_callbacks.size();) { | 141 for (size_t i = 0; i < m_callbacks.size();) { |
138 if (m_callbacks[i]->m_firedOrCancelled) | 142 if (m_callbacks[i]->m_firedOrCancelled) |
139 m_callbacks.remove(i); | 143 m_callbacks.remove(i); |
140 else | 144 else |
141 ++i; | 145 ++i; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 serviceScriptedAnimations(monotonicTimeNow); | 197 serviceScriptedAnimations(monotonicTimeNow); |
194 } | 198 } |
195 #endif | 199 #endif |
196 #endif | 200 #endif |
197 | 201 |
198 | 202 |
199 | 203 |
200 } | 204 } |
201 | 205 |
202 #endif | 206 #endif |
OLD | NEW |