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