Title: [133624] trunk/Source
Revision
133624
Author
[email protected]
Date
2012-11-06 09:34:48 -0800 (Tue, 06 Nov 2012)

Log Message

[Qt][WK2] Fit-to-width broken on pages with viewport meta tag
https://bugs.webkit.org/show_bug.cgi?id=99715

Reviewed by Jocelyn Turcotte.

Source/WebCore:

Add a bool that indicates if the content had an explicit
initial-scale in the viewport meta tag.

* dom/ViewportArguments.cpp:
(WebCore::computeViewportAttributes):
* dom/ViewportArguments.h:
(ViewportAttributes):

Source/WebKit2:

The initial scale from the viewport attributes should only
be applied if the scale was explicitly specified in the
viewport meta tag.
If the initial scale is auto it should be calculated using
the final contents size, which might be larger than the
layout size, so that the content fits horizontally into
the view.

Also add QML unit tests that cover this functionality.

* UIProcess/API/qt/tests/qmltests/WebView/tst_fitToView.qml:
* UIProcess/API/qt/tests/qmltests/common/test5.html: Added.
* UIProcess/PageViewportController.cpp:
(WebKit::PageViewportController::PageViewportController):
(WebKit::PageViewportController::pageTransitionViewportReady):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (133623 => 133624)


--- trunk/Source/WebCore/ChangeLog	2012-11-06 17:31:30 UTC (rev 133623)
+++ trunk/Source/WebCore/ChangeLog	2012-11-06 17:34:48 UTC (rev 133624)
@@ -1,3 +1,18 @@
+2012-11-06  Andras Becsi  <[email protected]>
+
+        [Qt][WK2] Fit-to-width broken on pages with viewport meta tag
+        https://bugs.webkit.org/show_bug.cgi?id=99715
+
+        Reviewed by Jocelyn Turcotte.
+
+        Add a bool that indicates if the content had an explicit
+        initial-scale in the viewport meta tag.
+
+        * dom/ViewportArguments.cpp:
+        (WebCore::computeViewportAttributes):
+        * dom/ViewportArguments.h:
+        (ViewportAttributes):
+
 2012-11-06  Mike West  <[email protected]>
 
         CSP 1.1: Tweak the script interface to match the spec.

Modified: trunk/Source/WebCore/dom/ViewportArguments.cpp (133623 => 133624)


--- trunk/Source/WebCore/dom/ViewportArguments.cpp	2012-11-06 17:31:30 UTC (rev 133623)
+++ trunk/Source/WebCore/dom/ViewportArguments.cpp	2012-11-06 17:34:48 UTC (rev 133624)
@@ -90,6 +90,8 @@
     if (args.height != ViewportArguments::ValueAuto)
         args.height = min(float(10000), max(args.height, float(1)));
 
+    result.initiallyFitToViewport = args.initialScale == ViewportArguments::ValueAuto;
+
     if (args.initialScale != ViewportArguments::ValueAuto)
         args.initialScale = min(float(10), max(args.initialScale, float(0.1)));
     if (args.minimumScale != ViewportArguments::ValueAuto)

Modified: trunk/Source/WebCore/dom/ViewportArguments.h (133623 => 133624)


--- trunk/Source/WebCore/dom/ViewportArguments.h	2012-11-06 17:31:30 UTC (rev 133623)
+++ trunk/Source/WebCore/dom/ViewportArguments.h	2012-11-06 17:34:48 UTC (rev 133624)
@@ -50,6 +50,7 @@
     float maximumScale;
 
     float userScalable;
+    bool initiallyFitToViewport;
 };
 
 struct ViewportArguments {

Modified: trunk/Source/WebKit2/ChangeLog (133623 => 133624)


--- trunk/Source/WebKit2/ChangeLog	2012-11-06 17:31:30 UTC (rev 133623)
+++ trunk/Source/WebKit2/ChangeLog	2012-11-06 17:34:48 UTC (rev 133624)
@@ -1,3 +1,26 @@
+2012-11-06  Andras Becsi  <[email protected]>
+
+        [Qt][WK2] Fit-to-width broken on pages with viewport meta tag
+        https://bugs.webkit.org/show_bug.cgi?id=99715
+
+        Reviewed by Jocelyn Turcotte.
+
+        The initial scale from the viewport attributes should only
+        be applied if the scale was explicitly specified in the
+        viewport meta tag.
+        If the initial scale is auto it should be calculated using
+        the final contents size, which might be larger than the
+        layout size, so that the content fits horizontally into
+        the view.
+
+        Also add QML unit tests that cover this functionality.
+
+        * UIProcess/API/qt/tests/qmltests/WebView/tst_fitToView.qml:
+        * UIProcess/API/qt/tests/qmltests/common/test5.html: Added.
+        * UIProcess/PageViewportController.cpp:
+        (WebKit::PageViewportController::PageViewportController):
+        (WebKit::PageViewportController::pageTransitionViewportReady):
+
 2012-11-06  Huang Dongsung  <[email protected]>
 
         Coordinated Graphics: Remove a parent member in WebLayerInfo.

Modified: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_fitToView.qml (133623 => 133624)


--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_fitToView.qml	2012-11-06 17:31:30 UTC (rev 133623)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_fitToView.qml	2012-11-06 17:34:48 UTC (rev 133624)
@@ -93,5 +93,39 @@
             compare(documentSize(), "960x1440")
             compare(test.contentsScale, 1.0)
         }
+
+        function test_localPageDeviceWidth() {
+            webView.url = ""
+            verify(webView.waitForLoadSucceeded())
+
+            webView.url = ""
+            verify(webView.waitForLoadSucceeded())
+            compare(test.contentsScale, 0.5)
+
+            // Add user interaction.
+            test.touchTap(webView, 10, 10)
+
+            webView.reload()
+            verify(webView.waitForLoadSucceeded())
+            // The page should still fit to view after a reload
+            compare(test.contentsScale, 0.5)
+        }
+
+        function test_localPageInitialScale() {
+            webView.url = ""
+            verify(webView.waitForLoadSucceeded())
+
+            webView.url = ""
+            verify(webView.waitForLoadSucceeded())
+
+            compare(test.contentsScale, 2.0)
+
+            // Add user interaction.
+            test.touchTap(webView, 10, 10)
+
+            webView.reload()
+            verify(webView.waitForLoadSucceeded())
+            compare(test.contentsScale, 2.0)
+        }
     }
 }

Modified: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test4.html (133623 => 133624)


--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test4.html	2012-11-06 17:31:30 UTC (rev 133623)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test4.html	2012-11-06 17:34:48 UTC (rev 133624)
@@ -9,6 +9,7 @@
                  font-size: 50px;
             }
         </style>
+        <meta name="viewport" content="initial-scale=2.0"/>
     </head>
     <body>
         <div id="content">

Added: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test5.html (0 => 133624)


--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test5.html	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test5.html	2012-11-06 17:34:48 UTC (rev 133624)
@@ -0,0 +1,10 @@
+<html>
+  <head>
+    <title>Local page with viewport meta tag: width=device-width</title>
+    <meta name="viewport" content="width=device-width"/>
+  </head>
+  <body>
+    <style type="text/css">body {width: 960px; height: 1440px; margin: 0; padding: 0;}</style>
+    <div>blah</div>
+  </body>
+</html>

Modified: trunk/Source/WebKit2/UIProcess/PageViewportController.cpp (133623 => 133624)


--- trunk/Source/WebKit2/UIProcess/PageViewportController.cpp	2012-11-06 17:31:30 UTC (rev 133623)
+++ trunk/Source/WebKit2/UIProcess/PageViewportController.cpp	2012-11-06 17:34:48 UTC (rev 133624)
@@ -56,6 +56,7 @@
     m_rawAttributes.minimumScale = 1;
     m_rawAttributes.maximumScale = 1;
     m_rawAttributes.userScalable = m_allowsUserScaling;
+    m_rawAttributes.initiallyFitToViewport = true;
 
     ASSERT(m_client);
     m_client->setController(this);
@@ -141,7 +142,8 @@
 {
     if (!m_rawAttributes.layoutSize.isEmpty()) {
         m_hadUserInteraction = false;
-        applyScaleAfterRenderingContents(innerBoundedViewportScale(toViewportScale(m_rawAttributes.initialScale)));
+        float initialScale = m_rawAttributes.initiallyFitToViewport ? m_minimumScaleToFit : m_rawAttributes.initialScale;
+        applyScaleAfterRenderingContents(innerBoundedViewportScale(toViewportScale(initialScale)));
     }
 
     // At this point we should already have received the first viewport arguments and the requested scroll
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to