| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 const AtomicString& eventInterfaceFilter) { | 92 const AtomicString& eventInterfaceFilter) { |
| 93 HeapVector<Member<Event>> events; | 93 HeapVector<Member<Event>> events; |
| 94 if (eventInterfaceFilter.isEmpty()) { | 94 if (eventInterfaceFilter.isEmpty()) { |
| 95 events.swap(m_eventQueue); | 95 events.swap(m_eventQueue); |
| 96 m_perFrameEvents.clear(); | 96 m_perFrameEvents.clear(); |
| 97 } else { | 97 } else { |
| 98 HeapVector<Member<Event>> remaining; | 98 HeapVector<Member<Event>> remaining; |
| 99 for (auto& event : m_eventQueue) { | 99 for (auto& event : m_eventQueue) { |
| 100 if (event && event->interfaceName() == eventInterfaceFilter) { | 100 if (event && event->interfaceName() == eventInterfaceFilter) { |
| 101 m_perFrameEvents.remove(eventTargetKey(event.get())); | 101 m_perFrameEvents.remove(eventTargetKey(event.get())); |
| 102 events.append(event.release()); | 102 events.push_back(event.release()); |
| 103 } else { | 103 } else { |
| 104 remaining.append(event.release()); | 104 remaining.push_back(event.release()); |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 remaining.swap(m_eventQueue); | 107 remaining.swap(m_eventQueue); |
| 108 } | 108 } |
| 109 | 109 |
| 110 for (const auto& event : events) { | 110 for (const auto& event : events) { |
| 111 EventTarget* eventTarget = event->target(); | 111 EventTarget* eventTarget = event->target(); |
| 112 // FIXME: we should figure out how to make dispatchEvent properly virtual to | 112 // FIXME: we should figure out how to make dispatchEvent properly virtual to |
| 113 // avoid special casting window. | 113 // avoid special casting window. |
| 114 // FIXME: We should not fire events for nodes that are no longer in the | 114 // FIXME: We should not fire events for nodes that are no longer in the |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 callMediaQueryListListeners(); | 163 callMediaQueryListListeners(); |
| 164 dispatchEvents(); | 164 dispatchEvents(); |
| 165 runTasks(); | 165 runTasks(); |
| 166 executeCallbacks(monotonicTimeNow); | 166 executeCallbacks(monotonicTimeNow); |
| 167 | 167 |
| 168 scheduleAnimationIfNeeded(); | 168 scheduleAnimationIfNeeded(); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void ScriptedAnimationController::enqueueTask( | 171 void ScriptedAnimationController::enqueueTask( |
| 172 std::unique_ptr<WTF::Closure> task) { | 172 std::unique_ptr<WTF::Closure> task) { |
| 173 m_taskQueue.append(std::move(task)); | 173 m_taskQueue.push_back(std::move(task)); |
| 174 scheduleAnimationIfNeeded(); | 174 scheduleAnimationIfNeeded(); |
| 175 } | 175 } |
| 176 | 176 |
| 177 void ScriptedAnimationController::enqueueEvent(Event* event) { | 177 void ScriptedAnimationController::enqueueEvent(Event* event) { |
| 178 InspectorInstrumentation::asyncTaskScheduled( | 178 InspectorInstrumentation::asyncTaskScheduled( |
| 179 event->target()->getExecutionContext(), event->type(), event); | 179 event->target()->getExecutionContext(), event->type(), event); |
| 180 m_eventQueue.append(event); | 180 m_eventQueue.push_back(event); |
| 181 scheduleAnimationIfNeeded(); | 181 scheduleAnimationIfNeeded(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 void ScriptedAnimationController::enqueuePerFrameEvent(Event* event) { | 184 void ScriptedAnimationController::enqueuePerFrameEvent(Event* event) { |
| 185 if (!m_perFrameEvents.add(eventTargetKey(event)).isNewEntry) | 185 if (!m_perFrameEvents.add(eventTargetKey(event)).isNewEntry) |
| 186 return; | 186 return; |
| 187 enqueueEvent(event); | 187 enqueueEvent(event); |
| 188 } | 188 } |
| 189 | 189 |
| 190 void ScriptedAnimationController::enqueueMediaQueryChangeListeners( | 190 void ScriptedAnimationController::enqueueMediaQueryChangeListeners( |
| 191 HeapVector<Member<MediaQueryListListener>>& listeners) { | 191 HeapVector<Member<MediaQueryListListener>>& listeners) { |
| 192 for (const auto& listener : listeners) { | 192 for (const auto& listener : listeners) { |
| 193 m_mediaQueryListListeners.add(listener); | 193 m_mediaQueryListListeners.add(listener); |
| 194 } | 194 } |
| 195 scheduleAnimationIfNeeded(); | 195 scheduleAnimationIfNeeded(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void ScriptedAnimationController::scheduleAnimationIfNeeded() { | 198 void ScriptedAnimationController::scheduleAnimationIfNeeded() { |
| 199 if (!hasScheduledItems()) | 199 if (!hasScheduledItems()) |
| 200 return; | 200 return; |
| 201 | 201 |
| 202 if (!m_document) | 202 if (!m_document) |
| 203 return; | 203 return; |
| 204 | 204 |
| 205 if (FrameView* frameView = m_document->view()) | 205 if (FrameView* frameView = m_document->view()) |
| 206 frameView->scheduleAnimation(); | 206 frameView->scheduleAnimation(); |
| 207 } | 207 } |
| 208 | 208 |
| 209 } // namespace blink | 209 } // namespace blink |
| OLD | NEW |