diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp
index ef95665e5b..9faa74ccc8 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Window.cpp
@@ -586,26 +586,6 @@ bool Window::dispatch_event(DOM::Event& event)
return DOM::EventDispatcher::dispatch(*this, event, true);
}
-// https://www.w3.org/TR/cssom-view-1/#dom-window-innerwidth
-int Window::inner_width() const
-{
- // The innerWidth attribute must return the viewport width including the size of a rendered scroll bar (if any),
- // or zero if there is no viewport.
- if (auto const* browsing_context = associated_document().browsing_context())
- return browsing_context->viewport_rect().width().value();
- return 0;
-}
-
-// https://www.w3.org/TR/cssom-view-1/#dom-window-innerheight
-int Window::inner_height() const
-{
- // The innerHeight attribute must return the viewport height including the size of a rendered scroll bar (if any),
- // or zero if there is no viewport.
- if (auto const* browsing_context = associated_document().browsing_context())
- return browsing_context->viewport_rect().height().value();
- return 0;
-}
-
Page* Window::page()
{
return associated_document().page();
@@ -1030,8 +1010,6 @@ WebIDL::ExceptionOr Window::initialize_web_interfaces(Badge> Window::screen()
return JS::NonnullGCPtr { *m_screen };
}
+// https://w3c.github.io/csswg-drafts/cssom-view/#dom-window-innerwidth
+i32 Window::inner_width() const
+{
+ // The innerWidth attribute must return the viewport width including the size of a rendered scroll bar (if any),
+ // or zero if there is no viewport.
+ if (auto const* browsing_context = associated_document().browsing_context())
+ return browsing_context->viewport_rect().width().value();
+ return 0;
+}
+
+// https://w3c.github.io/csswg-drafts/cssom-view/#dom-window-innerheight
+i32 Window::inner_height() const
+{
+ // The innerHeight attribute must return the viewport height including the size of a rendered scroll bar (if any),
+ // or zero if there is no viewport.
+ if (auto const* browsing_context = associated_document().browsing_context())
+ return browsing_context->viewport_rect().height().value();
+ return 0;
+}
+
// https://w3c.github.io/hr-time/#dom-windoworworkerglobalscope-performance
WebIDL::ExceptionOr> Window::performance()
{
@@ -1531,18 +1529,6 @@ JS_DEFINE_NATIVE_FUNCTION(Window::location_setter)
return JS::js_undefined();
}
-JS_DEFINE_NATIVE_FUNCTION(Window::inner_width_getter)
-{
- auto* impl = TRY(impl_from(vm));
- return JS::Value(impl->inner_width());
-}
-
-JS_DEFINE_NATIVE_FUNCTION(Window::inner_height_getter)
-{
- auto* impl = TRY(impl_from(vm));
- return JS::Value(impl->inner_height());
-}
-
JS_DEFINE_NATIVE_FUNCTION(Window::device_pixel_ratio_getter)
{
auto* impl = TRY(impl_from(vm));
diff --git a/Userland/Libraries/LibWeb/HTML/Window.h b/Userland/Libraries/LibWeb/HTML/Window.h
index ab0dacff04..0137a0b787 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.h
+++ b/Userland/Libraries/LibWeb/HTML/Window.h
@@ -87,9 +87,6 @@ public:
void queue_microtask_impl(WebIDL::CallbackType& callback);
- int inner_width() const;
- int inner_height() const;
-
void did_set_location_href(Badge, AK::URL const& new_href);
void did_call_location_reload(Badge);
void did_call_location_replace(Badge, DeprecatedString url);
@@ -165,6 +162,9 @@ public:
WebIDL::ExceptionOr> match_media(String const& query);
WebIDL::ExceptionOr> screen();
+ i32 inner_width() const;
+ i32 inner_height() const;
+
WebIDL::ExceptionOr> performance();
WebIDL::ExceptionOr> crypto();
@@ -231,9 +231,6 @@ public:
private:
JS_DECLARE_NATIVE_FUNCTION(location_setter);
- JS_DECLARE_NATIVE_FUNCTION(inner_width_getter);
- JS_DECLARE_NATIVE_FUNCTION(inner_height_getter);
-
JS_DECLARE_NATIVE_FUNCTION(device_pixel_ratio_getter);
JS_DECLARE_NATIVE_FUNCTION(scroll_x_getter);
diff --git a/Userland/Libraries/LibWeb/HTML/Window.idl b/Userland/Libraries/LibWeb/HTML/Window.idl
index ef02814c52..7534866308 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.idl
+++ b/Userland/Libraries/LibWeb/HTML/Window.idl
@@ -48,6 +48,10 @@ interface Window : EventTarget {
[NewObject] MediaQueryList matchMedia(CSSOMString query);
[SameObject, Replaceable] readonly attribute Screen screen;
+ // viewport
+ [Replaceable] readonly attribute long innerWidth;
+ [Replaceable] readonly attribute long innerHeight;
+
// FIXME: Everything from here on should be shared through WindowOrWorkerGlobalScope
// https://w3c.github.io/hr-time/#the-performance-attribute
[Replaceable] readonly attribute Performance performance;