1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:47: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

@ -16,27 +16,33 @@ namespace Web::DOM {
class DocumentFragment
: public ParentNode
, public NonElementParentNode<DocumentFragment> {
WEB_PLATFORM_OBJECT(DocumentFragment, ParentNode);
public:
using WrapperType = Bindings::DocumentFragmentWrapper;
static JS::NonnullGCPtr<DocumentFragment> create_with_global_object(HTML::Window& window);
static NonnullRefPtr<DocumentFragment> create_with_global_object(Bindings::WindowObject& window);
explicit DocumentFragment(Document& document);
virtual ~DocumentFragment() override = default;
virtual FlyString node_name() const override { return "#document-fragment"; }
Element* host() { return m_host; }
Element const* host() const { return m_host; }
Element* host() { return m_host.ptr(); }
Element const* host() const { return m_host.ptr(); }
void set_host(Element* host) { m_host = host; }
void set_host(Element*);
protected:
explicit DocumentFragment(Document& document);
virtual void visit_edges(Cell::Visitor&) override;
private:
// https://dom.spec.whatwg.org/#concept-documentfragment-host
WeakPtr<Element> m_host;
JS::GCPtr<Element> m_host;
};
template<>
inline bool Node::fast_is<DocumentFragment>() const { return is_document_fragment(); }
}
WRAPPER_HACK(DocumentFragment, Web::DOM)