RE: Behavior of device-pixel-ratio under zoom

[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 UTC