From a2fb3a1653cd8b963c1840af5f4a0ba981de2708 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Tue, 7 Mar 2023 18:14:33 +0000 Subject: [PATCH] LibWeb/HTML: Port Window.cancelAnimationFrame() to IDL --- .../LibWeb/HTML/AnimationFrameProvider.idl | 1 + Userland/Libraries/LibWeb/HTML/Window.cpp | 27 ++++++++----------- Userland/Libraries/LibWeb/HTML/Window.h | 3 +-- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/AnimationFrameProvider.idl b/Userland/Libraries/LibWeb/HTML/AnimationFrameProvider.idl index 91db5edabba..c34ab2974fc 100644 --- a/Userland/Libraries/LibWeb/HTML/AnimationFrameProvider.idl +++ b/Userland/Libraries/LibWeb/HTML/AnimationFrameProvider.idl @@ -5,4 +5,5 @@ callback FrameRequestCallback = undefined (DOMHighResTimeStamp time); // https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#animationframeprovider interface mixin AnimationFrameProvider { unsigned long requestAnimationFrame(FrameRequestCallback callback); + undefined cancelAnimationFrame(unsigned long handle); }; diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp index 22d077b44ff..134204410c4 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.cpp +++ b/Userland/Libraries/LibWeb/HTML/Window.cpp @@ -536,11 +536,6 @@ i32 Window::run_timer_initialization_steps(TimerHandler handler, i32 timeout, JS return id; } -void Window::cancel_animation_frame_impl(i32 id) -{ - m_animation_frame_callback_driver.remove(id); -} - void Window::did_set_location_href(Badge, AK::URL const& new_href) { auto* browsing_context = associated_document().browsing_context(); @@ -896,7 +891,6 @@ WebIDL::ExceptionOr Window::initialize_web_interfaces(Badge(JS::ErrorType::BadArgCountOne, "cancelAnimationFrame"); - auto id = TRY(vm.argument(0).to_i32(vm)); - impl->cancel_animation_frame_impl(id); - return JS::js_undefined(); -} - JS_DEFINE_NATIVE_FUNCTION(Window::queue_microtask) { auto* impl = TRY(impl_from(vm)); diff --git a/Userland/Libraries/LibWeb/HTML/Window.h b/Userland/Libraries/LibWeb/HTML/Window.h index ef8cd46d08f..bc5eadfe22b 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.h +++ b/Userland/Libraries/LibWeb/HTML/Window.h @@ -88,7 +88,6 @@ public: void set_import_maps_allowed(bool import_maps_allowed) { m_import_maps_allowed = import_maps_allowed; } WebIDL::ExceptionOr> open_impl(StringView url, StringView target, StringView features); - void cancel_animation_frame_impl(i32); bool has_animation_frame_callbacks() const { return m_animation_frame_callback_driver.has_callbacks(); } i32 set_timeout_impl(TimerHandler, i32 timeout, JS::MarkedVector arguments); @@ -178,6 +177,7 @@ public: double device_pixel_ratio() const; i32 request_animation_frame(WebIDL::CallbackType&); + void cancel_animation_frame(i32 handle); u32 request_idle_callback(WebIDL::CallbackType&, RequestIdleCallback::IdleRequestOptions const&); void cancel_idle_callback(u32 handle); @@ -259,7 +259,6 @@ private: JS_DECLARE_NATIVE_FUNCTION(set_timeout); JS_DECLARE_NATIVE_FUNCTION(clear_interval); JS_DECLARE_NATIVE_FUNCTION(clear_timeout); - JS_DECLARE_NATIVE_FUNCTION(cancel_animation_frame); JS_DECLARE_NATIVE_FUNCTION(queue_microtask);