mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:17:45 +00:00
LibWeb: Support "useCapture" parameter to add/removeEventListener
This is not a complete implementation of API, since we're also supposed to accept an options dictionary as the third argument. However, a lot of web content uses the boolean variant, and it's trivial to support.
This commit is contained in:
parent
e76e8e22b5
commit
9521f71944
3 changed files with 8 additions and 8 deletions
|
@ -46,10 +46,10 @@ EventTarget::~EventTarget()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener
|
// https://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener
|
||||||
void EventTarget::add_event_listener(FlyString const& type, RefPtr<IDLEventListener> callback)
|
void EventTarget::add_event_listener(FlyString const& type, RefPtr<IDLEventListener> callback, bool use_capture)
|
||||||
{
|
{
|
||||||
// FIXME: 1. Let capture, passive, once, and signal be the result of flattening more options.
|
// FIXME: 1. Let capture, passive, once, and signal be the result of flattening more options.
|
||||||
bool capture = false;
|
bool capture = use_capture;
|
||||||
bool passive = false;
|
bool passive = false;
|
||||||
bool once = false;
|
bool once = false;
|
||||||
RefPtr<AbortSignal> signal = nullptr;
|
RefPtr<AbortSignal> signal = nullptr;
|
||||||
|
@ -96,10 +96,10 @@ void EventTarget::add_an_event_listener(NonnullRefPtr<DOMEventListener> listener
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-eventtarget-removeeventlistener
|
// https://dom.spec.whatwg.org/#dom-eventtarget-removeeventlistener
|
||||||
void EventTarget::remove_event_listener(FlyString const& type, RefPtr<IDLEventListener> callback)
|
void EventTarget::remove_event_listener(FlyString const& type, RefPtr<IDLEventListener> callback, bool use_capture)
|
||||||
{
|
{
|
||||||
// FIXME: 1. Let capture be the result of flattening options.
|
// FIXME: 1. Let capture be the result of flattening options.
|
||||||
bool capture = false;
|
bool capture = use_capture;
|
||||||
|
|
||||||
// 2. If this’s event listener list contains an event listener whose type is type, callback is callback, and capture is capture,
|
// 2. If this’s event listener list contains an event listener whose type is type, callback is callback, and capture is capture,
|
||||||
// then remove an event listener with this and that event listener.
|
// then remove an event listener with this and that event listener.
|
||||||
|
|
|
@ -30,8 +30,8 @@ public:
|
||||||
|
|
||||||
virtual bool is_focusable() const { return false; }
|
virtual bool is_focusable() const { return false; }
|
||||||
|
|
||||||
void add_event_listener(FlyString const& type, RefPtr<IDLEventListener> callback);
|
void add_event_listener(FlyString const& type, RefPtr<IDLEventListener> callback, bool use_capture = false);
|
||||||
void remove_event_listener(FlyString const& type, RefPtr<IDLEventListener> callback);
|
void remove_event_listener(FlyString const& type, RefPtr<IDLEventListener> callback, bool use_capture = false);
|
||||||
|
|
||||||
virtual bool dispatch_event(NonnullRefPtr<Event>);
|
virtual bool dispatch_event(NonnullRefPtr<Event>);
|
||||||
ExceptionOr<bool> dispatch_event_binding(NonnullRefPtr<Event>);
|
ExceptionOr<bool> dispatch_event_binding(NonnullRefPtr<Event>);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
interface EventTarget {
|
interface EventTarget {
|
||||||
|
|
||||||
// FIXME: Both of these should take in options
|
// FIXME: Both of these should take in options
|
||||||
undefined addEventListener(DOMString type, EventListener? callback);
|
undefined addEventListener(DOMString type, EventListener? callback, optional boolean useCapture = false);
|
||||||
undefined removeEventListener(DOMString type, EventListener? callback);
|
undefined removeEventListener(DOMString type, EventListener? callback, optional boolean useCapture = false);
|
||||||
|
|
||||||
[ImplementedAs=dispatch_event_binding] boolean dispatchEvent(Event event);
|
[ImplementedAs=dispatch_event_binding] boolean dispatchEvent(Event event);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue