[whatwg] Processing the zoom level - MS extensions to window.screen

Charles Pritchard chuck at jumis.com
Fri Nov 19 12:04:53 PST 2010


It's not possible to discover the scaling of CSS pixels to actual device 
pixels, with the current standard.

There are three non-standard ways to access them, from what I can see.

Mozilla:
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindowUtils).screenPixelsPerCSSPixel

Google:
chrome.tabs.getZoomPercentage
window.innerWidth and window.outerWidth are decoupled, one is in CSS pixels,
the other is in screen pixels. So that's a minor work-around.

Microsoft:
window.screen

This is apart from the existing convention on mobile phones of 
targetDpiDensity and dpiPixelRatio.

Microsoft's solution, seems to be superior, by exposing everything:
http://msdn.microsoft.com/en-us/library/ms535868(v=VS.85).aspx

systemXDPI, deviceXDPI, logicalXDPI  (and YDPI ).

They also have fontSmoothingEnabled and updateInterval;
which are handy, but out of scope for this section.

Moz has animation hooks:
window.mozAnimationStartTime
window.addEventListener("MozBeforePaint")
window.mozRequestAnimationFrame()


I'm pushing Microsoft's solution, of exposing the data through 
window.screen.
Can we all get on board with that one? Are there other proposals?




More information about the whatwg mailing list