1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 13:07:46 +00:00

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.
This commit is contained in:
Andreas Kling 2022-08-28 13:42:07 +02:00
parent bb547ce1c4
commit 6f433c8656
445 changed files with 4797 additions and 4268 deletions

View file

@ -17,7 +17,6 @@ class WindowProxy final : public JS::Object {
JS_OBJECT(WindowProxy, JS::Object);
public:
WindowProxy(JS::Realm&, WindowObject&);
virtual ~WindowProxy() override = default;
virtual JS::ThrowCompletionOr<JS::Object*> internal_get_prototype_of() const override;
@ -31,18 +30,20 @@ public:
virtual JS::ThrowCompletionOr<bool> internal_delete(JS::PropertyKey const&) override;
virtual JS::ThrowCompletionOr<JS::MarkedVector<JS::Value>> internal_own_property_keys() const override;
WindowObject& window() { return *m_window; }
WindowObject const& window() const { return *m_window; }
HTML::Window& window() { return *m_window; }
HTML::Window const& window() const { return *m_window; }
// NOTE: Someone will have to replace the wrapped window object as well:
// "When the browsing context is navigated, the Window object wrapped by the browsing context's associated WindowProxy object is changed."
// I haven't found where that actually happens yet. Make sure to use a Badge<T> guarded setter.
private:
WindowProxy(JS::Realm&, HTML::Window&);
virtual void visit_edges(JS::Cell::Visitor&) override;
// [[Window]], https://html.spec.whatwg.org/multipage/window-object.html#concept-windowproxy-window
WindowObject* m_window { nullptr };
JS::GCPtr<HTML::Window> m_window;
};
}