LibWeb: Use HeapFunction for EventLoopPlugin::spin_until

This commit is contained in:
Shannon Booth 2024-10-31 01:06:56 +13:00 committed by Alexander Kalenik
commit 7487a782db
Notes: github-actions[bot] 2024-10-30 19:57:14 +00:00
15 changed files with 29 additions and 26 deletions

View file

@ -470,9 +470,9 @@ void execute_async_script(HTML::BrowsingContext const& browsing_context, ByteStr
return;
auto& script_promise = static_cast<JS::Promise&>(*script_promise_or_error.value());
vm.custom_data()->spin_event_loop_until([&] {
vm.custom_data()->spin_event_loop_until(JS::create_heap_function(vm.heap(), [timer, &script_promise]() {
return timer->is_timed_out() || script_promise.state() != JS::Promise::State::Pending;
});
}));
// 10. Upon fulfillment of scriptPromise with value v, resolve promise with value v.
if (script_promise.state() == JS::Promise::State::Fulfilled)

View file

@ -102,7 +102,7 @@ Response capture_element_screenshot(Painter const& painter, Page& page, DOM::Ele
encoded_string_or_error = encode_canvas_element(canvas_or_error.release_value());
});
Platform::EventLoopPlugin::the().spin_until([&]() { return encoded_string_or_error.has_value(); });
Platform::EventLoopPlugin::the().spin_until(JS::create_heap_function(element.document().heap(), [&]() { return encoded_string_or_error.has_value(); }));
return encoded_string_or_error.release_value();
}