Title: [237818] trunk
Revision
237818
Author
[email protected]
Date
2018-11-05 11:12:38 -0800 (Mon, 05 Nov 2018)

Log Message

[iOS] Changing view scale sometimes does not zoom the page to the new initial scale when the page is zoomed in when ignoring meta viewport
https://bugs.webkit.org/show_bug.cgi?id=191226
<rdar://problem/45781765>

Reviewed by Tim Horton.

Source/WebCore:

When `_setViewScale:` SPI is used to adjust the layout scale factor of the page, we multiply minimum, initial
and maximum scales by the given layout scale factor to adjust for a larger or smaller minimum layout size.
However, in the case where the layout size scale factor is greater than 1 and we're also forcing the viewport to
be scalable, we override the default minimum scale with 1 (i.e. `forceAlwaysUserScalableMinimumScale`). This
means that the might be off by a small margin due to rounding error when computing the content width and view
width (see: r237743).

This means that in the case where (1) the viewport is forced to be user-scalable, and (2) we're ignoring meta
viewport parameters, and (3) `_viewScale` exceeds 1, we may end up computing a slightly different minimum scale
than the default minimum scale multiplied by the layout size scale factor; subsequently, the page scale factor
will be slightly different from initial scale, such that we'll no longer zoom to the new initial scale when
changing view scale.

This patch adjusts `forceAlwaysUserScalableMinimumScale` and `forceAlwaysUserScalableMaximumScale` to take the
current layout scale factor into account when computing min and max scales when the viewport is forced to be
always scalable.

Test: fast/viewport/ios/minimum-scale-after-changing-view-scale.html

* page/ViewportConfiguration.cpp:
(WebCore::ViewportConfiguration::minimumScale const):
* page/ViewportConfiguration.h:
(WebCore::ViewportConfiguration::maximumScale const):
(WebCore::ViewportConfiguration::forceAlwaysUserScalableMaximumScale const):
(WebCore::ViewportConfiguration::forceAlwaysUserScalableMinimumScale const):

Turn these from constant values to const functions on ViewportConfiguration, which factor in the current
viewport layout size scale factor.

Tools:

Add a missing check for `shouldIgnoreMetaViewport` when comparing TestOptions, to ensure that "ignore meta
viewport" state doesn't unexpectedly persist after running a layout test that ignores meta viewport.

* WebKitTestRunner/TestOptions.h:
(WTR::TestOptions::hasSameInitializationOptions const):

LayoutTests:

Add a new layout test that sets the view scale to several values greater than or equal to 1 and verifies that
the minimum scale and resulting scroll view scale are exactly the same as the view scale, when (1) the "ignores
meta viewport" preference is enabled, and (2) the viewport is forced to be always scalable.

* fast/viewport/ios/minimum-scale-after-changing-view-scale-expected.txt: Added.
* fast/viewport/ios/minimum-scale-after-changing-view-scale.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (237817 => 237818)


--- trunk/LayoutTests/ChangeLog	2018-11-05 19:01:30 UTC (rev 237817)
+++ trunk/LayoutTests/ChangeLog	2018-11-05 19:12:38 UTC (rev 237818)
@@ -1,3 +1,18 @@
+2018-11-05  Wenson Hsieh  <[email protected]>
+
+        [iOS] Changing view scale sometimes does not zoom the page to the new initial scale when the page is zoomed in when ignoring meta viewport
+        https://bugs.webkit.org/show_bug.cgi?id=191226
+        <rdar://problem/45781765>
+
+        Reviewed by Tim Horton.
+
+        Add a new layout test that sets the view scale to several values greater than or equal to 1 and verifies that
+        the minimum scale and resulting scroll view scale are exactly the same as the view scale, when (1) the "ignores
+        meta viewport" preference is enabled, and (2) the viewport is forced to be always scalable.
+
+        * fast/viewport/ios/minimum-scale-after-changing-view-scale-expected.txt: Added.
+        * fast/viewport/ios/minimum-scale-after-changing-view-scale.html: Added.
+
 2018-11-05  Matt Baker  <[email protected]>
 
         Web Inspector: Table selection should not require that rows be in the cache

Added: trunk/LayoutTests/fast/viewport/ios/minimum-scale-after-changing-view-scale-expected.txt (0 => 237818)


--- trunk/LayoutTests/fast/viewport/ios/minimum-scale-after-changing-view-scale-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/viewport/ios/minimum-scale-after-changing-view-scale-expected.txt	2018-11-05 19:12:38 UTC (rev 237818)
@@ -0,0 +1,25 @@
+After setting the view scale to 1.15, the minimum scale is: 1.15000
+After setting the view scale to 1.15, the current scale is: 1.15000
+
+After setting the view scale to 1.25, the minimum scale is: 1.25000
+After setting the view scale to 1.25, the current scale is: 1.25000
+
+After setting the view scale to 1.5, the minimum scale is: 1.50000
+After setting the view scale to 1.5, the current scale is: 1.50000
+
+After setting the view scale to 1.75, the minimum scale is: 1.75000
+After setting the view scale to 1.75, the current scale is: 1.75000
+
+After setting the view scale to 2, the minimum scale is: 2.00000
+After setting the view scale to 2, the current scale is: 2.00000
+
+After setting the view scale to 2.5, the minimum scale is: 2.50000
+After setting the view scale to 2.5, the current scale is: 2.50000
+
+After setting the view scale to 3, the minimum scale is: 3.00000
+After setting the view scale to 3, the current scale is: 3.00000
+
+After setting the view scale to 1, the minimum scale is: 1.00000
+After setting the view scale to 1, the current scale is: 1.00000
+
+This test verifies that changing view scale to zoom to a scale of S > 1 results in a minimum scale of S, rather than a value close to (but not exactly) S. This test requires WebKitTestRunner.

Added: trunk/LayoutTests/fast/viewport/ios/minimum-scale-after-changing-view-scale.html (0 => 237818)


--- trunk/LayoutTests/fast/viewport/ios/minimum-scale-after-changing-view-scale.html	                        (rev 0)
+++ trunk/LayoutTests/fast/viewport/ios/minimum-scale-after-changing-view-scale.html	2018-11-05 19:12:38 UTC (rev 237818)
@@ -0,0 +1,51 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ shouldIgnoreMetaViewport=true ] -->
+<html>
+<head>
+    <style>
+    body {
+        margin: 0;
+        width: 100%;
+        height: 100%;
+    }
+
+    #output {
+        width: 100%;
+        height: 100%;
+        overflow: scroll;
+    }
+    </style>
+    <script src=""
+    <script>
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+        testRunner.setIgnoresViewportScaleLimits(true);
+    }
+
+    addEventListener("load", async () => {
+        const appendOutput = message => {
+            output.appendChild(document.createTextNode(message));
+            output.appendChild(document.createElement("br"));
+        };
+
+        for (const scale of [1.15, 1.25, 1.5, 1.75, 2, 2.5, 3, 1]) {
+            await UIHelper.setViewScale(scale);
+            await Promise.all([UIHelper.ensureVisibleContentRectUpdate(), UIHelper.ensurePresentationUpdate()]);
+            appendOutput(`After setting the view scale to ${scale}, the minimum scale is: ${(await UIHelper.minimumZoomScale()).toFixed(5)}`);
+            appendOutput(`After setting the view scale to ${scale}, the current scale is: ${(await UIHelper.zoomScale()).toFixed(5)}`);
+            appendOutput("");
+        }
+
+        testRunner.notifyDone();
+    });
+    </script>
+</head>
+
+<body>
+    <pre id="output"></pre>
+    <p id="description">This test verifies that changing view scale to zoom to a scale of <code>S &gt; 1</code> results
+        in a minimum scale of <code>S</code>, rather than a value close to (but not exactly) <code>S</code>. This test
+        requires WebKitTestRunner.
+    </p>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (237817 => 237818)


--- trunk/Source/WebCore/ChangeLog	2018-11-05 19:01:30 UTC (rev 237817)
+++ trunk/Source/WebCore/ChangeLog	2018-11-05 19:12:38 UTC (rev 237818)
@@ -1,3 +1,40 @@
+2018-11-05  Wenson Hsieh  <[email protected]>
+
+        [iOS] Changing view scale sometimes does not zoom the page to the new initial scale when the page is zoomed in when ignoring meta viewport
+        https://bugs.webkit.org/show_bug.cgi?id=191226
+        <rdar://problem/45781765>
+
+        Reviewed by Tim Horton.
+
+        When `_setViewScale:` SPI is used to adjust the layout scale factor of the page, we multiply minimum, initial
+        and maximum scales by the given layout scale factor to adjust for a larger or smaller minimum layout size.
+        However, in the case where the layout size scale factor is greater than 1 and we're also forcing the viewport to
+        be scalable, we override the default minimum scale with 1 (i.e. `forceAlwaysUserScalableMinimumScale`). This
+        means that the might be off by a small margin due to rounding error when computing the content width and view
+        width (see: r237743).
+
+        This means that in the case where (1) the viewport is forced to be user-scalable, and (2) we're ignoring meta
+        viewport parameters, and (3) `_viewScale` exceeds 1, we may end up computing a slightly different minimum scale
+        than the default minimum scale multiplied by the layout size scale factor; subsequently, the page scale factor
+        will be slightly different from initial scale, such that we'll no longer zoom to the new initial scale when
+        changing view scale.
+
+        This patch adjusts `forceAlwaysUserScalableMinimumScale` and `forceAlwaysUserScalableMaximumScale` to take the
+        current layout scale factor into account when computing min and max scales when the viewport is forced to be
+        always scalable.
+
+        Test: fast/viewport/ios/minimum-scale-after-changing-view-scale.html
+
+        * page/ViewportConfiguration.cpp:
+        (WebCore::ViewportConfiguration::minimumScale const):
+        * page/ViewportConfiguration.h:
+        (WebCore::ViewportConfiguration::maximumScale const):
+        (WebCore::ViewportConfiguration::forceAlwaysUserScalableMaximumScale const):
+        (WebCore::ViewportConfiguration::forceAlwaysUserScalableMinimumScale const):
+
+        Turn these from constant values to const functions on ViewportConfiguration, which factor in the current
+        viewport layout size scale factor.
+
 2018-11-05  Dean Jackson  <[email protected]>
 
         Expose a constructor for PointerEvent from PlatformTouchEvent

Modified: trunk/Source/WebCore/page/ViewportConfiguration.cpp (237817 => 237818)


--- trunk/Source/WebCore/page/ViewportConfiguration.cpp	2018-11-05 19:01:30 UTC (rev 237817)
+++ trunk/Source/WebCore/page/ViewportConfiguration.cpp	2018-11-05 19:12:38 UTC (rev 237818)
@@ -266,7 +266,7 @@
     double minimumScale = m_configuration.minimumScale;
     
     if (m_forceAlwaysUserScalable)
-        minimumScale = std::min(minimumScale, forceAlwaysUserScalableMinimumScale);
+        minimumScale = std::min(minimumScale, forceAlwaysUserScalableMinimumScale());
 
     auto scaleForFittingContentIsApproximatelyEqualToMinimumScale = [] (double viewLength, double contentLength, double minimumScale) {
         if (contentLength <= 1 || viewLength <= 1)

Modified: trunk/Source/WebCore/page/ViewportConfiguration.h (237817 => 237818)


--- trunk/Source/WebCore/page/ViewportConfiguration.h	2018-11-05 19:01:30 UTC (rev 237817)
+++ trunk/Source/WebCore/page/ViewportConfiguration.h	2018-11-05 19:12:38 UTC (rev 237818)
@@ -38,9 +38,6 @@
 
 namespace WebCore {
 
-static const double forceAlwaysUserScalableMaximumScale = 5.0;
-static const double forceAlwaysUserScalableMinimumScale = 1.0;
-
 class ViewportConfiguration {
     WTF_MAKE_NONCOPYABLE(ViewportConfiguration); WTF_MAKE_FAST_ALLOCATED;
 public:
@@ -97,7 +94,7 @@
     WEBCORE_EXPORT double initialScale() const;
     WEBCORE_EXPORT double initialScaleIgnoringContentSize() const;
     WEBCORE_EXPORT double minimumScale() const;
-    double maximumScale() const { return m_forceAlwaysUserScalable ? forceAlwaysUserScalableMaximumScale : m_configuration.maximumScale; }
+    double maximumScale() const { return m_forceAlwaysUserScalable ? forceAlwaysUserScalableMaximumScale() : m_configuration.maximumScale; }
     double maximumScaleIgnoringAlwaysScalable() const { return m_configuration.maximumScale; }
     WEBCORE_EXPORT bool allowsUserScaling() const;
     WEBCORE_EXPORT bool allowsUserScalingIgnoringAlwaysScalable() const;
@@ -130,6 +127,18 @@
     bool shouldIgnoreVerticalScalingConstraints() const;
     bool shouldIgnoreHorizontalScalingConstraints() const;
 
+    constexpr double forceAlwaysUserScalableMaximumScale() const
+    {
+        const double forceAlwaysUserScalableMaximumScaleIgnoringLayoutScaleFactor = 5;
+        return forceAlwaysUserScalableMaximumScaleIgnoringLayoutScaleFactor * m_layoutSizeScaleFactor;
+    }
+
+    constexpr double forceAlwaysUserScalableMinimumScale() const
+    {
+        const double forceAlwaysUserScalableMinimumScaleIgnoringLayoutScaleFactor = 1;
+        return forceAlwaysUserScalableMinimumScaleIgnoringLayoutScaleFactor * m_layoutSizeScaleFactor;
+    }
+
     void updateMinimumLayoutSize();
 
     Parameters m_configuration;

Modified: trunk/Tools/ChangeLog (237817 => 237818)


--- trunk/Tools/ChangeLog	2018-11-05 19:01:30 UTC (rev 237817)
+++ trunk/Tools/ChangeLog	2018-11-05 19:12:38 UTC (rev 237818)
@@ -1,3 +1,17 @@
+2018-11-05  Wenson Hsieh  <[email protected]>
+
+        [iOS] Changing view scale sometimes does not zoom the page to the new initial scale when the page is zoomed in when ignoring meta viewport
+        https://bugs.webkit.org/show_bug.cgi?id=191226
+        <rdar://problem/45781765>
+
+        Reviewed by Tim Horton.
+
+        Add a missing check for `shouldIgnoreMetaViewport` when comparing TestOptions, to ensure that "ignore meta
+        viewport" state doesn't unexpectedly persist after running a layout test that ignores meta viewport.
+
+        * WebKitTestRunner/TestOptions.h:
+        (WTR::TestOptions::hasSameInitializationOptions const):
+
 2018-11-05  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r237784 and r237788.

Modified: trunk/Tools/WebKitTestRunner/TestOptions.h (237817 => 237818)


--- trunk/Tools/WebKitTestRunner/TestOptions.h	2018-11-05 19:01:30 UTC (rev 237817)
+++ trunk/Tools/WebKitTestRunner/TestOptions.h	2018-11-05 19:12:38 UTC (rev 237818)
@@ -102,7 +102,8 @@
             || punchOutWhiteBackgroundsInDarkMode != options.punchOutWhiteBackgroundsInDarkMode
             || jscOptions != options.jscOptions
             || runSingly != options.runSingly
-            || checkForWorldLeaks != options.checkForWorldLeaks)
+            || checkForWorldLeaks != options.checkForWorldLeaks
+            || shouldIgnoreMetaViewport != options.shouldIgnoreMetaViewport)
             return false;
 
         if (experimentalFeatures != options.experimentalFeatures)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to