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

LibJS+LibWeb: Let Realm store a plain Object for [[GlobalObject]]

This removes the requirement of having a global object that actually
inherits from JS::GlobalObject, which is now a perfectly valid scenario.

With the upcoming removal of wrapper objects in LibWeb, the HTML::Window
object will inherit from DOM::EventTarget, which means it cannot also
inherit from JS::GlobalObject.
This commit is contained in:
Linus Groh 2022-08-28 15:03:45 +01:00
parent 72730422bb
commit 52543fc771
8 changed files with 20 additions and 20 deletions

View file

@ -28,11 +28,11 @@ public:
Realm() = default;
static Realm* create(VM&);
static ThrowCompletionOr<NonnullOwnPtr<ExecutionContext>> initialize_host_defined_realm(VM&, Function<GlobalObject*(Realm&)> create_global_object, Function<GlobalObject*(Realm&)> create_global_this_value);
static ThrowCompletionOr<NonnullOwnPtr<ExecutionContext>> initialize_host_defined_realm(VM&, Function<Object*(Realm&)> create_global_object, Function<Object*(Realm&)> create_global_this_value);
void set_global_object(GlobalObject* global_object, GlobalObject* this_value);
void set_global_object(Object* global_object, Object* this_value);
[[nodiscard]] GlobalObject& global_object() const { return *m_global_object; }
[[nodiscard]] Object& global_object() const { return *m_global_object; }
[[nodiscard]] GlobalEnvironment& global_environment() const { return *m_global_environment; }
[[nodiscard]] Intrinsics const& intrinsics() const { return *m_intrinsics; }
@ -51,7 +51,7 @@ private:
virtual void visit_edges(Visitor&) override;
Intrinsics* m_intrinsics { nullptr }; // [[Intrinsics]]
GlobalObject* m_global_object { nullptr }; // [[GlobalObject]]
Object* m_global_object { nullptr }; // [[GlobalObject]]
GlobalEnvironment* m_global_environment { nullptr }; // [[GlobalEnv]]
OwnPtr<HostDefined> m_host_defined; // [[HostDefined]]
};