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

LibWeb: Make DOMImplementation GC-allocated

This commit is contained in:
Andreas Kling 2022-08-08 15:52:48 +02:00
parent cfdb8f2a8e
commit 967a3e5a45
6 changed files with 47 additions and 26 deletions

View file

@ -1,9 +1,12 @@
/*
* Copyright (c) 2020, the SerenityOS developers.
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/DOMImplementationPrototype.h>
#include <LibWeb/Bindings/WindowObject.h>
#include <LibWeb/DOM/DOMImplementation.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/DocumentType.h>
@ -14,9 +17,24 @@
namespace Web::DOM {
DOMImplementation::DOMImplementation(Document& document)
: RefCountForwarder(document)
JS::NonnullGCPtr<DOMImplementation> DOMImplementation::create(Document& document)
{
auto& window_object = document.preferred_window_object();
return *window_object.heap().allocate<DOMImplementation>(window_object.realm(), document);
}
DOMImplementation::DOMImplementation(Document& document)
: PlatformObject(document.preferred_window_object().ensure_web_prototype<Bindings::DOMImplementationPrototype>("DOMImplementation"))
, m_document(document)
{
}
DOMImplementation::~DOMImplementation() = default;
void DOMImplementation::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_document);
}
// https://dom.spec.whatwg.org/#dom-domimplementation-createdocument