mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibWeb/HTML: Port Window.cancelAnimationFrame() to IDL
This commit is contained in:
parent
211e6c1fbc
commit
a2fb3a1653
Notes:
sideshowbarker
2024-07-17 21:11:12 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/a2fb3a1653 Pull-request: https://github.com/SerenityOS/serenity/pull/17752 Reviewed-by: https://github.com/awesomekling
3 changed files with 13 additions and 18 deletions
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -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<HTML::Location>, AK::URL const& new_href)
|
||||
{
|
||||
auto* browsing_context = associated_document().browsing_context();
|
||||
|
@ -896,7 +891,6 @@ WebIDL::ExceptionOr<void> Window::initialize_web_interfaces(Badge<WindowEnvironm
|
|||
define_native_function(realm, "setTimeout", set_timeout, 1, attr);
|
||||
define_native_function(realm, "clearInterval", clear_interval, 1, attr);
|
||||
define_native_function(realm, "clearTimeout", clear_timeout, 1, attr);
|
||||
define_native_function(realm, "cancelAnimationFrame", cancel_animation_frame, 1, attr);
|
||||
|
||||
define_native_function(realm, "queueMicrotask", queue_microtask, 1, attr);
|
||||
|
||||
|
@ -1431,6 +1425,17 @@ 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)
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
|
||||
// https://w3c.github.io/requestidlecallback/#dom-window-requestidlecallback
|
||||
u32 Window::request_idle_callback(WebIDL::CallbackType& callback, RequestIdleCallback::IdleRequestOptions const& options)
|
||||
{
|
||||
|
@ -1575,16 +1580,6 @@ JS_DEFINE_NATIVE_FUNCTION(Window::clear_interval)
|
|||
return JS::js_undefined();
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(Window::cancel_animation_frame)
|
||||
{
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
if (!vm.argument_count())
|
||||
return vm.throw_completion<JS::TypeError>(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));
|
||||
|
|
|
@ -88,7 +88,6 @@ public:
|
|||
void set_import_maps_allowed(bool import_maps_allowed) { m_import_maps_allowed = import_maps_allowed; }
|
||||
|
||||
WebIDL::ExceptionOr<JS::GCPtr<HTML::WindowProxy>> 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<JS::Value> 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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue