From 273fca9359a93eba96a4d197b8213f33132a92a3 Mon Sep 17 00:00:00 2001 From: Ryan Goldstein Date: Sat, 30 Jun 2018 17:22:56 -0400 Subject: [PATCH] Add support for Window.devicePixelRatio --- src/webapi/window.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/webapi/window.rs b/src/webapi/window.rs index d8754ada..5e2efa66 100644 --- a/src/webapi/window.rs +++ b/src/webapi/window.rs @@ -213,4 +213,14 @@ impl Window { return @{self}.pageXOffset; ).try_into().unwrap() } + + /// The ratio in resolution from physical pixels to CSS pixels + /// + /// [(JavaScript docs)](https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio) + // https://drafts.csswg.org/cssom-view/#ref-for-dom-window-devicepixelratio + pub fn device_pixel_ratio(&self) -> f64 { + js! ( + return @{self}.devicePixelRatio; + ).try_into().unwrap() + } }