1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:27:45 +00:00

LibWeb: Convert DOM::AbortSignal to use JS::SafeFunction

This protects the captured GC pointers automatically instead of
manually.
This commit is contained in:
Luke Wilde 2022-10-26 18:09:24 +01:00 committed by Linus Groh
parent 67e396d931
commit 07e3bb729d
3 changed files with 6 additions and 5 deletions

View file

@ -170,9 +170,10 @@ void EventTarget::add_an_event_listener(DOMEventListener& listener)
// 5. If listeners signal is not null, then add the following abort steps to it:
if (listener.signal) {
listener.signal->add_abort_algorithm([strong_event_target = JS::make_handle(*this), listener = JS::make_handle(&listener)]() mutable {
// NOTE: `this` and `listener` are protected by AbortSignal using JS::SafeFunction.
listener.signal->add_abort_algorithm([this, &listener]() mutable {
// 1. Remove an event listener with eventTarget and listener.
strong_event_target->remove_an_event_listener(*listener);
remove_an_event_listener(listener);
});
}
}