diff options
author | Linus Groh <mail@linusgroh.de> | 2022-08-22 18:56:16 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-08-23 13:58:30 +0100 |
commit | 7c468b5a772342243d1b306389c34ce485033392 (patch) | |
tree | 00a97c85b321b88e63709b5202b95c871d178abb /Userland/Libraries/LibWeb/Bindings | |
parent | b465f46e009164b5d2659f216b9307efee187222 (diff) | |
download | serenity-7c468b5a772342243d1b306389c34ce485033392.zip |
LibJS: Pass Realm to GlobalObject::initialize_global_object()
Global object initialization is tightly coupled to realm creation, so
simply pass it to the function instead of relying on the non-standard
'associated realm' concept, which I'd like to remove later.
This works essentially the same way as regular Object::initialize() now.
Additionally this allows us to forward the realm to GlobalObject's
add_constructor() / initialize_constructor() helpers, so they set the
correct realm on the allocated constructor function object.
Diffstat (limited to 'Userland/Libraries/LibWeb/Bindings')
-rw-r--r-- | Userland/Libraries/LibWeb/Bindings/WindowObject.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Bindings/WindowObject.h | 2 |
2 files changed, 3 insertions, 5 deletions
diff --git a/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp b/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp index cef091c1e4..febc8e93a9 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp +++ b/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp @@ -57,14 +57,12 @@ WindowObject::WindowObject(JS::Realm& realm, HTML::Window& impl) impl.set_wrapper({}, *this); } -void WindowObject::initialize_global_object() +void WindowObject::initialize_global_object(JS::Realm& realm) { - Base::initialize_global_object(); + Base::initialize_global_object(realm); Object::set_prototype(&ensure_web_prototype<WindowPrototype>("Window")); - auto& realm = *associated_realm(); - // FIXME: These should be native accessors, not properties define_direct_property("window", this, JS::Attribute::Enumerable); define_direct_property("frames", this, JS::Attribute::Enumerable); diff --git a/Userland/Libraries/LibWeb/Bindings/WindowObject.h b/Userland/Libraries/LibWeb/Bindings/WindowObject.h index 5d7f187b46..d65673aa33 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowObject.h +++ b/Userland/Libraries/LibWeb/Bindings/WindowObject.h @@ -33,7 +33,7 @@ class WindowObject public: explicit WindowObject(JS::Realm&, HTML::Window&); - virtual void initialize_global_object() override; + virtual void initialize_global_object(JS::Realm&) override; virtual ~WindowObject() override = default; HTML::Window& impl() { return *m_impl; } |