/src/serenity/Userland/Libraries/LibWeb/DOM/DocumentFragment.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <LibWeb/DOM/Element.h> |
10 | | #include <LibWeb/DOM/NonElementParentNode.h> |
11 | | #include <LibWeb/DOM/ParentNode.h> |
12 | | |
13 | | namespace Web::DOM { |
14 | | |
15 | | class DocumentFragment |
16 | | : public ParentNode |
17 | | , public NonElementParentNode<DocumentFragment> { |
18 | | WEB_PLATFORM_OBJECT(DocumentFragment, ParentNode); |
19 | | JS_DECLARE_ALLOCATOR(DocumentFragment); |
20 | | |
21 | | public: |
22 | | static WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> construct_impl(JS::Realm& realm); |
23 | | |
24 | | virtual ~DocumentFragment() override = default; |
25 | | |
26 | 0 | virtual FlyString node_name() const override { return "#document-fragment"_fly_string; } |
27 | | |
28 | 0 | Element* host() { return m_host.ptr(); } |
29 | 0 | Element const* host() const { return m_host.ptr(); } |
30 | | |
31 | | void set_host(Element*); |
32 | | |
33 | | protected: |
34 | | explicit DocumentFragment(Document& document); |
35 | | |
36 | | virtual void initialize(JS::Realm&) override; |
37 | | virtual void visit_edges(Cell::Visitor&) override; |
38 | | |
39 | | private: |
40 | | // https://dom.spec.whatwg.org/#concept-documentfragment-host |
41 | | JS::GCPtr<Element> m_host; |
42 | | }; |
43 | | |
44 | | template<> |
45 | 0 | inline bool Node::fast_is<DocumentFragment>() const { return is_document_fragment(); } |
46 | | |
47 | | } |