⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 248292 in webkit


Ignore:
Timestamp:
Aug 6, 2019, 7:49:25 AM (7 years ago)
Author:
Wenson Hsieh
Message:

[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.
Location:
trunk
Files:
6 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r248289 r248292  
     12019-08-06  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iPadOS] Unable to increase zoom level on Google using the Aa menu
     4        https://bugs.webkit.org/show_bug.cgi?id=200453
     5        <rdar://problem/52278579>
     6
     7        Reviewed by Tim Horton.
     8
     9        Adds a couple of layout tests (with device-specific expectations) to verify that the two scenarios targeted by
     10        this change are fixed.
     11
     12        * fast/viewport/ios/non-responsive-viewport-after-changing-view-scale-expected.txt: Added.
     13        * fast/viewport/ios/non-responsive-viewport-after-changing-view-scale.html: Added.
     14
     15        Verifies that, for a page with no viewport meta tag (where we fall back to a fixed 980px viewport on iPhone),
     16        changing view scale still changes page scale and window size.
     17
     18        * fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale-expected.txt: Added.
     19        * fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale.html: Added.
     20
     21        Verifies that, for a page with a responsive meta viewport tag containing a fixed-width element that forces a
     22        minimum width for the page, setting the view scale such that the page scrolls horizontally (2.5) doesn't result
     23        in the initial scale being adjusted back to the maximum scale that would accomodate the full contents of the
     24        page (2).
     25
     26        * platform/ipad/fast/viewport/ios/non-responsive-viewport-after-changing-view-scale-expected.txt: Added.
     27        * platform/ipad/fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale-expected.txt: Added.
     28
    1292019-08-05  Devin Rousso  <drousso@apple.com>
    230
  • trunk/Source/WebCore/ChangeLog

    r248290 r248292  
     12019-08-06  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iPadOS] Unable to increase zoom level on Google using the Aa menu
     4        https://bugs.webkit.org/show_bug.cgi?id=200453
     5        <rdar://problem/52278579>
     6
     7        Reviewed by Tim Horton.
     8
     9        Makes a couple of minor adjustments to how layout size scale factor is handled in ViewportConfiguration, to
     10        address some scenarios in which adjusting WKWebView's _viewScale does not have any apparent effect on the page.
     11        See changes below for more detail.
     12
     13        Tests: fast/viewport/ios/non-responsive-viewport-after-changing-view-scale.html
     14               fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale.html
     15
     16        * page/ViewportConfiguration.cpp:
     17        (WebCore::ViewportConfiguration::initialScaleFromSize const):
     18
     19        When the page is either zoomed in or zoomed out using _viewScale, let the specified initial scale take
     20        precedence over the scale computed by fitting the content width to the view width, or the scale computed by
     21        fitting the content height to the view height.
     22
     23        This avoids a scenario in which nothing happens when increasing view scale in a responsively designed web page
     24        that has a fixed minimum width. Before this change, when computing the initial scale at a view scale that would
     25        not allow the entire content width of the page to fit within the viewport, the new initial scale would remain
     26        unchanged if the initial scale in the meta viewport is not also set to 1, because a new initial scale would be
     27        computed in ViewportConfiguration::initialScaleFromSize to accomodate for the entire content width.
     28
     29        Our new behavior allows us to zoom into the page, even if doing so would cause horizontal scrolling.
     30
     31        (WebCore::ViewportConfiguration::updateConfiguration):
     32
     33        When the page is either zoomed in or zoomed out using _viewScale and the default viewport configuration has a
     34        fixed width (e.g. on iPhone), then adjust the width of the default viewport configuration to account for the
     35        _viewScale. For example, the default width of a viewport-less web page is 980px on iPhone; at a view scale of 2,
     36        this would become 490px instead, and at 0.5 view scale, it would become 1960px.
     37
     38        This ensures that on iPhone, for web pages without a meta viewport, changing the view scale still changes the
     39        layout and initial scale of the web page.
     40
     41        * page/ViewportConfiguration.h:
     42        (WebCore::ViewportConfiguration::layoutSizeIsExplicitlyScaled const):
     43
    1442019-08-05  Zalan Bujtas  <zalan@apple.com>
    245
  • trunk/Source/WebCore/page/ViewportConfiguration.cpp

    r244849 r248292  
    247247    ASSERT(!constraintsAreAllRelative(m_configuration));
    248248
     249    auto clampToMinimumAndMaximumScales = [&] (double initialScale) {
     250        return clampTo<double>(initialScale, shouldIgnoreScalingConstraints ? m_defaultConfiguration.minimumScale : m_configuration.minimumScale, m_configuration.maximumScale);
     251    };
     252
     253    if (layoutSizeIsExplicitlyScaled()) {
     254        if (m_configuration.initialScaleIsSet)
     255            return clampToMinimumAndMaximumScales(m_configuration.initialScale);
     256
     257        if (m_configuration.width > 0)
     258            return clampToMinimumAndMaximumScales(m_viewLayoutSize.width() / m_configuration.width);
     259    }
     260
    249261    // If the document has specified its own initial scale, use it regardless.
    250262    // This is guaranteed to be sanity checked already, so no need for MIN/MAX.
     
    262274        initialScale = m_viewLayoutSize.height() / height;
    263275
    264     return std::min(std::max(initialScale, shouldIgnoreScalingConstraints ? m_defaultConfiguration.minimumScale : m_configuration.minimumScale), m_configuration.maximumScale);
     276    return clampToMinimumAndMaximumScales(initialScale);
    265277}
    266278
     
    459471    bool viewportArgumentsOverridesHeight;
    460472
     473    auto effectiveLayoutScale = effectiveLayoutSizeScaleFactor();
     474
     475    if (layoutSizeIsExplicitlyScaled())
     476        m_configuration.width /= effectiveLayoutScale;
     477
    461478    applyViewportArgument(m_configuration.minimumScale, m_viewportArguments.minZoom, minimumViewportArgumentsScaleFactor, maximumViewportArgumentsScaleFactor);
    462479    applyViewportArgument(m_configuration.maximumScale, m_viewportArguments.maxZoom, m_configuration.minimumScale, maximumViewportArgumentsScaleFactor);
     
    487504    m_configuration.avoidsUnsafeArea = m_viewportArguments.viewportFit != ViewportFit::Cover;
    488505    m_configuration.initialScaleIgnoringLayoutScaleFactor = m_configuration.initialScale;
    489     float effectiveLayoutScale = effectiveLayoutSizeScaleFactor();
    490506    m_configuration.initialScale *= effectiveLayoutScale;
    491507    m_configuration.minimumScale *= effectiveLayoutScale;
  • trunk/Source/WebCore/page/ViewportConfiguration.h

    r244944 r248292  
    157157    bool canOverrideConfigurationParameters() const;
    158158
     159    constexpr bool layoutSizeIsExplicitlyScaled() const
     160    {
     161        return m_layoutSizeScaleFactor != 1;
     162    }
     163
    159164    constexpr double forceAlwaysUserScalableMaximumScale() const
    160165    {
Note: See TracChangeset for help on using the changeset viewer.