LibWeb: Do not create a RootVector to invoke IDL callbacks

These callbacks are evaluated synchronously via JS::Call. We do not need
to construct an expensive RootVector container just to immediately
invoke the callbacks.

Stylistically, this also helps indicate where the actual arguments start
at the call sites, by wrapping the arguments in braces.
This commit is contained in:
Timothy Flynn 2025-04-15 20:56:03 -04:00 committed by Tim Flynn
parent ca2f0141f6
commit 6dd2a4c945
Notes: github-actions[bot] 2025-04-16 11:32:56 +00:00
20 changed files with 60 additions and 119 deletions

View file

@ -1611,7 +1611,7 @@ WebIDL::UnsignedLong Window::request_animation_frame(GC::Ref<WebIDL::CallbackTyp
// FIXME: Make this fully spec compliant. Currently implements a mix of 'requestAnimationFrame()' and 'run the animation frame callbacks'.
return animation_frame_callback_driver().add(GC::create_function(heap(), [this, callback](double now) {
// 3. Invoke callback, passing now as the only argument, and if an exception is thrown, report the exception.
auto result = WebIDL::invoke_callback(*callback, {}, JS::Value(now));
auto result = WebIDL::invoke_callback(*callback, {}, { { JS::Value(now) } });
if (result.is_error())
report_exception(result, realm());
}));
@ -1655,7 +1655,7 @@ u32 Window::request_idle_callback(WebIDL::CallbackType& callback, RequestIdleCal
// 4. Push callback to the end of window's list of idle request callbacks, associated with handle.
auto handler = [callback = GC::make_root(callback)](GC::Ref<RequestIdleCallback::IdleDeadline> deadline) -> JS::Completion {
return WebIDL::invoke_callback(*callback, {}, deadline.ptr());
return WebIDL::invoke_callback(*callback, {}, { { deadline } });
};
m_idle_request_callbacks.append(adopt_ref(*new IdleCallback(move(handler), handle)));