diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp index 6110804e6d..01f93439e3 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.cpp +++ b/Userland/Libraries/LibWeb/HTML/Window.cpp @@ -744,12 +744,6 @@ void Window::queue_microtask_impl(WebIDL::CallbackType& callback) }); } -float Window::device_pixel_ratio() const -{ - // FIXME: Return 2.0f if we're in HiDPI mode! - return 1.0f; -} - // https://html.spec.whatwg.org/multipage/webstorage.html#dom-localstorage JS::NonnullGCPtr Window::local_storage() { @@ -956,7 +950,6 @@ WebIDL::ExceptionOr Window::initialize_web_interfaces(Badgepage()) + return page->client().device_pixels_per_css_pixel(); + return 1; +} + // https://w3c.github.io/hr-time/#dom-windoworworkerglobalscope-performance WebIDL::ExceptionOr> Window::performance() { @@ -1649,12 +1654,6 @@ JS_DEFINE_NATIVE_FUNCTION(Window::location_setter) return JS::js_undefined(); } -JS_DEFINE_NATIVE_FUNCTION(Window::device_pixel_ratio_getter) -{ - auto* impl = TRY(impl_from(vm)); - return JS::Value(impl->device_pixel_ratio()); -} - JS_DEFINE_NATIVE_FUNCTION(Window::get_computed_style) { auto* impl = TRY(impl_from(vm)); diff --git a/Userland/Libraries/LibWeb/HTML/Window.h b/Userland/Libraries/LibWeb/HTML/Window.h index 9dac88f53b..099e2880ff 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.h +++ b/Userland/Libraries/LibWeb/HTML/Window.h @@ -113,8 +113,6 @@ public: void fire_a_page_transition_event(DeprecatedFlyString const& event_name, bool persisted); - float device_pixel_ratio() const; - JS::NonnullGCPtr local_storage(); JS::NonnullGCPtr session_storage(); @@ -178,6 +176,7 @@ public: i32 screen_y() const; i32 outer_width() const; i32 outer_height() const; + double device_pixel_ratio() const; WebIDL::ExceptionOr> performance(); @@ -245,8 +244,6 @@ public: private: JS_DECLARE_NATIVE_FUNCTION(location_setter); - JS_DECLARE_NATIVE_FUNCTION(device_pixel_ratio_getter); - JS_DECLARE_NATIVE_FUNCTION(structured_clone); JS_DECLARE_NATIVE_FUNCTION(local_storage_getter); diff --git a/Userland/Libraries/LibWeb/HTML/Window.idl b/Userland/Libraries/LibWeb/HTML/Window.idl index a882f3fc05..f695736078 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.idl +++ b/Userland/Libraries/LibWeb/HTML/Window.idl @@ -71,6 +71,7 @@ interface Window : EventTarget { [Replaceable, ImplementedAs=screen_y] readonly attribute long screenTop; [Replaceable] readonly attribute long outerWidth; [Replaceable] readonly attribute long outerHeight; + [Replaceable] readonly attribute double devicePixelRatio; // FIXME: Everything from here on should be shared through WindowOrWorkerGlobalScope // https://w3c.github.io/hr-time/#the-performance-attribute