LibWeb: Support removing callbacks from AbortSignal

This will be needed by Streams. To support this, we now store callbacks
in a hash table, keyed by an ID. Callers may use that ID to remove the
callback at a later point.
This commit is contained in:
Timothy Flynn 2025-04-10 09:04:01 -04:00 committed by Tim Flynn
parent f268f24dd5
commit 4010c4643a
Notes: github-actions[bot] 2025-04-11 16:11:54 +00:00
5 changed files with 22 additions and 11 deletions

View file

@ -231,7 +231,7 @@ void EventTarget::add_an_event_listener(DOMEventListener& listener)
// 6. If listeners signal is not null, then add the following abort steps to it:
if (listener.signal) {
// NOTE: `this` and `listener` are protected by AbortSignal using GC::HeapFunction.
listener.signal->add_abort_algorithm([this, &listener] {
(void)listener.signal->add_abort_algorithm([this, &listener] {
// 1. Remove an event listener with eventTarget and listener.
remove_an_event_listener(listener);
});