RESOLVED FIXED 218753
Support AbortSignal in addEventListenerOptions to unsubscribe from events
https://bugs.webkit.org/show_bug.cgi?id=218753
Summary Support AbortSignal in addEventListenerOptions to unsubscribe from events
Benjamin Gruenbaum
Reported 2020-11-10 08:19:29 PST
See https://github.com/whatwg/dom/issues/911 and the spec PR https://github.com/whatwg/dom/pull/919 I am working on adding support for AbortController in various web APIs. One of those is adding support for passing `AbortSignal`s to `addEventListener` and have an easy way to remove a lot of listeners. As per the WHATWG process - I am filing a WebKit bug. Please feel free to ask any questions or make suggestions regarding this. I will follow up with WPTs in that PR.
Attachments
Patch (81.77 KB, patch)
2021-01-22 15:26 PST, Chris Dumez
no flags
Patch (81.85 KB, patch)
2021-01-22 15:30 PST, Chris Dumez
ews-feeder: commit-queue-
Patch (82.44 KB, patch)
2021-01-22 16:33 PST, Chris Dumez
no flags
Patch (82.96 KB, patch)
2021-01-22 17:59 PST, Chris Dumez
no flags
Patch (82.95 KB, patch)
2021-01-25 09:07 PST, Chris Dumez
no flags
Radar WebKit Bug Importer
Comment 1 2020-11-10 15:34:28 PST
Chris Dumez
Comment 2 2021-01-22 15:26:04 PST
Chris Dumez
Comment 3 2021-01-22 15:30:03 PST
Chris Dumez
Comment 4 2021-01-22 16:33:20 PST
EWS Watchlist
Comment 5 2021-01-22 16:34:32 PST
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See https://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Chris Dumez
Comment 6 2021-01-22 17:59:37 PST
Darin Adler
Comment 7 2021-01-23 12:22:01 PST
Comment on attachment 418202 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=418202&action=review > Source/WebCore/dom/AddEventListenerOptions.h:41 > + AddEventListenerOptions(bool capture = false, Optional<bool> passive = WTF::nullopt, bool once = false, RefPtr<AbortSignal>&& signal = nullptr) > + : EventListenerOptions(capture) > + , passive(passive) > + , once(once) > + , signal(WTFMove(signal)) > + { > + } It’s nice to have structs with default values but without constructors when we can. I guess there is code that depends on this? > Source/WebCore/dom/EventListener.h:37 > +class EventListener : public RefCounted<EventListener>, public CanMakeWeakPtr<EventListener> { I’m assuming there are not cases where an EventListener was: 1) not already doing the weak pointer thing 2) a small object allocated many, many times But I didn’t audit all the uses the way I often would when asking myself a question like that. > Source/WebCore/dom/EventListenerOptions.h:33 > + EventListenerOptions(bool capture = false) > + : capture(capture) > + { } It’s nice to have structs with default values but without constructors when we can. I guess there is code that depends on this?
Chris Dumez
Comment 8 2021-01-25 08:58:15 PST
Comment on attachment 418202 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=418202&action=review >> Source/WebCore/dom/AddEventListenerOptions.h:41 >> + } > > It’s nice to have structs with default values but without constructors when we can. I guess there is code that depends on this? There are call sites that call addEventListener with a simple boolean like so: addEventListener(type, listener, true) Using struct initialization here would be a bit awkward here I think, especially considering it involves struct inheritance.
Chris Dumez
Comment 9 2021-01-25 09:07:30 PST
EWS
Comment 10 2021-01-25 12:06:31 PST
Committed r271806: <https://trac.webkit.org/changeset/271806> All reviewed patches have been landed. Closing bug and clearing flags on attachment 418299 [details].
Note You need to log in before you can comment on or make changes to this bug.