[webkit-dev] Device and page scaling
abarth at webkit.org
Tue May 29 18:54:38 PDT 2012
There's a lot of confusion in the code base about how page and device
scaling works. Different ports are using Page::deviceScaleFactor for
incompatible purposes. On Mac, Page::deviceScaleFactor represents the
actual scaling factor of the physical device. It can change over time
because a given Page might be displayed on different devices over its
lifetime (e.g., if there are multiple monitors). On Chromium and Qt,
Page::deviceScaleFactor starts off as the actual scaling factor of the
physical device, but it can change over time if a web page has a
viewport meta tag that contains a target-densitydpi directive.
There's also Settings::defaultDeviceScaleFactor, which represents the
actual scaling factor of the physical device on ports that adjust
Page::deviceScaleFactor based on the target-densitydpi directive.
Settings::defaultDeviceScaleFactor does not work on Mac (and can't
work because of multimon).
Here's a proposal for making sense out of this mess:
== Page::pageScaleFactor ==
Page::pageScaleFactor is a scaling factor that arises from the meta
viewport tag and from "pinch-to-zoom" interactions. This proposal
doesn't change anything about page scaling.
== Page::deviceScaleFactor ==
Page::deviceScaleFactor is the scaling factor of the actual physical
device. It's value changes when the physical device displaying the
Page changes its scaling factor. It is not affected by
target-densitydpi or anything else unrelated to the physical device.
== Page::effectiveDeviceScaleFactor ==
Page::effectiveDeviceScaleFactor starts off as matching
Page::deviceScaleFactor but changes to reflect any target-densitydpi
directives. It's unclear to me how Page::effectiveDeviceScaleFactor
should react when the underlying physical device changes its scaling
factor. Currently, that shouldn't occur, so I'm inclined to add an
ASSERT and worry about it later.
== Settings::defaultDeviceScaleFactor ==
This variable will be deleted.
More information about the webkit-dev