window.open width/height is not interpreted as CSS pixels
Reported by
steffen....@gmail.com,
Oct 25 2017
|
|||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36 Steps to reproduce the problem: 1. Configure Windows to use 150% scaling. 2. Configure Chrome to use 200% scaling. 3. window.open( 'test.html', new Date().getTime(), 'width=600, height=300' ); What is the expected behavior? The resulting window window should have window.innerWidth == 600 && window.innerHeight == 300 https://drafts.csswg.org/cssom-view/#the-features-argument-to-the-open()-method What went wrong? window.open measures width and height in "windows pixels" instead of CSS pixels. If the window contains a image with 600px x 300px it will not fit. First test: window.open( 'test.html', new Date().getTime(), 'width=600, height=300' ); Windows Chrome Result (innerWidth x innerHeight) 100% 100% 600 x 300 (correct) 100% 200% 400 x 200 (incorrect) 150% 100% 602 x 302 (almost correct) 150% 200% 301 x 151 (incorrect) The problem can be shifted: window.open( 'test.html', new Date().getTime(), 'width=' + ( 600 * devicePixelRatio ) + ', height=' + ( 300 * devicePixelRatio ) ); Windows Chrome Result (innerWidth x innerHeight) 100% 100% 600 x 300 (correct) 100% 200% 600 x 300 (correct) 150% 100% 902 x 452 (incorrect) 150% 200% 901 x 451 (incorrect) So the solution can either handle windows scaling or chrome scaling but not both. Did this work before? N/A Chrome version: 61.0.3163.100 Channel: n/a OS Version: 10.0 Flash Version: If there was a way to detect the scale factor of chrome or windows independently, the problem would be easy to solve. However I only found devicePixelRatio which gives the product of windows and chrome scaling (i.e. 3.0 if windows is at 150% and chrome is at 200%).
,
Oct 26 2017
,
Oct 26 2017
,
Oct 28 2017
Firefox and Internet Explorer work correctly on Windows 10. Chrome and Edge behave equally incorrect. Is there a workaround? devicePixelRatio only helps for browser scaling but makes windows scaling even worse... I did not find a way to detect windows pixel scaling from within the browser. It would also help to detect browser scaling alone (devicePixelRatio / browser scaling = windows scaling)...
,
Nov 5 2017
Corrected Edge issue: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/14489864/ |
|||
►
Sign in to add a comment |
|||
Comment 1 by rbyers@chromium.org
, Oct 26 2017Components: -Blink Blink>WindowDialog
Labels: OS-Chrome OS-Linux
Status: Untriaged (was: Unconfirmed)
Summary: window.open width/height is not interpreted as CSS pixels (was: window.open does not correctly apply dimensions)