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

LibWeb: Add support for the options variant of {add,remove}EventListener

This also adds a variant of {add,remove}_event_listener called
{add,remove}_event_listener_with_options.

This is used internally to perform {add,remove}_event_listener with a
default constructed options struct. It was done like this because
default constructing the Variant with the options struct requires the
struct defintions to be present, which requires us to include
AbortSignal.h, which would cause a circular include as AbortSignal.h
includes EventTarget.h.
This commit is contained in:
Luke Wilde 2022-02-19 22:02:32 +00:00 committed by Andreas Kling
parent 0e6c7eea0f
commit 3479f1c4e8
6 changed files with 121 additions and 22 deletions

View file

@ -29,8 +29,12 @@ public:
virtual bool is_focusable() const { return false; }
void add_event_listener(FlyString const& type, RefPtr<IDLEventListener> callback, bool use_capture = false);
void remove_event_listener(FlyString const& type, RefPtr<IDLEventListener> callback, bool use_capture = false);
void add_event_listener(FlyString const& type, RefPtr<IDLEventListener> callback, Variant<AddEventListenerOptions, bool> const& options);
void remove_event_listener(FlyString const& type, RefPtr<IDLEventListener> callback, Variant<EventListenerOptions, bool> const& options);
// NOTE: These are for internal use only. They operate as though addEventListener(type, callback) was called instead of addEventListener(type, callback, options).
void add_event_listener_without_options(FlyString const& type, RefPtr<IDLEventListener> callback);
void remove_event_listener_without_options(FlyString const& type, RefPtr<IDLEventListener> callback);
virtual bool dispatch_event(NonnullRefPtr<Event>);
ExceptionOr<bool> dispatch_event_binding(NonnullRefPtr<Event>);