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)
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

index d912815..51a59ab 100644 (file)
@@ -1,3 +1,17 @@
+2018-01-10  Tim Horton  <timothy_horton@apple.com>
+
+        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.
+
+        * 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.
+
 2018-01-10  Ryan Haddad  <ryanhaddad@apple.com>
 
         Skip http/tests/workers/service/cors-image-fetch.html.
index 84d7544..ca0c3a2 100644 (file)
@@ -1761,3 +1761,5 @@ webkit.org/b/180560 accessibility/mac/html5-input-number.html [ Pass Failure ]
 webkit.org/b/180675 accessibility/mac/search-field-cancel-button.html [ Pass Failure ]
 
 webkit.org/b/181098 fast/workers/worker-terminate.html [ Pass Timeout ]
+
+webkit.org/b/181502 swipe/pushstate-with-manual-scrollrestoration.html [ Failure ]
\ No newline at end of file
diff --git a/LayoutTests/swipe/pushstate-with-manual-scrollrestoration-expected.txt b/LayoutTests/swipe/pushstate-with-manual-scrollrestoration-expected.txt
new file mode 100644 (file)
index 0000000..56f14de
--- /dev/null
@@ -0,0 +1,6 @@
+startSwipeGesture
+didBeginSwipe
+completeSwipeGesture
+didEndSwipe
+didRemoveSwipeSnapshot
+
diff --git a/LayoutTests/swipe/pushstate-with-manual-scrollrestoration.html b/LayoutTests/swipe/pushstate-with-manual-scrollrestoration.html
new file mode 100644 (file)
index 0000000..3ef28a9
--- /dev/null
@@ -0,0 +1,60 @@
+<head>
+<style>
+html {
+    font-size: 32pt;
+}
+</style>
+<script src="resources/swipe-test.js"></script>
+<script>
+history.scrollRestoration = "manual";
+
+function didBeginSwipeCallback()
+{
+    log("didBeginSwipe");
+
+    completeSwipeGesture();
+}
+
+function didEndSwipeCallback()
+{
+    log("didEndSwipe");
+
+    startMeasuringDuration("snapshotRemoval");
+}
+
+function didRemoveSwipeSnapshotCallback()
+{
+    log("didRemoveSwipeSnapshot");
+
+    measuredDurationShouldBeLessThan("snapshotRemoval", 1000, "Because we're using the page cache, it shouldn't be long between the gesture completing and the snapshot being removed.")
+
+    testComplete();
+}
+
+window.onload = function () {
+    if (!window.eventSender || !window.testRunner) {
+        document.body.innerHTML = "This test must be run in WebKitTestRunner.";
+        return;
+    }
+
+    initializeSwipeTest();
+
+    testRunner.installDidBeginSwipeCallback(didBeginSwipeCallback);
+    testRunner.installDidEndSwipeCallback(didEndSwipeCallback);
+    testRunner.installDidRemoveSwipeSnapshotCallback(didRemoveSwipeSnapshotCallback);
+
+    testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+
+    setTimeout(function () {
+        history.pushState({page: "second"}, "second", "?second");
+        document.body.innerHTML = "second";
+        startSwipeGesture();
+    }, 0);
+};
+</script>
+</head>
+<body>
+first
+</body>
\ No newline at end of file
index db33578..2a1c266 100644 (file)
@@ -1,3 +1,48 @@
+2018-01-10  Tim Horton  <timothy_horton@apple.com>
+
+        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.
+
 2018-01-10  Brent Fulgham  <bfulgham@apple.com>
 
         Use protectedThis for the 'updatePrevalentDomainsToPartitionOrBlockCookies' lambda
index cb20599..45d206c 100644 (file)
@@ -772,6 +772,7 @@ typedef NS_ENUM(NSInteger, _UIBackdropViewStylePrivate) {
 
 @interface _UINavigationInteractiveTransitionBase ()
 - (id)initWithGestureRecognizerView:(UIView *)gestureRecognizerView animator:(id<UIViewControllerAnimatedTransitioning>)animator delegate:(id<_UINavigationInteractiveTransitionBaseDelegate>)delegate;
+- (void)_completeStoppedInteractiveTransition;
 @property (nonatomic, weak) UIPanGestureRecognizer *gestureRecognizer;
 @property (nonatomic, assign) BOOL shouldReverseTranslation;
 @property (nonatomic, retain) _UINavigationParallaxTransition *animationController;
@@ -970,6 +971,10 @@ typedef NS_OPTIONS(NSUInteger, UIDragOperation)
 - (UIResponder *)firstResponder;
 @end
 
+@interface _UINavigationInteractiveTransitionBase ()
+- (void)_stopInteractiveTransition;
+@end
+
 #if __has_include(<UIKit/UITextAutofillSuggestion.h>)
 #import <UIKit/UITextAutofillSuggestion.h>
 #else
index 7124412..cbb91b7 100644 (file)
@@ -318,7 +318,7 @@ static std::optional<WebCore::ScrollbarOverlayStyle> toCoreScrollbarStyle(_WKOve
     WebCore::FloatBoxExtent _obscuredInsetsWhenSaved;
 
     std::optional<WebCore::FloatPoint> _unobscuredCenterToRestore;
-    uint64_t _firstTransactionIDAfterPageRestore;
+    std::optional<uint64_t> _firstTransactionIDAfterPageRestore;
     double _scaleToRestore;
 
     std::unique_ptr<WebKit::ViewGestureController> _gestureController;
@@ -1615,7 +1615,7 @@ static WebCore::Color scrollViewBackgroundColor(WKWebView *webView)
     _frozenUnobscuredContentRect = std::nullopt;
 
     _firstPaintAfterCommitLoadTransactionID = 0;
-    _firstTransactionIDAfterPageRestore = 0;
+    _firstTransactionIDAfterPageRestore = std::nullopt;
     _resizeAnimationTransformTransactionID = std::nullopt;
 
     _hasScheduledVisibleRectUpdate = NO;
@@ -1737,8 +1737,7 @@ static inline bool areEssentiallyEqualAsFloat(float a, float b)
         needUpdateVisibleContentRects = true;
     }
 
-    if (layerTreeTransaction.transactionID() >= _firstTransactionIDAfterPageRestore) {
-        bool shouldRestoreScrollPosition = false;
+    if (_firstTransactionIDAfterPageRestore && layerTreeTransaction.transactionID() >= _firstTransactionIDAfterPageRestore.value()) {
         if (_scrollOffsetToRestore) {
             WebCore::FloatPoint scaledScrollOffset = _scrollOffsetToRestore.value();
             _scrollOffsetToRestore = std::nullopt;
@@ -1749,8 +1748,6 @@ static inline bool areEssentiallyEqualAsFloat(float a, float b)
 
                 changeContentOffsetBoundedInValidRange(_scrollView.get(), contentOffsetInScrollViewCoordinates);
                 _commitDidRestoreScrollPosition = YES;
-
-                shouldRestoreScrollPosition = true;
             }
 
             needUpdateVisibleContentRects = true;
@@ -1769,15 +1766,15 @@ static inline bool areEssentiallyEqualAsFloat(float a, float b)
                 topLeftInDocumentCoordinates.moveBy(WebCore::FloatPoint(-_obscuredInsets.left, -_obscuredInsets.top));
 
                 changeContentOffsetBoundedInValidRange(_scrollView.get(), topLeftInDocumentCoordinates);
-
-                shouldRestoreScrollPosition = true;
             }
 
             needUpdateVisibleContentRects = true;
         }
 
-        if (shouldRestoreScrollPosition && _gestureController)
+        if (_gestureController)
             _gestureController->didRestoreScrollPosition();
+
+        _firstTransactionIDAfterPageRestore = std::nullopt;
     }
 
     if (needUpdateVisibleContentRects)
@@ -6167,6 +6164,28 @@ static WebCore::UserInterfaceLayoutDirection toUserInterfaceLayoutDirection(UISe
 
 #endif // PLATFORM(IOS)
 
+- (BOOL)_beginBackSwipeForTesting
+{
+#if PLATFORM(MAC)
+    return _impl->beginBackSwipeForTesting();
+#else
+    if (!_gestureController)
+        return NO;
+    return _gestureController->beginSimulatedSwipeInDirectionForTesting(WebKit::ViewGestureController::SwipeDirection::Back);
+#endif
+}
+
+- (BOOL)_completeBackSwipeForTesting
+{
+#if PLATFORM(MAC)
+    return _impl->completeBackSwipeForTesting();
+#else
+    if (!_gestureController)
+        return NO;
+    return _gestureController->completeSimulatedSwipeInDirectionForTesting(WebKit::ViewGestureController::SwipeDirection::Back);
+#endif
+}
+
 @end
 
 
index 768489e..0f33817 100644 (file)
@@ -454,6 +454,9 @@ typedef NS_OPTIONS(NSInteger, _WKRectEdge) {
 - (void)_disableBackForwardSnapshotVolatilityForTesting WK_API_AVAILABLE(macosx(10.12.3), ios(10.3));
 - (void)_executeEditCommand:(NSString *)command argument:(NSString *)argument completion:(void (^)(BOOL))completion WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 
+- (BOOL)_beginBackSwipeForTesting;
+- (BOOL)_completeBackSwipeForTesting;
+
 @end
 
 #endif
index 04b5a46..7f6309a 100644 (file)
@@ -135,6 +135,10 @@ public:
 
     void removeSwipeSnapshot();
 
+    // Testing
+    bool beginSimulatedSwipeInDirectionForTesting(SwipeDirection);
+    bool completeSimulatedSwipeInDirectionForTesting(SwipeDirection);
+
 private:
     // IPC::MessageReceiver.
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
index 8fd3712..b9ed3ec 100644 (file)
@@ -537,6 +537,9 @@ public:
 
     void prepareToDragPromisedBlob(const WebCore::PromisedBlobInfo&);
 
+    bool beginBackSwipeForTesting();
+    bool completeBackSwipeForTesting();
+
 private:
 #if HAVE(TOUCH_BAR)
     void setUpTextTouchBar(NSTouchBar *);
index 4036e51..ff260c2 100644 (file)
@@ -4943,6 +4943,20 @@ void WebViewImpl::setUserInterfaceLayoutDirection(NSUserInterfaceLayoutDirection
     m_page->setUserInterfaceLayoutDirection(toUserInterfaceLayoutDirection(direction));
 }
 
+bool WebViewImpl::beginBackSwipeForTesting()
+{
+    if (!m_gestureController)
+        return false;
+    return m_gestureController->beginSimulatedSwipeInDirectionForTesting(ViewGestureController::SwipeDirection::Back);
+}
+
+bool WebViewImpl::completeBackSwipeForTesting()
+{
+    if (!m_gestureController)
+        return false;
+    return m_gestureController->completeSimulatedSwipeInDirectionForTesting(ViewGestureController::SwipeDirection::Back);
+}
+
 } // namespace WebKit
 
 #endif // PLATFORM(MAC)
index a08f21d..4c33d55 100644 (file)
@@ -50,6 +50,8 @@ using namespace WebCore;
 @interface WKSwipeTransitionController : NSObject <_UINavigationInteractiveTransitionBaseDelegate>
 - (instancetype)initWithViewGestureController:(WebKit::ViewGestureController*)gestureController gestureRecognizerView:(UIView *)gestureRecognizerView;
 - (void)invalidate;
+
+- (_UINavigationInteractiveTransitionBase *)transitionForDirection:(WebKit::ViewGestureController::SwipeDirection)direction;
 @end
 
 @interface _UIViewControllerTransitionContext (WKDetails)
@@ -93,6 +95,11 @@ static const float swipeSnapshotRemovalRenderTreeSizeTargetFraction = 0.5;
     return transition == _backTransitionController ? WebKit::ViewGestureController::SwipeDirection::Back : WebKit::ViewGestureController::SwipeDirection::Forward;
 }
 
+- (_UINavigationInteractiveTransitionBase *)transitionForDirection:(WebKit::ViewGestureController::SwipeDirection)direction
+{
+    return direction == WebKit::ViewGestureController::SwipeDirection::Back ? _backTransitionController.get() : _forwardTransitionController.get();
+}
+
 - (void)startInteractiveTransition:(_UINavigationInteractiveTransitionBase *)transition
 {
     _gestureController->beginSwipeGesture(transition, [self directionForTransition:transition]);
@@ -361,6 +368,26 @@ void ViewGestureController::removeSwipeSnapshot()
     didEndGesture();
 }
 
+bool ViewGestureController::beginSimulatedSwipeInDirectionForTesting(SwipeDirection direction)
+{
+    if (!canSwipeInDirection(direction))
+        return false;
+
+    _UINavigationInteractiveTransitionBase *transition = [m_swipeInteractiveTransitionDelegate transitionForDirection:direction];
+    beginSwipeGesture(transition, direction);
+    [transition _stopInteractiveTransition];
+
+    return true;
+}
+
+bool ViewGestureController::completeSimulatedSwipeInDirectionForTesting(SwipeDirection direction)
+{
+    _UINavigationInteractiveTransitionBase *transition = [m_swipeInteractiveTransitionDelegate transitionForDirection:direction];
+    [transition _completeStoppedInteractiveTransition];
+
+    return true;
+}
+
 } // namespace WebKit
 
 #endif // PLATFORM(IOS)
index 54ad762..dffa547 100644 (file)
@@ -43,6 +43,7 @@
 #import "WebProcessProxy.h"
 #import <Cocoa/Cocoa.h>
 #import <WebCore/IOSurface.h>
+#import <WebCore/NotImplemented.h>
 #import <WebCore/WebActionDisablingCALayerDelegate.h>
 #import <pal/spi/cocoa/QuartzCoreSPI.h>
 #import <pal/spi/mac/NSEventSPI.h>
@@ -820,6 +821,18 @@ double ViewGestureController::magnification() const
     return m_webPageProxy.pageScaleFactor();
 }
 
+bool ViewGestureController::beginSimulatedSwipeInDirectionForTesting(SwipeDirection)
+{
+    notImplemented();
+    return false;
+}
+
+bool ViewGestureController::completeSimulatedSwipeInDirectionForTesting(SwipeDirection)
+{
+    notImplemented();
+    return false;
+}
+
 } // namespace WebKit
 
 #endif // PLATFORM(MAC)
index f88a076..571d7dc 100644 (file)
@@ -1,3 +1,27 @@
+2018-01-10  Tim Horton  <timothy_horton@apple.com>
+
+        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.
+
+        * 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.
+
 2018-01-10  Jonathan Bedard  <jbedard@apple.com>
 
         REGRESSION (r226715): ignore WARNING output in linter tests
index c9d2008..b613981 100644 (file)
@@ -335,6 +335,14 @@ void UIScriptController::setSafeAreaInsets(double, double, double, double)
 {
 }
 
+void UIScriptController::beginBackSwipe(JSValueRef callback)
+{
+}
+
+void UIScriptController::completeBackSwipe(JSValueRef callback)
+{
+}
+
 }
 
 #endif // PLATFORM(IOS)
index 666de93..2850945 100644 (file)
@@ -457,23 +457,23 @@ void UIScriptController::addViewToWindow(JSValueRef)
 {
 }
 
-#endif // !PLATFORM(COCOA)
-
-#if !PLATFORM(MAC)
-
-void UIScriptController::overridePreference(JSStringRef, JSStringRef)
+void UIScriptController::beginBackSwipe(JSValueRef callback)
 {
 }
 
-void UIScriptController::replaceTextAtRange(JSStringRef, int, int)
+void UIScriptController::completeBackSwipe(JSValueRef callback)
 {
 }
 
-void UIScriptController::beginBackSwipe(JSValueRef callback)
+#endif // !PLATFORM(COCOA)
+
+#if !PLATFORM(MAC)
+
+void UIScriptController::overridePreference(JSStringRef, JSStringRef)
 {
 }
 
-void UIScriptController::completeBackSwipe(JSValueRef callback)
+void UIScriptController::replaceTextAtRange(JSStringRef, int, int)
 {
 }
 
index 622f1a3..2472b3e 100644 (file)
@@ -356,6 +356,9 @@ RetainPtr<CGImageRef> PlatformWebView::windowSnapshotImage()
 
 void PlatformWebView::setNavigationGesturesEnabled(bool enabled)
 {
+#if WK_API_ENABLED
+    [platformView() setAllowsBackForwardNavigationGestures:enabled];
+#endif
 }
 
 } // namespace WTR
index 0996136..89b7764 100644 (file)
@@ -749,6 +749,24 @@ void UIScriptController::setSafeAreaInsets(double top, double right, double bott
     webView.overrideSafeAreaInsets = insets;
 }
 
+void UIScriptController::beginBackSwipe(JSValueRef callback)
+{
+    TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
+    [webView _beginBackSwipeForTesting];
+
+    unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent);
+    m_context->asyncTaskComplete(callbackID);
+}
+
+void UIScriptController::completeBackSwipe(JSValueRef callback)
+{
+    TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
+    [webView _completeBackSwipeForTesting];
+
+    unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent);
+    m_context->asyncTaskComplete(callbackID);
+}
+
 }
 
 #endif // PLATFORM(IOS)