From c33f6b2ff6aa4e29cdc42afe1c3928f4cefad037 Mon Sep 17 00:00:00 2001 From: Matthew Olsson Date: Wed, 27 Mar 2024 18:45:51 -0700 Subject: [PATCH] LibWeb: Ensure requestAnimationFrame callbacks run in the proper order From https://html.spec.whatwg.org/#list-of-animation-frame-callbacks: Each target object has a map of animation frame callbacks, which is an ordered map that must be initially empty, and an animation frame callback identifier, which is a number that must initially be zero. --- .../request-animation-frame-order.txt | 20 +++++++++++++++++++ .../input/request-animation-frame-order.html | 14 +++++++++++++ .../HTML/AnimationFrameCallbackDriver.h | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Text/expected/request-animation-frame-order.txt create mode 100644 Tests/LibWeb/Text/input/request-animation-frame-order.html diff --git a/Tests/LibWeb/Text/expected/request-animation-frame-order.txt b/Tests/LibWeb/Text/expected/request-animation-frame-order.txt new file mode 100644 index 00000000000..c9e9f4a0fd8 --- /dev/null +++ b/Tests/LibWeb/Text/expected/request-animation-frame-order.txt @@ -0,0 +1,20 @@ + 0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 diff --git a/Tests/LibWeb/Text/input/request-animation-frame-order.html b/Tests/LibWeb/Text/input/request-animation-frame-order.html new file mode 100644 index 00000000000..24b87c1404c --- /dev/null +++ b/Tests/LibWeb/Text/input/request-animation-frame-order.html @@ -0,0 +1,14 @@ + +
+ + diff --git a/Userland/Libraries/LibWeb/HTML/AnimationFrameCallbackDriver.h b/Userland/Libraries/LibWeb/HTML/AnimationFrameCallbackDriver.h index 3c5b07811a0..29894f67323 100644 --- a/Userland/Libraries/LibWeb/HTML/AnimationFrameCallbackDriver.h +++ b/Userland/Libraries/LibWeb/HTML/AnimationFrameCallbackDriver.h @@ -56,7 +56,7 @@ struct AnimationFrameCallbackDriver { } private: - HashMap m_callbacks; + OrderedHashMap m_callbacks; IDAllocator m_id_allocator; RefPtr m_timer; };