1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:47:36 +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

@ -29,28 +29,17 @@ namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/workers.html#the-workerglobalscope-common-interface
// WorkerGlobalScope is the base class of each real WorkerGlobalScope that will be created when the
// user agent runs the run a worker algorithm.
class WorkerGlobalScope
: public RefCounted<WorkerGlobalScope>
, public DOM::EventTarget
, public Bindings::Wrappable {
class WorkerGlobalScope : public DOM::EventTarget {
WEB_PLATFORM_OBJECT(WorkerGlobalScope, DOM::EventTarget);
public:
using WrapperType = Bindings::WorkerGlobalScopeWrapper;
using RefCounted::ref;
using RefCounted::unref;
virtual ~WorkerGlobalScope() override;
// ^EventTarget
virtual void ref_event_target() override { ref(); }
virtual void unref_event_target() override { unref(); }
virtual JS::Object* create_wrapper(JS::Realm&) override;
// Following methods are from the WorkerGlobalScope IDL definition
// https://html.spec.whatwg.org/multipage/workers.html#the-workerglobalscope-common-interface
// https://html.spec.whatwg.org/multipage/workers.html#dom-workerglobalscope-self
NonnullRefPtr<WorkerGlobalScope const> self() const { return *this; }
JS::NonnullGCPtr<WorkerGlobalScope> self() const { return *this; }
NonnullRefPtr<WorkerLocation const> location() const;
NonnullRefPtr<WorkerNavigator const> navigator() const;
@ -82,7 +71,7 @@ public:
void set_location(NonnullRefPtr<WorkerLocation> loc) { m_location = move(loc); }
protected:
explicit WorkerGlobalScope();
explicit WorkerGlobalScope(JS::Realm&);
private:
RefPtr<WorkerLocation> m_location;
@ -124,3 +113,5 @@ private:
};
}
WRAPPER_HACK(WorkerGlobalScope, Web::HTML)