1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:27:35 +00:00

LibWeb+LibJS: Make the EventTarget hierarchy (incl. DOM) GC-allocated

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.
This commit is contained in:
Andreas Kling 2022-08-28 13:42:07 +02:00
parent bb547ce1c4
commit 6f433c8656
445 changed files with 4797 additions and 4268 deletions

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/AttributePrototype.h>
#include <LibWeb/DOM/Attribute.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Element.h>
@ -12,9 +13,9 @@
namespace Web::DOM {
NonnullRefPtr<Attribute> Attribute::create(Document& document, FlyString local_name, String value, Element const* owner_element)
JS::NonnullGCPtr<Attribute> Attribute::create(Document& document, FlyString local_name, String value, Element const* owner_element)
{
return adopt_ref(*new Attribute(document, move(local_name), move(value), owner_element));
return *document.heap().allocate<Attribute>(document.realm(), document, move(local_name), move(value), owner_element);
}
Attribute::Attribute(Document& document, FlyString local_name, String value, Element const* owner_element)
@ -23,16 +24,23 @@ Attribute::Attribute(Document& document, FlyString local_name, String value, Ele
, m_value(move(value))
, m_owner_element(owner_element)
{
set_prototype(&window().ensure_web_prototype<Bindings::AttributePrototype>("Attribute"));
}
void Attribute::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_owner_element.ptr());
}
Element* Attribute::owner_element()
{
return m_owner_element;
return m_owner_element.ptr();
}
Element const* Attribute::owner_element() const
{
return m_owner_element;
return m_owner_element.ptr();
}
void Attribute::set_owner_element(Element const* owner_element)