diff options
author | Linus Groh <mail@linusgroh.de> | 2022-08-16 00:20:49 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-08-23 13:58:30 +0100 |
commit | 5dd5896588b0e5a7bc7bdadeaa7dd4865f663b79 (patch) | |
tree | b8c099aac88ad59a9fb06624fd6245f9662a9796 /Userland/Libraries/LibWeb | |
parent | ecd163bdf1cbf8c9bca9e209a385a41ff5ca4f81 (diff) | |
download | serenity-5dd5896588b0e5a7bc7bdadeaa7dd4865f663b79.zip |
LibJS+LibWeb: Replace GlobalObject with Realm in initialize() functions
This is a continuation of the previous commit.
Calling initialize() is the first thing that's done after allocating a
cell on the JS heap - and in the common case of allocating an object,
that's where properties are assigned and intrinsics occasionally
accessed.
Since those are supposed to live on the realm eventually, this is
another step into that direction.
Diffstat (limited to 'Userland/Libraries/LibWeb')
36 files changed, 70 insertions, 72 deletions
diff --git a/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp index b881df327d..7fa1bbe632 100644 --- a/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp @@ -19,11 +19,11 @@ AudioConstructor::AudioConstructor(JS::Realm& realm) { } -void AudioConstructor::initialize(JS::GlobalObject& global_object) +void AudioConstructor::initialize(JS::Realm& realm) { auto& vm = this->vm(); - auto& window = static_cast<WindowObject&>(global_object); - NativeFunction::initialize(global_object); + auto& window = static_cast<WindowObject&>(realm.global_object()); + NativeFunction::initialize(realm); define_direct_property(vm.names.prototype, &window.ensure_web_prototype<HTMLAudioElementPrototype>("HTMLAudioElement"), 0); define_direct_property(vm.names.length, JS::Value(0), JS::Attribute::Configurable); diff --git a/Userland/Libraries/LibWeb/Bindings/AudioConstructor.h b/Userland/Libraries/LibWeb/Bindings/AudioConstructor.h index 912bef0885..36a88b628b 100644 --- a/Userland/Libraries/LibWeb/Bindings/AudioConstructor.h +++ b/Userland/Libraries/LibWeb/Bindings/AudioConstructor.h @@ -14,7 +14,7 @@ namespace Web::Bindings { class AudioConstructor final : public JS::NativeFunction { public: explicit AudioConstructor(JS::Realm&); - virtual void initialize(JS::GlobalObject&) override; + virtual void initialize(JS::Realm&) override; virtual ~AudioConstructor() override = default; virtual JS::ThrowCompletionOr<JS::Value> call() override; diff --git a/Userland/Libraries/LibWeb/Bindings/CSSNamespace.cpp b/Userland/Libraries/LibWeb/Bindings/CSSNamespace.cpp index a46ec1998f..943d1a0c01 100644 --- a/Userland/Libraries/LibWeb/Bindings/CSSNamespace.cpp +++ b/Userland/Libraries/LibWeb/Bindings/CSSNamespace.cpp @@ -18,9 +18,9 @@ CSSNamespace::CSSNamespace(JS::Realm& realm) { } -void CSSNamespace::initialize(JS::GlobalObject& global_object) +void CSSNamespace::initialize(JS::Realm& realm) { - Object::initialize(global_object); + Object::initialize(realm); u8 attr = JS::Attribute::Enumerable; define_native_function("escape", escape, 1, attr); define_native_function("supports", supports, 2, attr); diff --git a/Userland/Libraries/LibWeb/Bindings/CSSNamespace.h b/Userland/Libraries/LibWeb/Bindings/CSSNamespace.h index 05d4979a4a..cdd92bdc9a 100644 --- a/Userland/Libraries/LibWeb/Bindings/CSSNamespace.h +++ b/Userland/Libraries/LibWeb/Bindings/CSSNamespace.h @@ -17,7 +17,7 @@ class CSSNamespace final : public JS::Object { public: explicit CSSNamespace(JS::Realm&); - virtual void initialize(JS::GlobalObject&) override; + virtual void initialize(JS::Realm&) override; virtual ~CSSNamespace() override = default; private: diff --git a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp index ee7aeaaaf6..48157f754a 100644 --- a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp @@ -19,11 +19,11 @@ ImageConstructor::ImageConstructor(JS::Realm& realm) { } -void ImageConstructor::initialize(JS::GlobalObject& global_object) +void ImageConstructor::initialize(JS::Realm& realm) { auto& vm = this->vm(); - auto& window = static_cast<WindowObject&>(global_object); - NativeFunction::initialize(global_object); + auto& window = static_cast<WindowObject&>(realm.global_object()); + NativeFunction::initialize(realm); define_direct_property(vm.names.prototype, &window.ensure_web_prototype<HTMLImageElementPrototype>("HTMLImageElement"), 0); define_direct_property(vm.names.length, JS::Value(0), JS::Attribute::Configurable); diff --git a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.h b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.h index 3a4a603497..d16e61bbb9 100644 --- a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.h +++ b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.h @@ -14,7 +14,7 @@ namespace Web::Bindings { class ImageConstructor final : public JS::NativeFunction { public: explicit ImageConstructor(JS::Realm&); - virtual void initialize(JS::GlobalObject&) override; + virtual void initialize(JS::Realm&) override; virtual ~ImageConstructor() override = default; virtual JS::ThrowCompletionOr<JS::Value> call() override; diff --git a/Userland/Libraries/LibWeb/Bindings/LocationConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/LocationConstructor.cpp index a6be55e5da..7158152b17 100644 --- a/Userland/Libraries/LibWeb/Bindings/LocationConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/LocationConstructor.cpp @@ -28,12 +28,12 @@ JS::ThrowCompletionOr<JS::Object*> LocationConstructor::construct(FunctionObject return vm().throw_completion<JS::TypeError>(global_object(), JS::ErrorType::NotAConstructor, "Location"); } -void LocationConstructor::initialize(JS::GlobalObject& global_object) +void LocationConstructor::initialize(JS::Realm& realm) { auto& vm = this->vm(); - auto& window = static_cast<WindowObject&>(global_object); + auto& window = static_cast<WindowObject&>(realm.global_object()); - NativeFunction::initialize(global_object); + NativeFunction::initialize(realm); define_direct_property(vm.names.prototype, &window.ensure_web_prototype<LocationPrototype>("Location"), 0); define_direct_property(vm.names.length, JS::Value(0), JS::Attribute::Configurable); } diff --git a/Userland/Libraries/LibWeb/Bindings/LocationConstructor.h b/Userland/Libraries/LibWeb/Bindings/LocationConstructor.h index dd05c3551e..41b5345a24 100644 --- a/Userland/Libraries/LibWeb/Bindings/LocationConstructor.h +++ b/Userland/Libraries/LibWeb/Bindings/LocationConstructor.h @@ -15,7 +15,7 @@ class LocationConstructor : public JS::NativeFunction { public: explicit LocationConstructor(JS::Realm&); - virtual void initialize(JS::GlobalObject&) override; + virtual void initialize(JS::Realm&) override; virtual ~LocationConstructor() override; virtual JS::ThrowCompletionOr<JS::Value> call() override; diff --git a/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp b/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp index d51a4e4bea..93b62b166e 100644 --- a/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp +++ b/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp @@ -29,11 +29,11 @@ LocationObject::LocationObject(JS::Realm& realm) { } -void LocationObject::initialize(JS::GlobalObject& global_object) +void LocationObject::initialize(JS::Realm& realm) { - auto& vm = global_object.vm(); + auto& vm = this->vm(); - Object::initialize(global_object); + Object::initialize(realm); u8 attr = JS::Attribute::Writable | JS::Attribute::Enumerable; define_native_accessor("href", href_getter, href_setter, attr); define_native_accessor("host", host_getter, {}, attr); diff --git a/Userland/Libraries/LibWeb/Bindings/LocationObject.h b/Userland/Libraries/LibWeb/Bindings/LocationObject.h index 34c0684d84..f48ee23114 100644 --- a/Userland/Libraries/LibWeb/Bindings/LocationObject.h +++ b/Userland/Libraries/LibWeb/Bindings/LocationObject.h @@ -22,7 +22,7 @@ class LocationObject final : public JS::Object { public: explicit LocationObject(JS::Realm&); - virtual void initialize(JS::GlobalObject&) override; + virtual void initialize(JS::Realm&) override; virtual ~LocationObject() override = default; virtual JS::ThrowCompletionOr<JS::Object*> internal_get_prototype_of() const override; diff --git a/Userland/Libraries/LibWeb/Bindings/NavigatorConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/NavigatorConstructor.cpp index 2deb4efef2..560033963f 100644 --- a/Userland/Libraries/LibWeb/Bindings/NavigatorConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/NavigatorConstructor.cpp @@ -28,12 +28,12 @@ JS::ThrowCompletionOr<JS::Object*> NavigatorConstructor::construct(FunctionObjec return vm().throw_completion<JS::TypeError>(global_object(), JS::ErrorType::NotAConstructor, "Navigator"); } -void NavigatorConstructor::initialize(JS::GlobalObject& global_object) +void NavigatorConstructor::initialize(JS::Realm& realm) { auto& vm = this->vm(); - auto& window = static_cast<WindowObject&>(global_object); + auto& window = static_cast<WindowObject&>(realm.global_object()); - NativeFunction::initialize(global_object); + NativeFunction::initialize(realm); define_direct_property(vm.names.prototype, &window.ensure_web_prototype<NavigatorPrototype>("Navigator"), 0); define_direct_property(vm.names.length, JS::Value(0), JS::Attribute::Configurable); } diff --git a/Userland/Libraries/LibWeb/Bindings/NavigatorConstructor.h b/Userland/Libraries/LibWeb/Bindings/NavigatorConstructor.h index 12054f5ebf..add6edde6c 100644 --- a/Userland/Libraries/LibWeb/Bindings/NavigatorConstructor.h +++ b/Userland/Libraries/LibWeb/Bindings/NavigatorConstructor.h @@ -15,7 +15,7 @@ class NavigatorConstructor : public JS::NativeFunction { public: explicit NavigatorConstructor(JS::Realm&); - virtual void initialize(JS::GlobalObject&) override; + virtual void initialize(JS::Realm&) override; virtual ~NavigatorConstructor() override; virtual JS::ThrowCompletionOr<JS::Value> call() override; diff --git a/Userland/Libraries/LibWeb/Bindings/NavigatorObject.cpp b/Userland/Libraries/LibWeb/Bindings/NavigatorObject.cpp index a7f844b80f..b4c2fccc20 100644 --- a/Userland/Libraries/LibWeb/Bindings/NavigatorObject.cpp +++ b/Userland/Libraries/LibWeb/Bindings/NavigatorObject.cpp @@ -18,10 +18,10 @@ NavigatorObject::NavigatorObject(JS::Realm& realm) { } -void NavigatorObject::initialize(JS::GlobalObject& global_object) +void NavigatorObject::initialize(JS::Realm& realm) { auto& heap = this->heap(); - auto* languages = MUST(JS::Array::create(global_object, 0)); + auto* languages = MUST(JS::Array::create(realm.global_object(), 0)); languages->indexed_properties().append(js_string(heap, "en-US")); // FIXME: All of these should be in Navigator's prototype and be native accessors diff --git a/Userland/Libraries/LibWeb/Bindings/NavigatorObject.h b/Userland/Libraries/LibWeb/Bindings/NavigatorObject.h index 026f65aab4..e91a7c6198 100644 --- a/Userland/Libraries/LibWeb/Bindings/NavigatorObject.h +++ b/Userland/Libraries/LibWeb/Bindings/NavigatorObject.h @@ -17,7 +17,7 @@ class NavigatorObject final : public JS::Object { public: NavigatorObject(JS::Realm&); - virtual void initialize(JS::GlobalObject&) override; + virtual void initialize(JS::Realm&) override; virtual ~NavigatorObject() override = default; private: diff --git a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp index d8582e8830..330f34b334 100644 --- a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp @@ -20,11 +20,11 @@ OptionConstructor::OptionConstructor(JS::Realm& realm) { } -void OptionConstructor::initialize(JS::GlobalObject& global_object) +void OptionConstructor::initialize(JS::Realm& realm) { auto& vm = this->vm(); - auto& window = static_cast<WindowObject&>(global_object); - NativeFunction::initialize(global_object); + auto& window = static_cast<WindowObject&>(realm.global_object()); + NativeFunction::initialize(realm); define_direct_property(vm.names.prototype, &window.ensure_web_prototype<HTMLOptionElementPrototype>("HTMLOptionElement"), 0); define_direct_property(vm.names.length, JS::Value(0), JS::Attribute::Configurable); diff --git a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.h b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.h index d485f2859e..919762b970 100644 --- a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.h +++ b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.h @@ -14,7 +14,7 @@ namespace Web::Bindings { class OptionConstructor final : public JS::NativeFunction { public: explicit OptionConstructor(JS::Realm&); - virtual void initialize(JS::GlobalObject&) override; + virtual void initialize(JS::Realm&) override; virtual ~OptionConstructor() override = default; virtual JS::ThrowCompletionOr<JS::Value> call() override; diff --git a/Userland/Libraries/LibWeb/Bindings/WindowConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/WindowConstructor.cpp index be0d7c5cdb..185fe1d991 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/WindowConstructor.cpp @@ -28,12 +28,12 @@ JS::ThrowCompletionOr<JS::Object*> WindowConstructor::construct(FunctionObject&) return vm().throw_completion<JS::TypeError>(global_object(), JS::ErrorType::NotAConstructor, "Window"); } -void WindowConstructor::initialize(JS::GlobalObject& global_object) +void WindowConstructor::initialize(JS::Realm& realm) { auto& vm = this->vm(); - auto& window = static_cast<WindowObject&>(global_object); + auto& window = static_cast<WindowObject&>(realm.global_object()); - NativeFunction::initialize(global_object); + NativeFunction::initialize(realm); define_direct_property(vm.names.prototype, &window.ensure_web_prototype<WindowPrototype>("Window"), 0); define_direct_property(vm.names.length, JS::Value(0), JS::Attribute::Configurable); } diff --git a/Userland/Libraries/LibWeb/Bindings/WindowConstructor.h b/Userland/Libraries/LibWeb/Bindings/WindowConstructor.h index 5b25ee6c92..3dda78c0d3 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowConstructor.h +++ b/Userland/Libraries/LibWeb/Bindings/WindowConstructor.h @@ -15,7 +15,7 @@ class WindowConstructor : public JS::NativeFunction { public: explicit WindowConstructor(JS::Realm&); - virtual void initialize(JS::GlobalObject&) override; + virtual void initialize(JS::Realm&) override; virtual ~WindowConstructor() override; virtual JS::ThrowCompletionOr<JS::Value> call() override; diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp index b7441a457c..71bf399464 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp @@ -40,12 +40,12 @@ JS::ThrowCompletionOr<JS::Object*> WebAssemblyInstanceConstructor::construct(Fun return heap().allocate<WebAssemblyInstanceObject>(global_object, realm, result); } -void WebAssemblyInstanceConstructor::initialize(JS::GlobalObject& global_object) +void WebAssemblyInstanceConstructor::initialize(JS::Realm& realm) { auto& vm = this->vm(); - auto& window = static_cast<WindowObject&>(global_object); + auto& window = static_cast<WindowObject&>(realm.global_object()); - NativeFunction::initialize(global_object); + NativeFunction::initialize(realm); define_direct_property(vm.names.prototype, &window.ensure_web_prototype<WebAssemblyInstancePrototype>("WebAssemblyInstancePrototype"), 0); define_direct_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable); } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.h index f217182b63..98bf578947 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.h @@ -15,7 +15,7 @@ class WebAssemblyInstanceConstructor : public JS::NativeFunction { public: explicit WebAssemblyInstanceConstructor(JS::Realm&); - virtual void initialize(JS::GlobalObject&) override; + virtual void initialize(JS::Realm&) override; virtual ~WebAssemblyInstanceConstructor() override; virtual JS::ThrowCompletionOr<JS::Value> call() override; diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp index afae00d11a..2ff380e32e 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp @@ -23,14 +23,12 @@ WebAssemblyInstanceObject::WebAssemblyInstanceObject(JS::Realm& realm, size_t in { } -void WebAssemblyInstanceObject::initialize(JS::GlobalObject& global_object) +void WebAssemblyInstanceObject::initialize(JS::Realm& realm) { - Object::initialize(global_object); - - auto& realm = *global_object.associated_realm(); + Object::initialize(realm); VERIFY(!m_exports_object); - m_exports_object = create(global_object, nullptr); + m_exports_object = create(realm.global_object(), nullptr); auto& instance = this->instance(); auto& cache = this->cache(); for (auto& export_ : instance.exports()) { @@ -38,7 +36,7 @@ void WebAssemblyInstanceObject::initialize(JS::GlobalObject& global_object) [&](Wasm::FunctionAddress const& address) { Optional<JS::FunctionObject*> object = cache.function_instances.get(address); if (!object.has_value()) { - object = create_native_function(global_object, address, export_.name()); + object = create_native_function(realm.global_object(), address, export_.name()); cache.function_instances.set(address, *object); } m_exports_object->define_direct_property(export_.name(), *object, JS::default_attributes); @@ -46,7 +44,7 @@ void WebAssemblyInstanceObject::initialize(JS::GlobalObject& global_object) [&](Wasm::MemoryAddress const& address) { Optional<WebAssemblyMemoryObject*> object = cache.memory_instances.get(address); if (!object.has_value()) { - object = heap().allocate<Web::Bindings::WebAssemblyMemoryObject>(global_object, realm, address); + object = heap().allocate<Web::Bindings::WebAssemblyMemoryObject>(realm.global_object(), realm, address); cache.memory_instances.set(address, *object); } m_exports_object->define_direct_property(export_.name(), *object, JS::default_attributes); diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.h index de8cd1381e..d39b3dd8bb 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.h @@ -20,7 +20,7 @@ class WebAssemblyInstanceObject final : public JS::Object { public: explicit WebAssemblyInstanceObject(JS::Realm&, size_t index); - virtual void initialize(JS::GlobalObject&) override; + virtual void initialize(JS::Realm&) override; virtual ~WebAssemblyInstanceObject() override = default; size_t index() const { return m_index; } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.cpp index 1f05165f9d..bc5580cdc9 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.cpp @@ -10,9 +10,9 @@ namespace Web::Bindings { -void WebAssemblyInstancePrototype::initialize(JS::GlobalObject& global_object) +void WebAssemblyInstancePrototype::initialize(JS::Realm& realm) { - Object::initialize(global_object); + Object::initialize(realm); define_native_accessor("exports", exports_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable); } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.h index 06f51667ba..8f409538a3 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.h @@ -22,7 +22,7 @@ public: { } - virtual void initialize(JS::GlobalObject&) override; + virtual void initialize(JS::Realm&) override; private: JS_DECLARE_NATIVE_FUNCTION(exports_getter); diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp index d37649efef..077c0d8196 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp @@ -54,12 +54,12 @@ JS::ThrowCompletionOr<JS::Object*> WebAssemblyMemoryConstructor::construct(Funct return vm.heap().allocate<WebAssemblyMemoryObject>(global_object, realm, *address); } -void WebAssemblyMemoryConstructor::initialize(JS::GlobalObject& global_object) +void WebAssemblyMemoryConstructor::initialize(JS::Realm& realm) { auto& vm = this->vm(); - auto& window = static_cast<WindowObject&>(global_object); + auto& window = static_cast<WindowObject&>(realm.global_object()); - NativeFunction::initialize(global_object); + NativeFunction::initialize(realm); define_direct_property(vm.names.prototype, &window.ensure_web_prototype<WebAssemblyMemoryPrototype>("WebAssemblyMemoryPrototype"), 0); define_direct_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable); } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.h index f435b0905e..df983ac235 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.h @@ -15,7 +15,7 @@ class WebAssemblyMemoryConstructor : public JS::NativeFunction { public: explicit WebAssemblyMemoryConstructor(JS::Realm&); - virtual void initialize(JS::GlobalObject&) override; + virtual void initialize(JS::Realm&) override; virtual ~WebAssemblyMemoryConstructor() override; virtual JS::ThrowCompletionOr<JS::Value> call() override; diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp index 71783240f1..30f6fa8cf2 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp @@ -10,9 +10,9 @@ namespace Web::Bindings { -void WebAssemblyMemoryPrototype::initialize(JS::GlobalObject& global_object) +void WebAssemblyMemoryPrototype::initialize(JS::Realm& realm) { - Object::initialize(global_object); + Object::initialize(realm); define_native_accessor("buffer", buffer_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable); define_native_function("grow", grow, 1, JS::Attribute::Writable | JS::Attribute::Enumerable | JS::Attribute::Configurable); } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h index 390761f23f..ac68af75fd 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h @@ -24,7 +24,7 @@ public: { } - virtual void initialize(JS::GlobalObject&) override; + virtual void initialize(JS::Realm&) override; private: JS_DECLARE_NATIVE_FUNCTION(grow); diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp index 072f0ab8cd..53705691e6 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp @@ -38,12 +38,12 @@ JS::ThrowCompletionOr<JS::Object*> WebAssemblyModuleConstructor::construct(Funct return heap().allocate<WebAssemblyModuleObject>(global_object, realm, result); } -void WebAssemblyModuleConstructor::initialize(JS::GlobalObject& global_object) +void WebAssemblyModuleConstructor::initialize(JS::Realm& realm) { auto& vm = this->vm(); - auto& window = static_cast<WindowObject&>(global_object); + auto& window = static_cast<WindowObject&>(realm.global_object()); - NativeFunction::initialize(global_object); + NativeFunction::initialize(realm); define_direct_property(vm.names.prototype, &window.ensure_web_prototype<WebAssemblyModulePrototype>("WebAssemblyModulePrototype"), 0); define_direct_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable); } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.h index ac1dfdf8a4..911f3582a4 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.h @@ -15,7 +15,7 @@ class WebAssemblyModuleConstructor : public JS::NativeFunction { public: explicit WebAssemblyModuleConstructor(JS::Realm&); - virtual void initialize(JS::GlobalObject&) override; + virtual void initialize(JS::Realm&) override; virtual ~WebAssemblyModuleConstructor() override; virtual JS::ThrowCompletionOr<JS::Value> call() override; diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp index 898882e2ee..6dec92b7c4 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp @@ -31,18 +31,18 @@ WebAssemblyObject::WebAssemblyObject(JS::Realm& realm) s_abstract_machine.enable_instruction_count_limit(); } -void WebAssemblyObject::initialize(JS::GlobalObject& global_object) +void WebAssemblyObject::initialize(JS::Realm& realm) { - Object::initialize(global_object); + Object::initialize(realm); u8 attr = JS::Attribute::Configurable | JS::Attribute::Writable | JS::Attribute::Enumerable; define_native_function("validate", validate, 1, attr); define_native_function("compile", compile, 1, attr); define_native_function("instantiate", instantiate, 1, attr); - auto& vm = global_object.vm(); + auto& vm = this->vm(); - auto& window = static_cast<WindowObject&>(global_object); + auto& window = static_cast<WindowObject&>(realm.global_object()); auto& memory_constructor = window.ensure_web_constructor<WebAssemblyMemoryConstructor>("WebAssembly.Memory"); memory_constructor.define_direct_property(vm.names.name, js_string(vm, "WebAssembly.Memory"), JS::Attribute::Configurable); auto& memory_prototype = window.ensure_web_prototype<WebAssemblyMemoryPrototype>("WebAssemblyMemoryPrototype"); diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h index 6ada19ec3a..35080471cd 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h @@ -24,7 +24,7 @@ class WebAssemblyObject final : public JS::Object { public: explicit WebAssemblyObject(JS::Realm&); - virtual void initialize(JS::GlobalObject&) override; + virtual void initialize(JS::Realm&) override; virtual ~WebAssemblyObject() override = default; virtual void visit_edges(Cell::Visitor&) override; diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.cpp index 1ca586a1ce..1ff1d30ddb 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.cpp @@ -81,12 +81,12 @@ JS::ThrowCompletionOr<JS::Object*> WebAssemblyTableConstructor::construct(Functi return vm.heap().allocate<WebAssemblyTableObject>(global_object, realm, *address); } -void WebAssemblyTableConstructor::initialize(JS::GlobalObject& global_object) +void WebAssemblyTableConstructor::initialize(JS::Realm& realm) { auto& vm = this->vm(); - auto& window = static_cast<WindowObject&>(global_object); + auto& window = static_cast<WindowObject&>(realm.global_object()); - NativeFunction::initialize(global_object); + NativeFunction::initialize(realm); define_direct_property(vm.names.prototype, &window.ensure_web_prototype<WebAssemblyTablePrototype>("WebAssemblyTablePrototype"), 0); define_direct_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable); } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.h index babf1f5aed..f8c0df3225 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.h @@ -15,7 +15,7 @@ class WebAssemblyTableConstructor : public JS::NativeFunction { public: explicit WebAssemblyTableConstructor(JS::Realm&); - virtual void initialize(JS::GlobalObject&) override; + virtual void initialize(JS::Realm&) override; virtual ~WebAssemblyTableConstructor() override; virtual JS::ThrowCompletionOr<JS::Value> call() override; diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.cpp index ac9b8704e6..91f7fe0bb4 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.cpp @@ -10,9 +10,9 @@ namespace Web::Bindings { -void WebAssemblyTablePrototype::initialize(JS::GlobalObject& global_object) +void WebAssemblyTablePrototype::initialize(JS::Realm& realm) { - Object::initialize(global_object); + Object::initialize(realm); define_native_accessor("length", length_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable); define_native_function("grow", grow, 1, JS::Attribute::Writable | JS::Attribute::Enumerable | JS::Attribute::Configurable); define_native_function("get", get, 1, JS::Attribute::Writable | JS::Attribute::Enumerable | JS::Attribute::Configurable); diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.h index 14067840bb..c3d576f0a9 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.h @@ -24,7 +24,7 @@ public: { } - virtual void initialize(JS::GlobalObject& global_object) override; + virtual void initialize(JS::Realm&) override; private: JS_DECLARE_NATIVE_FUNCTION(grow); |