mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibWeb: Make requestAnimationFrame() callback IDs sequential
This is required by the spec, so let's stop returning random IDs in favor of a simple sequential integer sequence.
This commit is contained in:
parent
a034d1e675
commit
0e1256e5a4
Notes:
github-actions[bot]
2024-08-05 07:13:03 +00:00
Author: https://github.com/awesomekling
Commit: 0e1256e5a4
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/962
6 changed files with 32 additions and 14 deletions
|
@ -1438,7 +1438,7 @@ double Window::device_pixel_ratio() const
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#dom-animationframeprovider-requestanimationframe
|
||||
i32 Window::request_animation_frame(WebIDL::CallbackType& callback)
|
||||
WebIDL::UnsignedLong Window::request_animation_frame(WebIDL::CallbackType& callback)
|
||||
{
|
||||
// FIXME: Make this fully spec compliant. Currently implements a mix of 'requestAnimationFrame()' and 'run the animation frame callbacks'.
|
||||
return m_animation_frame_callback_driver.add([this, callback = JS::make_handle(callback)](double now) {
|
||||
|
@ -1450,14 +1450,14 @@ i32 Window::request_animation_frame(WebIDL::CallbackType& callback)
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#animationframeprovider-cancelanimationframe
|
||||
void Window::cancel_animation_frame(i32 handle)
|
||||
void Window::cancel_animation_frame(WebIDL::UnsignedLong handle)
|
||||
{
|
||||
// 1. If this is not supported, then throw a "NotSupportedError" DOMException.
|
||||
// NOTE: Doesn't apply in this Window-specific implementation.
|
||||
|
||||
// 2. Let callbacks be this's target object's map of animation frame callbacks.
|
||||
// 3. Remove callbacks[handle].
|
||||
m_animation_frame_callback_driver.remove(handle);
|
||||
(void)m_animation_frame_callback_driver.remove(handle);
|
||||
}
|
||||
|
||||
// https://w3c.github.io/requestidlecallback/#dom-window-requestidlecallback
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue