1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:18:11 +00:00

LibWeb: Make DOMImplementation forward its ref count to DOM::Document

This allows document.implementation to keep the underlying document
alive for as long as we need it (for example, if someone holds on to a
DOMImplementation JS wrapper after the document is GC'd.)
This commit is contained in:
Andreas Kling 2021-12-09 12:51:05 +01:00
parent e1287a9a45
commit d368b08698
4 changed files with 22 additions and 14 deletions

View file

@ -15,7 +15,7 @@
namespace Web::DOM {
DOMImplementation::DOMImplementation(Document& document)
: m_document(document)
: RefCountForwarder(document)
{
}
@ -37,7 +37,7 @@ NonnullRefPtr<Document> DOMImplementation::create_document(const String& namespa
if (element)
xml_document->append_child(element.release_nonnull());
xml_document->set_origin(m_document.origin());
xml_document->set_origin(document().origin());
if (namespace_ == Namespace::HTML)
xml_document->set_content_type("application/xhtml+xml");
@ -79,16 +79,16 @@ NonnullRefPtr<Document> DOMImplementation::create_html_document(const String& ti
auto body_element = create_element(html_document, HTML::TagNames::body, Namespace::HTML);
html_element->append_child(body_element);
html_document->set_origin(m_document.origin());
html_document->set_origin(document().origin());
return html_document;
}
// https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype
NonnullRefPtr<DocumentType> DOMImplementation::create_document_type(const String& qualified_name, const String& public_id, const String& system_id) const
NonnullRefPtr<DocumentType> DOMImplementation::create_document_type(String const& qualified_name, String const& public_id, String const& system_id)
{
// FIXME: Validate qualified_name.
auto document_type = DocumentType::create(m_document);
auto document_type = DocumentType::create(document());
document_type->set_name(qualified_name);
document_type->set_public_id(public_id);
document_type->set_system_id(system_id);