Title: [167766] trunk/Source/WebKit2
Revision
167766
Author
[email protected]
Date
2014-04-24 10:48:28 -0700 (Thu, 24 Apr 2014)

Log Message

[wk2] Provide SPI allowing clients to hand events directly to swipe code, bypassing scrolling
https://bugs.webkit.org/show_bug.cgi?id=132092
<rdar://problem/15948244>

Reviewed by Darin Adler.

* UIProcess/API/Cocoa/WKViewPrivate.h:
* UIProcess/API/mac/WKView.mm:
(-[WKView _tryToSwipeWithEvent:ignoringPinnedState:]):
Added. Hand the event directly to ViewGestureController, optionally
ignoring whether or not the WKView is scrollable (always pretending that it is not).

* UIProcess/mac/ViewGestureController.h:
(WebKit::ViewGestureController::shouldIgnorePinnedState):
(WebKit::ViewGestureController::setShouldIgnorePinnedState):
* UIProcess/mac/ViewGestureControllerMac.mm:
(WebKit::ViewGestureController::ViewGestureController):
(WebKit::ViewGestureController::scrollEventCanBecomeSwipe):
(WebKit::ViewGestureController::handleScrollWheelEvent):
(WebKit::ViewGestureController::wheelEventWasNotHandledByWebCore):
(WebKit::scrollEventCanBecomeSwipe):
If we're ignoring the view's pinned state, pretend that we're always pinned,
and don't worry about sending events to WebCore.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (167765 => 167766)


--- trunk/Source/WebKit2/ChangeLog	2014-04-24 17:30:57 UTC (rev 167765)
+++ trunk/Source/WebKit2/ChangeLog	2014-04-24 17:48:28 UTC (rev 167766)
@@ -1,3 +1,29 @@
+2014-04-24  Tim Horton  <[email protected]>
+
+        [wk2] Provide SPI allowing clients to hand events directly to swipe code, bypassing scrolling
+        https://bugs.webkit.org/show_bug.cgi?id=132092
+        <rdar://problem/15948244>
+
+        Reviewed by Darin Adler.
+
+        * UIProcess/API/Cocoa/WKViewPrivate.h:
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView _tryToSwipeWithEvent:ignoringPinnedState:]):
+        Added. Hand the event directly to ViewGestureController, optionally
+        ignoring whether or not the WKView is scrollable (always pretending that it is not).
+
+        * UIProcess/mac/ViewGestureController.h:
+        (WebKit::ViewGestureController::shouldIgnorePinnedState):
+        (WebKit::ViewGestureController::setShouldIgnorePinnedState):
+        * UIProcess/mac/ViewGestureControllerMac.mm:
+        (WebKit::ViewGestureController::ViewGestureController):
+        (WebKit::ViewGestureController::scrollEventCanBecomeSwipe):
+        (WebKit::ViewGestureController::handleScrollWheelEvent):
+        (WebKit::ViewGestureController::wheelEventWasNotHandledByWebCore):
+        (WebKit::scrollEventCanBecomeSwipe):
+        If we're ignoring the view's pinned state, pretend that we're always pinned,
+        and don't worry about sending events to WebCore.
+
 2014-04-24  Carlos Garcia Campos  <[email protected]>
 
         [GTK] wmode='transparent' for flash plugin doesn't work

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h (167765 => 167766)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h	2014-04-24 17:30:57 UTC (rev 167765)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h	2014-04-24 17:48:28 UTC (rev 167766)
@@ -106,6 +106,7 @@
 
 // Views must be layer-backed, have no transform applied, be in back-to-front z-order, and the whole set must be a contiguous opaque rectangle.
 - (void)_setCustomSwipeViews:(NSArray *)customSwipeViews;
+- (BOOL)_tryToSwipeWithEvent:(NSEvent *)event ignoringPinnedState:(BOOL)ignoringPinnedState;
 
 #endif
 

Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (167765 => 167766)


--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2014-04-24 17:30:57 UTC (rev 167765)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2014-04-24 17:48:28 UTC (rev 167766)
@@ -3893,6 +3893,23 @@
     _data->_gestureController->setCustomSwipeViews(views);
 }
 
+- (BOOL)_tryToSwipeWithEvent:(NSEvent *)event ignoringPinnedState:(BOOL)ignoringPinnedState
+{
+    if (!_data->_allowsBackForwardNavigationGestures)
+        return NO;
+
+    [self _ensureGestureController];
+
+    BOOL wasIgnoringPinnedState = _data->_gestureController->shouldIgnorePinnedState();
+    _data->_gestureController->setShouldIgnorePinnedState(ignoringPinnedState);
+
+    BOOL handledEvent = _data->_gestureController->handleScrollWheelEvent(event);
+
+    _data->_gestureController->setShouldIgnorePinnedState(wasIgnoringPinnedState);
+
+    return handledEvent;
+}
+
 @end
 
 @implementation WKResponderChainSink

Modified: trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h (167765 => 167766)


--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h	2014-04-24 17:30:57 UTC (rev 167765)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h	2014-04-24 17:48:28 UTC (rev 167766)
@@ -97,6 +97,9 @@
     WebCore::FloatRect windowRelativeBoundsForCustomSwipeViews() const;
 
     void endActiveGesture();
+
+    bool shouldIgnorePinnedState() { return m_shouldIgnorePinnedState; }
+    void setShouldIgnorePinnedState(bool ignore) { m_shouldIgnorePinnedState = ignore; }
 #else
     void installSwipeHandler(UIView *gestureRecognizerView, UIView *swipingView);
     bool canSwipeInDirection(SwipeDirection);
@@ -126,6 +129,7 @@
     void handleSwipeGesture(WebBackForwardListItem* targetItem, double progress, SwipeDirection);
     void endSwipeGesture(WebBackForwardListItem* targetItem, bool cancelled);
     bool deltaIsSufficientToBeginSwipe(NSEvent *);
+    bool scrollEventCanBecomeSwipe(NSEvent *, SwipeDirection&);
 #endif
     
     WebPageProxy& m_webPageProxy;
@@ -162,6 +166,8 @@
     PendingSwipeReason m_pendingSwipeReason;
     SwipeDirection m_pendingSwipeDirection;
     WebCore::FloatSize m_cumulativeDeltaForPendingSwipe;
+
+    bool m_shouldIgnorePinnedState;
 #else    
     UIView *m_liveSwipeView;
     RetainPtr<UIView> m_snapshotView;

Modified: trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm (167765 => 167766)


--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm	2014-04-24 17:30:57 UTC (rev 167765)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm	2014-04-24 17:48:28 UTC (rev 167766)
@@ -103,6 +103,7 @@
     , m_frameHandlesMagnificationGesture(false)
     , m_swipeTransitionStyle(SwipeTransitionStyle::Overlap)
     , m_pendingSwipeReason(PendingSwipeReason::None)
+    , m_shouldIgnorePinnedState(false)
 {
     m_webPageProxy.process().addMessageReceiver(Messages::ViewGestureController::messageReceiverName(), m_webPageProxy.pageID(), *this);
 }
@@ -257,7 +258,7 @@
     m_lastMagnificationGestureWasSmartMagnification = true;
 }
 
-static bool scrollEventCanBecomeSwipe(NSEvent *event, WebPageProxy& webPageProxy, ViewGestureController::SwipeDirection& potentialSwipeDirection)
+bool ViewGestureController::scrollEventCanBecomeSwipe(NSEvent *event, ViewGestureController::SwipeDirection& potentialSwipeDirection)
 {
     if (event.phase != NSEventPhaseBegan)
         return false;
@@ -271,8 +272,11 @@
     if (fabs(event.scrollingDeltaX) <= fabs(event.scrollingDeltaY))
         return false;
 
-    bool willSwipeLeft = event.scrollingDeltaX > 0 && webPageProxy.isPinnedToLeftSide() && webPageProxy.backForwardList().backItem();
-    bool willSwipeRight = event.scrollingDeltaX < 0 && webPageProxy.isPinnedToRightSide() && webPageProxy.backForwardList().forwardItem();
+    bool isPinnedToLeft = m_shouldIgnorePinnedState || m_webPageProxy.isPinnedToLeftSide();
+    bool isPinnedToRight = m_shouldIgnorePinnedState || m_webPageProxy.isPinnedToRightSide();
+
+    bool willSwipeLeft = event.scrollingDeltaX > 0 && isPinnedToLeft && m_webPageProxy.backForwardList().backItem();
+    bool willSwipeRight = event.scrollingDeltaX < 0 && isPinnedToRight && m_webPageProxy.backForwardList().forwardItem();
     if (!willSwipeLeft && !willSwipeRight)
         return false;
 
@@ -320,10 +324,10 @@
         return false;
 
     SwipeDirection direction;
-    if (!scrollEventCanBecomeSwipe(event, m_webPageProxy, direction))
+    if (!scrollEventCanBecomeSwipe(event, direction))
         return false;
 
-    if (m_webPageProxy.willHandleHorizontalScrollEvents()) {
+    if (!m_shouldIgnorePinnedState && m_webPageProxy.willHandleHorizontalScrollEvents()) {
         m_pendingSwipeReason = PendingSwipeReason::WebCoreMayScroll;
         m_pendingSwipeDirection = direction;
         return false;
@@ -348,7 +352,7 @@
     m_pendingSwipeReason = PendingSwipeReason::None;
 
     SwipeDirection direction;
-    if (!scrollEventCanBecomeSwipe(event, m_webPageProxy, direction))
+    if (!scrollEventCanBecomeSwipe(event, direction))
         return;
 
     if (!deltaIsSufficientToBeginSwipe(event)) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to