diff options
author | Luke Wilde <lukew@serenityos.org> | 2022-08-23 17:25:10 +0100 |
---|---|---|
committer | Andrew Kaster <andrewdkaster@gmail.com> | 2022-12-25 07:58:58 -0700 |
commit | c9e6967d7b18f85f01793d4e19a6e3c49727e1c1 (patch) | |
tree | a2165d515dcf6c21f4214ad66e9ad09e47a502b2 /Ladybird | |
parent | a14b00e046f02fd39cb27f033686c1b8d3747673 (diff) | |
download | serenity-c9e6967d7b18f85f01793d4e19a6e3c49727e1c1.zip |
Ladybird: Update for LibJS realm changes
Diffstat (limited to 'Ladybird')
-rw-r--r-- | Ladybird/ConsoleClient.cpp | 7 | ||||
-rw-r--r-- | Ladybird/ConsoleGlobalObject.cpp | 13 | ||||
-rw-r--r-- | Ladybird/ConsoleGlobalObject.h | 2 | ||||
-rw-r--r-- | Ladybird/WebView.cpp | 7 |
4 files changed, 17 insertions, 12 deletions
diff --git a/Ladybird/ConsoleClient.cpp b/Ladybird/ConsoleClient.cpp index 8f44aa444a..1a72de5fdc 100644 --- a/Ladybird/ConsoleClient.cpp +++ b/Ladybird/ConsoleClient.cpp @@ -26,16 +26,17 @@ ConsoleClient::ConsoleClient(JS::Console& console, WeakPtr<JS::Interpreter> inte JS::DeferGC defer_gc(m_interpreter->heap()); auto& vm = m_interpreter->vm(); - auto& global_object = m_interpreter->global_object(); + auto& realm = m_interpreter->realm(); + auto& window = static_cast<Web::Bindings::WindowObject&>(realm.global_object()); - auto console_global_object = m_interpreter->heap().allocate_without_global_object<ConsoleGlobalObject>(*global_object.associated_realm(), static_cast<Web::Bindings::WindowObject&>(global_object)); + auto console_global_object = m_interpreter->heap().allocate_without_realm<ConsoleGlobalObject>(realm, window); // NOTE: We need to push an execution context here for NativeFunction::create() to succeed during global object initialization. // It gets removed immediately after creating the interpreter in Document::interpreter(). auto& eso = verify_cast<Web::HTML::EnvironmentSettingsObject>(*m_interpreter->realm().host_defined()); vm.push_execution_context(eso.realm_execution_context()); console_global_object->set_associated_realm(m_interpreter->realm()); - console_global_object->initialize_global_object(); + console_global_object->initialize_global_object(realm); vm.pop_execution_context(); m_console_global_object = JS::make_handle(console_global_object); diff --git a/Ladybird/ConsoleGlobalObject.cpp b/Ladybird/ConsoleGlobalObject.cpp index 07ba5329f1..c4da91221e 100644 --- a/Ladybird/ConsoleGlobalObject.cpp +++ b/Ladybird/ConsoleGlobalObject.cpp @@ -21,12 +21,12 @@ ConsoleGlobalObject::ConsoleGlobalObject(JS::Realm& realm, Web::Bindings::Window { } -void ConsoleGlobalObject::initialize_global_object() +void ConsoleGlobalObject::initialize_global_object(JS::Realm& realm) { - Base::initialize_global_object(); + Base::initialize_global_object(realm); // $0 magic variable - define_native_accessor("$0", inspected_node_getter, nullptr, 0); + define_native_accessor(realm, "$0", inspected_node_getter, nullptr, 0); } void ConsoleGlobalObject::visit_edges(Visitor& visitor) @@ -98,10 +98,11 @@ JS::ThrowCompletionOr<JS::MarkedVector<JS::Value>> ConsoleGlobalObject::internal JS_DEFINE_NATIVE_FUNCTION(ConsoleGlobalObject::inspected_node_getter) { - auto* this_object = TRY(vm.this_value(global_object).to_object(global_object)); + auto& realm = *vm.current_realm(); + auto* this_object = TRY(vm.this_value().to_object(vm)); if (!is<ConsoleGlobalObject>(this_object)) - return vm.throw_completion<JS::TypeError>(global_object, JS::ErrorType::NotAnObjectOfType, "ConsoleGlobalObject"); + return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "ConsoleGlobalObject"); auto console_global_object = static_cast<ConsoleGlobalObject*>(this_object); auto& window = console_global_object->m_window_object->impl(); @@ -109,7 +110,7 @@ JS_DEFINE_NATIVE_FUNCTION(ConsoleGlobalObject::inspected_node_getter) if (!inspected_node) return JS::js_undefined(); - return Web::Bindings::wrap(global_object, *inspected_node); + return Web::Bindings::wrap(realm, *inspected_node); } } diff --git a/Ladybird/ConsoleGlobalObject.h b/Ladybird/ConsoleGlobalObject.h index 2e50f951cf..e6f4c60c16 100644 --- a/Ladybird/ConsoleGlobalObject.h +++ b/Ladybird/ConsoleGlobalObject.h @@ -38,7 +38,7 @@ public: virtual JS::ThrowCompletionOr<bool> internal_delete(JS::PropertyKey const& name) override; virtual JS::ThrowCompletionOr<JS::MarkedVector<JS::Value>> internal_own_property_keys() const override; - virtual void initialize_global_object() override; + virtual void initialize_global_object(JS::Realm&) override; private: virtual void visit_edges(Visitor&) override; diff --git a/Ladybird/WebView.cpp b/Ladybird/WebView.cpp index a53f5d3fcf..5c5d06e8ed 100644 --- a/Ladybird/WebView.cpp +++ b/Ladybird/WebView.cpp @@ -186,8 +186,11 @@ public: return; m_interpreter = interpreter; - m_console_client = make<Ladybird::ConsoleClient>(interpreter->global_object().console(), interpreter, m_view); - interpreter->global_object().console().set_client(*m_console_client.ptr()); + + auto& realm = interpreter->realm(); + auto& global_object = realm.global_object(); + m_console_client = make<Ladybird::ConsoleClient>(global_object.console(), interpreter, m_view); + global_object.console().set_client(*m_console_client.ptr()); } virtual void page_did_change_selection() override |