Title: [236215] branches/safari-606-branch/Source/WebKit
Revision
236215
Author
[email protected]
Date
2018-09-19 12:13:36 -0700 (Wed, 19 Sep 2018)

Log Message

Cherry-pick r236086. rdar://problem/44576830

    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.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236086 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-606-branch/Source/WebKit/ChangeLog (236214 => 236215)


--- branches/safari-606-branch/Source/WebKit/ChangeLog	2018-09-19 19:13:32 UTC (rev 236214)
+++ branches/safari-606-branch/Source/WebKit/ChangeLog	2018-09-19 19:13:36 UTC (rev 236215)
@@ -1,3 +1,68 @@
+2018-09-19  Kocsen Chung  <[email protected]>
+
+        Cherry-pick r236086. rdar://problem/44576830
+
+    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.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236086 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    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-06  Babak Shafiei  <[email protected]>
 
         Cherry-pick r235506. rdar://problem/44169670

Modified: branches/safari-606-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (236214 => 236215)


--- branches/safari-606-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2018-09-19 19:13:32 UTC (rev 236214)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2018-09-19 19:13:36 UTC (rev 236215)
@@ -3090,16 +3090,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: branches/safari-606-branch/Source/WebKit/UIProcess/Cocoa/ViewGestureController.cpp (236214 => 236215)


--- branches/safari-606-branch/Source/WebKit/UIProcess/Cocoa/ViewGestureController.cpp	2018-09-19 19:13:32 UTC (rev 236214)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/Cocoa/ViewGestureController.cpp	2018-09-19 19:13:36 UTC (rev 236215)
@@ -113,10 +113,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: branches/safari-606-branch/Source/WebKit/UIProcess/Cocoa/ViewGestureController.h (236214 => 236215)


--- branches/safari-606-branch/Source/WebKit/UIProcess/Cocoa/ViewGestureController.h	2018-09-19 19:13:32 UTC (rev 236214)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/Cocoa/ViewGestureController.h	2018-09-19 19:13:36 UTC (rev 236215)
@@ -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