Title: [236086] trunk/Source/WebKit
Revision
236086
Author
[email protected]
Date
2018-09-17 14:59:33 -0700 (Mon, 17 Sep 2018)

Log Message

Swipe snapshot can get stuck if swiping is disabled while it is visible
https://bugs.webkit.org/show_bug.cgi?id=189667
<rdar://problem/40367780>

Reviewed by Simon Fraser.

If navigation gestures are disabled while a swipe snapshot is visible,
WKWebView will tear down the ViewGestureController, which means that
the SnapshotRemovalTracker will no longer be around to ever remove
the snapshot.

It's currently very hard to write a test for this because we have
yet to come up with a good mechanism for testing swiping on iOS.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView setAllowsBackForwardNavigationGestures:]):
Instead of tearing down the ViewGestureController when navigation
gestures are disabled, just set a bit on it that disables gestures.

* UIProcess/Cocoa/ViewGestureController.cpp:
(WebKit::ViewGestureController::canSwipeInDirection const):
* UIProcess/Cocoa/ViewGestureController.h:
(WebKit::ViewGestureController::setSwipeGestureEnabled):
(WebKit::ViewGestureController::isSwipeGestureEnabled):
Add a bit to ViewGestureController that makes starting new gestures
always fail, but allows e.g. snapshots from existing swipes to continue
their usual behavior.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (236085 => 236086)


--- trunk/Source/WebKit/ChangeLog	2018-09-17 21:41:13 UTC (rev 236085)
+++ trunk/Source/WebKit/ChangeLog	2018-09-17 21:59:33 UTC (rev 236086)
@@ -1,3 +1,33 @@
+2018-09-17  Tim Horton  <[email protected]>
+
+        Swipe snapshot can get stuck if swiping is disabled while it is visible
+        https://bugs.webkit.org/show_bug.cgi?id=189667
+        <rdar://problem/40367780>
+
+        Reviewed by Simon Fraser.
+
+        If navigation gestures are disabled while a swipe snapshot is visible,
+        WKWebView will tear down the ViewGestureController, which means that
+        the SnapshotRemovalTracker will no longer be around to ever remove
+        the snapshot.
+
+        It's currently very hard to write a test for this because we have
+        yet to come up with a good mechanism for testing swiping on iOS.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView setAllowsBackForwardNavigationGestures:]):
+        Instead of tearing down the ViewGestureController when navigation
+        gestures are disabled, just set a bit on it that disables gestures.
+
+        * UIProcess/Cocoa/ViewGestureController.cpp:
+        (WebKit::ViewGestureController::canSwipeInDirection const):
+        * UIProcess/Cocoa/ViewGestureController.h:
+        (WebKit::ViewGestureController::setSwipeGestureEnabled):
+        (WebKit::ViewGestureController::isSwipeGestureEnabled):
+        Add a bit to ViewGestureController that makes starting new gestures
+        always fail, but allows e.g. snapshots from existing swipes to continue
+        their usual behavior.
+
 2018-09-17  Alex Christensen  <[email protected]>
 
         Expose WKWebProcess.h as a private header

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (236085 => 236086)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2018-09-17 21:41:13 UTC (rev 236085)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2018-09-17 21:59:33 UTC (rev 236086)
@@ -3089,16 +3089,16 @@
 
     _allowsBackForwardNavigationGestures = allowsBackForwardNavigationGestures;
 
-    if (allowsBackForwardNavigationGestures) {
-        if (!_gestureController) {
-            _gestureController = std::make_unique<WebKit::ViewGestureController>(*_page);
-            _gestureController->installSwipeHandler(self, [self scrollView]);
-            if (WKWebView *alternateWebView = [_configuration _alternateWebViewForNavigationGestures])
-                _gestureController->setAlternateBackForwardListSourcePage(alternateWebView->_page.get());
-        }
-    } else
-        _gestureController = nullptr;
+    if (allowsBackForwardNavigationGestures && !_gestureController) {
+        _gestureController = std::make_unique<WebKit::ViewGestureController>(*_page);
+        _gestureController->installSwipeHandler(self, [self scrollView]);
+        if (WKWebView *alternateWebView = [_configuration _alternateWebViewForNavigationGestures])
+            _gestureController->setAlternateBackForwardListSourcePage(alternateWebView->_page.get());
+    }
 
+    if (_gestureController)
+        _gestureController->setSwipeGestureEnabled(allowsBackForwardNavigationGestures);
+
     _page->setShouldRecordNavigationSnapshots(allowsBackForwardNavigationGestures);
 }
 

Modified: trunk/Source/WebKit/UIProcess/Cocoa/ViewGestureController.cpp (236085 => 236086)


--- trunk/Source/WebKit/UIProcess/Cocoa/ViewGestureController.cpp	2018-09-17 21:41:13 UTC (rev 236085)
+++ trunk/Source/WebKit/UIProcess/Cocoa/ViewGestureController.cpp	2018-09-17 21:59:33 UTC (rev 236086)
@@ -112,10 +112,14 @@
     
 bool ViewGestureController::canSwipeInDirection(SwipeDirection direction) const
 {
+    if (!m_swipeGestureEnabled)
+        return false;
+
 #if ENABLE(FULLSCREEN_API)
     if (m_webPageProxy.fullScreenManager() && m_webPageProxy.fullScreenManager()->isFullScreen())
         return false;
 #endif
+
     RefPtr<WebPageProxy> alternateBackForwardListSourcePage = m_alternateBackForwardListSourcePage.get();
     auto& backForwardList = alternateBackForwardListSourcePage ? alternateBackForwardListSourcePage->backForwardList() : m_webPageProxy.backForwardList();
     if (direction == SwipeDirection::Back)

Modified: trunk/Source/WebKit/UIProcess/Cocoa/ViewGestureController.h (236085 => 236086)


--- trunk/Source/WebKit/UIProcess/Cocoa/ViewGestureController.h	2018-09-17 21:41:13 UTC (rev 236085)
+++ trunk/Source/WebKit/UIProcess/Cocoa/ViewGestureController.h	2018-09-17 21:59:33 UTC (rev 236086)
@@ -136,6 +136,9 @@
 
     void removeSwipeSnapshot();
 
+    void setSwipeGestureEnabled(bool enabled) { m_swipeGestureEnabled = enabled; }
+    bool isSwipeGestureEnabled() { return m_swipeGestureEnabled; }
+
     // Testing
     bool beginSimulatedSwipeInDirectionForTesting(SwipeDirection);
     bool completeSimulatedSwipeInDirectionForTesting(SwipeDirection);
@@ -247,6 +250,8 @@
     WebPageProxy& m_webPageProxy;
     ViewGestureType m_activeGestureType { ViewGestureType::None };
 
+    bool m_swipeGestureEnabled { true };
+
     RunLoop::Timer<ViewGestureController> m_swipeActiveLoadMonitoringTimer;
 
     WebCore::Color m_backgroundColorForCurrentSnapshot;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to