Implement viewport-width-based fast-click heuristic
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Oct 2015 23:34:54 +0000 (23:34 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Oct 2015 23:34:54 +0000 (23:34 +0000)
commitb7023bce13f7c6a03bf0fecc3ebfd9ed879cb298
treec3d3eca5d3ab5395dfff177f028190269c880d14
parent66f289f5038610a099d9c2fa19a7b06a1bc30950
Implement viewport-width-based fast-click heuristic
https://bugs.webkit.org/show_bug.cgi?id=150604
<rdar://problem/23267308>

Reviewed by Simon Fraser.

Source/WebKit2:

Implement a new fast-click heuristic that applies to viewports with width = device-width. The basic rules are
as follows: when a page has viewport width = device-width and is at initial zoom scale, we disable double-tapping
in favor of fast-clicking. However, if the viewport scale is not the initial scale, we allow double tapping. For
fast-clicking to remain useful after the user pinch-zooms, we change our double-tap to zoom out behavior to zoom
to the initial scale rather than the minimum scale. For unscalable viewports, we default to fast-clicking behavior,
and for all other viewports not at device-width, we double-tap to zoom and scroll as normal.

This patch removes some logic previously used for our scroll- and zoom-based fast-clicking heuristic, and adds
information about the viewport width and initial scale to RemoteLayerTreeTransactions. This information is then
used by the UI process to determine whether double tapping should be disabled or enabled.

The fast-click heuristic can be turned off through user default preferences, and a tap highlight for debugging
fast-clicking can also be enabled through a user default preference. A red highlight indicates that a single-
tap was slow, whereas a green highlight indicates a fast single-tap.

* Shared/mac/RemoteLayerTreeTransaction.h:
(WebKit::RemoteLayerTreeTransaction::initialScaleFactor):
(WebKit::RemoteLayerTreeTransaction::setInitialScaleFactor):
(WebKit::RemoteLayerTreeTransaction::viewportMetaTagWidth):
(WebKit::RemoteLayerTreeTransaction::setViewportMetaTagWidth):
* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::encode):
(WebKit::RemoteLayerTreeTransaction::decode):
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView initWithFrame:configuration:]):
(-[WKWebView _processDidExit]):
(-[WKWebView _didCommitLayerTree:]):
(-[WKWebView _zoomToInitialScaleWithOrigin:animated:]):
(-[WKWebView _allowsDoubleTapGestures]):
(-[WKWebView _setViewportMetaTagWidth:]): Deleted.
(-[WKWebView _contentZoomScale]): Deleted.
(-[WKWebView _viewportMetaTagWidth]): Deleted.
(-[WKWebView _viewportIsUserScalable]): Deleted.
* UIProcess/API/Cocoa/WKWebViewInternal.h:
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::disableDoubleTapGesturesDuringTapIfNecessary):
(WebKit::PageClientImpl::didChangeViewportMetaTagWidth): Deleted.
(WebKit::PageClientImpl::disableDoubleTapGesturesUntilTapIsFinishedIfNecessary): Deleted.
* UIProcess/ios/SmartMagnificationController.h:
* UIProcess/ios/SmartMagnificationController.mm:
(WebKit::SmartMagnificationController::didCollectGeometryForSmartMagnificationGesture):
* UIProcess/ios/WKContentView.h:
* UIProcess/ios/WKContentView.mm:
(-[WKContentView _zoomToInitialScaleWithOrigin:]):
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView setupInteraction]):
(-[WKContentView _showTapHighlight]):
(-[WKContentView _didGetTapHighlightForRequest:color:quads:topLeftRadius:topRightRadius:bottomLeftRadius:bottomRightRadius:]):
(-[WKContentView _mayDisableDoubleTapGesturesDuringSingleTap]):
(-[WKContentView _disableDoubleTapGesturesDuringTapIfNecessary:]):
(-[WKContentView _finishInteraction]):
(-[WKContentView _endPotentialTapAndEnableDoubleTapGesturesIfNecessary]):
(-[WKContentView _tapHighlightColorForFastClick:]):
(-[WKContentView _setDoubleTapGesturesEnabled:]):
(-[WKContentView _fastClickZoomThreshold]): Deleted.
(-[WKContentView _allowDoubleTapToZoomForCurrentZoomScale:andTargetZoomScale:]): Deleted.
(-[WKContentView _disableDoubleTapGesturesUntilTapIsFinishedIfNecessary:allowsDoubleTapZoom:targetRect:isReplaced:minimumScale:maximumScale:]): Deleted.
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::disableDoubleTapGesturesDuringTapIfNecessary):
(WebKit::WebPageProxy::viewportMetaTagWidthDidChange): Deleted.
(WebKit::WebPageProxy::disableDoubleTapGesturesUntilTapIsFinishedIfNecessary): Deleted.
* WebProcess/WebPage/ViewGestureGeometryCollector.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::willCommitLayerTree):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::potentialTapAtPosition):
(WebKit::WebPage::viewportPropertiesDidChange): Deleted.

LayoutTests:

Implement a new fast-click heuristic that applies to viewports with width = device-width. Adds
new tests to check various fast-clicking behaviors. These three tests check (for pages with width=
device-width) that:

- Double-tapping to zoom still works when the scale is not the initial scale.
- If the page is at initial scale, we fire fast-clicks instead of zooming.
- When zooming out from element scale, we end up at initial scale instead of minimum scale.

* fast/events/ios/viewport-device-width-allows-double-tap-zoom-out-expected.txt: Added.
* fast/events/ios/viewport-device-width-allows-double-tap-zoom-out.html: Added.
* fast/events/ios/viewport-device-width-at-initial-scale-fast-clicks-expected.txt: Added.
* fast/events/ios/viewport-device-width-at-initial-scale-fast-clicks.html: Added.
* fast/events/ios/viewport-zooms-from-element-to-initial-scale-expected.txt: Added.
* fast/events/ios/viewport-zooms-from-element-to-initial-scale.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191644 268f45cc-cd09-0410-ab3c-d52691b4dbfc
28 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/events/ios/viewport-device-width-allows-double-tap-zoom-out-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/ios/viewport-device-width-allows-double-tap-zoom-out.html [new file with mode: 0644]
LayoutTests/fast/events/ios/viewport-device-width-at-initial-scale-fast-clicks-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/ios/viewport-device-width-at-initial-scale-fast-clicks.html [new file with mode: 0644]
LayoutTests/fast/events/ios/viewport-zooms-from-element-to-initial-scale-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/ios/viewport-zooms-from-element-to-initial-scale.html [new file with mode: 0644]
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h
Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/UIProcess/ios/PageClientImplIOS.h
Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm
Source/WebKit2/UIProcess/ios/SmartMagnificationController.h
Source/WebKit2/UIProcess/ios/SmartMagnificationController.mm
Source/WebKit2/UIProcess/ios/WKContentView.h
Source/WebKit2/UIProcess/ios/WKContentView.mm
Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h
Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm
Source/WebKit2/WebProcess/WebPage/ViewGestureGeometryCollector.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm