1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 00:17:46 +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

@ -34,9 +34,9 @@ class MutationObserver final
public:
using WrapperType = Bindings::MutationObserverWrapper;
static NonnullRefPtr<MutationObserver> create_with_global_object(Bindings::WindowObject& window_object, Bindings::CallbackType callback)
static NonnullRefPtr<MutationObserver> create_with_global_object(Bindings::WindowObject& window_object, Bindings::CallbackType* callback)
{
return adopt_ref(*new MutationObserver(window_object, move(callback)));
return adopt_ref(*new MutationObserver(window_object, JS::make_handle(callback)));
}
virtual ~MutationObserver() override = default;
@ -48,7 +48,7 @@ public:
Vector<WeakPtr<Node>>& node_list() { return m_node_list; }
Vector<WeakPtr<Node>> const& node_list() const { return m_node_list; }
Bindings::CallbackType& callback() { return m_callback; }
Bindings::CallbackType& callback() { return *m_callback; }
void enqueue_record(Badge<Node>, NonnullRefPtr<MutationRecord> mutation_record)
{
@ -56,10 +56,10 @@ public:
}
private:
MutationObserver(Bindings::WindowObject& window_object, Bindings::CallbackType callback);
MutationObserver(Bindings::WindowObject& window_object, JS::Handle<Bindings::CallbackType> callback);
// https://dom.spec.whatwg.org/#concept-mo-callback
Bindings::CallbackType m_callback;
JS::Handle<Bindings::CallbackType> m_callback;
// https://dom.spec.whatwg.org/#mutationobserver-node-list
Vector<WeakPtr<Node>> m_node_list;