Title: [135442] trunk/Source/WebKit/chromium
Revision
135442
Author
[email protected]
Date
2012-11-21 15:09:25 -0800 (Wed, 21 Nov 2012)

Log Message

Use m_webView->size() for viewport update
https://bugs.webkit.org/show_bug.cgi?id=102764

Patch by Tien-Ren Chen <[email protected]> on 2012-11-21
Reviewed by Adam Barth.

m_webView->client()->windowRect() returns the outer rect of the browser
window, which includes the decorations such as the title bar.
We should use the size of the WebView for layout and rendering purpose.

Existing tests are updated to work without windowRect().

* src/ChromeClientImpl.cpp:
(WebKit::ChromeClientImpl::dispatchViewportPropertiesDidChange):
* tests/WebFrameTest.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebKit/chromium/ChangeLog (135441 => 135442)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-11-21 23:01:23 UTC (rev 135441)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-11-21 23:09:25 UTC (rev 135442)
@@ -1,3 +1,20 @@
+2012-11-21  Tien-Ren Chen  <[email protected]>
+
+        Use m_webView->size() for viewport update
+        https://bugs.webkit.org/show_bug.cgi?id=102764
+
+        Reviewed by Adam Barth.
+
+        m_webView->client()->windowRect() returns the outer rect of the browser
+        window, which includes the decorations such as the title bar.
+        We should use the size of the WebView for layout and rendering purpose.
+
+        Existing tests are updated to work without windowRect().
+
+        * src/ChromeClientImpl.cpp:
+        (WebKit::ChromeClientImpl::dispatchViewportPropertiesDidChange):
+        * tests/WebFrameTest.cpp:
+
 2012-11-21  Peter Beverloo  <[email protected]>
 
         [Chromium] webkit_unit_tests should depend on forwarder2 for Android

Modified: trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp (135441 => 135442)


--- trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp	2012-11-21 23:01:23 UTC (rev 135441)
+++ trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp	2012-11-21 23:09:25 UTC (rev 135442)
@@ -626,17 +626,17 @@
         return;
 
     WebViewClient* client = m_webView->client();
-    WebRect deviceRect = client->windowRect();
+    WebSize deviceSize = m_webView->size();
     // If the window size has not been set yet don't attempt to set the viewport
-    if (!deviceRect.width || !deviceRect.height)
+    if (!deviceSize.width || !deviceSize.height)
         return;
 
     Settings* settings = m_webView->page()->settings();
     float devicePixelRatio = client->screenInfo().deviceScaleFactor;
     // Call the common viewport computing logic in ViewportArguments.cpp.
     ViewportAttributes computed = computeViewportAttributes(
-        arguments, settings->layoutFallbackWidth(), deviceRect.width, deviceRect.height,
-        devicePixelRatio, IntSize(deviceRect.width, deviceRect.height));
+        arguments, settings->layoutFallbackWidth(), deviceSize.width, deviceSize.height,
+        devicePixelRatio, IntSize(deviceSize.width, deviceSize.height));
 
     restrictScaleFactorToInitialScaleIfNotUserScalable(computed);
 

Modified: trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp (135441 => 135442)


--- trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp	2012-11-21 23:01:23 UTC (rev 135441)
+++ trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp	2012-11-21 23:09:25 UTC (rev 135442)
@@ -220,10 +220,8 @@
 
 class FixedLayoutTestWebViewClient : public WebViewClient {
  public:
-    virtual WebRect windowRect() OVERRIDE { return m_windowRect; }
     virtual WebScreenInfo screenInfo() OVERRIDE { return m_screenInfo; }
 
-    WebRect m_windowRect;
     WebScreenInfo m_screenInfo;
 };
 
@@ -236,7 +234,6 @@
 
     FixedLayoutTestWebViewClient client;
     client.m_screenInfo.deviceScaleFactor = 2;
-    client.m_windowRect = WebRect(0, 0, viewportWidth, viewportHeight);
 
     WebView* webView = static_cast<WebView*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "no_viewport_tag.html", true, 0, &client));
 
@@ -263,7 +260,6 @@
     client.m_screenInfo.deviceScaleFactor = 1;
     int viewportWidth = 640;
     int viewportHeight = 480;
-    client.m_windowRect = WebRect(0, 0, viewportWidth, viewportHeight);
 
     // Make sure we initialize to minimum scale, even if the window size
     // only becomes available after the load begins.
@@ -300,7 +296,6 @@
     client.m_screenInfo.horizontalDPI = 212;
     int viewportWidth = 800;
     int viewportHeight = 1057;
-    client.m_windowRect = WebRect(0, 0, viewportWidth, viewportHeight);
 
     WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "scale_oscillate.html", true, 0, &client));
     webViewImpl->enableFixedLayoutMode(true);
@@ -319,7 +314,6 @@
     client.m_screenInfo.deviceScaleFactor = 1;
     int viewportWidth = 640;
     int viewportHeight = 480;
-    client.m_windowRect = WebRect(0, 0, viewportWidth, viewportHeight);
 
     WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "no_scale_for_you.html", true, 0, &client));
     webViewImpl->enableFixedLayoutMode(true);
@@ -334,13 +328,6 @@
 }
 
 #if ENABLE(GESTURE_EVENTS)
-class DivAutoZoomTestWebViewClient : public WebViewClient {
-    public:
-    virtual WebRect windowRect() OVERRIDE { return m_windowRect; }
-
-    WebRect m_windowRect;
-};
-
 void setScaleAndScrollAndLayout(WebKit::WebView* webView, WebPoint scroll, float scale)
 {
     webView->setPageScaleFactor(scale, WebPoint(scroll.x, scroll.y));
@@ -351,11 +338,9 @@
 {
     registerMockedHttpURLLoad("get_scale_for_auto_zoom_into_div_test.html");
 
-    DivAutoZoomTestWebViewClient client;
     int viewportWidth = 640;
     int viewportHeight = 480;
-    client.m_windowRect = WebRect(0, 0, viewportWidth, viewportHeight);
-    WebKit::WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_for_auto_zoom_into_div_test.html", true, 0, &client);
+    WebKit::WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_for_auto_zoom_into_div_test.html");
     webView->enableFixedLayoutMode(true);
     webView->setDeviceScaleFactor(2.0f);
     webView->resize(WebSize(viewportWidth, viewportHeight));
@@ -419,12 +404,10 @@
 {
     registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html");
 
-    DivAutoZoomTestWebViewClient client;
     int viewportWidth = 640;
     int viewportHeight = 480;
     float doubleTapZoomAlreadyLegibleRatio = 1.2f;
-    client.m_windowRect = WebRect(0, 0, viewportWidth, viewportHeight);
-    WebKit::WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom_test.html", true, 0, &client);
+    WebKit::WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom_test.html");
     webView->enableFixedLayoutMode(true);
     webView->resize(WebSize(viewportWidth, viewportHeight));
     webView->setPageScaleFactorLimits(1, 4);
@@ -460,12 +443,10 @@
 {
     registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html");
 
-    DivAutoZoomTestWebViewClient client;
     int viewportWidth = 640;
     int viewportHeight = 480;
     float doubleTapZoomAlreadyLegibleRatio = 1.2f;
-    client.m_windowRect = WebRect(0, 0, viewportWidth, viewportHeight);
-    WebKit::WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_bounds_check_for_auto_zoom_test.html", true, 0, &client);
+    WebKit::WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_bounds_check_for_auto_zoom_test.html");
     webView->enableFixedLayoutMode(true);
     webView->resize(WebSize(viewportWidth, viewportHeight));
     webView->setPageScaleFactorLimits(1, 4);
@@ -522,14 +503,12 @@
 {
     registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html");
 
-    DivAutoZoomTestWebViewClient client;
     int viewportWidth = 640;
     int viewportHeight = 480;
     float leftBoxRatio = 0.3f;
     int caretPadding = 10;
     int minReadableCaretHeight = 18;
-    client.m_windowRect = WebRect(0, 0, viewportWidth, viewportHeight);
-    WebKit::WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_for_zoom_into_editable_test.html", true, 0, &client);
+    WebKit::WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_for_zoom_into_editable_test.html");
     webView->enableFixedLayoutMode(true);
     webView->resize(WebSize(viewportWidth, viewportHeight));
     webView->setPageScaleFactorLimits(1, 10);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to