diff options
author | Andreas Kling <kling@serenityos.org> | 2022-08-28 13:42:07 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-09-06 00:27:09 +0200 |
commit | 6f433c86564c24d47d520cb5bdcc2209d724ac96 (patch) | |
tree | 886a2f727782e466e99c61c628637872c1b7403f /Userland/Libraries/LibWeb/DOM/DOMImplementation.h | |
parent | bb547ce1c4251e3689287eac845593398a379ca5 (diff) | |
download | serenity-6f433c86564c24d47d520cb5bdcc2209d724ac96.zip |
LibWeb+LibJS: Make the EventTarget hierarchy (incl. DOM) GC-allocated
This is a monster patch that turns all EventTargets into GC-allocated
PlatformObjects. Their C++ wrapper classes are removed, and the LibJS
garbage collector is now responsible for their lifetimes.
There's a fair amount of hacks and band-aids in this patch, and we'll
have a lot of cleanup to do after this.
Diffstat (limited to 'Userland/Libraries/LibWeb/DOM/DOMImplementation.h')
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/DOMImplementation.h | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/DOMImplementation.h b/Userland/Libraries/LibWeb/DOM/DOMImplementation.h index 136cd83e1b..9315e459eb 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMImplementation.h +++ b/Userland/Libraries/LibWeb/DOM/DOMImplementation.h @@ -7,30 +7,29 @@ #pragma once -#include <AK/NonnullRefPtr.h> +#include <LibJS/Heap/GCPtr.h> #include <LibWeb/Bindings/PlatformObject.h> #include <LibWeb/DOM/Document.h> namespace Web::DOM { class DOMImplementation final : public Bindings::PlatformObject { - JS_OBJECT(DOMImplementation, Bindings::PlatformObject); + WEB_PLATFORM_OBJECT(DOMImplementation, Bindings::PlatformObject); public: static JS::NonnullGCPtr<DOMImplementation> create(Document&); - explicit DOMImplementation(Document&); virtual ~DOMImplementation(); - 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; - ExceptionOr<NonnullRefPtr<DocumentType>> create_document_type(String const& qualified_name, String const& public_id, String const& system_id); + ExceptionOr<JS::NonnullGCPtr<Document>> create_document(String const&, String const&, JS::GCPtr<DocumentType>) const; + JS::NonnullGCPtr<Document> create_html_document(String const& title) const; + ExceptionOr<JS::NonnullGCPtr<DocumentType>> create_document_type(String const& qualified_name, String const& public_id, String const& system_id); // https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature bool has_feature() const { return true; } private: + explicit DOMImplementation(Document&); + virtual void visit_edges(Cell::Visitor&) override; Document& document() { return m_document; } @@ -41,7 +40,4 @@ private: } -namespace Web::Bindings { -inline JS::Object* wrap(JS::Realm&, Web::DOM::DOMImplementation& object) { return &object; } -using DOMImplementationWrapper = Web::DOM::DOMImplementation; -} +WRAPPER_HACK(DOMImplementation, Web::DOM) |