2020-08-01 03:07:00 +01:00
|
|
|
/*
|
2021-04-28 22:46:44 +02:00
|
|
|
* Copyright (c) 2020, the SerenityOS developers.
|
2020-08-01 03:07:00 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-08-01 03:07:00 +01:00
|
|
|
*/
|
|
|
|
|
2020-08-19 22:30:33 +01:00
|
|
|
#include <LibWeb/DOM/Document.h>
|
2020-08-01 03:07:00 +01:00
|
|
|
#include <LibWeb/HTML/HTMLTemplateElement.h>
|
|
|
|
|
|
|
|
namespace Web::HTML {
|
|
|
|
|
2021-02-07 11:20:15 +01:00
|
|
|
HTMLTemplateElement::HTMLTemplateElement(DOM::Document& document, QualifiedName qualified_name)
|
|
|
|
: HTMLElement(document, move(qualified_name))
|
2020-08-01 03:07:00 +01:00
|
|
|
{
|
2021-04-23 16:46:57 +02:00
|
|
|
m_content = adopt_ref(*new DOM::DocumentFragment(appropriate_template_contents_owner_document(document)));
|
2020-08-19 22:30:33 +01:00
|
|
|
m_content->set_host(*this);
|
2020-08-01 03:07:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
HTMLTemplateElement::~HTMLTemplateElement()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-08-19 22:30:33 +01:00
|
|
|
DOM::Document& HTMLTemplateElement::appropriate_template_contents_owner_document(DOM::Document& document)
|
|
|
|
{
|
|
|
|
if (!document.created_for_appropriate_template_contents()) {
|
|
|
|
if (!document.associated_inert_template_document()) {
|
2020-10-23 08:31:26 +02:00
|
|
|
auto new_document = DOM::Document::create();
|
|
|
|
new_document->set_created_for_appropriate_template_contents(true);
|
2020-08-19 22:30:33 +01:00
|
|
|
|
|
|
|
// FIXME: If doc is an HTML document, mark new doc as an HTML document also.
|
|
|
|
|
|
|
|
document.set_associated_inert_template_document(new_document);
|
|
|
|
}
|
|
|
|
|
|
|
|
return *document.associated_inert_template_document();
|
|
|
|
}
|
|
|
|
|
|
|
|
return document;
|
|
|
|
}
|
|
|
|
|
2020-08-01 03:07:00 +01:00
|
|
|
}
|