mirror of
https://github.com/RGBCube/serenity
synced 2025-07-03 04:52:13 +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
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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue