From dcff775ab197ef957b6d4c782684f7258d1812cb Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sun, 5 Mar 2023 18:48:45 +0000 Subject: [PATCH] LibWeb/HTML: Port Window.frames to IDL --- Userland/Libraries/LibWeb/HTML/Window.cpp | 16 +++++++--------- Userland/Libraries/LibWeb/HTML/Window.h | 4 ++-- Userland/Libraries/LibWeb/HTML/Window.idl | 3 +++ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp index 52a5d60db1c..fb40af8e9dd 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.cpp +++ b/Userland/Libraries/LibWeb/HTML/Window.cpp @@ -1092,7 +1092,6 @@ WebIDL::ExceptionOr Window::initialize_web_interfaces(Badge Window::self() const return verify_cast(relevant_realm(*this).global_environment().global_this_value()); } +// https://html.spec.whatwg.org/multipage/window-object.html#dom-frames +JS::NonnullGCPtr Window::frames() const +{ + // The window, frames, and self getter steps are to return this's relevant realm.[[GlobalEnv]].[[GlobalThisValue]]. + return verify_cast(relevant_realm(*this).global_environment().global_this_value()); +} + // https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator JS::NonnullGCPtr Window::navigator() const { @@ -1536,14 +1542,6 @@ JS_DEFINE_NATIVE_FUNCTION(Window::top_getter) return browsing_context->top_level_browsing_context().window_proxy(); } -// https://html.spec.whatwg.org/multipage/window-object.html#dom-frames -JS_DEFINE_NATIVE_FUNCTION(Window::frames_getter) -{ - auto* impl = TRY(impl_from(vm)); - // The window, frames, and self getter steps are to return this's relevant realm.[[GlobalEnv]].[[GlobalThisValue]]. - return &relevant_realm(*impl).global_environment().global_this_value(); -} - JS_DEFINE_NATIVE_FUNCTION(Window::parent_getter) { auto* impl = TRY(impl_from(vm)); diff --git a/Userland/Libraries/LibWeb/HTML/Window.h b/Userland/Libraries/LibWeb/HTML/Window.h index 7b9b4a6592c..189c4abb791 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.h +++ b/Userland/Libraries/LibWeb/HTML/Window.h @@ -143,6 +143,8 @@ public: JS::NonnullGCPtr window() const; JS::NonnullGCPtr self() const; + JS::NonnullGCPtr frames() const; + JS::NonnullGCPtr navigator() const; void alert(String const& message = {}); @@ -243,8 +245,6 @@ private: JS_DECLARE_NATIVE_FUNCTION(inner_width_getter); JS_DECLARE_NATIVE_FUNCTION(inner_height_getter); - JS_DECLARE_NATIVE_FUNCTION(frames_getter); - JS_DECLARE_NATIVE_FUNCTION(parent_getter); JS_DECLARE_NATIVE_FUNCTION(device_pixel_ratio_getter); diff --git a/Userland/Libraries/LibWeb/HTML/Window.idl b/Userland/Libraries/LibWeb/HTML/Window.idl index 9d7ad25a721..f70ff80cd12 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.idl +++ b/Userland/Libraries/LibWeb/HTML/Window.idl @@ -9,6 +9,9 @@ interface Window : EventTarget { [LegacyUnforgeable] readonly attribute WindowProxy window; [Replaceable] readonly attribute WindowProxy self; + // other browsing contexts + [Replaceable] readonly attribute WindowProxy frames; + // the user agent readonly attribute Navigator navigator; [ImplementedAs=navigator] readonly attribute Navigator clientInformation; // legacy alias of .navigator