LibWeb: Remove unnecessary WeakPtr in queue_microtask_impl()

Capturing a WeakPtr to a GC-allocated object in a JS::SafeFunction is
basically pointless, since the SafeFunction mechanism will then keep
the object alive anyway.
This commit is contained in:
Andreas Kling 2022-10-16 15:19:13 +02:00
parent 57f508f048
commit 94f0c34dfe
Notes: sideshowbarker 2024-07-17 05:17:50 +09:00

View file

@ -488,15 +488,11 @@ void Window::fire_a_page_transition_event(FlyString const& event_name, bool pers
void Window::queue_microtask_impl(WebIDL::CallbackType& callback)
{
// The queueMicrotask(callback) method must queue a microtask to invoke callback,
HTML::queue_a_microtask(&associated_document(), [weak_window = make_weak_ptr<Window>(), &callback]() mutable {
JS::GCPtr<Window> window = weak_window.ptr();
if (!window)
return;
HTML::queue_a_microtask(&associated_document(), [this, &callback]() mutable {
auto result = WebIDL::invoke_callback(callback, {});
// and if callback throws an exception, report the exception.
if (result.is_error())
HTML::report_exception(result, window->realm());
HTML::report_exception(result, realm());
});
}