mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:47:35 +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:
parent
bb547ce1c4
commit
6f433c8656
445 changed files with 4797 additions and 4268 deletions
|
@ -6,19 +6,49 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Weakable.h>
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
namespace Web::Bindings {
|
||||
|
||||
#define WEB_PLATFORM_OBJECT(class_, base_class) \
|
||||
JS_OBJECT(class_, base_class) \
|
||||
auto& impl() \
|
||||
{ \
|
||||
return *this; \
|
||||
} \
|
||||
auto const& impl() const \
|
||||
{ \
|
||||
return *this; \
|
||||
}
|
||||
|
||||
#define WRAPPER_HACK(class_, namespace_) \
|
||||
namespace Web::Bindings { \
|
||||
inline JS::Object* wrap(JS::Realm&, namespace_::class_& object) \
|
||||
{ \
|
||||
return &object; \
|
||||
} \
|
||||
using class_##Wrapper = namespace_::class_; \
|
||||
}
|
||||
|
||||
// https://webidl.spec.whatwg.org/#dfn-platform-object
|
||||
class PlatformObject : public JS::Object {
|
||||
class PlatformObject
|
||||
: public JS::Object
|
||||
, public Weakable<PlatformObject> {
|
||||
JS_OBJECT(PlatformObject, JS::Object);
|
||||
|
||||
public:
|
||||
virtual ~PlatformObject() override;
|
||||
|
||||
JS::Realm& realm() const;
|
||||
|
||||
// FIXME: This should return a type that works in both window and worker contexts.
|
||||
HTML::Window& global_object() const;
|
||||
|
||||
protected:
|
||||
PlatformObject(JS::Realm&);
|
||||
explicit PlatformObject(JS::Object& prototype);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue