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

Charles Pritchard chuck at jumis.com
Tue Dec 14 10:22:07 PST 2010


On 11/24/2010 1:12 AM, Robert O'Callahan wrote:
> On Wed, Nov 24, 2010 at 9:09 PM, Charles Pritchard <chuck at jumis.com 
> <mailto:chuck at jumis.com>> wrote:
>
>     On 11/21/2010 4:12 PM, Robert O'Callahan wrote:
>>     On Sun, Nov 21, 2010 at 9:59 AM, Charles Pritchard
>>     <chuck at jumis.com <mailto:chuck at jumis.com>> wrote:
>>
>>         Rob: Mobile deployments using dpiPixelRatio (as has been
>>         adopted by Moz and Webkit) and target-DpiDensity work well on
>>         the mobile, they are not hooked to zoom on the desktop,
>>
>>
>>     It is in Firefox.
>     I just tested in 4b7, and it's not changing dpiPixelRatio.
>
>
> Try this:
> <style>
> div { display:none; }
> @media screen and (min--moz-device-pixel-ratio: 1.5) {
>   .in { display:block; }
> }
> @media screen and (max--moz-device-pixel-ratio: 0.66666666) {
>   .out { display:block; }
> }
> </style>
> <div class="in">Zoomed in by a factor of at least 1.5</div>
> <div class="out">Zoomed out by a factor of at least 1.5</div>
>
> Try zooming in a lot and zooming out a lot. It works for me.

I've started working to get this behavior supported in webkit.

Currently, nobody is touching the devicePixelRatio [mislabeled 
dpiPixelRatio in my prior e-mails],
outside of the mobile device atmosphere. As such, the CSS 
device-pixel-ratio and window.devicePixelRatio
should be considered two different things. An unfortunate naming overlap.

I'd hoped for a cleaner resolution to the issue.

This represents my existing understanding of the consequences of 
Mozilla's don't-make-it-easy policy:

var mozObfuscatedRatio = 0;
if(window.devicePixelRatio != 1) mozObfuscatedRatio = 
window.devicePixelRatio;
else if(window.mozDevicePixelRatio != 1) mozObfuscatedRatio = 
window.mozDevicePixelRatio;
else while(mozObfuscatedRatio < 10) {
  mozObfuscatedRatio += .1;
  if (false === matchMedia('(min--moz-device-pixel-ratio: 
'+(mozObfuscatedRatio)+')').matches ) {
   mozObfuscatedRatio -= .1; break;
  }
}

The numbers should be tuned for typical zoom steps.

This doesn't feel like a win for anybody.

We couldn't even begin to talk about normalizing 
window.innerWidth/window.outerWidth .
Mozilla's practice of normalizing all metrics to CSS units makes a lot 
of sense.
Obfuscating access to device-pixel-ratio does not.


-Charles

In response to fiddling with ImageData: looks like a related 
conversation took place in 2008:
http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2008-February/013923.html

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20101214/8d6be655/attachment-0002.htm>


More information about the whatwg mailing list