Fix HiDPI vs. set_cursor_icon for web (#1652)

PhysicalSize is recorded as canvas.size, whereas LogicalSize is stored
as canvas.style.size.

The previous cursor behavior on stdweb clobbered all style - thus losing
the LogicalSize.
This commit is contained in:
Michael Kirk 2020-08-17 16:48:29 -07:00 committed by GitHub
parent 412bd94ea4
commit 9c72cc2a98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 11 deletions

View file

@ -81,13 +81,15 @@ pub fn set_canvas_size(raw: &HtmlCanvasElement, size: Size) {
raw.set_width(physical_size.width);
raw.set_height(physical_size.height);
set_canvas_style_property(raw, "width", &format!("{}px", logical_size.width));
set_canvas_style_property(raw, "height", &format!("{}px", logical_size.height));
}
pub fn set_canvas_style_property(raw: &HtmlCanvasElement, property: &str, value: &str) {
let style = raw.style();
style
.set_property("width", &format!("{}px", logical_size.width))
.expect("Failed to set canvas width");
style
.set_property("height", &format!("{}px", logical_size.height))
.expect("Failed to set canvas height");
.set_property(property, value)
.expect(&format!("Failed to set {}", property));
}
pub fn is_fullscreen(canvas: &HtmlCanvasElement) -> bool {