W3C home > Mailing lists > Public > www-style@w3.org > November 2012

RE: Behavior of device-pixel-ratio under zoom

From: Sylvain Galineau <sylvaing@microsoft.com>
Date: Wed, 14 Nov 2012 23:47:29 +0000
To: Boris Zbarsky <bzbarsky@MIT.EDU>, "www-style@w3.org" <www-style@w3.org>
Message-ID: <3C4041FF83E1E04A986B6DC50F0178291BE78800@TK5EX14MBXC222.redmond.corp.microsoft.com>
[Boris Zbarsky:]
> 
> On 11/13/12 6:02 PM, James Robinson wrote:
> > Neither change
> > window.devicePixelRatio - that's an artifact of the display and cannot
> > be changed by user interaction.
> 
> How is it an artifact of the display?  It's a ratio of CSS pixels to
> device pixels; the display knows nothing about CSS pixels, and in fact
> "page zoom" in your terminology changes this ratio!
> 
Right. In 'legacy' rescaling zooms the page content reflows because the 
viewport is smaller; the viewport is smaller because the Zoom/Ctrl+
operation remapped the number of device pixels per CSS pixel.

What we at MSFT call optical zooms - as on smartphones - are treated a 
display 'artifact'. And in fairness it gets a bit confusing here because 
in this case the UA adds a level of indirection whereby the ratio of 
layout viewport [1] pixels to CSS pixels remains the same; but the 
number of raw device pixels per layout viewport pixels changes as you 
pinch in/out. 

Which implies devicePixelRatio really refers to layout viewport pixels per CSS
pixel; it just happens that some UAs - e.g. on desktop PCs - map layout viewport 
pixels to device pixels at a fixed ratio and zoom content by increasing the number 
of layout viewport pixels per CSS pixels, thus shrinking the viewport size. 
Other UAs  - e.g. on modern phones - keep layout viewport pixels per CSS pixels 
constant but adjust the layout-viewport-px/device-px ratio as users zoom in/out.

While it'd be nice to make everyone agree on a single approach across all UAs I 
agree with Roc it'd be nicer for now to agree on how we make the property consistently
reflect both approaches at runtime. (At least I think that is the intent; correct me 
if wrong)

[1] As described by PPK in http://www.quirksmode.org/mobile/viewports2.html
Received on Wednesday, 14 November 2012 23:48:47 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:21:02 GMT