mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-27 03:37:53 +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:
32
Userland/Libraries/LibWeb/HTML/EventHandler.cpp
Normal file
32
Userland/Libraries/LibWeb/HTML/EventHandler.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/DOM/DOMEventListener.h>
|
||||
#include <LibWeb/HTML/EventHandler.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
EventHandler::EventHandler(String s)
|
||||
: value(move(s))
|
||||
{
|
||||
}
|
||||
|
||||
EventHandler::EventHandler(Bindings::CallbackType& c)
|
||||
: value(&c)
|
||||
{
|
||||
}
|
||||
|
||||
void EventHandler::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Cell::visit_edges(visitor);
|
||||
visitor.visit(listener);
|
||||
|
||||
if (auto* callback = value.get_pointer<Bindings::CallbackType*>())
|
||||
visitor.visit(*callback);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user