1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 00:35:08 +00:00

LibWeb: Use JS::SafeFunction in the HTML task queues

This means that HTML tasks automatically protect anything in their
capture lists, and we no longer need to jump through hoops with
JS::Handle etc.
This commit is contained in:
Andreas Kling 2022-09-24 12:04:06 +02:00
parent 131c3f50de
commit d505192014
4 changed files with 13 additions and 11 deletions

View file

@ -231,13 +231,13 @@ void EventLoop::process()
// FIXME: This is here to paper over an issue in the HTML parser where it'll create new interpreters (and thus ESOs) on temporary documents created for innerHTML if it uses Document::realm() to get the global object.
// Use queue_global_task instead.
void old_queue_global_task_with_document(HTML::Task::Source source, DOM::Document& document, Function<void()> steps)
void old_queue_global_task_with_document(HTML::Task::Source source, DOM::Document& document, JS::SafeFunction<void()> steps)
{
main_thread_event_loop().task_queue().add(HTML::Task::create(source, &document, move(steps)));
}
// https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-global-task
void queue_global_task(HTML::Task::Source source, JS::Object& global_object, Function<void()> steps)
void queue_global_task(HTML::Task::Source source, JS::Object& global_object, JS::SafeFunction<void()> steps)
{
// 1. Let event loop be global's relevant agent's event loop.
auto& global_custom_data = verify_cast<Bindings::WebEngineCustomData>(*global_object.vm().custom_data());
@ -255,7 +255,7 @@ void queue_global_task(HTML::Task::Source source, JS::Object& global_object, Fun
}
// https://html.spec.whatwg.org/#queue-a-microtask
void queue_a_microtask(DOM::Document* document, Function<void()> steps)
void queue_a_microtask(DOM::Document* document, JS::SafeFunction<void()> steps)
{
// 1. If event loop was not given, set event loop to the implied event loop.
auto& event_loop = HTML::main_thread_event_loop();