Changing view scale should zoom to initial scale if the page is already at initial...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Oct 2018 17:36:31 +0000 (17:36 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Oct 2018 17:36:31 +0000 (17:36 +0000)
commit10570df1b5b2803633d0db69cb3989ef2283e2ba
treeb347ea2c88e07e3ff56dba17327e2bf89c61b884
parenta9be7a21d51bb5b8917e3f15069a03382a705f3a
Changing view scale should zoom to initial scale if the page is already at initial scale
https://bugs.webkit.org/show_bug.cgi?id=190570
<rdar://problem/45261877>

Reviewed by Tim Horton.

Source/WebCore:

Add a getter for ViewportConfiguration's layout size scale factor.
See Source/WebKit/ChangeLog for more details.

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

Source/WebKit:

r237087 added support for changing the view scale on iOS, by making it possible to let the minimum layout size
be a factor of the view size; this allows internal clients to change page zoom levels on iOS. Currently,
changing the page zoom level automatically zooms to the new initial scale only if the user has not manually
scaled the page before, even if the page is already at initial scale (e.g. after the user double taps to zoom on
a small element, and double taps again to zoom back out to initial scale).

This patch makes some minor adjustments to automatically zoom to the new initial scale after changing the view
scale, as long as the page was at initial scale when changing zoom levels.

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

* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::areEssentiallyEqualAsFloat):

Move this function further up in the file, so that we can use it in `setViewportConfigurationViewLayoutSize`.

(WebKit::WebPage::setViewportConfigurationViewLayoutSize):

If the page is near initial scale and the zoom level changes, zoom to the new initial scale.

(WebKit::WebPage::viewportConfigurationChanged):

Make this take a new enum argument that determines whether we want to zoom to initial scale as a result of the
viewport configuration change (`No` by default).

LayoutTests:

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

Add a new layout test to verify that:
1.  Changing view scale before the page scale factor is changed by the user zooms to the new initial scale.
2.  Changing view scale after the user changes the page scale to something different than initial scale does not
    cause the page to zoom to the new initial scale.
3.  Changing view scale after the user changes the page scale factor back to initial scale causes the page to
    zoom to the new initial scale.

* resources/basic-gestures.js:

Make a small tweak in `doubleTapToZoomAtPoint` to ensure that both single taps as well as zooming are complete
before invoking UIScriptController completion.

(return.new.Promise):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237127 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/viewport/ios/initial-scale-after-changing-view-scale-expected.txt [new file with mode: 0644]
LayoutTests/fast/viewport/ios/initial-scale-after-changing-view-scale.html [new file with mode: 0644]
LayoutTests/resources/basic-gestures.js
Source/WebCore/ChangeLog
Source/WebCore/page/ViewportConfiguration.h
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm