Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(736)

Unified Diff: third_party/WebKit/Source/core/dom/ScriptedAnimationController.cpp

Issue 2536643002: Introduce animation frame tasks (Closed)
Patch Set: drop 'the' Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/ScriptedAnimationController.cpp
diff --git a/third_party/WebKit/Source/core/dom/ScriptedAnimationController.cpp b/third_party/WebKit/Source/core/dom/ScriptedAnimationController.cpp
index 05e09a4ca48b9b9877118a3151132cf402a5f9fd..d834fe81dbd587e5d1cf73251593287a4d189205 100644
--- a/third_party/WebKit/Source/core/dom/ScriptedAnimationController.cpp
+++ b/third_party/WebKit/Source/core/dom/ScriptedAnimationController.cpp
@@ -81,6 +81,13 @@ void ScriptedAnimationController::cancelCallback(CallbackId id) {
m_callbackCollection.cancelCallback(id);
}
+void ScriptedAnimationController::runTasks() {
+ Vector<std::unique_ptr<WTF::Closure>> tasks;
+ tasks.swap(m_taskQueue);
+ for (auto& task : tasks)
+ (*task)();
+}
+
void ScriptedAnimationController::dispatchEvents(
const AtomicString& eventInterfaceFilter) {
HeapVector<Member<Event>> events;
@@ -144,8 +151,8 @@ bool ScriptedAnimationController::hasScheduledItems() const {
if (m_suspendCount)
return false;
- return !m_callbackCollection.isEmpty() || !m_eventQueue.isEmpty() ||
- !m_mediaQueryListListeners.isEmpty();
+ return !m_callbackCollection.isEmpty() || !m_taskQueue.isEmpty() ||
+ !m_eventQueue.isEmpty() || !m_mediaQueryListListeners.isEmpty();
}
void ScriptedAnimationController::serviceScriptedAnimations(
@@ -155,11 +162,18 @@ void ScriptedAnimationController::serviceScriptedAnimations(
callMediaQueryListListeners();
dispatchEvents();
+ runTasks();
executeCallbacks(monotonicTimeNow);
scheduleAnimationIfNeeded();
}
+void ScriptedAnimationController::enqueueTask(
+ std::unique_ptr<WTF::Closure> task) {
+ m_taskQueue.append(std::move(task));
+ scheduleAnimationIfNeeded();
+}
+
void ScriptedAnimationController::enqueueEvent(Event* event) {
InspectorInstrumentation::asyncTaskScheduled(
event->target()->getExecutionContext(), event->type(), event);

Powered by Google App Engine
This is Rietveld 408576698