DescriptionMerge 139356
> Fix scale of screen.width, window.outerWidth and @media device-width when page scale not applied in compositor.
> https://bugs.webkit.org/show_bug.cgi?id=106460
>
> Patch by John Mellor <johnme@chromium.org> on 2013-01-10
> Reviewed by Kenneth Rohde Christiansen.
>
> Source/WebCore:
>
> screen.width, window.outerWidth and @media device-width should be in
> density independent (UI) pixels, not physical screen pixels.
>
> This already works on most ports (including iOS). However Chrome for
> Android currently internally sizes its windows in physical screen pixels
> instead of density independent pixels, and this leaks through in the
> sizes provided to WebCore.
>
> This patch scales these sizes appropriately before they reach JavaScript,
> on platforms where the applyPageScaleFactorInCompositor setting is false
> (i.e. just Chrome for Android). Once Chrome for Android switches over to
> the same coordinate space, the applyPageScaleFactorInCompositor setting
> will be removed, along with any code (such as this) that depends on it.
>
> The effect of this patch on Chrome for Android when viewing a page with
> a width=device-width viewport on a Galaxy Nexus (720x1280 @ dPR 2) is:
> @media device-width changes from 720 to 360
> screen.width changes from 720 to 360
> screen.availWidth changes from 720 to 360
> window.outerWidth changes from 720 to 360
> window.innerWidth remains 360 (at overview zoom)
> @media width remains 360
> document.documentElement.clientWidth remains 360
> document.documentElement.offsetWidth remains 360
> document.documentElement.scrollWidth remains 360
> document.body.clientWidth remains 360
> document.body.offsetWidth remains 360
> document.body.scrollWidth remains 360
> And similarly for heights (though they are slightly less than 640, since
> toolbars etc. get subtracted from the available height).
>
> No new tests, as applyDeviceScaleFactorInCompositor appears to always be
> true in DumpRenderTree, so this situation cannot occur there.
>
> * page/Settings.in:
> Added applyDeviceScaleFactorInCompositor setting, which allows
> detecting whether we need to normalize the scale.
> * platform/chromium/PlatformScreenChromium.cpp:
> (WebCore::toUserSpace):
> Static function for normalizing screen rect scale.
> (WebCore::screenRect):
> Uses toUserSpace.
> (WebCore::screenAvailableRect):
> Uses toUserSpace.
> * rendering/TextAutosizer.cpp:
> (WebCore::TextAutosizer::processSubtree):
> Use applyDeviceScaleFactorInCompositor instead of
> applyPageScaleFactorInCompositor, to scale the window rect correctly
> on platforms other than Chrome for Android.
>
> Source/WebKit/chromium:
>
> 1. Exposes the existing applyDeviceScaleFactorInCompositor from
> WebSettings on Settings (and stores the value there instead), so it can
> be accessed from WebCore.
>
> 2. Changes ChromeClientImpl::windowRect to return values in density
> independent (UI) pixels pixels instead of physical screen pixels (see
> explanation in Source/WebCore/ChangeLog).
>
> * src/ChromeClientImpl.cpp:
> (WebKit::ChromeClientImpl::windowRect):
> Normalizes window rect scale.
> * src/WebSettingsImpl.cpp:
> (WebKit::WebSettingsImpl::WebSettingsImpl):
> (WebKit::WebSettingsImpl::setApplyDeviceScaleFactorInCompositor):
> (WebKit::WebSettingsImpl::applyDeviceScaleFactorInCompositor):
> (WebKit):
> * src/WebSettingsImpl.h:
> (WebSettingsImpl):
TBR=commit-queue@webkit.org
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=139472
Patch Set 1 #
Messages
Total messages: 1 (0 generated)
|