1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:28:12 +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:
Andreas Kling 2022-08-08 14:12:01 +02:00
parent 967a3e5a45
commit 8cda70c892
57 changed files with 425 additions and 345 deletions

View file

@ -57,7 +57,7 @@ JS::Object* MediaQueryList::create_wrapper(JS::Realm& realm)
}
// https://www.w3.org/TR/cssom-view/#dom-mediaquerylist-addlistener
void MediaQueryList::add_listener(RefPtr<DOM::IDLEventListener> listener)
void MediaQueryList::add_listener(DOM::IDLEventListener* listener)
{
// 1. If listener is null, terminate these steps.
if (!listener)
@ -67,19 +67,19 @@ void MediaQueryList::add_listener(RefPtr<DOM::IDLEventListener> listener)
// callback set to listener, and capture set to false, unless there already is an event listener
// in that list with the same type, callback, and capture.
// (NOTE: capture is set to false by default)
add_event_listener_without_options(HTML::EventNames::change, listener);
add_event_listener_without_options(HTML::EventNames::change, *listener);
}
// https://www.w3.org/TR/cssom-view/#dom-mediaquerylist-removelistener
void MediaQueryList::remove_listener(RefPtr<DOM::IDLEventListener> listener)
void MediaQueryList::remove_listener(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.
// This means if an event listener removes another event listener that comes after it, the removed event listener will not be invoked.
remove_event_listener_without_options(HTML::EventNames::change, listener);
remove_event_listener_without_options(HTML::EventNames::change, *listener);
}
void MediaQueryList::set_onchange(Optional<Bindings::CallbackType> event_handler)
void MediaQueryList::set_onchange(Bindings::CallbackType* event_handler)
{
set_event_handler_attribute(HTML::EventNames::change, event_handler);
}