ladybird/Userland/Libraries/LibWeb/HTML/EventHandler.cpp
Andreas Kling 8cda70c892 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.
2022-09-06 00:27:09 +02:00

32 lines
624 B
C++

/*
* 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);
}
}