2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
|
2019-11-06 20:27:53 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
2023-01-08 19:23:00 -05:00
|
|
|
#include <AK/DeprecatedFlyString.h>
|
2020-09-18 09:49:51 +02:00
|
|
|
#include <LibWeb/DOM/Element.h>
|
2020-03-28 09:12:13 +01:00
|
|
|
#include <LibWeb/DOM/NonElementParentNode.h>
|
2020-03-07 10:32:51 +01:00
|
|
|
#include <LibWeb/DOM/ParentNode.h>
|
2019-11-06 20:27:53 +01:00
|
|
|
|
2020-07-26 19:37:56 +02:00
|
|
|
namespace Web::DOM {
|
2020-03-07 10:27:02 +01:00
|
|
|
|
2020-03-28 09:12:13 +01:00
|
|
|
class DocumentFragment
|
|
|
|
|
: public ParentNode
|
|
|
|
|
, public NonElementParentNode<DocumentFragment> {
|
2022-08-28 13:42:07 +02:00
|
|
|
WEB_PLATFORM_OBJECT(DocumentFragment, ParentNode);
|
2020-08-19 22:30:33 +01:00
|
|
|
|
2022-08-28 13:42:07 +02:00
|
|
|
public:
|
2023-02-14 20:43:19 +01:00
|
|
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> construct_impl(JS::Realm& realm);
|
2021-09-06 01:07:11 +01:00
|
|
|
|
2022-03-14 13:21:51 -06:00
|
|
|
virtual ~DocumentFragment() override = default;
|
2019-11-06 20:27:53 +01:00
|
|
|
|
2023-01-08 19:23:00 -05:00
|
|
|
virtual DeprecatedFlyString node_name() const override { return "#document-fragment"; }
|
2020-08-19 22:30:33 +01:00
|
|
|
|
2022-08-28 13:42:07 +02:00
|
|
|
Element* host() { return m_host.ptr(); }
|
|
|
|
|
Element const* host() const { return m_host.ptr(); }
|
2020-08-19 22:30:33 +01:00
|
|
|
|
2022-08-28 13:42:07 +02:00
|
|
|
void set_host(Element*);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
explicit DocumentFragment(Document& document);
|
|
|
|
|
|
2023-01-28 12:33:35 -05:00
|
|
|
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
2022-08-28 13:42:07 +02:00
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
2020-08-19 22:30:33 +01:00
|
|
|
|
|
|
|
|
private:
|
2022-03-14 12:46:14 +01:00
|
|
|
// https://dom.spec.whatwg.org/#concept-documentfragment-host
|
2022-08-28 13:42:07 +02:00
|
|
|
JS::GCPtr<Element> m_host;
|
2019-11-06 20:27:53 +01:00
|
|
|
};
|
|
|
|
|
|
2022-03-29 23:28:17 +02:00
|
|
|
template<>
|
|
|
|
|
inline bool Node::fast_is<DocumentFragment>() const { return is_document_fragment(); }
|
|
|
|
|
|
2019-11-06 20:27:53 +01:00
|
|
|
}
|