2020-08-17 19:14:30 +01:00
|
|
|
/*
|
2021-09-06 01:07:11 +01:00
|
|
|
* Copyright (c) 2020-2021, Luke Wilde <lukew@serenityos.org>
|
2020-08-17 19:14:30 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-08-17 19:14:30 +01:00
|
|
|
*/
|
|
|
|
|
2024-04-27 12:09:58 +12:00
|
|
|
#include <LibWeb/Bindings/DocumentFragmentPrototype.h>
|
2020-08-17 19:14:30 +01:00
|
|
|
#include <LibWeb/DOM/DocumentFragment.h>
|
2022-03-07 23:08:26 +01:00
|
|
|
#include <LibWeb/HTML/Window.h>
|
2020-08-17 19:14:30 +01:00
|
|
|
|
|
|
|
namespace Web::DOM {
|
|
|
|
|
2023-11-19 19:47:52 +01:00
|
|
|
JS_DEFINE_ALLOCATOR(DocumentFragment);
|
|
|
|
|
2020-08-17 19:14:30 +01:00
|
|
|
DocumentFragment::DocumentFragment(Document& document)
|
|
|
|
: ParentNode(document, NodeType::DOCUMENT_FRAGMENT_NODE)
|
|
|
|
{
|
2023-01-10 06:28:20 -05:00
|
|
|
}
|
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
void DocumentFragment::initialize(JS::Realm& realm)
|
2023-01-10 06:28:20 -05:00
|
|
|
{
|
2023-08-07 08:41:28 +02:00
|
|
|
Base::initialize(realm);
|
2024-03-16 13:13:08 +01:00
|
|
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(DocumentFragment);
|
2022-08-28 13:42:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void DocumentFragment::visit_edges(Cell::Visitor& visitor)
|
|
|
|
{
|
|
|
|
Base::visit_edges(visitor);
|
2023-11-19 16:18:00 +13:00
|
|
|
visitor.visit(m_host);
|
2022-08-28 13:42:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void DocumentFragment::set_host(Web::DOM::Element* element)
|
|
|
|
{
|
|
|
|
m_host = element;
|
2020-08-17 19:14:30 +01:00
|
|
|
}
|
|
|
|
|
2021-09-06 01:07:11 +01:00
|
|
|
// https://dom.spec.whatwg.org/#dom-documentfragment-documentfragment
|
2023-02-14 20:43:19 +01:00
|
|
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> DocumentFragment::construct_impl(JS::Realm& realm)
|
2021-09-06 01:07:11 +01:00
|
|
|
{
|
2022-09-25 16:15:49 -06:00
|
|
|
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
2023-08-13 13:05:26 +02:00
|
|
|
return realm.heap().allocate<DocumentFragment>(realm, window.associated_document());
|
2021-09-06 01:07:11 +01:00
|
|
|
}
|
|
|
|
|
2020-08-17 19:14:30 +01:00
|
|
|
}
|