From 20c39e38f2668295812ba63c4afbeef32ce666db Mon Sep 17 00:00:00 2001 From: Nick Senger Date: Mon, 19 Feb 2024 11:14:13 -0800 Subject: [PATCH] Revert "fix: Restore old canvas resize logic" This reverts commit f3100d9a81a4a14829cced546a342c2b47a8f063. --- src/platform_impl/web/web_sys/mod.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/platform_impl/web/web_sys/mod.rs b/src/platform_impl/web/web_sys/mod.rs index 016d32728d6..45dd7bf4875 100644 --- a/src/platform_impl/web/web_sys/mod.rs +++ b/src/platform_impl/web/web_sys/mod.rs @@ -72,13 +72,11 @@ pub fn set_canvas_size( style: &CssStyleDeclaration, new_size: LogicalSize, ) { - let scale_factor = scale_factor(&web_sys::window().expect("Failed to obtain window")); + if !document.contains(Some(raw)) || style.get_property_value("display").unwrap() == "none" { + return; + } let new_size = fix_canvas_size(style, new_size); - let physical_size = new_size.to_physical(scale_factor); - - raw.set_width(physical_size.width); - raw.set_height(physical_size.height); set_canvas_style_property(raw, "width", &format!("{}px", new_size.width)); set_canvas_style_property(raw, "height", &format!("{}px", new_size.height));