mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 12:27:34 +00:00
LibWeb: Move event listeners, handlers and callbacks to the GC heap
This patch moves the following things to being GC-allocated: - Bindings::CallbackType - HTML::EventHandler - DOM::IDLEventListener - DOM::DOMEventListener - DOM::NodeFilter Note that we only use PlatformObject for things that might be exposed to web content. Anything that is only used internally inherits directly from JS::Cell instead, making them a bit more lightweight.
This commit is contained in:
parent
967a3e5a45
commit
8cda70c892
57 changed files with 425 additions and 345 deletions
|
@ -29,12 +29,12 @@ public:
|
|||
|
||||
virtual bool is_focusable() const { return 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);
|
||||
void add_event_listener(FlyString const& type, IDLEventListener* callback, Variant<AddEventListenerOptions, bool> const& options);
|
||||
void remove_event_listener(FlyString const& type, 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);
|
||||
void add_event_listener_without_options(FlyString const& type, IDLEventListener& callback);
|
||||
void remove_event_listener_without_options(FlyString const& type, IDLEventListener& callback);
|
||||
|
||||
virtual bool dispatch_event(NonnullRefPtr<Event>);
|
||||
ExceptionOr<bool> dispatch_event_binding(NonnullRefPtr<Event>);
|
||||
|
@ -43,7 +43,7 @@ public:
|
|||
|
||||
virtual EventTarget* get_parent(Event const&) { return nullptr; }
|
||||
|
||||
void add_an_event_listener(NonnullRefPtr<DOMEventListener>);
|
||||
void add_an_event_listener(DOMEventListener&);
|
||||
void remove_an_event_listener(DOMEventListener&);
|
||||
void remove_from_event_listener_list(DOMEventListener&);
|
||||
|
||||
|
@ -58,7 +58,7 @@ public:
|
|||
virtual void legacy_cancelled_activation_behavior_was_not_called() { }
|
||||
|
||||
Bindings::CallbackType* event_handler_attribute(FlyString const& name);
|
||||
void set_event_handler_attribute(FlyString const& name, Optional<Bindings::CallbackType>);
|
||||
void set_event_handler_attribute(FlyString const& name, Bindings::CallbackType*);
|
||||
|
||||
protected:
|
||||
EventTarget();
|
||||
|
@ -69,11 +69,11 @@ protected:
|
|||
void element_event_handler_attribute_changed(FlyString const& local_name, String const& value);
|
||||
|
||||
private:
|
||||
Vector<NonnullRefPtr<DOMEventListener>> m_event_listener_list;
|
||||
Vector<JS::Handle<DOMEventListener>> m_event_listener_list;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-map
|
||||
// Spec Note: The order of the entries of event handler map could be arbitrary. It is not observable through any algorithms that operate on the map.
|
||||
HashMap<FlyString, HTML::EventHandler> m_event_handler_map;
|
||||
HashMap<FlyString, JS::Handle<HTML::EventHandler>> m_event_handler_map;
|
||||
|
||||
Bindings::CallbackType* get_current_value_of_event_handler(FlyString const& name);
|
||||
void activate_event_handler(FlyString const& name, HTML::EventHandler& event_handler);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue