Title: [118121] trunk/Source/WebKit/chromium
Revision
118121
Author
[email protected]
Date
2012-05-22 22:03:16 -0700 (Tue, 22 May 2012)

Log Message

[chromium] Apply viewport tag initial-scale only once
https://bugs.webkit.org/show_bug.cgi?id=82949

Patch by Alexandre Elias <[email protected]> on 2012-05-22
Reviewed by Adam Barth.

First, check that isPageScaleFactorSet return false before setting
initial-scale. We need to call dispatchViewportPropertiesDidChange()
when the viewport width changes, since that's an input to the viewport
tag calculation. When this happens, we shouldn't pop back to initial
scale.

Second, check that isNewNavigation is true when deciding to clear
isPageScaleFactorIsSet in didCommitLoad. We only want to clear it on
the very first commit, otherwise we'll pop back to initial scale if
the user zooms in before the load is complete.

New test WebFrameTest::FixedLayoutInitializeAtMinimumPageScale.

* src/ChromeClientImpl.cpp:
(WebKit::ChromeClientImpl::dispatchViewportPropertiesDidChange):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::didCommitLoad):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/chromium/ChangeLog (118120 => 118121)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-05-23 04:56:28 UTC (rev 118120)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-05-23 05:03:16 UTC (rev 118121)
@@ -1,3 +1,28 @@
+2012-05-22  Alexandre Elias  <[email protected]>
+
+        [chromium] Apply viewport tag initial-scale only once
+        https://bugs.webkit.org/show_bug.cgi?id=82949
+
+        Reviewed by Adam Barth.
+
+        First, check that isPageScaleFactorSet return false before setting
+        initial-scale. We need to call dispatchViewportPropertiesDidChange()
+        when the viewport width changes, since that's an input to the viewport
+        tag calculation. When this happens, we shouldn't pop back to initial
+        scale.
+
+        Second, check that isNewNavigation is true when deciding to clear
+        isPageScaleFactorIsSet in didCommitLoad. We only want to clear it on
+        the very first commit, otherwise we'll pop back to initial scale if
+        the user zooms in before the load is complete.
+
+        New test WebFrameTest::FixedLayoutInitializeAtMinimumPageScale.
+
+        * src/ChromeClientImpl.cpp:
+        (WebKit::ChromeClientImpl::dispatchViewportPropertiesDidChange):
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::didCommitLoad):
+
 2012-05-21  Shawn Singh  <[email protected]>
 
         Improve W3C conformance of backface-visibility

Modified: trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp (118120 => 118121)


--- trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp	2012-05-23 04:56:28 UTC (rev 118120)
+++ trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp	2012-05-23 05:03:16 UTC (rev 118121)
@@ -665,14 +665,14 @@
     int layoutHeight = computed.layoutSize.height();
     m_webView->setFixedLayoutSize(IntSize(layoutWidth, layoutHeight));
 
-    // FIXME: Investigate the impact this has on layout/rendering if any.
-    // This exposes the correct device scale to _javascript_ and media queries.
+    bool needInitializePageScale = !m_webView->isPageScaleFactorSet();
     if (useDefaultDeviceScaleFactor && settings->defaultDeviceScaleFactor())
         m_webView->setDeviceScaleFactor(settings->defaultDeviceScaleFactor());
     else
         m_webView->setDeviceScaleFactor(computed.devicePixelRatio);
     m_webView->setPageScaleFactorLimits(computed.minimumScale, computed.maximumScale);
-    m_webView->setPageScaleFactorPreservingScrollOffset(computed.initialScale * computed.devicePixelRatio);
+    if (needInitializePageScale)
+        m_webView->setPageScaleFactorPreservingScrollOffset(computed.initialScale * computed.devicePixelRatio);
 #endif
 }
 

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (118120 => 118121)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-05-23 04:56:28 UTC (rev 118120)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-05-23 05:03:16 UTC (rev 118121)
@@ -3102,7 +3102,7 @@
     m_newNavigationLoader = 0;
 #endif
     m_observedNewNavigation = false;
-    if (!isNavigationWithinPage)
+    if (*isNewNavigation && !isNavigationWithinPage)
         m_pageScaleFactorIsSet = false;
 
     m_gestureAnimation.clear();

Modified: trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp (118120 => 118121)


--- trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp	2012-05-23 04:56:28 UTC (rev 118120)
+++ trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp	2012-05-23 05:03:16 UTC (rev 118121)
@@ -34,11 +34,13 @@
 
 #include "Frame.h"
 #include "FrameTestHelpers.h"
+#include "FrameView.h"
 #include "ResourceError.h"
 #include "WebDocument.h"
 #include "WebFindOptions.h"
 #include "WebFormElement.h"
 #include "WebFrameClient.h"
+#include "WebFrameImpl.h"
 #include "WebRange.h"
 #include "WebScriptSource.h"
 #include "WebSearchableFormData.h"
@@ -243,6 +245,43 @@
     // Force the layout to happen before leaving the test.
     webView->mainFrame()->contentAsText(1024).utf8();
 }
+
+TEST_F(WebFrameTest, FixedLayoutInitializeAtMinimumPageScale)
+{
+    registerMockedHttpURLLoad("fixed_layout.html");
+
+    FixedLayoutTestWebViewClient client;
+    client.m_screenInfo.horizontalDPI = 160;
+    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.
+    WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client));
+    webViewImpl->enableFixedLayoutMode(true);
+    webViewImpl->settings()->setViewportEnabled(true);
+    webViewImpl->resize(WebSize(viewportWidth, viewportHeight));
+
+    int defaultFixedLayoutWidth = 980;
+    float minimumPageScaleFactor = viewportWidth / (float) defaultFixedLayoutWidth;
+    EXPECT_EQ(minimumPageScaleFactor, webViewImpl->pageScaleFactor());
+
+    // Assume the user has pinch zoomed to page scale factor 2.
+    float userPinchPageScaleFactor = 2;
+    webViewImpl->setPageScaleFactorPreservingScrollOffset(userPinchPageScaleFactor);
+    webViewImpl->mainFrameImpl()->frameView()->layout();
+
+    // Make sure we don't reset to initial scale if the page continues to load.
+    bool isNewNavigation;
+    webViewImpl->didCommitLoad(&isNewNavigation, false);
+    webViewImpl->didChangeContentsSize();
+    EXPECT_EQ(userPinchPageScaleFactor, webViewImpl->pageScaleFactor());
+
+    // Make sure we don't reset to initial scale if the viewport size changes.
+    webViewImpl->resize(WebSize(viewportWidth, viewportHeight + 100));
+    EXPECT_EQ(userPinchPageScaleFactor, webViewImpl->pageScaleFactor());
+}
 #endif
 
 #if ENABLE(GESTURE_EVENTS)

Added: trunk/Source/WebKit/chromium/tests/data/fixed_layout.html (0 => 118121)


--- trunk/Source/WebKit/chromium/tests/data/fixed_layout.html	                        (rev 0)
+++ trunk/Source/WebKit/chromium/tests/data/fixed_layout.html	2012-05-23 05:03:16 UTC (rev 118121)
@@ -0,0 +1 @@
+<body>Ordinary non-mobile page</body>
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to