Skip to content

Commit

Permalink
Add Window::device_pixel_ratio (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanisaacg authored and koute committed Jul 1, 2018
1 parent dff1e06 commit 2fde081
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/webapi/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

0 comments on commit 2fde081

Please sign in to comment.