diff options
60 files changed, 261 insertions, 235 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp index f31d49df28..6ffebcf539 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp @@ -913,7 +913,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter // The lambda must take the JS::Value to convert as a parameter instead of capturing it in order to support union types being variadic. StringBuilder to_variant_captures; - to_variant_captures.append("&global_object, &vm"sv); + to_variant_captures.append("&global_object, &vm, &realm"sv); if (dictionary_type) to_variant_captures.append(String::formatted(", &{}{}_to_dictionary", js_name, js_suffix)); @@ -925,6 +925,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter // These might be unused. (void)global_object; (void)vm; + (void)realm; )~~~"); // 1. If the union type includes undefined and V is undefined, then return the unique undefined value. @@ -1507,10 +1508,11 @@ static void generate_wrap_statement(SourceGenerator& generator, String const& va auto cpp_type = IDL::idl_type_name_to_cpp_type(current_union_type, interface); union_generator.set("current_type", cpp_type.name); union_generator.append(R"~~~( - [&vm, &global_object](@current_type@ const& visited_union_value@recursion_depth@) -> JS::Value { + [&vm, &global_object, &realm](@current_type@ const& visited_union_value@recursion_depth@) -> JS::Value { // These may be unused. (void)vm; (void)global_object; + (void) realm; )~~~"); // NOTE: While we are using const&, the underlying type for wrappable types in unions is (Nonnull)RefPtr, which are not references. @@ -1609,11 +1611,11 @@ static void generate_wrap_statement(SourceGenerator& generator, String const& va } else { if (wrapping_reference == WrappingReference::No) { scoped_generator.append(R"~~~( - @result_expression@ wrap(global_object, const_cast<@type@&>(*@value@)); + @result_expression@ wrap(realm, const_cast<@type@&>(*@value@)); )~~~"); } else { scoped_generator.append(R"~~~( - @result_expression@ wrap(global_object, const_cast<@type@&>(@value@)); + @result_expression@ wrap(realm, const_cast<@type@&>(@value@)); )~~~"); } } @@ -1948,7 +1950,7 @@ inline String idl_enum_to_string(@enum.type.name@ value) { if (should_emit_wrapper_factory(interface)) { generator.append(R"~~~( -@wrapper_class@* wrap(JS::GlobalObject&, @fully_qualified_name@&); +@wrapper_class@* wrap(JS::Realm&, @fully_qualified_name@&); )~~~"); } @@ -2045,9 +2047,9 @@ void @wrapper_class@::initialize(JS::Realm& realm) if (should_emit_wrapper_factory(interface)) { generator.append(R"~~~( -@wrapper_class@* wrap(JS::GlobalObject& global_object, @fully_qualified_name@& impl) +@wrapper_class@* wrap(JS::Realm& realm, @fully_qualified_name@& impl) { - return static_cast<@wrapper_class@*>(wrap_impl(global_object, impl)); + return static_cast<@wrapper_class@*>(wrap_impl(realm, impl)); } )~~~"); } @@ -2072,6 +2074,7 @@ void @wrapper_class@::visit_edges(JS::Cell::Visitor& visitor) static JS::Value wrap_for_legacy_platform_object_get_own_property(JS::GlobalObject& global_object, [[maybe_unused]] auto& retval) { [[maybe_unused]] auto& vm = global_object.vm(); + [[maybe_unused]] auto& realm = *vm.current_realm(); )~~~"); if (interface.named_property_getter.has_value()) { @@ -2989,7 +2992,7 @@ JS::ThrowCompletionOr<JS::Object*> @constructor_class@::construct(FunctionObject )~~~"); } generator.append(R"~~~( - return wrap(global_object, *impl); + return wrap(realm, *impl); )~~~"); } else { // Multiple constructor overloads - can't do that yet. @@ -3528,9 +3531,10 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::to_string) iterator_generator.append(R"~~~( JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::entries) { + auto& realm = *vm.current_realm(); auto* impl = TRY(impl_from(vm, global_object)); - return wrap(global_object, @iterator_name@::create(*impl, Object::PropertyKind::KeyAndValue)); + return wrap(realm, @iterator_name@::create(*impl, Object::PropertyKind::KeyAndValue)); } JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::for_each) @@ -3557,16 +3561,18 @@ JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::for_each) JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::keys) { + auto& realm = *vm.current_realm(); auto* impl = TRY(impl_from(vm, global_object)); - return wrap(global_object, @iterator_name@::create(*impl, Object::PropertyKind::Key)); + return wrap(realm, @iterator_name@::create(*impl, Object::PropertyKind::Key)); } JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::values) { + auto& realm = *vm.current_realm(); auto* impl = TRY(impl_from(vm, global_object)); - return wrap(global_object, @iterator_name@::create(*impl, Object::PropertyKind::Value)); + return wrap(realm, @iterator_name@::create(*impl, Object::PropertyKind::Value)); } )~~~"); } @@ -3613,7 +3619,7 @@ private: NonnullRefPtr<@fully_qualified_name@> m_impl; }; -@wrapper_class@* wrap(JS::GlobalObject&, @fully_qualified_name@&); +@wrapper_class@* wrap(JS::Realm&, @fully_qualified_name@&); } // namespace Web::Bindings )~~~"); @@ -3696,9 +3702,9 @@ void @wrapper_class@::visit_edges(Cell::Visitor& visitor) impl().visit_edges(visitor); } -@wrapper_class@* wrap(JS::GlobalObject& global_object, @fully_qualified_name@& impl) +@wrapper_class@* wrap(JS::Realm& realm, @fully_qualified_name@& impl) { - return static_cast<@wrapper_class@*>(wrap_impl(global_object, impl)); + return static_cast<@wrapper_class@*>(wrap_impl(realm, impl)); } } // namespace Web::Bindings diff --git a/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp index c2213231e6..54ef788791 100644 --- a/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp @@ -38,6 +38,7 @@ JS::ThrowCompletionOr<JS::Value> AudioConstructor::call() JS::ThrowCompletionOr<JS::Object*> AudioConstructor::construct(FunctionObject&) { auto& vm = this->vm(); + auto& realm = *vm.current_realm(); // 1. Let document be the current global object's associated Document. auto& window = static_cast<WindowObject&>(HTML::current_global_object()); @@ -59,7 +60,7 @@ JS::ThrowCompletionOr<JS::Object*> AudioConstructor::construct(FunctionObject&) } // 5. Return audio. - return wrap(global_object(), audio); + return wrap(realm, audio); } } diff --git a/Userland/Libraries/LibWeb/Bindings/CSSRuleWrapperFactory.cpp b/Userland/Libraries/LibWeb/Bindings/CSSRuleWrapperFactory.cpp index c46d960a31..2870c97f4c 100644 --- a/Userland/Libraries/LibWeb/Bindings/CSSRuleWrapperFactory.cpp +++ b/Userland/Libraries/LibWeb/Bindings/CSSRuleWrapperFactory.cpp @@ -20,22 +20,22 @@ namespace Web::Bindings { -CSSRuleWrapper* wrap(JS::GlobalObject& global_object, CSS::CSSRule& rule) +CSSRuleWrapper* wrap(JS::Realm& realm, CSS::CSSRule& rule) { if (rule.wrapper()) return static_cast<CSSRuleWrapper*>(rule.wrapper()); if (is<CSS::CSSStyleRule>(rule)) - return static_cast<CSSRuleWrapper*>(wrap_impl(global_object, verify_cast<CSS::CSSStyleRule>(rule))); + return static_cast<CSSRuleWrapper*>(wrap_impl(realm, verify_cast<CSS::CSSStyleRule>(rule))); if (is<CSS::CSSImportRule>(rule)) - return static_cast<CSSRuleWrapper*>(wrap_impl(global_object, verify_cast<CSS::CSSImportRule>(rule))); + return static_cast<CSSRuleWrapper*>(wrap_impl(realm, verify_cast<CSS::CSSImportRule>(rule))); if (is<CSS::CSSMediaRule>(rule)) - return static_cast<CSSRuleWrapper*>(wrap_impl(global_object, verify_cast<CSS::CSSMediaRule>(rule))); + return static_cast<CSSRuleWrapper*>(wrap_impl(realm, verify_cast<CSS::CSSMediaRule>(rule))); if (is<CSS::CSSFontFaceRule>(rule)) - return static_cast<CSSRuleWrapper*>(wrap_impl(global_object, verify_cast<CSS::CSSFontFaceRule>(rule))); + return static_cast<CSSRuleWrapper*>(wrap_impl(realm, verify_cast<CSS::CSSFontFaceRule>(rule))); if (is<CSS::CSSSupportsRule>(rule)) - return static_cast<CSSRuleWrapper*>(wrap_impl(global_object, verify_cast<CSS::CSSSupportsRule>(rule))); - return static_cast<CSSRuleWrapper*>(wrap_impl(global_object, rule)); + return static_cast<CSSRuleWrapper*>(wrap_impl(realm, verify_cast<CSS::CSSSupportsRule>(rule))); + return static_cast<CSSRuleWrapper*>(wrap_impl(realm, rule)); } } diff --git a/Userland/Libraries/LibWeb/Bindings/CSSRuleWrapperFactory.h b/Userland/Libraries/LibWeb/Bindings/CSSRuleWrapperFactory.h index de30b69dc2..2382bfef97 100644 --- a/Userland/Libraries/LibWeb/Bindings/CSSRuleWrapperFactory.h +++ b/Userland/Libraries/LibWeb/Bindings/CSSRuleWrapperFactory.h @@ -11,6 +11,6 @@ namespace Web::Bindings { -CSSRuleWrapper* wrap(JS::GlobalObject&, CSS::CSSRule&); +CSSRuleWrapper* wrap(JS::Realm&, CSS::CSSRule&); } diff --git a/Userland/Libraries/LibWeb/Bindings/EventTargetWrapperFactory.cpp b/Userland/Libraries/LibWeb/Bindings/EventTargetWrapperFactory.cpp index 684da8bf8d..1f764e6d23 100644 --- a/Userland/Libraries/LibWeb/Bindings/EventTargetWrapperFactory.cpp +++ b/Userland/Libraries/LibWeb/Bindings/EventTargetWrapperFactory.cpp @@ -9,9 +9,9 @@ namespace Web::Bindings { -JS::Object* wrap(JS::GlobalObject& global_object, DOM::EventTarget& target) +JS::Object* wrap(JS::Realm& realm, DOM::EventTarget& target) { - return target.create_wrapper(global_object); + return target.create_wrapper(realm); } } diff --git a/Userland/Libraries/LibWeb/Bindings/EventTargetWrapperFactory.h b/Userland/Libraries/LibWeb/Bindings/EventTargetWrapperFactory.h index 75757f7125..5ebd48575e 100644 --- a/Userland/Libraries/LibWeb/Bindings/EventTargetWrapperFactory.h +++ b/Userland/Libraries/LibWeb/Bindings/EventTargetWrapperFactory.h @@ -11,6 +11,6 @@ namespace Web::Bindings { -JS::Object* wrap(JS::GlobalObject&, DOM::EventTarget&); +JS::Object* wrap(JS::Realm&, DOM::EventTarget&); } diff --git a/Userland/Libraries/LibWeb/Bindings/EventWrapperFactory.cpp b/Userland/Libraries/LibWeb/Bindings/EventWrapperFactory.cpp index 32c38fdeb4..6a3e33d0a1 100644 --- a/Userland/Libraries/LibWeb/Bindings/EventWrapperFactory.cpp +++ b/Userland/Libraries/LibWeb/Bindings/EventWrapperFactory.cpp @@ -21,36 +21,36 @@ namespace Web::Bindings { -EventWrapper* wrap(JS::GlobalObject& global_object, DOM::Event& event) +EventWrapper* wrap(JS::Realm& realm, DOM::Event& event) { if (event.wrapper()) return static_cast<EventWrapper*>(event.wrapper()); if (is<DOM::CustomEvent>(event)) - return static_cast<CustomEventWrapper*>(wrap_impl(global_object, static_cast<DOM::CustomEvent&>(event))); + return static_cast<CustomEventWrapper*>(wrap_impl(realm, static_cast<DOM::CustomEvent&>(event))); if (is<CSS::MediaQueryListEvent>(event)) - return static_cast<MediaQueryListEventWrapper*>(wrap_impl(global_object, static_cast<CSS::MediaQueryListEvent&>(event))); + return static_cast<MediaQueryListEventWrapper*>(wrap_impl(realm, static_cast<CSS::MediaQueryListEvent&>(event))); if (is<HTML::CloseEvent>(event)) - return static_cast<CloseEventWrapper*>(wrap_impl(global_object, static_cast<HTML::CloseEvent&>(event))); + return static_cast<CloseEventWrapper*>(wrap_impl(realm, static_cast<HTML::CloseEvent&>(event))); if (is<HTML::MessageEvent>(event)) - return static_cast<MessageEventWrapper*>(wrap_impl(global_object, static_cast<HTML::MessageEvent&>(event))); + return static_cast<MessageEventWrapper*>(wrap_impl(realm, static_cast<HTML::MessageEvent&>(event))); if (is<HTML::PageTransitionEvent>(event)) - return static_cast<PageTransitionEventWrapper*>(wrap_impl(global_object, static_cast<HTML::PageTransitionEvent&>(event))); + return static_cast<PageTransitionEventWrapper*>(wrap_impl(realm, static_cast<HTML::PageTransitionEvent&>(event))); if (is<HTML::PromiseRejectionEvent>(event)) - return static_cast<PromiseRejectionEventWrapper*>(wrap_impl(global_object, static_cast<HTML::PromiseRejectionEvent&>(event))); + return static_cast<PromiseRejectionEventWrapper*>(wrap_impl(realm, static_cast<HTML::PromiseRejectionEvent&>(event))); if (is<HTML::SubmitEvent>(event)) - return static_cast<SubmitEventWrapper*>(wrap_impl(global_object, static_cast<HTML::SubmitEvent&>(event))); + return static_cast<SubmitEventWrapper*>(wrap_impl(realm, static_cast<HTML::SubmitEvent&>(event))); if (is<UIEvents::KeyboardEvent>(event)) - return static_cast<KeyboardEventWrapper*>(wrap_impl(global_object, static_cast<UIEvents::KeyboardEvent&>(event))); + return static_cast<KeyboardEventWrapper*>(wrap_impl(realm, static_cast<UIEvents::KeyboardEvent&>(event))); if (is<UIEvents::MouseEvent>(event)) - return static_cast<MouseEventWrapper*>(wrap_impl(global_object, static_cast<UIEvents::MouseEvent&>(event))); + return static_cast<MouseEventWrapper*>(wrap_impl(realm, static_cast<UIEvents::MouseEvent&>(event))); if (is<XHR::ProgressEvent>(event)) - return static_cast<ProgressEventWrapper*>(wrap_impl(global_object, static_cast<XHR::ProgressEvent&>(event))); + return static_cast<ProgressEventWrapper*>(wrap_impl(realm, static_cast<XHR::ProgressEvent&>(event))); if (is<UIEvents::UIEvent>(event)) - return static_cast<UIEventWrapper*>(wrap_impl(global_object, static_cast<UIEvents::UIEvent&>(event))); + return static_cast<UIEventWrapper*>(wrap_impl(realm, static_cast<UIEvents::UIEvent&>(event))); if (is<WebGL::WebGLContextEvent>(event)) - return static_cast<WebGLContextEventWrapper*>(wrap_impl(global_object, static_cast<WebGL::WebGLContextEvent&>(event))); - return static_cast<EventWrapper*>(wrap_impl(global_object, event)); + return static_cast<WebGLContextEventWrapper*>(wrap_impl(realm, static_cast<WebGL::WebGLContextEvent&>(event))); + return static_cast<EventWrapper*>(wrap_impl(realm, event)); } } diff --git a/Userland/Libraries/LibWeb/Bindings/EventWrapperFactory.h b/Userland/Libraries/LibWeb/Bindings/EventWrapperFactory.h index bde4ad7381..c57c13cdb5 100644 --- a/Userland/Libraries/LibWeb/Bindings/EventWrapperFactory.h +++ b/Userland/Libraries/LibWeb/Bindings/EventWrapperFactory.h @@ -11,6 +11,6 @@ namespace Web::Bindings { -EventWrapper* wrap(JS::GlobalObject&, DOM::Event&); +EventWrapper* wrap(JS::Realm&, DOM::Event&); } diff --git a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp index 68e7c8498e..7c2810aff6 100644 --- a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp @@ -38,6 +38,7 @@ JS::ThrowCompletionOr<JS::Value> ImageConstructor::call() JS::ThrowCompletionOr<JS::Object*> ImageConstructor::construct(FunctionObject&) { auto& vm = this->vm(); + auto& realm = *vm.current_realm(); // 1. Let document be the current global object's associated Document. auto& window = static_cast<WindowObject&>(HTML::current_global_object()); @@ -59,7 +60,7 @@ JS::ThrowCompletionOr<JS::Object*> ImageConstructor::construct(FunctionObject&) } // 5. Return img. - return wrap(global_object(), image_element); + return wrap(realm, image_element); } } diff --git a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp index 5c7edc4bc2..73c94e6a74 100644 --- a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp +++ b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp @@ -343,18 +343,17 @@ void queue_mutation_observer_microtask(DOM::Document& document) // 4. If records is not empty, then invoke mo’s callback with « records, mo », and mo. If this throws an exception, catch it, and report the exception. if (!records.is_empty()) { auto& callback = mutation_observer.callback(); - auto& global_object = callback.callback_context.global_object(); auto& realm = callback.callback_context.realm(); auto* wrapped_records = MUST(JS::Array::create(realm, 0)); for (size_t i = 0; i < records.size(); ++i) { auto& record = records.at(i); - auto* wrapped_record = Bindings::wrap(global_object, record); + auto* wrapped_record = Bindings::wrap(realm, record); auto property_index = JS::PropertyKey { i }; MUST(wrapped_records->create_data_property(property_index, wrapped_record)); } - auto* wrapped_mutation_observer = Bindings::wrap(global_object, mutation_observer); + auto* wrapped_mutation_observer = Bindings::wrap(realm, mutation_observer); auto result = IDL::invoke_callback(callback, wrapped_mutation_observer, wrapped_records, wrapped_mutation_observer); if (result.is_abrupt()) diff --git a/Userland/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp b/Userland/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp index c3a7370c72..62b58e9cb8 100644 --- a/Userland/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp +++ b/Userland/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp @@ -175,186 +175,186 @@ namespace Web::Bindings { -NodeWrapper* wrap(JS::GlobalObject& global_object, DOM::Node& node) +NodeWrapper* wrap(JS::Realm& realm, DOM::Node& node) { if (node.wrapper()) return static_cast<NodeWrapper*>(node.wrapper()); if (is<DOM::Document>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<DOM::Document>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<DOM::Document>(node))); if (is<DOM::DocumentType>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<DOM::DocumentType>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<DOM::DocumentType>(node))); if (is<HTML::HTMLAnchorElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLAnchorElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLAnchorElement>(node))); if (is<HTML::HTMLAreaElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLAreaElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLAreaElement>(node))); if (is<HTML::HTMLAudioElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLAudioElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLAudioElement>(node))); if (is<HTML::HTMLBaseElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLBaseElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLBaseElement>(node))); if (is<HTML::HTMLBodyElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLBodyElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLBodyElement>(node))); if (is<HTML::HTMLBRElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLBRElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLBRElement>(node))); if (is<HTML::HTMLButtonElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLButtonElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLButtonElement>(node))); if (is<HTML::HTMLCanvasElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLCanvasElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLCanvasElement>(node))); if (is<HTML::HTMLDataElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLDataElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLDataElement>(node))); if (is<HTML::HTMLDataListElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLDataListElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLDataListElement>(node))); if (is<HTML::HTMLDetailsElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLDetailsElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLDetailsElement>(node))); if (is<HTML::HTMLDialogElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLDialogElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLDialogElement>(node))); if (is<HTML::HTMLDirectoryElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLDirectoryElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLDirectoryElement>(node))); if (is<HTML::HTMLDivElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLDivElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLDivElement>(node))); if (is<HTML::HTMLDListElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLDListElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLDListElement>(node))); if (is<HTML::HTMLEmbedElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLEmbedElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLEmbedElement>(node))); if (is<HTML::HTMLFieldSetElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLFieldSetElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLFieldSetElement>(node))); if (is<HTML::HTMLFontElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLFontElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLFontElement>(node))); if (is<HTML::HTMLFormElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLFormElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLFormElement>(node))); if (is<HTML::HTMLFrameElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLFrameElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLFrameElement>(node))); if (is<HTML::HTMLFrameSetElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLFrameSetElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLFrameSetElement>(node))); if (is<HTML::HTMLHeadElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLHeadElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLHeadElement>(node))); if (is<HTML::HTMLHeadingElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLHeadingElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLHeadingElement>(node))); if (is<HTML::HTMLHRElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLHRElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLHRElement>(node))); if (is<HTML::HTMLHtmlElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLHtmlElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLHtmlElement>(node))); if (is<HTML::HTMLIFrameElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLIFrameElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLIFrameElement>(node))); if (is<HTML::HTMLImageElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLImageElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLImageElement>(node))); if (is<HTML::HTMLInputElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLInputElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLInputElement>(node))); if (is<HTML::HTMLLabelElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLLabelElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLLabelElement>(node))); if (is<HTML::HTMLLegendElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLLegendElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLLegendElement>(node))); if (is<HTML::HTMLLIElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLLIElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLLIElement>(node))); if (is<HTML::HTMLLinkElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLLinkElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLLinkElement>(node))); if (is<HTML::HTMLMapElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLMapElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLMapElement>(node))); if (is<HTML::HTMLMarqueeElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLMarqueeElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLMarqueeElement>(node))); if (is<HTML::HTMLMenuElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLMenuElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLMenuElement>(node))); if (is<HTML::HTMLMetaElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLMetaElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLMetaElement>(node))); if (is<HTML::HTMLMeterElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLMeterElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLMeterElement>(node))); if (is<HTML::HTMLModElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLModElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLModElement>(node))); if (is<HTML::HTMLObjectElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLObjectElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLObjectElement>(node))); if (is<HTML::HTMLOListElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLOListElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLOListElement>(node))); if (is<HTML::HTMLOptGroupElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLOptGroupElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLOptGroupElement>(node))); if (is<HTML::HTMLOptionElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLOptionElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLOptionElement>(node))); if (is<HTML::HTMLOutputElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLOutputElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLOutputElement>(node))); if (is<HTML::HTMLParagraphElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLParagraphElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLParagraphElement>(node))); if (is<HTML::HTMLParamElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLParamElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLParamElement>(node))); if (is<HTML::HTMLPictureElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLPictureElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLPictureElement>(node))); if (is<HTML::HTMLPreElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLPreElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLPreElement>(node))); if (is<HTML::HTMLProgressElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLProgressElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLProgressElement>(node))); if (is<HTML::HTMLQuoteElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLQuoteElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLQuoteElement>(node))); if (is<HTML::HTMLScriptElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLScriptElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLScriptElement>(node))); if (is<HTML::HTMLSelectElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLSelectElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLSelectElement>(node))); if (is<HTML::HTMLSlotElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLSlotElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLSlotElement>(node))); if (is<HTML::HTMLSourceElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLSourceElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLSourceElement>(node))); if (is<HTML::HTMLSpanElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLSpanElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLSpanElement>(node))); if (is<HTML::HTMLStyleElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLStyleElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLStyleElement>(node))); if (is<HTML::HTMLTableCaptionElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLTableCaptionElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLTableCaptionElement>(node))); if (is<HTML::HTMLTableCellElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLTableCellElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLTableCellElement>(node))); if (is<HTML::HTMLTableColElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLTableColElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLTableColElement>(node))); if (is<HTML::HTMLTableElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLTableElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLTableElement>(node))); if (is<HTML::HTMLTableRowElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLTableRowElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLTableRowElement>(node))); if (is<HTML::HTMLTableSectionElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLTableSectionElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLTableSectionElement>(node))); if (is<HTML::HTMLTemplateElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLTemplateElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLTemplateElement>(node))); if (is<HTML::HTMLTextAreaElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLTextAreaElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLTextAreaElement>(node))); if (is<HTML::HTMLTimeElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLTimeElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLTimeElement>(node))); if (is<HTML::HTMLTitleElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLTitleElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLTitleElement>(node))); if (is<HTML::HTMLTrackElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLTrackElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLTrackElement>(node))); if (is<HTML::HTMLUListElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLUListElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLUListElement>(node))); if (is<HTML::HTMLUnknownElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLUnknownElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLUnknownElement>(node))); if (is<HTML::HTMLVideoElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLVideoElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLVideoElement>(node))); if (is<HTML::HTMLElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<HTML::HTMLElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<HTML::HTMLElement>(node))); if (is<SVG::SVGSVGElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<SVG::SVGSVGElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<SVG::SVGSVGElement>(node))); if (is<SVG::SVGCircleElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<SVG::SVGCircleElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<SVG::SVGCircleElement>(node))); if (is<SVG::SVGEllipseElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<SVG::SVGEllipseElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<SVG::SVGEllipseElement>(node))); if (is<SVG::SVGLineElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<SVG::SVGLineElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<SVG::SVGLineElement>(node))); if (is<SVG::SVGPolygonElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<SVG::SVGPolygonElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<SVG::SVGPolygonElement>(node))); if (is<SVG::SVGPolylineElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<SVG::SVGPolylineElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<SVG::SVGPolylineElement>(node))); if (is<SVG::SVGPathElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<SVG::SVGPathElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<SVG::SVGPathElement>(node))); if (is<SVG::SVGRectElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<SVG::SVGRectElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<SVG::SVGRectElement>(node))); if (is<SVG::SVGTextContentElement>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<SVG::SVGTextContentElement>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<SVG::SVGTextContentElement>(node))); if (is<DOM::Element>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<DOM::Element>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<DOM::Element>(node))); if (is<DOM::DocumentFragment>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<DOM::DocumentFragment>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<DOM::DocumentFragment>(node))); if (is<DOM::Comment>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<DOM::Comment>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<DOM::Comment>(node))); if (is<DOM::Text>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<DOM::Text>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<DOM::Text>(node))); if (is<DOM::CharacterData>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<DOM::CharacterData>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<DOM::CharacterData>(node))); if (is<DOM::Attribute>(node)) - return static_cast<NodeWrapper*>(wrap_impl(global_object, verify_cast<DOM::Attribute>(node))); - return static_cast<NodeWrapper*>(wrap_impl(global_object, node)); + return static_cast<NodeWrapper*>(wrap_impl(realm, verify_cast<DOM::Attribute>(node))); + return static_cast<NodeWrapper*>(wrap_impl(realm, node)); } } diff --git a/Userland/Libraries/LibWeb/Bindings/NodeWrapperFactory.h b/Userland/Libraries/LibWeb/Bindings/NodeWrapperFactory.h index 025e0c3f2f..69bad2cc08 100644 --- a/Userland/Libraries/LibWeb/Bindings/NodeWrapperFactory.h +++ b/Userland/Libraries/LibWeb/Bindings/NodeWrapperFactory.h @@ -12,7 +12,7 @@ namespace Web { namespace Bindings { -NodeWrapper* wrap(JS::GlobalObject&, DOM::Node&); +NodeWrapper* wrap(JS::Realm&, DOM::Node&); } } diff --git a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp index a00911c09e..8f72bab816 100644 --- a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp @@ -39,6 +39,7 @@ JS::ThrowCompletionOr<JS::Value> OptionConstructor::call() JS::ThrowCompletionOr<JS::Object*> OptionConstructor::construct(FunctionObject&) { auto& vm = this->vm(); + auto& realm = *vm.current_realm(); // 1. Let document be the current global object's associated Document. auto& window = static_cast<WindowObject&>(HTML::current_global_object()); @@ -74,7 +75,7 @@ JS::ThrowCompletionOr<JS::Object*> OptionConstructor::construct(FunctionObject&) option_element->m_selected = vm.argument(3).to_boolean(); // 7. Return option. - return wrap(global_object(), option_element); + return wrap(realm, option_element); } } diff --git a/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp b/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp index 12df07e316..7feda31cc1 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp +++ b/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp @@ -427,14 +427,16 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::parent_getter) JS_DEFINE_NATIVE_FUNCTION(WindowObject::document_getter) { + auto& realm = *vm.current_realm(); auto* impl = TRY(impl_from(vm, global_object)); - return wrap(global_object, impl->associated_document()); + return wrap(realm, impl->associated_document()); } JS_DEFINE_NATIVE_FUNCTION(WindowObject::performance_getter) { + auto& realm = *vm.current_realm(); auto* impl = TRY(impl_from(vm, global_object)); - return wrap(global_object, impl->performance()); + return wrap(realm, impl->performance()); } JS_DEFINE_NATIVE_FUNCTION(WindowObject::performance_setter) @@ -457,16 +459,18 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::performance_setter) JS_DEFINE_NATIVE_FUNCTION(WindowObject::screen_getter) { + auto& realm = *vm.current_realm(); auto* impl = TRY(impl_from(vm, global_object)); - return wrap(global_object, impl->screen()); + return wrap(realm, impl->screen()); } JS_DEFINE_NATIVE_FUNCTION(WindowObject::event_getter) { + auto& realm = *vm.current_realm(); auto* impl = TRY(impl_from(vm, global_object)); if (!impl->current_event()) return JS::js_undefined(); - return wrap(global_object, const_cast<DOM::Event&>(*impl->current_event())); + return wrap(realm, const_cast<DOM::Event&>(*impl->current_event())); } JS_DEFINE_NATIVE_FUNCTION(WindowObject::event_setter) @@ -491,8 +495,9 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::location_setter) JS_DEFINE_NATIVE_FUNCTION(WindowObject::crypto_getter) { + auto& realm = *vm.current_realm(); auto* impl = TRY(impl_from(vm, global_object)); - return wrap(global_object, impl->crypto()); + return wrap(realm, impl->crypto()); } JS_DEFINE_NATIVE_FUNCTION(WindowObject::inner_width_getter) @@ -515,28 +520,31 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::device_pixel_ratio_getter) JS_DEFINE_NATIVE_FUNCTION(WindowObject::get_computed_style) { + auto& realm = *vm.current_realm(); auto* impl = TRY(impl_from(vm, global_object)); auto* object = TRY(vm.argument(0).to_object(vm)); if (!is<ElementWrapper>(object)) return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "DOM element"); - return wrap(global_object, impl->get_computed_style(static_cast<ElementWrapper*>(object)->impl())); + return wrap(realm, impl->get_computed_style(static_cast<ElementWrapper*>(object)->impl())); } JS_DEFINE_NATIVE_FUNCTION(WindowObject::get_selection) { + auto& realm = *vm.current_realm(); auto* impl = TRY(impl_from(vm, global_object)); auto* selection = impl->get_selection(); if (!selection) return JS::js_null(); - return wrap(global_object, *selection); + return wrap(realm, *selection); } JS_DEFINE_NATIVE_FUNCTION(WindowObject::match_media) { + auto& realm = *vm.current_realm(); auto* impl = TRY(impl_from(vm, global_object)); auto media = TRY(vm.argument(0).to_string(vm)); - return wrap(global_object, impl->match_media(move(media))); + return wrap(realm, impl->match_media(move(media))); } // https://www.w3.org/TR/cssom-view/#dom-window-scrollx @@ -668,8 +676,9 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::scroll_by) JS_DEFINE_NATIVE_FUNCTION(WindowObject::history_getter) { + auto& realm = *vm.current_realm(); auto* impl = TRY(impl_from(vm, global_object)); - return wrap(global_object, impl->associated_document().history()); + return wrap(realm, impl->associated_document().history()); } JS_DEFINE_NATIVE_FUNCTION(WindowObject::screen_left_getter) @@ -713,16 +722,18 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::origin_getter) JS_DEFINE_NATIVE_FUNCTION(WindowObject::local_storage_getter) { + auto& realm = *vm.current_realm(); auto* impl = TRY(impl_from(vm, global_object)); // FIXME: localStorage may throw. We have to deal with that here. - return wrap(global_object, *impl->local_storage()); + return wrap(realm, *impl->local_storage()); } JS_DEFINE_NATIVE_FUNCTION(WindowObject::session_storage_getter) { + auto& realm = *vm.current_realm(); auto* impl = TRY(impl_from(vm, global_object)); // FIXME: sessionStorage may throw. We have to deal with that here. - return wrap(global_object, *impl->session_storage()); + return wrap(realm, *impl->session_storage()); } JS_DEFINE_NATIVE_FUNCTION(WindowObject::name_getter) diff --git a/Userland/Libraries/LibWeb/Bindings/Wrappable.h b/Userland/Libraries/LibWeb/Bindings/Wrappable.h index 0e0a5dc7ad..eae64d1ee8 100644 --- a/Userland/Libraries/LibWeb/Bindings/Wrappable.h +++ b/Userland/Libraries/LibWeb/Bindings/Wrappable.h @@ -26,9 +26,8 @@ private: }; template<class NativeObject> -inline Wrapper* wrap_impl(JS::GlobalObject& global_object, NativeObject& native_object) +inline Wrapper* wrap_impl(JS::Realm& realm, NativeObject& native_object) { - auto& realm = *global_object.associated_realm(); if (!native_object.wrapper()) { native_object.set_wrapper(*realm.heap().allocate<typename NativeObject::WrapperType>(realm, realm, native_object)); } diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h index bb40ad01cb..4b726a4274 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h @@ -119,6 +119,6 @@ private: namespace Web::Bindings { -CSSStyleDeclarationWrapper* wrap(JS::GlobalObject&, CSS::CSSStyleDeclaration&); +CSSStyleDeclarationWrapper* wrap(JS::Realm&, CSS::CSSStyleDeclaration&); } diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h index c9ae813d7e..53178ce391 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h @@ -66,6 +66,6 @@ private: namespace Web::Bindings { -CSSStyleSheetWrapper* wrap(JS::GlobalObject&, CSS::CSSStyleSheet&); +CSSStyleSheetWrapper* wrap(JS::Realm&, CSS::CSSStyleSheet&); } diff --git a/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp b/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp index 7f1f63f60d..23bda33f00 100644 --- a/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp +++ b/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org> * Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause @@ -51,9 +51,9 @@ bool MediaQueryList::evaluate() return now_matches; } -JS::Object* MediaQueryList::create_wrapper(JS::GlobalObject& global_object) +JS::Object* MediaQueryList::create_wrapper(JS::Realm& realm) { - return wrap(global_object, *this); + return wrap(realm, *this); } // https://www.w3.org/TR/cssom-view/#dom-mediaquerylist-addlistener diff --git a/Userland/Libraries/LibWeb/CSS/MediaQueryList.h b/Userland/Libraries/LibWeb/CSS/MediaQueryList.h index 456a414276..0c6c5df248 100644 --- a/Userland/Libraries/LibWeb/CSS/MediaQueryList.h +++ b/Userland/Libraries/LibWeb/CSS/MediaQueryList.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -43,7 +43,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; void add_listener(RefPtr<DOM::IDLEventListener> listener); void remove_listener(RefPtr<DOM::IDLEventListener> listener); @@ -62,6 +62,6 @@ private: namespace Web::Bindings { -MediaQueryListWrapper* wrap(JS::GlobalObject&, CSS::MediaQueryList&); +MediaQueryListWrapper* wrap(JS::Realm&, CSS::MediaQueryList&); } diff --git a/Userland/Libraries/LibWeb/CSS/StyleSheetList.h b/Userland/Libraries/LibWeb/CSS/StyleSheetList.h index be152a1875..098936ffd0 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleSheetList.h +++ b/Userland/Libraries/LibWeb/CSS/StyleSheetList.h @@ -57,6 +57,6 @@ private: namespace Web::Bindings { -StyleSheetListWrapper* wrap(JS::GlobalObject&, CSS::StyleSheetList&); +StyleSheetListWrapper* wrap(JS::Realm&, CSS::StyleSheetList&); } diff --git a/Userland/Libraries/LibWeb/Crypto/Crypto.h b/Userland/Libraries/LibWeb/Crypto/Crypto.h index 59dfeb4087..0ae8890981 100644 --- a/Userland/Libraries/LibWeb/Crypto/Crypto.h +++ b/Userland/Libraries/LibWeb/Crypto/Crypto.h @@ -39,6 +39,6 @@ private: namespace Web::Bindings { -CryptoWrapper* wrap(JS::GlobalObject&, Crypto::Crypto&); +CryptoWrapper* wrap(JS::Realm&, Crypto::Crypto&); } diff --git a/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp b/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp index e84d964dc8..ffbebe75b1 100644 --- a/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp +++ b/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -9,6 +9,7 @@ #include <LibJS/Runtime/Promise.h> #include <LibWeb/Bindings/DOMExceptionWrapper.h> #include <LibWeb/Bindings/IDLAbstractOperations.h> +#include <LibWeb/Bindings/MainThreadVM.h> #include <LibWeb/Bindings/Wrapper.h> #include <LibWeb/Crypto/SubtleCrypto.h> #include <LibWeb/DOM/DOMException.h> @@ -17,15 +18,15 @@ namespace Web::Crypto { JS::Promise* SubtleCrypto::digest(String const& algorithm, JS::Handle<JS::Object> const& data) { - auto& global_object = wrapper()->global_object(); - auto& realm = *global_object.associated_realm(); + auto& vm = Bindings::main_thread_vm(); + auto& realm = *vm.current_realm(); // 1. Let algorithm be the algorithm parameter passed to the digest() method. // 2. Let data be the result of getting a copy of the bytes held by the data parameter passed to the digest() method. auto data_buffer_or_error = Bindings::IDL::get_buffer_source_copy(*data.cell()); if (data_buffer_or_error.is_error()) { - auto* error = wrap(wrapper()->global_object(), DOM::OperationError::create("Failed to copy bytes from ArrayBuffer")); + auto* error = wrap(realm, DOM::OperationError::create("Failed to copy bytes from ArrayBuffer")); auto* promise = JS::Promise::create(realm); promise->reject(error); return promise; @@ -46,7 +47,7 @@ JS::Promise* SubtleCrypto::digest(String const& algorithm, JS::Handle<JS::Object } // 4. If an error occurred, return a Promise rejected with normalizedAlgorithm. else { - auto* error = wrap(wrapper()->global_object(), DOM::NotSupportedError::create(String::formatted("Invalid hash function '{}'", algorithm))); + auto* error = wrap(realm, DOM::NotSupportedError::create(String::formatted("Invalid hash function '{}'", algorithm))); auto* promise = JS::Promise::create(realm); promise->reject(error); return promise; @@ -67,7 +68,7 @@ JS::Promise* SubtleCrypto::digest(String const& algorithm, JS::Handle<JS::Object auto digest = hash.digest(); auto result_buffer = ByteBuffer::copy(digest.immutable_data(), hash.digest_size()); if (result_buffer.is_error()) { - auto* error = wrap(wrapper()->global_object(), DOM::OperationError::create("Failed to create result buffer")); + auto* error = wrap(realm, DOM::OperationError::create("Failed to create result buffer")); promise->reject(error); return promise; } diff --git a/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.h b/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.h index 24f762919c..b1ae67badd 100644 --- a/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.h +++ b/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -32,6 +32,6 @@ private: namespace Web::Bindings { -SubtleCryptoWrapper* wrap(JS::GlobalObject&, Crypto::SubtleCrypto&); +SubtleCryptoWrapper* wrap(JS::Realm&, Crypto::SubtleCrypto&); } diff --git a/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp b/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp index e98893d46f..df48463fe3 100644 --- a/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp +++ b/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp @@ -19,9 +19,9 @@ AbortSignal::AbortSignal() { } -JS::Object* AbortSignal::create_wrapper(JS::GlobalObject& global_object) +JS::Object* AbortSignal::create_wrapper(JS::Realm& realm) { - return wrap(global_object, *this); + return wrap(realm, *this); } // https://dom.spec.whatwg.org/#abortsignal-add @@ -38,6 +38,10 @@ void AbortSignal::add_abort_algorithm(Function<void()> abort_algorithm) // https://dom.spec.whatwg.org/#abortsignal-signal-abort void AbortSignal::signal_abort(JS::Value reason) { + VERIFY(wrapper()); + auto& vm = wrapper()->vm(); + auto& realm = *vm.current_realm(); + // 1. If signal is aborted, then return. if (aborted()) return; @@ -46,7 +50,7 @@ void AbortSignal::signal_abort(JS::Value reason) if (!reason.is_undefined()) m_abort_reason = reason; else - m_abort_reason = wrap(wrapper()->global_object(), AbortError::create("Aborted without reason")); + m_abort_reason = wrap(realm, AbortError::create("Aborted without reason")); // 3. For each algorithm in signal’s abort algorithms: run algorithm. for (auto& algorithm : m_abort_algorithms) diff --git a/Userland/Libraries/LibWeb/DOM/AbortSignal.h b/Userland/Libraries/LibWeb/DOM/AbortSignal.h index fd45590a27..b05e1e9d06 100644 --- a/Userland/Libraries/LibWeb/DOM/AbortSignal.h +++ b/Userland/Libraries/LibWeb/DOM/AbortSignal.h @@ -60,7 +60,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; private: AbortSignal(); diff --git a/Userland/Libraries/LibWeb/DOM/DOMTokenList.h b/Userland/Libraries/LibWeb/DOM/DOMTokenList.h index aef12842e5..b96ae20b30 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMTokenList.h +++ b/Userland/Libraries/LibWeb/DOM/DOMTokenList.h @@ -58,6 +58,6 @@ private: namespace Web::Bindings { -DOMTokenListWrapper* wrap(JS::GlobalObject&, DOM::DOMTokenList&); +DOMTokenListWrapper* wrap(JS::Realm&, DOM::DOMTokenList&); } diff --git a/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp b/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp index 8ae3f2b254..b37bc4fde8 100644 --- a/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp +++ b/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp @@ -88,7 +88,8 @@ bool EventDispatcher::inner_invoke(Event& event, Vector<NonnullRefPtr<DOM::DOMEv // 6. Let global be listener callback’s associated Realm’s global object. auto& callback = listener->callback->callback(); - auto& global = callback.callback.cell()->global_object(); + auto& realm = callback.callback->shape().realm(); + auto& global = realm.global_object(); // 7. Let currentEvent be undefined. RefPtr<Event> current_event; @@ -112,8 +113,8 @@ bool EventDispatcher::inner_invoke(Event& event, Vector<NonnullRefPtr<DOM::DOMEv // 10. Call a user object’s operation with listener’s callback, "handleEvent", « event », and event’s currentTarget attribute value. If this throws an exception, then: // FIXME: These should be wrapped for us in call_user_object_operation, but it currently doesn't do that. - auto* this_value = Bindings::wrap(global, *event.current_target()); - auto* wrapped_event = Bindings::wrap(global, event); + auto* this_value = Bindings::wrap(realm, *event.current_target()); + auto* wrapped_event = Bindings::wrap(realm, event); auto result = Bindings::IDL::call_user_object_operation(callback, "handleEvent", this_value, wrapped_event); // If this throws an exception, then: diff --git a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp index ae1905081c..4d3352c18e 100644 --- a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp +++ b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp @@ -384,10 +384,10 @@ Bindings::CallbackType* EventTarget::get_current_value_of_event_handler(FlyStrin return nullptr; } - auto& global_object = settings_object.global_object(); + auto& vm = Bindings::main_thread_vm(); // 8. Push settings object's realm execution context onto the JavaScript execution context stack; it is now the running JavaScript execution context. - global_object.vm().push_execution_context(settings_object.realm_execution_context()); + vm.push_execution_context(settings_object.realm_execution_context()); // 9. Let function be the result of calling OrdinaryFunctionCreate, with arguments: // functionPrototype @@ -419,19 +419,19 @@ Bindings::CallbackType* EventTarget::get_current_value_of_event_handler(FlyStrin // 3. If eventHandler is an element's event handler, then set scope to NewObjectEnvironment(document, true, scope). // (Otherwise, eventHandler is a Window object's event handler.) if (is<Element>(this)) { - auto* wrapped_document = Bindings::wrap(global_object, *document); + auto* wrapped_document = Bindings::wrap(realm, *document); scope = JS::new_object_environment(*wrapped_document, true, scope); } // 4. If form owner is not null, then set scope to NewObjectEnvironment(form owner, true, scope). if (form_owner) { - auto* wrapped_form_owner = Bindings::wrap(global_object, *form_owner); + auto* wrapped_form_owner = Bindings::wrap(realm, *form_owner); scope = JS::new_object_environment(*wrapped_form_owner, true, scope); } // 5. If element is not null, then set scope to NewObjectEnvironment(element, true, scope). if (element) { - auto* wrapped_element = Bindings::wrap(global_object, *element); + auto* wrapped_element = Bindings::wrap(realm, *element); scope = JS::new_object_environment(*wrapped_element, true, scope); } @@ -441,8 +441,8 @@ Bindings::CallbackType* EventTarget::get_current_value_of_event_handler(FlyStrin VERIFY(function); // 10. Remove settings object's realm execution context from the JavaScript execution context stack. - VERIFY(global_object.vm().execution_context_stack().last() == &settings_object.realm_execution_context()); - global_object.vm().pop_execution_context(); + VERIFY(vm.execution_context_stack().last() == &settings_object.realm_execution_context()); + vm.pop_execution_context(); // 11. Set function.[[ScriptOrModule]] to null. function->set_script_or_module({}); @@ -602,6 +602,7 @@ JS::ThrowCompletionOr<void> EventTarget::process_event_handler_for_event(FlyStri // Needed for wrapping. auto* callback_object = callback->callback.cell(); + auto& realm = callback_object->shape().realm(); if (special_error_event_handling) { // -> If special error event handling is true @@ -619,7 +620,7 @@ JS::ThrowCompletionOr<void> EventTarget::process_event_handler_for_event(FlyStri // NOTE: current_target is always non-null here, as the event dispatcher takes care to make sure it's non-null (and uses it as the this value for the callback!) // FIXME: This is rewrapping the this value of the callback defined in activate_event_handler. While I don't think this is observable as the event dispatcher // calls directly into the callback without considering things such as proxies, it is a waste. However, if it observable, then we must reuse the this_value that was given to the callback. - auto* this_value = Bindings::wrap(callback_object->global_object(), *error_event.current_target()); + auto* this_value = Bindings::wrap(realm, *error_event.current_target()); return_value_or_error = Bindings::IDL::invoke_callback(*callback, this_value, wrapped_message, wrapped_filename, wrapped_lineno, wrapped_colno, error_event.error()); } else { @@ -627,10 +628,10 @@ JS::ThrowCompletionOr<void> EventTarget::process_event_handler_for_event(FlyStri // Invoke callback with one argument, the value of which is the Event object event, with the callback this value set to event's currentTarget. Let return value be the callback's return value. [WEBIDL] // FIXME: This has the same rewrapping issue as this_value. - auto* wrapped_event = Bindings::wrap(callback_object->global_object(), event); + auto* wrapped_event = Bindings::wrap(realm, event); // FIXME: The comments about this in the special_error_event_handling path also apply here. - auto* this_value = Bindings::wrap(callback_object->global_object(), *event.current_target()); + auto* this_value = Bindings::wrap(realm, *event.current_target()); return_value_or_error = Bindings::IDL::invoke_callback(*callback, this_value, wrapped_event); } diff --git a/Userland/Libraries/LibWeb/DOM/EventTarget.h b/Userland/Libraries/LibWeb/DOM/EventTarget.h index 3882cbc3bb..854776eb0f 100644 --- a/Userland/Libraries/LibWeb/DOM/EventTarget.h +++ b/Userland/Libraries/LibWeb/DOM/EventTarget.h @@ -39,7 +39,7 @@ public: virtual bool dispatch_event(NonnullRefPtr<Event>); ExceptionOr<bool> dispatch_event_binding(NonnullRefPtr<Event>); - virtual JS::Object* create_wrapper(JS::GlobalObject&) = 0; + virtual JS::Object* create_wrapper(JS::Realm&) = 0; virtual EventTarget* get_parent(Event const&) { return nullptr; } diff --git a/Userland/Libraries/LibWeb/DOM/HTMLCollection.h b/Userland/Libraries/LibWeb/DOM/HTMLCollection.h index 9a4241edb9..ea1ceaa883 100644 --- a/Userland/Libraries/LibWeb/DOM/HTMLCollection.h +++ b/Userland/Libraries/LibWeb/DOM/HTMLCollection.h @@ -64,6 +64,6 @@ private: namespace Web::Bindings { -HTMLCollectionWrapper* wrap(JS::GlobalObject&, DOM::HTMLCollection&); +HTMLCollectionWrapper* wrap(JS::Realm&, DOM::HTMLCollection&); } diff --git a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h index c13be70230..a2c8144b8d 100644 --- a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h +++ b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h @@ -64,6 +64,6 @@ private: namespace Web::Bindings { -NamedNodeMapWrapper* wrap(JS::GlobalObject&, DOM::NamedNodeMap&); +NamedNodeMapWrapper* wrap(JS::Realm&, DOM::NamedNodeMap&); } diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index 4fab9e639a..a4b3235325 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -806,9 +806,9 @@ bool Node::is_editable() const return parent() && parent()->is_editable(); } -JS::Object* Node::create_wrapper(JS::GlobalObject& global_object) +JS::Object* Node::create_wrapper(JS::Realm& realm) { - return wrap(global_object, *this); + return wrap(realm, *this); } void Node::removed_last_ref() diff --git a/Userland/Libraries/LibWeb/DOM/Node.h b/Userland/Libraries/LibWeb/DOM/Node.h index 34fd59e63d..d0e7354d69 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.h +++ b/Userland/Libraries/LibWeb/DOM/Node.h @@ -56,7 +56,7 @@ public: // ^EventTarget virtual void ref_event_target() final { ref(); } virtual void unref_event_target() final { unref(); } - virtual JS::Object* create_wrapper(JS::GlobalObject&) override; + virtual JS::Object* create_wrapper(JS::Realm&) override; virtual ~Node(); diff --git a/Userland/Libraries/LibWeb/DOM/NodeFilter.h b/Userland/Libraries/LibWeb/DOM/NodeFilter.h index 47f530e99e..189dd359ce 100644 --- a/Userland/Libraries/LibWeb/DOM/NodeFilter.h +++ b/Userland/Libraries/LibWeb/DOM/NodeFilter.h @@ -38,7 +38,7 @@ private: Bindings::CallbackType m_callback; }; -inline JS::Object* wrap(JS::GlobalObject&, Web::DOM::NodeFilter& filter) +inline JS::Object* wrap(JS::Realm&, Web::DOM::NodeFilter& filter) { return filter.callback().callback.cell(); } diff --git a/Userland/Libraries/LibWeb/DOM/NodeIterator.cpp b/Userland/Libraries/LibWeb/DOM/NodeIterator.cpp index a3ad581cd3..ebf01cf928 100644 --- a/Userland/Libraries/LibWeb/DOM/NodeIterator.cpp +++ b/Userland/Libraries/LibWeb/DOM/NodeIterator.cpp @@ -118,12 +118,12 @@ JS::ThrowCompletionOr<RefPtr<Node>> NodeIterator::traverse(Direction direction) JS::ThrowCompletionOr<NodeFilter::Result> NodeIterator::filter(Node& node) { VERIFY(wrapper()); - auto& global_object = wrapper()->global_object(); auto& vm = wrapper()->vm(); + auto& realm = *vm.current_realm(); // 1. If traverser’s active flag is set, then throw an "InvalidStateError" DOMException. if (m_active) - return JS::throw_completion(wrap(global_object, InvalidStateError::create("NodeIterator is already active"))); + return JS::throw_completion(wrap(realm, InvalidStateError::create("NodeIterator is already active"))); // 2. Let n be node’s nodeType attribute value − 1. auto n = node.node_type() - 1; @@ -141,7 +141,7 @@ JS::ThrowCompletionOr<NodeFilter::Result> NodeIterator::filter(Node& node) // 6. Let result be the return value of call a user object’s operation with traverser’s filter, "acceptNode", and « node ». // If this throws an exception, then unset traverser’s active flag and rethrow the exception. - auto result = Bindings::IDL::call_user_object_operation(m_filter->callback(), "acceptNode", {}, wrap(global_object, node)); + auto result = Bindings::IDL::call_user_object_operation(m_filter->callback(), "acceptNode", {}, wrap(realm, node)); if (result.is_abrupt()) { m_active = false; return result; diff --git a/Userland/Libraries/LibWeb/DOM/TreeWalker.cpp b/Userland/Libraries/LibWeb/DOM/TreeWalker.cpp index f2938d0b68..cbcaadd8b0 100644 --- a/Userland/Libraries/LibWeb/DOM/TreeWalker.cpp +++ b/Userland/Libraries/LibWeb/DOM/TreeWalker.cpp @@ -221,12 +221,12 @@ JS::ThrowCompletionOr<RefPtr<Node>> TreeWalker::next_node() JS::ThrowCompletionOr<NodeFilter::Result> TreeWalker::filter(Node& node) { VERIFY(wrapper()); - auto& global_object = wrapper()->global_object(); auto& vm = wrapper()->vm(); + auto& realm = *vm.current_realm(); // 1. If traverser’s active flag is set, then throw an "InvalidStateError" DOMException. if (m_active) - return JS::throw_completion(wrap(global_object, InvalidStateError::create("NodeIterator is already active"))); + return JS::throw_completion(wrap(realm, InvalidStateError::create("NodeIterator is already active"))); // 2. Let n be node’s nodeType attribute value − 1. auto n = node.node_type() - 1; @@ -244,7 +244,7 @@ JS::ThrowCompletionOr<NodeFilter::Result> TreeWalker::filter(Node& node) // 6. Let result be the return value of call a user object’s operation with traverser’s filter, "acceptNode", and « node ». // If this throws an exception, then unset traverser’s active flag and rethrow the exception. - auto result = Bindings::IDL::call_user_object_operation(m_filter->callback(), "acceptNode", {}, wrap(global_object, node)); + auto result = Bindings::IDL::call_user_object_operation(m_filter->callback(), "acceptNode", {}, wrap(realm, node)); if (result.is_abrupt()) { m_active = false; return result; diff --git a/Userland/Libraries/LibWeb/Fetch/Headers.h b/Userland/Libraries/LibWeb/Fetch/Headers.h index ef5a7d1fc5..828bb6758b 100644 --- a/Userland/Libraries/LibWeb/Fetch/Headers.h +++ b/Userland/Libraries/LibWeb/Fetch/Headers.h @@ -72,6 +72,6 @@ private: namespace Web::Bindings { -HeadersWrapper* wrap(JS::GlobalObject&, Fetch::Headers&); +HeadersWrapper* wrap(JS::Realm&, Fetch::Headers&); } diff --git a/Userland/Libraries/LibWeb/Fetch/HeadersIterator.h b/Userland/Libraries/LibWeb/Fetch/HeadersIterator.h index a678abacb0..bfdf093506 100644 --- a/Userland/Libraries/LibWeb/Fetch/HeadersIterator.h +++ b/Userland/Libraries/LibWeb/Fetch/HeadersIterator.h @@ -42,6 +42,6 @@ private: namespace Web::Bindings { -HeadersIteratorWrapper* wrap(JS::GlobalObject&, Fetch::HeadersIterator&); +HeadersIteratorWrapper* wrap(JS::Realm&, Fetch::HeadersIterator&); } diff --git a/Userland/Libraries/LibWeb/FileAPI/Blob.cpp b/Userland/Libraries/LibWeb/FileAPI/Blob.cpp index 4c5f9993c4..23c713f7f4 100644 --- a/Userland/Libraries/LibWeb/FileAPI/Blob.cpp +++ b/Userland/Libraries/LibWeb/FileAPI/Blob.cpp @@ -262,9 +262,9 @@ JS::Promise* Blob::array_buffer() return promise; } -JS::Object* Blob::create_wrapper(JS::GlobalObject& global_object) +JS::Object* Blob::create_wrapper(JS::Realm& realm) { - return wrap(global_object, *this); + return wrap(realm, *this); } } diff --git a/Userland/Libraries/LibWeb/FileAPI/Blob.h b/Userland/Libraries/LibWeb/FileAPI/Blob.h index b9ff185a54..1604fd6a6e 100644 --- a/Userland/Libraries/LibWeb/FileAPI/Blob.h +++ b/Userland/Libraries/LibWeb/FileAPI/Blob.h @@ -52,7 +52,7 @@ public: JS::Promise* text(); JS::Promise* array_buffer(); - virtual JS::Object* create_wrapper(JS::GlobalObject&); + virtual JS::Object* create_wrapper(JS::Realm&); ReadonlyBytes bytes() const { return m_byte_buffer.bytes(); } 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 diff --git a/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp b/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp index 468e28bddf..071cae9d7f 100644 --- a/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp +++ b/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp @@ -39,9 +39,9 @@ void Performance::unref_event_target() m_window.unref(); } -JS::Object* Performance::create_wrapper(JS::GlobalObject& global_object) +JS::Object* Performance::create_wrapper(JS::Realm& realm) { - return Bindings::wrap(global_object, *this); + return Bindings::wrap(realm, *this); } } diff --git a/Userland/Libraries/LibWeb/HighResolutionTime/Performance.h b/Userland/Libraries/LibWeb/HighResolutionTime/Performance.h index 15fd0fa0c2..39ae47f082 100644 --- a/Userland/Libraries/LibWeb/HighResolutionTime/Performance.h +++ b/Userland/Libraries/LibWeb/HighResolutionTime/Performance.h @@ -32,7 +32,7 @@ public: virtual void ref_event_target() override; virtual void unref_event_target() override; - virtual JS::Object* create_wrapper(JS::GlobalObject&) override; + virtual JS::Object* create_wrapper(JS::Realm&) override; private: HTML::Window& m_window; diff --git a/Userland/Libraries/LibWeb/URL/URLSearchParams.h b/Userland/Libraries/LibWeb/URL/URLSearchParams.h index 042c8e1109..50ea3e4e83 100644 --- a/Userland/Libraries/LibWeb/URL/URLSearchParams.h +++ b/Userland/Libraries/LibWeb/URL/URLSearchParams.h @@ -63,6 +63,6 @@ private: namespace Web::Bindings { -URLSearchParamsWrapper* wrap(JS::GlobalObject&, URL::URLSearchParams&); +URLSearchParamsWrapper* wrap(JS::Realm&, URL::URLSearchParams&); } diff --git a/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.h b/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.h index 880a087d0c..baec659ffb 100644 --- a/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.h +++ b/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.h @@ -41,6 +41,6 @@ private: namespace Web::Bindings { -URLSearchParamsIteratorWrapper* wrap(JS::GlobalObject&, URL::URLSearchParamsIterator&); +URLSearchParamsIteratorWrapper* wrap(JS::Realm&, URL::URLSearchParamsIterator&); } diff --git a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp index 63b124fdd9..1d67485d1b 100644 --- a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp +++ b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp @@ -226,9 +226,9 @@ void WebSocket::on_message(ByteBuffer message, bool is_text) TODO(); } -JS::Object* WebSocket::create_wrapper(JS::GlobalObject& global_object) +JS::Object* WebSocket::create_wrapper(JS::Realm& realm) { - return wrap(global_object, *this); + return wrap(realm, *this); } #undef __ENUMERATE diff --git a/Userland/Libraries/LibWeb/WebSockets/WebSocket.h b/Userland/Libraries/LibWeb/WebSockets/WebSocket.h index 2bc3b42838..c12662ca72 100644 --- a/Userland/Libraries/LibWeb/WebSockets/WebSocket.h +++ b/Userland/Libraries/LibWeb/WebSockets/WebSocket.h @@ -77,7 +77,7 @@ public: private: 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; void on_open(); void on_message(ByteBuffer message, bool is_text); diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp index a4d4f32b30..f1ef2b1c8d 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp @@ -124,7 +124,7 @@ DOM::ExceptionOr<JS::Value> XMLHttpRequest::response() else if (m_response_type == Bindings::XMLHttpRequestResponseType::Blob) { auto blob_part = TRY_OR_RETURN_OOM(try_make_ref_counted<FileAPI::Blob>(m_received_bytes, get_final_mime_type().type())); auto blob = TRY(FileAPI::Blob::create(Vector<FileAPI::BlobPart> { move(blob_part) })); - m_response_object = JS::make_handle(JS::Value(blob->create_wrapper(global_object))); + m_response_object = JS::make_handle(JS::Value(blob->create_wrapper(realm))); } // 7. Otherwise, if this’s response type is "document", set a document response for this. else if (m_response_type == Bindings::XMLHttpRequestResponseType::Document) { @@ -568,9 +568,9 @@ DOM::ExceptionOr<void> XMLHttpRequest::send(Optional<XMLHttpRequestBodyInit> bod return {}; } -JS::Object* XMLHttpRequest::create_wrapper(JS::GlobalObject& global_object) +JS::Object* XMLHttpRequest::create_wrapper(JS::Realm& realm) { - return wrap(global_object, *this); + return wrap(realm, *this); } Bindings::CallbackType* XMLHttpRequest::onreadystatechange() diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h index 4380441417..c2894d6743 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h @@ -82,7 +82,7 @@ public: private: 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; void set_ready_state(ReadyState); void set_status(Fetch::Infrastructure::Status status) { m_status = status; } diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequestEventTarget.h b/Userland/Libraries/LibWeb/XHR/XMLHttpRequestEventTarget.h index 9a3e1a8adb..5858299305 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequestEventTarget.h +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequestEventTarget.h @@ -43,9 +43,9 @@ protected: } private: - virtual JS::Object* create_wrapper(JS::GlobalObject& global_object) override + virtual JS::Object* create_wrapper(JS::Realm& realm) override { - return wrap(global_object, *this); + return wrap(realm, *this); } }; diff --git a/Userland/Services/WebContent/ConsoleGlobalObject.cpp b/Userland/Services/WebContent/ConsoleGlobalObject.cpp index 0a1a3ed903..d4adda9bd9 100644 --- a/Userland/Services/WebContent/ConsoleGlobalObject.cpp +++ b/Userland/Services/WebContent/ConsoleGlobalObject.cpp @@ -97,6 +97,7 @@ JS::ThrowCompletionOr<JS::MarkedVector<JS::Value>> ConsoleGlobalObject::internal JS_DEFINE_NATIVE_FUNCTION(ConsoleGlobalObject::inspected_node_getter) { + auto& realm = *vm.current_realm(); auto* this_object = TRY(vm.this_value().to_object(vm)); if (!is<ConsoleGlobalObject>(this_object)) @@ -108,7 +109,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); } } |