Title: [135669] trunk
Revision
135669
Author
[email protected]
Date
2012-11-25 10:30:14 -0800 (Sun, 25 Nov 2012)

Log Message

[WK2] TiledBackingStore: page contents is scaled wrongly
https://bugs.webkit.org/show_bug.cgi?id=103090

Patch by Mikhail Pozdnyakov <[email protected]> on 2012-11-25
Reviewed by Kenneth Rohde Christiansen.

Source/WebKit2:

Before this change the page contents scaling in PageViewportController was
defined all the times by m_rawAttributes.initialScale. If initial scale had not
been specified in the viewport meta tag it was set to m_minimumScaleToFit inside
PageViewportController::didChangeViewportAttributes().

The problem was that m_minimumScaleToFit could have wrong value as contents size
might have not be updated by the time PageViewportController::didChangeViewportAttributes()
was invoked.

The solution is to use m_minimumScaleToFit for contents scaling if initial scale
is not specified in the viewport meta tag, as it is updated all the time.
Also a flag m_initiallyFitToViewport is added to PageViewportController to detect
whether m_minimumScaleToFit should be used for scaling.

* UIProcess/PageViewportController.cpp:
(WebKit::PageViewportController::PageViewportController):
(WebKit::PageViewportController::didChangeContentsSize):
(WebKit::PageViewportController::pageTransitionViewportReady):
(WebKit::PageViewportController::didChangeViewportAttributes):
* UIProcess/PageViewportController.h:
(PageViewportController):

LayoutTests:

Added new layout test to verify that viewport 'width' descriptor does not
affect contents width of next loaded page.

* css3/device-adapt/resources/check-contents-width.html: Added.
* css3/device-adapt/viewport-width-not-affecting-next-page-expected.txt: Added.
* css3/device-adapt/viewport-width-not-affecting-next-page.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (135668 => 135669)


--- trunk/LayoutTests/ChangeLog	2012-11-25 16:53:44 UTC (rev 135668)
+++ trunk/LayoutTests/ChangeLog	2012-11-25 18:30:14 UTC (rev 135669)
@@ -1,3 +1,17 @@
+2012-11-25  Mikhail Pozdnyakov  <[email protected]>
+
+        [WK2] TiledBackingStore: page contents is scaled wrongly
+        https://bugs.webkit.org/show_bug.cgi?id=103090
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Added new layout test to verify that viewport 'width' descriptor does not
+        affect contents width of next loaded page. 
+
+        * css3/device-adapt/resources/check-contents-width.html: Added.
+        * css3/device-adapt/viewport-width-not-affecting-next-page-expected.txt: Added.
+        * css3/device-adapt/viewport-width-not-affecting-next-page.html: Added.
+
 2012-11-24  Robert Kroeger  <[email protected]>
 
         Unreviewed gardening: updated expectations for failures in:

Added: trunk/LayoutTests/css3/device-adapt/resources/check-contents-width.html (0 => 135669)


--- trunk/LayoutTests/css3/device-adapt/resources/check-contents-width.html	                        (rev 0)
+++ trunk/LayoutTests/css3/device-adapt/resources/check-contents-width.html	2012-11-25 18:30:14 UTC (rev 135669)
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+       body { margin: 0; }
+       html, body, #result { width: 100%; height: 100%; }
+    </style>
+    <script type="text/_javascript_">
+        setTimeout(function() {
+            var result = document.getElementById("result");
+            result.innerHTML = (result.offsetWidth == window.innerWidth) ? "PASS" : "FAIL";
+
+            if (window.testRunner)
+                testRunner.notifyDone();
+        }, 200); // Have to use timeout because of raise condition caused by WK2 IPC.
+    </script>
+</head>
+<body>
+    <div id="result">
+        </p>
+    </div>
+</body>
+</html>

Added: trunk/LayoutTests/css3/device-adapt/viewport-width-not-affecting-next-page-expected.txt (0 => 135669)


--- trunk/LayoutTests/css3/device-adapt/viewport-width-not-affecting-next-page-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/css3/device-adapt/viewport-width-not-affecting-next-page-expected.txt	2012-11-25 18:30:14 UTC (rev 135669)
@@ -0,0 +1 @@
+PASS

Added: trunk/LayoutTests/css3/device-adapt/viewport-width-not-affecting-next-page.html (0 => 135669)


--- trunk/LayoutTests/css3/device-adapt/viewport-width-not-affecting-next-page.html	                        (rev 0)
+++ trunk/LayoutTests/css3/device-adapt/viewport-width-not-affecting-next-page.html	2012-11-25 18:30:14 UTC (rev 135669)
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>CSS Test: viewport 'width' descriptor does not affect contents width of next loaded page.</title>
+    <link rel="author" title="Mikhail Pozdnyakov" href="" />
+    <style type="text/css">
+        @-webkit-viewport {
+            width: 300px;
+        }
+    </style>
+    <script type="text/_javascript_">
+        if (window.testRunner) {
+            testRunner.dumpAsText();
+            testRunner.waitUntilDone();
+        }
+
+        function onLoad() {
+            window.location = "resources/check-contents-width.html";
+        }
+    </script>
+</head>
+<body _onload_="onLoad()"/>
+</html>

Modified: trunk/Source/WebKit2/ChangeLog (135668 => 135669)


--- trunk/Source/WebKit2/ChangeLog	2012-11-25 16:53:44 UTC (rev 135668)
+++ trunk/Source/WebKit2/ChangeLog	2012-11-25 18:30:14 UTC (rev 135669)
@@ -1,3 +1,32 @@
+2012-11-25  Mikhail Pozdnyakov  <[email protected]>
+
+        [WK2] TiledBackingStore: page contents is scaled wrongly
+        https://bugs.webkit.org/show_bug.cgi?id=103090
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Before this change the page contents scaling in PageViewportController was
+        defined all the times by m_rawAttributes.initialScale. If initial scale had not
+        been specified in the viewport meta tag it was set to m_minimumScaleToFit inside
+        PageViewportController::didChangeViewportAttributes().
+
+        The problem was that m_minimumScaleToFit could have wrong value as contents size
+        might have not be updated by the time PageViewportController::didChangeViewportAttributes()
+        was invoked.
+
+        The solution is to use m_minimumScaleToFit for contents scaling if initial scale
+        is not specified in the viewport meta tag, as it is updated all the time. 
+        Also a flag m_initiallyFitToViewport is added to PageViewportController to detect
+        whether m_minimumScaleToFit should be used for scaling.
+
+        * UIProcess/PageViewportController.cpp:
+        (WebKit::PageViewportController::PageViewportController):
+        (WebKit::PageViewportController::didChangeContentsSize):
+        (WebKit::PageViewportController::pageTransitionViewportReady):
+        (WebKit::PageViewportController::didChangeViewportAttributes):
+        * UIProcess/PageViewportController.h:
+        (PageViewportController):
+
 2012-11-24  Mikhail Pozdnyakov  <[email protected]>
 
         [EFL][WK2] Stop the mess with DECLARE_EWK_VIEW_CALLBACK arg type definition

Modified: trunk/Source/WebKit2/UIProcess/PageViewportController.cpp (135668 => 135669)


--- trunk/Source/WebKit2/UIProcess/PageViewportController.cpp	2012-11-25 16:53:44 UTC (rev 135668)
+++ trunk/Source/WebKit2/UIProcess/PageViewportController.cpp	2012-11-25 18:30:14 UTC (rev 135669)
@@ -44,6 +44,7 @@
     , m_client(client)
     , m_allowsUserScaling(false)
     , m_minimumScaleToFit(1)
+    , m_initiallyFitToViewport(true)
     , m_hasSuspendedContent(false)
     , m_hadUserInteraction(false)
     , m_effectiveScale(1)
@@ -109,7 +110,17 @@
 void PageViewportController::didChangeContentsSize(const IntSize& newSize)
 {
     m_contentsSize = newSize;
-    if (updateMinimumScaleToFit())
+
+    bool minimumScaleUpdated = updateMinimumScaleToFit();
+
+    if (m_initiallyFitToViewport) {
+        // Restrict scale factors to m_minimumScaleToFit.
+        ASSERT(m_minimumScaleToFit > 0);
+        m_rawAttributes.initialScale = m_minimumScaleToFit;
+        WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(m_rawAttributes);
+    }
+
+    if (minimumScaleUpdated)
         m_client->didChangeViewportAttributes();
 }
 
@@ -149,8 +160,8 @@
 {
     if (!m_rawAttributes.layoutSize.isEmpty()) {
         m_hadUserInteraction = false;
-        ASSERT(m_rawAttributes.initialScale > 0);
-        applyScaleAfterRenderingContents(innerBoundedViewportScale(toViewportScale(m_rawAttributes.initialScale)));
+        float initialScale = m_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
@@ -218,18 +229,12 @@
 
     m_rawAttributes = newAttributes;
     m_allowsUserScaling = !!m_rawAttributes.userScalable;
+    m_initiallyFitToViewport = (m_rawAttributes.initialScale < 0);
 
-    bool minimumScaleUpdated = updateMinimumScaleToFit();
+    if (!m_initiallyFitToViewport)
+        WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(m_rawAttributes);
 
-    ASSERT(m_minimumScaleToFit > 0);
-
-    // Set the initial scale if it was not specified in the viewport meta tag.
-    if (m_rawAttributes.initialScale < 0)
-        m_rawAttributes.initialScale = m_minimumScaleToFit;
-
-    WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(m_rawAttributes);
-
-    if (minimumScaleUpdated)
+    if (updateMinimumScaleToFit())
         m_client->didChangeViewportAttributes();
 }
 

Modified: trunk/Source/WebKit2/UIProcess/PageViewportController.h (135668 => 135669)


--- trunk/Source/WebKit2/UIProcess/PageViewportController.h	2012-11-25 16:53:44 UTC (rev 135668)
+++ trunk/Source/WebKit2/UIProcess/PageViewportController.h	2012-11-25 18:30:14 UTC (rev 135669)
@@ -94,6 +94,7 @@
 
     bool m_allowsUserScaling;
     float m_minimumScaleToFit;
+    bool m_initiallyFitToViewport;
 
     bool m_hasSuspendedContent;
     bool m_hadUserInteraction;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to