From ffc648196a7e2745ff2b58a175a060f21ffb36fc Mon Sep 17 00:00:00 2001 From: Matthew Olsson Date: Wed, 27 Mar 2024 18:12:17 -0700 Subject: [PATCH] LibWeb: Dispatch animation events before requestAnimationFrame callbacks Most of the time there won't be any animation frame callbacks, and we can keep our behavior of dispatching events in the animation timer. --- Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp b/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp index 0737b211e85..6b43f205796 100644 --- a/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp +++ b/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp @@ -253,7 +253,13 @@ void EventLoop::process() }); // 10. For each fully active Document in docs, update animations and send events for that Document, passing in now as the timestamp. [WEBANIMATIONS] - // Note: This is handled by the document's animation timer + // Note: This is handled by the document's animation timer, however, if a document has any requestAnimationFrame callbacks, we need + // to dispatch events before that happens below. Not dispatching here would be observable. + for_each_fully_active_document_in_docs([&](DOM::Document& document) { + if (document.window()->animation_frame_callback_driver().has_callbacks()) { + document.update_animations_and_send_events(document.window()->performance()->now()); + } + }); // FIXME: 11. For each fully active Document in docs, run the fullscreen steps for that Document, passing in now as the timestamp. [FULLSCREEN]