[webkit-dev] Device and page scaling

Adam Barth abarth at webkit.org
Thu May 31 23:21:30 PDT 2012


I've posted a patch to remove target-densitydpi:

https://bugs.webkit.org/show_bug.cgi?id=88047

There's some concern that target-densitydpi is used by some apps that
are bundled with Android, but folks appear willing to deprecate the
feature and to migrate those apps to using other mechanisms, such as
responsive images and CSS device units.

Once that patch lands, I'll start to unwind the complexity introduced
by the feature.

Thanks,
Adam


On Wed, May 30, 2012 at 7:57 PM, Maciej Stachowiak <mjs at apple.com> wrote:
>
> On May 30, 2012, at 4:24 PM, John Mellor <johnme at chromium.org> wrote:
>
>>
>> Maciej Stachowiak wrote:
>> > Can you explain why the target-densitydpi feature even exists? It
>> > seems ill-conceived to me, and the most straightforward fix would
>> > be to remove it. I have not heard anyone explain the use case for
>> > it. (I'm also not clear on the details of what it actually does, and
>> > neither the name nor the docs are enlightening.)
>>
>> Designers who insist on pixel-perfect rendering can use "width=device-width, target-densityDpi=device-dpi" to make their site render at one CSS pixel per screen pixel, letting you get crisp non-scaled borders etc. It does however require the designer to manually adjust dimensions and font-sizes to compensate for the dpi using window.devicePixelRatio, which is incredibly onerous (especially in a cross-platform design, which must look the same on devices that don't support target-densityDpi, hence everything needs to be implemented twice).
>>
>> That's the main use case, though it's pretty niche (if you want pixel-perfect UI, it's generally less hassle to just use high resolution images and scale them down). The other values I don't know of any compelling use cases for; I'll talk to the engineer who first added this and see if they have any good ones.
>
> It seems to me that you could better address this use case by supporting fractional CSS pixels, which hopefully our new subpixel layout code can enable. The tricky thing about "target-densityDpi=device-dpi" is that it forces you to sniff the device pixel ratio and change pretty much all your layout based on it. If historically it would actually alter what is reported for devicePixelRatio, then it would be pretty hard to make a site design that looks right on both 1x and 2x devices with "target-densityDpi=device-dpi. So I'm skeptical that anyone has made good use of it.
>
>>
>> I don't know whether or not we can remove it (would need to check how popular it is), but it might be possible to deprecate it (recommend against using it). That's probably something we should discuss on www-style rather than here.
>
> I guess that would be the right place to discuss dropping it from the spec, but it seems like here is the right place to discuss dropping it from the implementation. From comments in the CSS Device Adaptation spec, it seems like it was only added because it was in Android.
>
> Regards,
> Maciej
>


More information about the webkit-dev mailing list