mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 23:25:20 +00:00
LibWeb: Separate "event listener" from "EventListener"
I can't imagine how this happened, but it seems we've managed to
conflate the "event listener" and "EventListener" concepts from the DOM
specification in some parts of the code.
We previously had two things:
- DOM::EventListener
- DOM::EventTarget::EventListenerRegistration
DOM::EventListener was roughly the "EventListener" IDL type,
and DOM::EventTarget::EventListenerRegistration was roughly the "event
listener" concept. However, they were used interchangeably (and
incorrectly!) in many places.
After this patch, we now have:
- DOM::IDLEventListener
- DOM::DOMEventListener
DOM::IDLEventListener is the "EventListener" IDL type,
and DOM::DOMEventListener is the "event listener" concept.
This patch also updates the addEventListener() and removeEventListener()
functions to follow the spec more closely, along with the "inner invoke"
function in our EventDispatcher.
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
#include <LibWeb/CSS/MediaQueryList.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/EventDispatcher.h>
|
||||
#include <LibWeb/DOM/EventListener.h>
|
||||
#include <LibWeb/DOM/IDLEventListener.h>
|
||||
#include <LibWeb/HTML/EventHandler.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
@@ -61,7 +61,7 @@ JS::Object* MediaQueryList::create_wrapper(JS::GlobalObject& global_object)
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/cssom-view/#dom-mediaquerylist-addlistener
|
||||
void MediaQueryList::add_listener(RefPtr<DOM::EventListener> listener)
|
||||
void MediaQueryList::add_listener(RefPtr<DOM::IDLEventListener> listener)
|
||||
{
|
||||
// 1. If listener is null, terminate these steps.
|
||||
if (!listener)
|
||||
@@ -75,7 +75,7 @@ void MediaQueryList::add_listener(RefPtr<DOM::EventListener> listener)
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/cssom-view/#dom-mediaquerylist-removelistener
|
||||
void MediaQueryList::remove_listener(RefPtr<DOM::EventListener> listener)
|
||||
void MediaQueryList::remove_listener(RefPtr<DOM::IDLEventListener> listener)
|
||||
{
|
||||
// 1. Remove an event listener from the associated list of event listeners, whose type is change, callback is listener, and capture is false.
|
||||
// NOTE: While the spec doesn't technically use remove_event_listener and instead manipulates the list directly, every major engine uses remove_event_listener.
|
||||
|
||||
Reference in New Issue
Block a user