summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/DOM/DOMImplementation.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-08-08 15:52:48 +0200
committerAndreas Kling <kling@serenityos.org>2022-09-06 00:27:09 +0200
commit967a3e5a45af23f7922cffab9d77c0870ecbf3f2 (patch)
tree07aff3433ccd695933a62c6e1e1c9d6638bd86cd /Userland/Libraries/LibWeb/DOM/DOMImplementation.h
parentcfdb8f2a8e8a3a5351d44be8430dcaabb3ed61ef (diff)
downloadserenity-967a3e5a45af23f7922cffab9d77c0870ecbf3f2.zip
LibWeb: Make DOMImplementation GC-allocated
Diffstat (limited to 'Userland/Libraries/LibWeb/DOM/DOMImplementation.h')
-rw-r--r--Userland/Libraries/LibWeb/DOM/DOMImplementation.h35
1 files changed, 19 insertions, 16 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/DOMImplementation.h b/Userland/Libraries/LibWeb/DOM/DOMImplementation.h
index 1c8d828696..136cd83e1b 100644
--- a/Userland/Libraries/LibWeb/DOM/DOMImplementation.h
+++ b/Userland/Libraries/LibWeb/DOM/DOMImplementation.h
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2020, the SerenityOS developers.
+ * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -7,25 +8,20 @@
#pragma once
#include <AK/NonnullRefPtr.h>
-#include <AK/RefCountForwarder.h>
-#include <AK/RefCounted.h>
-#include <AK/Weakable.h>
-#include <LibWeb/Bindings/Wrappable.h>
+#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/DOM/Document.h>
namespace Web::DOM {
-class DOMImplementation final
- : public RefCountForwarder<Document>
- , public Weakable<DOMImplementation>
- , public Bindings::Wrappable {
+class DOMImplementation final : public Bindings::PlatformObject {
+ JS_OBJECT(DOMImplementation, Bindings::PlatformObject);
+
public:
- using WrapperType = Bindings::DOMImplementationWrapper;
+ static JS::NonnullGCPtr<DOMImplementation> create(Document&);
+ explicit DOMImplementation(Document&);
+ virtual ~DOMImplementation();
- static NonnullOwnPtr<DOMImplementation> create(Badge<Document>, Document& document)
- {
- return adopt_own(*new DOMImplementation(document));
- }
+ DOMImplementation& impl() { return *this; }
ExceptionOr<NonnullRefPtr<Document>> create_document(String const&, String const&, RefPtr<DocumentType>) const;
NonnullRefPtr<Document> create_html_document(String const& title) const;
@@ -35,10 +31,17 @@ public:
bool has_feature() const { return true; }
private:
- explicit DOMImplementation(Document&);
+ virtual void visit_edges(Cell::Visitor&) override;
- Document& document() { return ref_count_target(); }
- Document const& document() const { return ref_count_target(); }
+ Document& document() { return m_document; }
+ Document const& document() const { return m_document; }
+
+ Document& m_document;
};
}
+
+namespace Web::Bindings {
+inline JS::Object* wrap(JS::Realm&, Web::DOM::DOMImplementation& object) { return &object; }
+using DOMImplementationWrapper = Web::DOM::DOMImplementation;
+}