ladybird/Userland/Libraries/LibWeb/DOM/DocumentFragment.h
Andreas Kling 6f433c8656 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.
2022-09-06 00:27:09 +02:00

48 lines
1.2 KiB
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/FlyString.h>
#include <LibWeb/DOM/Element.h>
#include <LibWeb/DOM/NonElementParentNode.h>
#include <LibWeb/DOM/ParentNode.h>
namespace Web::DOM {
class DocumentFragment
: public ParentNode
, public NonElementParentNode<DocumentFragment> {
WEB_PLATFORM_OBJECT(DocumentFragment, ParentNode);
public:
static JS::NonnullGCPtr<DocumentFragment> create_with_global_object(HTML::Window& window);
virtual ~DocumentFragment() override = default;
virtual FlyString node_name() const override { return "#document-fragment"; }
Element* host() { return m_host.ptr(); }
Element const* host() const { return m_host.ptr(); }
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
JS::GCPtr<Element> m_host;
};
template<>
inline bool Node::fast_is<DocumentFragment>() const { return is_document_fragment(); }
}
WRAPPER_HACK(DocumentFragment, Web::DOM)