
This is a monster patch that turns all EventTargets into GC-allocated PlatformObjects. Their C++ wrapper classes are removed, and the LibJS garbage collector is now responsible for their lifetimes. There's a fair amount of hacks and band-aids in this patch, and we'll have a lot of cleanup to do after this.
32 lines
614 B
C++
32 lines
614 B
C++
/*
|
|
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibWeb/DOM/DOMEventListener.h>
|
|
#include <LibWeb/HTML/EventHandler.h>
|
|
#include <LibWeb/HTML/Window.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);
|
|
}
|
|
|
|
}
|