[chromium] move webpermissionclient related methods to TestRunner library
https://bugs.webkit.org/show_bug.cgi?id=106548

Patch by Dan Carney <dcarney@google.com> on 2013-01-10
Reviewed by Jochen Eisinger.

* DumpRenderTree/DumpRenderTree.gypi:
* DumpRenderTree/chromium/DRTTestRunner.cpp:
(DRTTestRunner::DRTTestRunner):
(DRTTestRunner::reset):
* DumpRenderTree/chromium/DRTTestRunner.h:
(DRTTestRunner):
* DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h:
(WebTestRunner::WebTestDelegate::normalizeLayoutTestURL):
* DumpRenderTree/chromium/TestRunner/public/WebTestRunner.h:
(WebKit):
(WebTestRunner::WebTestRunner::webPermissions):
* DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp:
(WebTestRunner::TestRunner::TestRunner):
(WebTestRunner::TestRunner::setDelegate):
(WebTestRunner):
(WebTestRunner::TestRunner::reset):
(WebTestRunner::TestRunner::webPermissions):
(WebTestRunner::TestRunner::dumpPermissionClientCallbacks):
(WebTestRunner::TestRunner::setImagesAllowed):
(WebTestRunner::TestRunner::setScriptsAllowed):
(WebTestRunner::TestRunner::setStorageAllowed):
(WebTestRunner::TestRunner::setPluginsAllowed):
(WebTestRunner::TestRunner::setAllowDisplayOfInsecureContent):
(WebTestRunner::TestRunner::setAllowRunningOfInsecureContent):
* DumpRenderTree/chromium/TestRunner/src/TestRunner.h:
(WebTestRunner):
(TestRunner):
* DumpRenderTree/chromium/TestRunner/src/WebPermissions.cpp: Renamed from Tools/DumpRenderTree/chromium/WebPermissions.cpp.
(WebTestRunner):
(WebTestRunner::WebPermissions::WebPermissions):
(WebTestRunner::WebPermissions::~WebPermissions):
(WebTestRunner::WebPermissions::allowImage):
(WebTestRunner::WebPermissions::allowScriptFromSource):
(WebTestRunner::WebPermissions::allowStorage):
(WebTestRunner::WebPermissions::allowPlugins):
(WebTestRunner::WebPermissions::allowDisplayingInsecureContent):
(WebTestRunner::WebPermissions::allowRunningInsecureContent):
(WebTestRunner::WebPermissions::setImagesAllowed):
(WebTestRunner::WebPermissions::setScriptsAllowed):
(WebTestRunner::WebPermissions::setStorageAllowed):
(WebTestRunner::WebPermissions::setPluginsAllowed):
(WebTestRunner::WebPermissions::setDisplayingInsecureContentAllowed):
(WebTestRunner::WebPermissions::setRunningInsecureContentAllowed):
(WebTestRunner::WebPermissions::setDelegate):
(WebTestRunner::WebPermissions::setDumpCallbacks):
(WebTestRunner::WebPermissions::reset):
* DumpRenderTree/chromium/TestRunner/src/WebPermissions.h: Renamed from Tools/DumpRenderTree/chromium/WebPermissions.h.
(WebTestRunner):
(WebPermissions):
* DumpRenderTree/chromium/TestShell.cpp:
(TestShell::initialize):
(TestShell::resetTestController):
(TestShell::createNewWindow):
* DumpRenderTree/chromium/TestShell.h:
(TestShell):
* DumpRenderTree/chromium/WebViewHost.cpp:
(WebViewHost::normalizeLayoutTestURL):
* DumpRenderTree/chromium/WebViewHost.h:
(WebViewHost):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@139355 268f45cc-cd09-0410-ab3c-d52691b4dbfc
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):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@139356 268f45cc-cd09-0410-ab3c-d52691b4dbfc