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
|
|
|
*/
|
|
|
|
|
|
|
|
#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 {
|
|
|
|
|
|
|
|
DocumentFragment::DocumentFragment(Document& document)
|
|
|
|
: ParentNode(document, NodeType::DOCUMENT_FRAGMENT_NODE)
|
|
|
|
{
|
2023-01-10 06:28:20 -05:00
|
|
|
}
|
|
|
|
|
2023-01-28 12:33:35 -05:00
|
|
|
JS::ThrowCompletionOr<void> DocumentFragment::initialize(JS::Realm& realm)
|
2023-01-10 06:28:20 -05:00
|
|
|
{
|
2023-01-28 12:33:35 -05:00
|
|
|
MUST_OR_THROW_OOM(Base::initialize(realm));
|
2023-01-10 06:28:20 -05:00
|
|
|
set_prototype(&Bindings::ensure_web_prototype<Bindings::DocumentFragmentPrototype>(realm, "DocumentFragment"));
|
2023-01-28 12:33:35 -05:00
|
|
|
|
|
|
|
return {};
|
2022-08-28 13:42:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void DocumentFragment::visit_edges(Cell::Visitor& visitor)
|
|
|
|
{
|
|
|
|
Base::visit_edges(visitor);
|
|
|
|
visitor.visit(m_host.ptr());
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2022-09-25 16:15:49 -06:00
|
|
|
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-01-28 13:39:44 -05:00
|
|
|
return realm.heap().allocate<DocumentFragment>(realm, window.associated_document()).release_allocated_value_but_fixme_should_propagate_errors();
|
2021-09-06 01:07:11 +01:00
|
|
|
}
|
|
|
|
|
2020-08-17 19:14:30 +01:00
|
|
|
}
|