[iPadOS] Unable to increase zoom level on Google using the Aa menu
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Aug 2019 14:49:25 +0000 (14:49 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Aug 2019 14:49:25 +0000 (14:49 +0000)
commit4589b44d77bb9b92b0046fe616ab4f0567445658
treeb34091fc31260eed26060c22f0fdb7674826ff45
parentc9bd496c6c55ec73767b8d647ccfd4a3086667df
[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
LayoutTests/ChangeLog
LayoutTests/fast/viewport/ios/non-responsive-viewport-after-changing-view-scale-expected.txt [new file with mode: 0644]
LayoutTests/fast/viewport/ios/non-responsive-viewport-after-changing-view-scale.html [new file with mode: 0644]
LayoutTests/fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale-expected.txt [new file with mode: 0644]
LayoutTests/fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale.html [new file with mode: 0644]
LayoutTests/platform/ipad/fast/viewport/ios/non-responsive-viewport-after-changing-view-scale-expected.txt [new file with mode: 0644]
LayoutTests/platform/ipad/fast/viewport/ios/responsive-viewport-with-minimum-width-after-changing-view-scale-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/ViewportConfiguration.cpp
Source/WebCore/page/ViewportConfiguration.h