diff options
author | Linus Groh <mail@linusgroh.de> | 2022-08-22 18:31:08 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-08-23 13:58:30 +0100 |
commit | 40a70461a0f6b0224c51fe7fb1be28edd26bb4b3 (patch) | |
tree | 5d54bb00d2d82dac774137057bcec21cc9d5d56d /Userland/Libraries/LibWeb/HTML | |
parent | 56b2ae5ac0a383c96163c4b7b07bddd79da23c7a (diff) | |
download | serenity-40a70461a0f6b0224c51fe7fb1be28edd26bb4b3.zip |
LibWeb: Replace GlobalObject with Realm in wrapper functions
Similar to create() in LibJS, wrap() et al. are on a low enough level to
warrant passing a Realm directly instead of relying on the current realm
from the VM, as a wrapper may need to be allocated while no JS is being
executed.
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML')
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/MessagePort.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/MessagePort.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/Storage.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/Window.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/Window.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/Worker.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/Worker.h | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h | 2 |
10 files changed, 17 insertions, 17 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.h b/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.h index 7444607cfd..105009b4ff 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.h @@ -34,6 +34,6 @@ protected: namespace Web::Bindings { -HTMLOptionsCollectionWrapper* wrap(JS::GlobalObject&, HTML::HTMLOptionsCollection&); +HTMLOptionsCollectionWrapper* wrap(JS::Realm&, HTML::HTMLOptionsCollection&); } diff --git a/Userland/Libraries/LibWeb/HTML/MessagePort.cpp b/Userland/Libraries/LibWeb/HTML/MessagePort.cpp index 59d013601e..cbbc0e230d 100644 --- a/Userland/Libraries/LibWeb/HTML/MessagePort.cpp +++ b/Userland/Libraries/LibWeb/HTML/MessagePort.cpp @@ -84,9 +84,9 @@ void MessagePort::post_message(JS::Value message) })); } -JS::Object* MessagePort::create_wrapper(JS::GlobalObject& global_object) +JS::Object* MessagePort::create_wrapper(JS::Realm& realm) { - return wrap(global_object, *this); + return wrap(realm, *this); } void MessagePort::start() diff --git a/Userland/Libraries/LibWeb/HTML/MessagePort.h b/Userland/Libraries/LibWeb/HTML/MessagePort.h index fc8031582b..d2b5a476fb 100644 --- a/Userland/Libraries/LibWeb/HTML/MessagePort.h +++ b/Userland/Libraries/LibWeb/HTML/MessagePort.h @@ -40,7 +40,7 @@ public: // ^EventTarget virtual void ref_event_target() override { ref(); } virtual void unref_event_target() override { unref(); } - virtual JS::Object* create_wrapper(JS::GlobalObject&) override; + virtual JS::Object* create_wrapper(JS::Realm&) override; // https://html.spec.whatwg.org/multipage/web-messaging.html#entangle void entangle_with(MessagePort&); diff --git a/Userland/Libraries/LibWeb/HTML/Storage.h b/Userland/Libraries/LibWeb/HTML/Storage.h index 4f5465ac2f..c8ad3f99f9 100644 --- a/Userland/Libraries/LibWeb/HTML/Storage.h +++ b/Userland/Libraries/LibWeb/HTML/Storage.h @@ -49,6 +49,6 @@ private: namespace Web::Bindings { -StorageWrapper* wrap(JS::GlobalObject&, HTML::Storage&); +StorageWrapper* wrap(JS::Realm&, HTML::Storage&); } diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp index ab07a46022..c1e2afaec6 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.cpp +++ b/Userland/Libraries/LibWeb/HTML/Window.cpp @@ -284,9 +284,9 @@ bool Window::dispatch_event(NonnullRefPtr<DOM::Event> event) return DOM::EventDispatcher::dispatch(*this, event, true); } -JS::Object* Window::create_wrapper(JS::GlobalObject& global_object) +JS::Object* Window::create_wrapper(JS::Realm& realm) { - return &global_object; + return &realm.global_object(); } // https://www.w3.org/TR/cssom-view-1/#dom-window-innerwidth @@ -653,8 +653,8 @@ u32 Window::request_idle_callback(NonnullOwnPtr<Bindings::CallbackType> callback auto handle = window.m_idle_callback_identifier; // 4. Push callback to the end of window's list of idle request callbacks, associated with handle. auto handler = [callback = move(callback)](NonnullRefPtr<RequestIdleCallback::IdleDeadline> deadline) -> JS::Completion { - auto& global_object = callback->callback.cell()->global_object(); - auto* wrapped_deadline = Bindings::wrap(global_object, *deadline); + auto& realm = callback->callback.cell()->shape().realm(); + auto* wrapped_deadline = Bindings::wrap(realm, *deadline); return Bindings::IDL::invoke_callback(const_cast<Bindings::CallbackType&>(*callback), {}, JS::Value(wrapped_deadline)); }; window.m_idle_request_callbacks.append(adopt_ref(*new IdleCallback(move(handler), handle))); diff --git a/Userland/Libraries/LibWeb/HTML/Window.h b/Userland/Libraries/LibWeb/HTML/Window.h index dcb711f506..a1284ba8aa 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.h +++ b/Userland/Libraries/LibWeb/HTML/Window.h @@ -44,7 +44,7 @@ public: virtual void ref_event_target() override { RefCounted::ref(); } virtual void unref_event_target() override { RefCounted::unref(); } virtual bool dispatch_event(NonnullRefPtr<DOM::Event>) override; - virtual JS::Object* create_wrapper(JS::GlobalObject&) override; + virtual JS::Object* create_wrapper(JS::Realm&) override; Page* page(); Page const* page() const; diff --git a/Userland/Libraries/LibWeb/HTML/Worker.cpp b/Userland/Libraries/LibWeb/HTML/Worker.cpp index 9cafb21f37..970b471944 100644 --- a/Userland/Libraries/LibWeb/HTML/Worker.cpp +++ b/Userland/Libraries/LibWeb/HTML/Worker.cpp @@ -314,9 +314,9 @@ void Worker::post_message(JS::Value message, JS::Value) target_port->post_message(message); } -JS::Object* Worker::create_wrapper(JS::GlobalObject& global_object) +JS::Object* Worker::create_wrapper(JS::Realm& realm) { - return wrap(global_object, *this); + return wrap(realm, *this); } #undef __ENUMERATE diff --git a/Userland/Libraries/LibWeb/HTML/Worker.h b/Userland/Libraries/LibWeb/HTML/Worker.h index f37ff1014a..0b7be28446 100644 --- a/Userland/Libraries/LibWeb/HTML/Worker.h +++ b/Userland/Libraries/LibWeb/HTML/Worker.h @@ -58,7 +58,7 @@ public: // ^EventTarget virtual void ref_event_target() override { ref(); } virtual void unref_event_target() override { unref(); } - virtual JS::Object* create_wrapper(JS::GlobalObject&) override; + virtual JS::Object* create_wrapper(JS::Realm&) override; MessagePort* implicit_message_port() { return m_implicit_port; } RefPtr<MessagePort> outside_message_port() { return m_outside_port; } @@ -102,6 +102,6 @@ private: namespace Web::Bindings { -WorkerWrapper* wrap(JS::GlobalObject&, HTML::Worker&); +WorkerWrapper* wrap(JS::Realm&, HTML::Worker&); } diff --git a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp index 038093d240..1515d32640 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp +++ b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp @@ -54,9 +54,9 @@ DOM::ExceptionOr<void> WorkerGlobalScope::import_scripts(Vector<String> urls) return {}; } -JS::Object* WorkerGlobalScope::create_wrapper(JS::GlobalObject& global_object) +JS::Object* WorkerGlobalScope::create_wrapper(JS::Realm& realm) { - return wrap(global_object, *this); + return wrap(realm, *this); } // https://html.spec.whatwg.org/multipage/workers.html#dom-workerglobalscope-location diff --git a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h index ba2cdc3809..29802976f1 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h +++ b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h @@ -44,7 +44,7 @@ public: // ^EventTarget virtual void ref_event_target() override { ref(); } virtual void unref_event_target() override { unref(); } - virtual JS::Object* create_wrapper(JS::GlobalObject&) override; + virtual JS::Object* create_wrapper(JS::Realm&) override; // Following methods are from the WorkerGlobalScope IDL definition // https://html.spec.whatwg.org/multipage/workers.html#the-workerglobalscope-common-interface |