mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:17:44 +00:00
LibWeb: Make event dispatching spec-compliant
Specification: https://dom.spec.whatwg.org/#concept-event-dispatch This also introduces shadow roots due to it being a requirement of the event dispatcher. However, it does not introduce the full shadow DOM, that can be left for future work. This changes some event dispatches which require certain attributes to be initialised to a value.
This commit is contained in:
parent
819f099a8e
commit
e8b3a65581
32 changed files with 858 additions and 54 deletions
|
@ -27,6 +27,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/FlyString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/Noncopyable.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibJS/Forward.h>
|
||||
|
@ -47,10 +48,14 @@ public:
|
|||
void add_event_listener(const FlyString& event_name, NonnullRefPtr<EventListener>);
|
||||
void remove_event_listener(const FlyString& event_name, NonnullRefPtr<EventListener>);
|
||||
|
||||
virtual void dispatch_event(NonnullRefPtr<Event>) = 0;
|
||||
void remove_from_event_listener_list(NonnullRefPtr<EventListener>);
|
||||
|
||||
virtual bool dispatch_event(NonnullRefPtr<Event>) = 0;
|
||||
virtual Bindings::EventTargetWrapper* create_wrapper(JS::GlobalObject&) = 0;
|
||||
Bindings::ScriptExecutionContext* script_execution_context() { return m_script_execution_context; }
|
||||
|
||||
virtual EventTarget* get_parent(const Event&) { return nullptr; }
|
||||
|
||||
struct EventListenerRegistration {
|
||||
FlyString event_name;
|
||||
NonnullRefPtr<EventListener> listener;
|
||||
|
@ -58,6 +63,15 @@ public:
|
|||
|
||||
const Vector<EventListenerRegistration>& listeners() const { return m_listeners; }
|
||||
|
||||
virtual bool is_node() const { return false; }
|
||||
virtual bool is_window() const { return false; }
|
||||
|
||||
Function<void(const Event&)> activation_behaviour;
|
||||
|
||||
// NOTE: These only exist for checkbox and radio input elements.
|
||||
Function<void()> legacy_pre_activation_behaviour;
|
||||
Function<void()> legacy_cancelled_activation_behaviour;
|
||||
|
||||
protected:
|
||||
explicit EventTarget(Bindings::ScriptExecutionContext&);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue