2020-01-18 09:38:21 +01:00
|
|
|
/*
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
|
2020-01-18 09:38:21 +01:00
|
|
|
*
|
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
|
|
|
|
|
2020-09-18 09:49:51 +02:00
|
|
|
#include <LibWeb/DOM/Element.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
|
2025-03-25 17:30:52 +00:00
|
|
|
: public ParentNode {
|
2022-08-28 13:42:07 +02:00
|
|
|
WEB_PLATFORM_OBJECT(DocumentFragment, ParentNode);
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DECLARE_ALLOCATOR(DocumentFragment);
|
2020-08-19 22:30:33 +01:00
|
|
|
|
2022-08-28 13:42:07 +02:00
|
|
|
public:
|
2024-11-15 04:01:23 +13:00
|
|
|
static WebIDL::ExceptionOr<GC::Ref<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-09-17 10:51:43 +12:00
|
|
|
virtual FlyString node_name() const override { return "#document-fragment"_fly_string; }
|
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-08-07 08:41:28 +02:00
|
|
|
virtual 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
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ptr<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
|
|
|
}
|