Truly independent web browser
/*
* Copyright (c) 2018-2020, Andreas Kling <[email protected]>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibJS/Forward.h>
#include <LibWeb/DOM/Element.h>
#include <LibWeb/DOM/ParentNode.h>
#include <LibWeb/Export.h>
#include <LibWeb/Forward.h>
namespace Web::DOM {
class WEB_API DocumentFragment
: public ParentNode {
WEB_WRAPPABLE(DocumentFragment, ParentNode);
GC_DECLARE_ALLOCATOR(DocumentFragment);
public:
[[nodiscard]] static GC::Ref<DocumentFragment> create(Document&);
[[nodiscard]] static GC::Ref<DocumentFragment> create_for_constructor(JS::Object&);
virtual ~DocumentFragment() override = default;
virtual Utf16FlyString node_name() const override { return "#document-fragment"_utf16_fly_string; }
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
GC::Member<Element> m_host;
};
template<>
inline bool Node::fast_is<DocumentFragment>() const { return is_document_fragment(); }
}