Title: [248614] branches/safari-608-branch
Revision
248614
Author
alanc...@apple.com
Date
2019-08-13 13:00:54 -0700 (Tue, 13 Aug 2019)

Log Message

Cherry-pick r248292. rdar://problem/54236220

    [iPadOS] Unable to increase zoom level on Google using the Aa menu
    https://bugs.webkit.org/show_bug.cgi?id=200453
    <rdar://problem/52278579>

    Reviewed by Tim Horton.

    Source/WebCore:

    Makes a couple of minor adjustments to how layout size scale factor is handled in ViewportConfiguration, to
    address some scenarios in which adjusting WKWebView's _viewScale does not have any apparent effect on the page.
    See changes below for more detail.

    Tests: fast/viewport/ios/non-responsive-viewport-after-changing-view-scale.html
           fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale.html

    * page/ViewportConfiguration.cpp:
    (WebCore::ViewportConfiguration::initialScaleFromSize const):

    When the page is either zoomed in or zoomed out using _viewScale, let the specified initial scale take
    precedence over the scale computed by fitting the content width to the view width, or the scale computed by
    fitting the content height to the view height.

    This avoids a scenario in which nothing happens when increasing view scale in a responsively designed web page
    that has a fixed minimum width. Before this change, when computing the initial scale at a view scale that would
    not allow the entire content width of the page to fit within the viewport, the new initial scale would remain
    unchanged if the initial scale in the meta viewport is not also set to 1, because a new initial scale would be
    computed in ViewportConfiguration::initialScaleFromSize to accomodate for the entire content width.

    Our new behavior allows us to zoom into the page, even if doing so would cause horizontal scrolling.

    (WebCore::ViewportConfiguration::updateConfiguration):

    When the page is either zoomed in or zoomed out using _viewScale and the default viewport configuration has a
    fixed width (e.g. on iPhone), then adjust the width of the default viewport configuration to account for the
    _viewScale. For example, the default width of a viewport-less web page is 980px on iPhone; at a view scale of 2,
    this would become 490px instead, and at 0.5 view scale, it would become 1960px.

    This ensures that on iPhone, for web pages without a meta viewport, changing the view scale still changes the
    layout and initial scale of the web page.

    * page/ViewportConfiguration.h:
    (WebCore::ViewportConfiguration::layoutSizeIsExplicitlyScaled const):

    LayoutTests:

    Adds a couple of layout tests (with device-specific expectations) to verify that the two scenarios targeted by
    this change are fixed.

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

    Verifies that, for a page with no viewport meta tag (where we fall back to a fixed 980px viewport on iPhone),
    changing view scale still changes page scale and window size.

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

    Verifies that, for a page with a responsive meta viewport tag containing a fixed-width element that forces a
    minimum width for the page, setting the view scale such that the page scrolls horizontally (2.5) doesn't result
    in the initial scale being adjusted back to the maximum scale that would accomodate the full contents of the
    page (2).

    * platform/ipad/fast/viewport/ios/non-responsive-viewport-after-changing-view-scale-expected.txt: Added.
    * platform/ipad/fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale-expected.txt: Added.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248292 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Diff

Modified: branches/safari-608-branch/LayoutTests/ChangeLog (248613 => 248614)


--- branches/safari-608-branch/LayoutTests/ChangeLog	2019-08-13 20:00:50 UTC (rev 248613)
+++ branches/safari-608-branch/LayoutTests/ChangeLog	2019-08-13 20:00:54 UTC (rev 248614)
@@ -1,5 +1,105 @@
 2019-08-13  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r248292. rdar://problem/54236220
+
+    [iPadOS] Unable to increase zoom level on Google using the Aa menu
+    https://bugs.webkit.org/show_bug.cgi?id=200453
+    <rdar://problem/52278579>
+    
+    Reviewed by Tim Horton.
+    
+    Source/WebCore:
+    
+    Makes a couple of minor adjustments to how layout size scale factor is handled in ViewportConfiguration, to
+    address some scenarios in which adjusting WKWebView's _viewScale does not have any apparent effect on the page.
+    See changes below for more detail.
+    
+    Tests: fast/viewport/ios/non-responsive-viewport-after-changing-view-scale.html
+           fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale.html
+    
+    * page/ViewportConfiguration.cpp:
+    (WebCore::ViewportConfiguration::initialScaleFromSize const):
+    
+    When the page is either zoomed in or zoomed out using _viewScale, let the specified initial scale take
+    precedence over the scale computed by fitting the content width to the view width, or the scale computed by
+    fitting the content height to the view height.
+    
+    This avoids a scenario in which nothing happens when increasing view scale in a responsively designed web page
+    that has a fixed minimum width. Before this change, when computing the initial scale at a view scale that would
+    not allow the entire content width of the page to fit within the viewport, the new initial scale would remain
+    unchanged if the initial scale in the meta viewport is not also set to 1, because a new initial scale would be
+    computed in ViewportConfiguration::initialScaleFromSize to accomodate for the entire content width.
+    
+    Our new behavior allows us to zoom into the page, even if doing so would cause horizontal scrolling.
+    
+    (WebCore::ViewportConfiguration::updateConfiguration):
+    
+    When the page is either zoomed in or zoomed out using _viewScale and the default viewport configuration has a
+    fixed width (e.g. on iPhone), then adjust the width of the default viewport configuration to account for the
+    _viewScale. For example, the default width of a viewport-less web page is 980px on iPhone; at a view scale of 2,
+    this would become 490px instead, and at 0.5 view scale, it would become 1960px.
+    
+    This ensures that on iPhone, for web pages without a meta viewport, changing the view scale still changes the
+    layout and initial scale of the web page.
+    
+    * page/ViewportConfiguration.h:
+    (WebCore::ViewportConfiguration::layoutSizeIsExplicitlyScaled const):
+    
+    LayoutTests:
+    
+    Adds a couple of layout tests (with device-specific expectations) to verify that the two scenarios targeted by
+    this change are fixed.
+    
+    * fast/viewport/ios/non-responsive-viewport-after-changing-view-scale-expected.txt: Added.
+    * fast/viewport/ios/non-responsive-viewport-after-changing-view-scale.html: Added.
+    
+    Verifies that, for a page with no viewport meta tag (where we fall back to a fixed 980px viewport on iPhone),
+    changing view scale still changes page scale and window size.
+    
+    * fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale-expected.txt: Added.
+    * fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale.html: Added.
+    
+    Verifies that, for a page with a responsive meta viewport tag containing a fixed-width element that forces a
+    minimum width for the page, setting the view scale such that the page scrolls horizontally (2.5) doesn't result
+    in the initial scale being adjusted back to the maximum scale that would accomodate the full contents of the
+    page (2).
+    
+    * platform/ipad/fast/viewport/ios/non-responsive-viewport-after-changing-view-scale-expected.txt: Added.
+    * platform/ipad/fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale-expected.txt: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248292 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-08-06  Wenson Hsieh  <wenson_hs...@apple.com>
+
+            [iPadOS] Unable to increase zoom level on Google using the Aa menu
+            https://bugs.webkit.org/show_bug.cgi?id=200453
+            <rdar://problem/52278579>
+
+            Reviewed by Tim Horton.
+
+            Adds a couple of layout tests (with device-specific expectations) to verify that the two scenarios targeted by
+            this change are fixed.
+
+            * fast/viewport/ios/non-responsive-viewport-after-changing-view-scale-expected.txt: Added.
+            * fast/viewport/ios/non-responsive-viewport-after-changing-view-scale.html: Added.
+
+            Verifies that, for a page with no viewport meta tag (where we fall back to a fixed 980px viewport on iPhone),
+            changing view scale still changes page scale and window size.
+
+            * fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale-expected.txt: Added.
+            * fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale.html: Added.
+
+            Verifies that, for a page with a responsive meta viewport tag containing a fixed-width element that forces a
+            minimum width for the page, setting the view scale such that the page scrolls horizontally (2.5) doesn't result
+            in the initial scale being adjusted back to the maximum scale that would accomodate the full contents of the
+            page (2).
+
+            * platform/ipad/fast/viewport/ios/non-responsive-viewport-after-changing-view-scale-expected.txt: Added.
+            * platform/ipad/fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale-expected.txt: Added.
+
+2019-08-13  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r248189. rdar://problem/54237682
 
     [ Mac ] Layout Test accessibility/mac/press-not-work-for-disabled-menu-list.html is a flaky failure

Added: branches/safari-608-branch/LayoutTests/fast/viewport/ios/non-responsive-viewport-after-changing-view-scale-expected.txt (0 => 248614)


--- branches/safari-608-branch/LayoutTests/fast/viewport/ios/non-responsive-viewport-after-changing-view-scale-expected.txt	                        (rev 0)
+++ branches/safari-608-branch/LayoutTests/fast/viewport/ios/non-responsive-viewport-after-changing-view-scale-expected.txt	2019-08-13 20:00:54 UTC (rev 248614)
@@ -0,0 +1,17 @@
+setViewScale(1.00)
+window size: [980, 1678]
+zoom scale: 0.33
+
+setViewScale(0.50)
+window size: [1960, 3357]
+zoom scale: 0.16
+
+setViewScale(2.00)
+window size: [490, 839]
+zoom scale: 0.65
+
+setViewScale(1.00)
+window size: [980, 1678]
+zoom scale: 0.33
+
+

Added: branches/safari-608-branch/LayoutTests/fast/viewport/ios/non-responsive-viewport-after-changing-view-scale.html (0 => 248614)


--- branches/safari-608-branch/LayoutTests/fast/viewport/ios/non-responsive-viewport-after-changing-view-scale.html	                        (rev 0)
+++ branches/safari-608-branch/LayoutTests/fast/viewport/ios/non-responsive-viewport-after-changing-view-scale.html	2019-08-13 20:00:54 UTC (rev 248614)
@@ -0,0 +1,54 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<html>
+<head>
+    <style>
+        #output {
+            width: 100%;
+            height: 100%;
+            overflow: scroll;
+        }
+
+        #bar {
+            width: 980px;
+            height: 100px;
+            background: linear-gradient(to right, red 0%, green 50%, blue 100%);
+        }
+
+        body {
+            margin: 0;
+            width: 100%;
+            height: 100%;
+        }
+    </style>
+    <script src=""
+    <script>
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+    }
+
+    async function runTest() {
+        const appendOutput = message => {
+            output.appendChild(document.createTextNode(message));
+            output.appendChild(document.createElement("br"));
+        };
+
+        for (const targetScale of [1, 0.5, 2, 1]) {
+            await UIHelper.setViewScale(targetScale);
+            await UIHelper.ensurePresentationUpdate();
+            appendOutput(`setViewScale(${targetScale.toFixed(2)})`);
+            appendOutput(`window size: [${innerWidth}, ${innerHeight}]`);
+            appendOutput(`zoom scale: ${(await UIHelper.zoomScale()).toFixed(2)}`);
+            appendOutput("");
+        }
+
+        testRunner.notifyDone();
+    }
+    </script>
+</head>
+
+<body _onload_="runTest()">
+    <div id="bar"></div>
+    <pre id="output"></pre>
+</body>
+</html>

Added: branches/safari-608-branch/LayoutTests/fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale-expected.txt (0 => 248614)


--- branches/safari-608-branch/LayoutTests/fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale-expected.txt	                        (rev 0)
+++ branches/safari-608-branch/LayoutTests/fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale-expected.txt	2019-08-13 20:00:54 UTC (rev 248614)
@@ -0,0 +1,17 @@
+setViewScale(1.00)
+window size: [320, 548]
+zoom scale: 1.00
+
+setViewScale(2.00)
+window size: [160, 274]
+zoom scale: 2.00
+
+setViewScale(2.50)
+window size: [128, 219]
+zoom scale: 2.50
+
+setViewScale(1.00)
+window size: [320, 548]
+zoom scale: 1.00
+
+

Added: branches/safari-608-branch/LayoutTests/fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale.html (0 => 248614)


--- branches/safari-608-branch/LayoutTests/fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale.html	                        (rev 0)
+++ branches/safari-608-branch/LayoutTests/fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale.html	2019-08-13 20:00:54 UTC (rev 248614)
@@ -0,0 +1,55 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<html>
+<head>
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <style>
+        #output {
+            width: 100%;
+            height: 100%;
+            overflow: scroll;
+        }
+
+        #bar {
+            width: 160px;
+            height: 40px;
+            background: linear-gradient(to right, red 0%, green 50%, blue 100%);
+        }
+
+        body {
+            margin: 0;
+            width: 100%;
+            height: 100%;
+        }
+    </style>
+    <script src=""
+    <script>
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+    }
+
+    async function runTest() {
+        const appendOutput = message => {
+            output.appendChild(document.createTextNode(message));
+            output.appendChild(document.createElement("br"));
+        };
+
+        for (const targetScale of [1, 2, 2.5, 1]) {
+            await UIHelper.setViewScale(targetScale);
+            await UIHelper.ensurePresentationUpdate();
+            appendOutput(`setViewScale(${targetScale.toFixed(2)})`);
+            appendOutput(`window size: [${innerWidth}, ${innerHeight}]`);
+            appendOutput(`zoom scale: ${(await UIHelper.zoomScale()).toFixed(2)}`);
+            appendOutput("");
+        }
+
+        testRunner.notifyDone();
+    }
+    </script>
+</head>
+
+<body _onload_="runTest()">
+    <div id="bar"></div>
+    <pre id="output"></pre>
+</body>
+</html>

Added: branches/safari-608-branch/LayoutTests/platform/ipad/fast/viewport/ios/non-responsive-viewport-after-changing-view-scale-expected.txt (0 => 248614)


--- branches/safari-608-branch/LayoutTests/platform/ipad/fast/viewport/ios/non-responsive-viewport-after-changing-view-scale-expected.txt	                        (rev 0)
+++ branches/safari-608-branch/LayoutTests/platform/ipad/fast/viewport/ios/non-responsive-viewport-after-changing-view-scale-expected.txt	2019-08-13 20:00:54 UTC (rev 248614)
@@ -0,0 +1,17 @@
+setViewScale(1.00)
+window size: [980, 1281]
+zoom scale: 0.78
+
+setViewScale(0.50)
+window size: [1960, 2562]
+zoom scale: 0.39
+
+setViewScale(2.00)
+window size: [490, 641]
+zoom scale: 1.57
+
+setViewScale(1.00)
+window size: [980, 1281]
+zoom scale: 0.78
+
+

Added: branches/safari-608-branch/LayoutTests/platform/ipad/fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale-expected.txt (0 => 248614)


--- branches/safari-608-branch/LayoutTests/platform/ipad/fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale-expected.txt	                        (rev 0)
+++ branches/safari-608-branch/LayoutTests/platform/ipad/fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale-expected.txt	2019-08-13 20:00:54 UTC (rev 248614)
@@ -0,0 +1,17 @@
+setViewScale(1.00)
+window size: [768, 1004]
+zoom scale: 1.00
+
+setViewScale(2.00)
+window size: [384, 502]
+zoom scale: 2.00
+
+setViewScale(2.50)
+window size: [307, 401]
+zoom scale: 2.50
+
+setViewScale(1.00)
+window size: [768, 1004]
+zoom scale: 1.00
+
+

Modified: branches/safari-608-branch/Source/WebCore/ChangeLog (248613 => 248614)


--- branches/safari-608-branch/Source/WebCore/ChangeLog	2019-08-13 20:00:50 UTC (rev 248613)
+++ branches/safari-608-branch/Source/WebCore/ChangeLog	2019-08-13 20:00:54 UTC (rev 248614)
@@ -1,5 +1,120 @@
 2019-08-13  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r248292. rdar://problem/54236220
+
+    [iPadOS] Unable to increase zoom level on Google using the Aa menu
+    https://bugs.webkit.org/show_bug.cgi?id=200453
+    <rdar://problem/52278579>
+    
+    Reviewed by Tim Horton.
+    
+    Source/WebCore:
+    
+    Makes a couple of minor adjustments to how layout size scale factor is handled in ViewportConfiguration, to
+    address some scenarios in which adjusting WKWebView's _viewScale does not have any apparent effect on the page.
+    See changes below for more detail.
+    
+    Tests: fast/viewport/ios/non-responsive-viewport-after-changing-view-scale.html
+           fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale.html
+    
+    * page/ViewportConfiguration.cpp:
+    (WebCore::ViewportConfiguration::initialScaleFromSize const):
+    
+    When the page is either zoomed in or zoomed out using _viewScale, let the specified initial scale take
+    precedence over the scale computed by fitting the content width to the view width, or the scale computed by
+    fitting the content height to the view height.
+    
+    This avoids a scenario in which nothing happens when increasing view scale in a responsively designed web page
+    that has a fixed minimum width. Before this change, when computing the initial scale at a view scale that would
+    not allow the entire content width of the page to fit within the viewport, the new initial scale would remain
+    unchanged if the initial scale in the meta viewport is not also set to 1, because a new initial scale would be
+    computed in ViewportConfiguration::initialScaleFromSize to accomodate for the entire content width.
+    
+    Our new behavior allows us to zoom into the page, even if doing so would cause horizontal scrolling.
+    
+    (WebCore::ViewportConfiguration::updateConfiguration):
+    
+    When the page is either zoomed in or zoomed out using _viewScale and the default viewport configuration has a
+    fixed width (e.g. on iPhone), then adjust the width of the default viewport configuration to account for the
+    _viewScale. For example, the default width of a viewport-less web page is 980px on iPhone; at a view scale of 2,
+    this would become 490px instead, and at 0.5 view scale, it would become 1960px.
+    
+    This ensures that on iPhone, for web pages without a meta viewport, changing the view scale still changes the
+    layout and initial scale of the web page.
+    
+    * page/ViewportConfiguration.h:
+    (WebCore::ViewportConfiguration::layoutSizeIsExplicitlyScaled const):
+    
+    LayoutTests:
+    
+    Adds a couple of layout tests (with device-specific expectations) to verify that the two scenarios targeted by
+    this change are fixed.
+    
+    * fast/viewport/ios/non-responsive-viewport-after-changing-view-scale-expected.txt: Added.
+    * fast/viewport/ios/non-responsive-viewport-after-changing-view-scale.html: Added.
+    
+    Verifies that, for a page with no viewport meta tag (where we fall back to a fixed 980px viewport on iPhone),
+    changing view scale still changes page scale and window size.
+    
+    * fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale-expected.txt: Added.
+    * fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale.html: Added.
+    
+    Verifies that, for a page with a responsive meta viewport tag containing a fixed-width element that forces a
+    minimum width for the page, setting the view scale such that the page scrolls horizontally (2.5) doesn't result
+    in the initial scale being adjusted back to the maximum scale that would accomodate the full contents of the
+    page (2).
+    
+    * platform/ipad/fast/viewport/ios/non-responsive-viewport-after-changing-view-scale-expected.txt: Added.
+    * platform/ipad/fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale-expected.txt: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248292 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-08-06  Wenson Hsieh  <wenson_hs...@apple.com>
+
+            [iPadOS] Unable to increase zoom level on Google using the Aa menu
+            https://bugs.webkit.org/show_bug.cgi?id=200453
+            <rdar://problem/52278579>
+
+            Reviewed by Tim Horton.
+
+            Makes a couple of minor adjustments to how layout size scale factor is handled in ViewportConfiguration, to
+            address some scenarios in which adjusting WKWebView's _viewScale does not have any apparent effect on the page.
+            See changes below for more detail.
+
+            Tests: fast/viewport/ios/non-responsive-viewport-after-changing-view-scale.html
+                   fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale.html
+
+            * page/ViewportConfiguration.cpp:
+            (WebCore::ViewportConfiguration::initialScaleFromSize const):
+
+            When the page is either zoomed in or zoomed out using _viewScale, let the specified initial scale take
+            precedence over the scale computed by fitting the content width to the view width, or the scale computed by
+            fitting the content height to the view height.
+
+            This avoids a scenario in which nothing happens when increasing view scale in a responsively designed web page
+            that has a fixed minimum width. Before this change, when computing the initial scale at a view scale that would
+            not allow the entire content width of the page to fit within the viewport, the new initial scale would remain
+            unchanged if the initial scale in the meta viewport is not also set to 1, because a new initial scale would be
+            computed in ViewportConfiguration::initialScaleFromSize to accomodate for the entire content width.
+
+            Our new behavior allows us to zoom into the page, even if doing so would cause horizontal scrolling.
+
+            (WebCore::ViewportConfiguration::updateConfiguration):
+
+            When the page is either zoomed in or zoomed out using _viewScale and the default viewport configuration has a
+            fixed width (e.g. on iPhone), then adjust the width of the default viewport configuration to account for the
+            _viewScale. For example, the default width of a viewport-less web page is 980px on iPhone; at a view scale of 2,
+            this would become 490px instead, and at 0.5 view scale, it would become 1960px.
+
+            This ensures that on iPhone, for web pages without a meta viewport, changing the view scale still changes the
+            layout and initial scale of the web page.
+
+            * page/ViewportConfiguration.h:
+            (WebCore::ViewportConfiguration::layoutSizeIsExplicitlyScaled const):
+
+2019-08-13  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r248188. rdar://problem/54237663
 
     Add accessibility object method to determine whether an element is inside a table cell. Needed for iOS accessibility client.

Modified: branches/safari-608-branch/Source/WebCore/page/ViewportConfiguration.cpp (248613 => 248614)


--- branches/safari-608-branch/Source/WebCore/page/ViewportConfiguration.cpp	2019-08-13 20:00:50 UTC (rev 248613)
+++ branches/safari-608-branch/Source/WebCore/page/ViewportConfiguration.cpp	2019-08-13 20:00:54 UTC (rev 248614)
@@ -246,6 +246,18 @@
 {
     ASSERT(!constraintsAreAllRelative(m_configuration));
 
+    auto clampToMinimumAndMaximumScales = [&] (double initialScale) {
+        return clampTo<double>(initialScale, shouldIgnoreScalingConstraints ? m_defaultConfiguration.minimumScale : m_configuration.minimumScale, m_configuration.maximumScale);
+    };
+
+    if (layoutSizeIsExplicitlyScaled()) {
+        if (m_configuration.initialScaleIsSet)
+            return clampToMinimumAndMaximumScales(m_configuration.initialScale);
+
+        if (m_configuration.width > 0)
+            return clampToMinimumAndMaximumScales(m_viewLayoutSize.width() / m_configuration.width);
+    }
+
     // If the document has specified its own initial scale, use it regardless.
     // This is guaranteed to be sanity checked already, so no need for MIN/MAX.
     if (m_configuration.initialScaleIsSet && !shouldIgnoreScalingConstraints)
@@ -261,7 +273,7 @@
     if (height > 0 && height * initialScale < m_viewLayoutSize.height() && !shouldIgnoreHorizontalScalingConstraints())
         initialScale = m_viewLayoutSize.height() / height;
 
-    return std::min(std::max(initialScale, shouldIgnoreScalingConstraints ? m_defaultConfiguration.minimumScale : m_configuration.minimumScale), m_configuration.maximumScale);
+    return clampToMinimumAndMaximumScales(initialScale);
 }
 
 double ViewportConfiguration::initialScale() const
@@ -458,6 +470,11 @@
     bool viewportArgumentsOverridesWidth;
     bool viewportArgumentsOverridesHeight;
 
+    auto effectiveLayoutScale = effectiveLayoutSizeScaleFactor();
+
+    if (layoutSizeIsExplicitlyScaled())
+        m_configuration.width /= effectiveLayoutScale;
+
     applyViewportArgument(m_configuration.minimumScale, m_viewportArguments.minZoom, minimumViewportArgumentsScaleFactor, maximumViewportArgumentsScaleFactor);
     applyViewportArgument(m_configuration.maximumScale, m_viewportArguments.maxZoom, m_configuration.minimumScale, maximumViewportArgumentsScaleFactor);
     applyViewportArgument(m_configuration.initialScale, viewportArgumentsOverridesInitialScale, m_viewportArguments.zoom, m_configuration.minimumScale, m_configuration.maximumScale);
@@ -486,7 +503,6 @@
 
     m_configuration.avoidsUnsafeArea = m_viewportArguments.viewportFit != ViewportFit::Cover;
     m_configuration.initialScaleIgnoringLayoutScaleFactor = m_configuration.initialScale;
-    float effectiveLayoutScale = effectiveLayoutSizeScaleFactor();
     m_configuration.initialScale *= effectiveLayoutScale;
     m_configuration.minimumScale *= effectiveLayoutScale;
     m_configuration.maximumScale *= effectiveLayoutScale;

Modified: branches/safari-608-branch/Source/WebCore/page/ViewportConfiguration.h (248613 => 248614)


--- branches/safari-608-branch/Source/WebCore/page/ViewportConfiguration.h	2019-08-13 20:00:50 UTC (rev 248613)
+++ branches/safari-608-branch/Source/WebCore/page/ViewportConfiguration.h	2019-08-13 20:00:54 UTC (rev 248614)
@@ -156,6 +156,11 @@
     void updateDefaultConfiguration();
     bool canOverrideConfigurationParameters() const;
 
+    constexpr bool layoutSizeIsExplicitlyScaled() const
+    {
+        return m_layoutSizeScaleFactor != 1;
+    }
+
     constexpr double forceAlwaysUserScalableMaximumScale() const
     {
         const double forceAlwaysUserScalableMaximumScaleIgnoringLayoutScaleFactor = 5;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to