[Extra zoom mode] Add a mechanism to extend the height of the layout viewport in...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Apr 2018 21:00:50 +0000 (21:00 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Apr 2018 21:00:50 +0000 (21:00 +0000)
commitd1f00e0ddd0cfa6a17cc110a46050bfad19603d7
tree617532c1c3c3146e3fe67f77dfd50341a3edaf3c
parente902b7a9e125c36d006a0e178447686f6da7f711
[Extra zoom mode] Add a mechanism to extend the height of the layout viewport in extra zoom mode
https://bugs.webkit.org/show_bug.cgi?id=184782
<rdar://problem/38346712>

Reviewed by Tim Horton.

Source/WebCore:

Add a new helper on FrameView to compute an expanded layout viewport size, as well as a new setting for the
height expansion factor when computing visual viewport dimensions. See WebKit/ChangeLog for more detail.

Test: fast/visual-viewport/extrazoom/layout-viewport-after-scrolling-and-resizing.html

* page/FrameView.cpp:
(WebCore::FrameView::expandedLayoutViewportSize):
* page/FrameView.h:
* page/Settings.yaml:

Source/WebKit:

In extra zoom mode, at initial scale, fixed position elements may take up a large portion of the viewport. This
leaves little room for non-fixed-position elements; to improve this experience, we introduce a mechanism to
extend the height of the layout viewport. By default, the layout viewport size is determined by the FrameView's
baseLayoutViewportSize, and passed into FrameView::computeUpdatedLayoutViewportRect in the client layer; in
extra zoom mode, if the layout viewport is shorter than the document width, we try to double the height of the
layout viewport and clamp to the document height if necessary.

* Shared/WebPreferences.yaml:

Add a new preference to determine the factor by which we should expand the height of the layout viewport. By
default, this is 0 (no increase in layout viewport height); in extra zoom mode, this is 1, which means we'll
increase the layout viewport's height by 1x the default height.

* Shared/WebPreferencesDefaultValues.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView activeMinimumLayoutSizes:]):

Fixes a bug when computing the active minimum layout size. If a minimum allowed layout width is specified, we
clamp the active layout width (normally the view size) so that it is no less than the minimum allowed layout
width. However, the height is currently unaffected, which causes FrameView::baseLayoutViewportSize to return a
bogus size, where the width is scaled to 320px but the height isn't. Instead, we should scale the layout height
to match the new width here.

* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::computeCustomFixedPositionRect const):

Expand the base viewport layout size if necessary, given the expansion factor in WebPreferences.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::dynamicViewportSizeUpdate):

Expand the base viewport layout size if necessary, given the expansion factor in Settings.

LayoutTests:

Add a new layout test to exercise the following scenarios:
•   The layout viewport should be fully extended when the document is much taller than the viewport.
•   Programmatically shrinking the document height to less than the viewport height causes the layout viewport
    to shrink to the viewport height.
•   Programmatically extending the document height to a little more than the viewport height causes the layout
    viewport to also expand, but this time, only to the new document height.

* TestExpectations:

Skip tests in fast/visual-viewport/extrazoom by default.

* fast/visual-viewport/extrazoom/layout-viewport-after-scrolling-and-resizing-expected.txt: Added.
* fast/visual-viewport/extrazoom/layout-viewport-after-scrolling-and-resizing.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230819 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/fast/visual-viewport/extrazoom/layout-viewport-after-scrolling-and-resizing-expected.txt [new file with mode: 0644]
LayoutTests/fast/visual-viewport/extrazoom/layout-viewport-after-scrolling-and-resizing.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h
Source/WebCore/page/Settings.yaml
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebPreferences.yaml
Source/WebKit/Shared/WebPreferencesDefaultValues.h
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm