REGRESSION (r213590): Swipe from edge to go to previous page is significantly slower...
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Jan 2018 02:18:45 +0000 (02:18 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Jan 2018 02:18:45 +0000 (02:18 +0000)
commit3f28b5ad24358fac5134b8958912e8bb53d16eab
tree3ce33f3839602948c591dec2dbcb8344319587a4
parent6b9ae2e8e48db90fab7103230a42140acebb0e75
REGRESSION (r213590): Swipe from edge to go to previous page is significantly slower than tapping back button on Twitter
https://bugs.webkit.org/show_bug.cgi?id=181269
<rdar://problem/35110344>

Reviewed by Simon Fraser.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _processDidExit]):
(-[WKWebView _didCommitLayerTree:]):
When swiping to a page that set history.scrollRestoration = "manual",
we will never restore the scroll position. We will still restore
"state", but won't have a location. Currently, the code assumes that
it should wait to remove the swipe snapshot until the scroll position
is restored. Instead, wait until the "state" is restored, whether
or not that includes a scroll position/center point restoration.

Do this by making _firstTransactionIDAfterPageRestore an optional,
and reset it after it fires, so that we only run the restoration code
in _didCommitLayerTree for the first commit after state restoration,
not all subsequent commits. Then, tell ViewGestureController that
the scroll position has been restored even if the page opted out.

The reason that this is specific to pushState is that normal,
non-same-document loads bail from waiting for the scroll position
restoration in VGC::didReachMainFrameLoadTerminalState() (see the long
comment there for an explanation).

(-[WKWebView _beginBackSwipeForTesting]):
(-[WKWebView _completeBackSwipeForTesting]):
* Platform/spi/ios/UIKitSPI.h:
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/Cocoa/ViewGestureController.h:
* UIProcess/ios/ViewGestureControllerIOS.mm:
(-[WKSwipeTransitionController transitionForDirection:]):
(WebKit::ViewGestureController::beginSimulatedSwipeInDirectionForTesting):
(WebKit::ViewGestureController::completeSimulatedSwipeInDirectionForTesting):
* UIProcess/mac/ViewGestureControllerMac.mm:
(WebKit::ViewGestureController::beginSimulatedSwipeInDirectionForTesting):
(WebKit::ViewGestureController::completeSimulatedSwipeInDirectionForTesting):
Add a mechanism to forcefully test swipe back. Instead of simulating
events like on Mac, we just talk to the UIKit internals and force
the interaction to start, pause, and then complete when we want.

* swipe/pushstate-with-manual-scrollrestoration-expected.txt: Added.
* swipe/pushstate-with-manual-scrollrestoration.html: Added.
Add a test (which previously would complain about taking too long)
that using manual scroll position restoration and pushState together
doesn't cause swipes to hang until the watchdog fires.

* DumpRenderTree/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::beginBackSwipe):
(WTR::UIScriptController::completeBackSwipe):
* TestRunnerShared/UIScriptContext/UIScriptController.cpp:
(WTR::UIScriptController::beginBackSwipe):
(WTR::UIScriptController::completeBackSwipe):
(WTR::UIScriptController::overridePreference):
(WTR::UIScriptController::replaceTextAtRange):
* WebKitTestRunner/ios/PlatformWebViewIOS.mm:
(WTR::PlatformWebView::setNavigationGesturesEnabled):
* WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::beginBackSwipe):
(WTR::UIScriptController::completeBackSwipe):
Implement beginBackSwipe and completeBackSwipe on iOS (they already
exist on Mac) in terms of the new WKWebView testing SPI.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226750 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac/TestExpectations
LayoutTests/swipe/pushstate-with-manual-scrollrestoration-expected.txt [new file with mode: 0644]
LayoutTests/swipe/pushstate-with-manual-scrollrestoration.html [new file with mode: 0644]
Source/WebKit/ChangeLog
Source/WebKit/Platform/spi/ios/UIKitSPI.h
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit/UIProcess/Cocoa/ViewGestureController.h
Source/WebKit/UIProcess/Cocoa/WebViewImpl.h
Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
Source/WebKit/UIProcess/ios/ViewGestureControllerIOS.mm
Source/WebKit/UIProcess/mac/ViewGestureControllerMac.mm
Tools/ChangeLog
Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm
Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp
Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm
Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm