Title: [218579] trunk
Revision
218579
Author
[email protected]
Date
2017-06-20 03:09:04 -0700 (Tue, 20 Jun 2017)

Log Message

[iOS DnD] [WK2] Remove custom logic for disambiguating long press action sheet gestures and drag lift
https://bugs.webkit.org/show_bug.cgi?id=173578
<rdar://problem/32825028>

Reviewed by Tim Horton.

Source/WebKit2:

Custom logic to cancel the long press action gesture recognizer in WebKit2 was added months ago to achieve
spec'ed behavior when initiating a drag on an element with an action sheet to show on long press. Now that UIKit
defers firing long-press gesture recognizers while a drag lift is recognizing, no extra work in WebKit is needed
to achieve expected behavior.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _simulateLongPressActionAtLocation:]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:

Add testing SPI for showing an action sheet popover at a given location in content view coordinates.

* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _startDataInteractionWithImage:withIndicatorData:atClientPosition:anchorPoint:action:]):
(-[WKContentView _didHandleStartDataInteractionRequest:]):
(-[WKContentView _dragInteraction:prepareForSession:completion:]):
(-[WKContentView dragInteraction:sessionWillBegin:]):
(-[WKContentView _api_dragInteraction:session:didEndWithOperation:]):
(-[WKContentView _simulateLongPressActionAtLocation:]):
(longPressActionDelayAfterLift): Deleted.
(-[WKContentView performDeferredActionAtDragOrigin]): Deleted.
(-[WKContentView cancelDeferredActionAtDragOrigin]): Deleted.

Tools:

Slight tweak to ensure that DataInteractionTests.CustomActionSheetPopover still passes and verifies that showing
a custom popover does not cause dragging to fail when the popover is presented.

* TestWebKitAPI/ios/DataInteractionSimulator.mm:
(-[DataInteractionSimulator _advanceProgress]):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (218578 => 218579)


--- trunk/Source/WebKit2/ChangeLog	2017-06-20 10:00:09 UTC (rev 218578)
+++ trunk/Source/WebKit2/ChangeLog	2017-06-20 10:09:04 UTC (rev 218579)
@@ -1,3 +1,34 @@
+2017-06-20  Wenson Hsieh  <[email protected]>
+
+        [iOS DnD] [WK2] Remove custom logic for disambiguating long press action sheet gestures and drag lift
+        https://bugs.webkit.org/show_bug.cgi?id=173578
+        <rdar://problem/32825028>
+
+        Reviewed by Tim Horton.
+
+        Custom logic to cancel the long press action gesture recognizer in WebKit2 was added months ago to achieve
+        spec'ed behavior when initiating a drag on an element with an action sheet to show on long press. Now that UIKit
+        defers firing long-press gesture recognizers while a drag lift is recognizing, no extra work in WebKit is needed
+        to achieve expected behavior.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _simulateLongPressActionAtLocation:]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+
+        Add testing SPI for showing an action sheet popover at a given location in content view coordinates.
+
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _startDataInteractionWithImage:withIndicatorData:atClientPosition:anchorPoint:action:]):
+        (-[WKContentView _didHandleStartDataInteractionRequest:]):
+        (-[WKContentView _dragInteraction:prepareForSession:completion:]):
+        (-[WKContentView dragInteraction:sessionWillBegin:]):
+        (-[WKContentView _api_dragInteraction:session:didEndWithOperation:]):
+        (-[WKContentView _simulateLongPressActionAtLocation:]):
+        (longPressActionDelayAfterLift): Deleted.
+        (-[WKContentView performDeferredActionAtDragOrigin]): Deleted.
+        (-[WKContentView cancelDeferredActionAtDragOrigin]): Deleted.
+
 2017-06-20  Carlos Garcia Campos  <[email protected]>
 
         [WPE] Add initial implementation of glib API

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (218578 => 218579)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2017-06-20 10:00:09 UTC (rev 218578)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2017-06-20 10:09:04 UTC (rev 218579)
@@ -5635,6 +5635,11 @@
 #endif
 }
 
+- (void)_simulateLongPressActionAtLocation:(CGPoint)location
+{
+    [_contentView _simulateLongPressActionAtLocation:location];
+}
+
 #endif // PLATFORM(IOS)
 
 @end

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (218578 => 218579)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2017-06-20 10:00:09 UTC (rev 218578)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2017-06-20 10:09:04 UTC (rev 218579)
@@ -356,6 +356,7 @@
 - (void)_simulateWillBeginDataInteractionWithSession:(id)session WK_API_AVAILABLE(ios(WK_IOS_TBA));
 - (NSArray *)_simulatedItemsForSession:(id)session WK_API_AVAILABLE(ios(WK_IOS_TBA));
 - (void)_simulatePrepareForDataInteractionSession:(id)session completion:(dispatch_block_t)completion WK_API_AVAILABLE(ios(WK_IOS_TBA));
+- (void)_simulateLongPressActionAtLocation:(CGPoint)location;
 
 - (_WKDraggableElementInfo *)_draggableElementAtPosition:(CGPoint)position WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 - (void)_requestDraggableElementAtPosition:(CGPoint)position completionBlock:(void (^)(_WKDraggableElementInfo *))block WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (218578 => 218579)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2017-06-20 10:00:09 UTC (rev 218578)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2017-06-20 10:09:04 UTC (rev 218579)
@@ -113,7 +113,6 @@
 struct WKDataInteractionState {
     RetainPtr<UIImage> image;
     std::optional<WebCore::TextIndicatorData> indicatorData;
-    CGPoint gestureOrigin { CGPointZero };
     CGPoint adjustedOrigin { CGPointZero };
     CGPoint lastGlobalPosition { CGPointZero };
     CGRect elementBounds { CGRectZero };
@@ -248,7 +247,6 @@
     WebKit::WKDataInteractionState _dataInteractionState;
     RetainPtr<UIDragInteraction> _dataInteraction;
     RetainPtr<UIDropInteraction> _dataOperation;
-    CGPoint _deferredActionSheetRequestLocation;
 #endif
 }
 
@@ -345,6 +343,8 @@
 - (void)_simulatePrepareForDataInteractionSession:(id)session completion:(dispatch_block_t)completion;
 #endif
 
+- (void)_simulateLongPressActionAtLocation:(CGPoint)location;
+
 @end
 
 @interface WKContentView (WKTesting)

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (218578 => 218579)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2017-06-20 10:00:09 UTC (rev 218578)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2017-06-20 10:09:04 UTC (rev 218579)
@@ -4181,11 +4181,6 @@
     return _UIDragInteractionDefaultLiftDelay();
 }
 
-static NSTimeInterval longPressActionDelayAfterLift()
-{
-    return _UIDragInteractionDefaultCompetingLongPressDelay() - _UIDragInteractionDefaultLiftDelay();
-}
-
 - (id <WKUIDelegatePrivate>)webViewUIDelegate
 {
     return (id <WKUIDelegatePrivate>)[_webView UIDelegate];
@@ -4220,14 +4215,6 @@
     _dataInteractionState.image = adoptNS([[UIImage alloc] initWithCGImage:image.get() scale:_page->deviceScaleFactor() orientation:UIImageOrientationUp]);
     _dataInteractionState.indicatorData = indicatorData;
     _dataInteractionState.sourceAction = static_cast<DragSourceAction>(action);
-
-    // As the drag is being recognized, schedule the action sheet to show in 500 ms, if there is an action sheet to be shown.
-    // We will handle showing the action sheet here, instead of going through the long press gesture recognizer.
-    [_longPressGestureRecognizer setEnabled:NO];
-    [_longPressGestureRecognizer setEnabled:YES];
-    [self cancelDeferredActionAtDragOrigin];
-    [self performSelector:@selector(performDeferredActionAtDragOrigin) withObject:nil afterDelay:longPressActionDelayAfterLift()];
-    _deferredActionSheetRequestLocation = _dataInteractionState.gestureOrigin;
 }
 
 - (void)_didHandleStartDataInteractionRequest:(BOOL)started
@@ -4236,10 +4223,7 @@
     _dataInteractionState.dragStartCompletionBlock = nil;
     ASSERT(savedCompletionBlock);
 
-    if (started) {
-        // Since we're going through with the drag, don't allow the highlight long press gesture recognizer to fire a synthetic click.
-        [self _cancelLongPressGestureRecognizer];
-    } else {
+    if (!started) {
         // The web process rejected the drag start request, so don't go through with the drag.
         // By clearing out the source session state, we force -itemsForDragInteraction:session: to return an empty array, which
         // causes UIKit to bail before beginning the lift animation.
@@ -4329,25 +4313,6 @@
     return nil;
 }
 
-- (void)performDeferredActionAtDragOrigin
-{
-    auto deferredActionPosition = roundedIntPoint(_deferredActionSheetRequestLocation);
-    [self cancelDeferredActionAtDragOrigin];
-    [self _cancelLongPressGestureRecognizer];
-
-    RetainPtr<WKContentView> retainedSelf(self);
-    [self doAfterPositionInformationUpdate:[retainedSelf] (InteractionInformationAtPosition positionInformation) {
-        if (auto action = "" _actionForLongPressFromPositionInformation:positionInformation])
-            [retainedSelf performSelector:action];
-    } forRequest:InteractionInformationRequest(deferredActionPosition)];
-}
-
-- (void)cancelDeferredActionAtDragOrigin
-{
-    [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(performDeferredActionAtDragOrigin) object:nil];
-    _deferredActionSheetRequestLocation = CGPointZero;
-}
-
 - (void)computeClientAndGlobalPointsForDropSession:(id <UIDropSession>)session outClientPoint:(CGPoint *)outClientPoint outGlobalPoint:(CGPoint *)outGlobalPoint
 {
     if (outClientPoint)
@@ -4551,7 +4516,6 @@
 
         auto& state = retainedSelf->_dataInteractionState;
         state.dragStartCompletionBlock = capturedBlock;
-        state.gestureOrigin = dragOrigin;
         state.adjustedOrigin = retainedSelf->_positionInformation.adjustedPointForNodeRespondingToClickEvents;
         state.elementBounds = retainedSelf->_positionInformation.bounds;
         state.linkTitle = retainedSelf->_positionInformation.title;
@@ -4625,7 +4589,6 @@
     if ([uiDelegate respondsToSelector:@selector(_webView:dataInteraction:sessionWillBegin:)])
         [uiDelegate _webView:_webView dataInteraction:interaction sessionWillBegin:session];
 
-    [self cancelDeferredActionAtDragOrigin];
     [_actionSheetAssistant cleanupSheet];
 
     _dataInteractionState.didBeginDragging = YES;
@@ -4643,9 +4606,7 @@
     if (_dataInteractionState.isPerformingOperation)
         return;
 
-    [self cancelDeferredActionAtDragOrigin];
     [self cleanUpDragSourceSessionState];
-
     _page->dragEnded(roundedIntPoint(_dataInteractionState.adjustedOrigin), roundedIntPoint([self convertPoint:_dataInteractionState.adjustedOrigin toView:self.window]), operation);
 }
 
@@ -4828,6 +4789,15 @@
 
 #endif
 
+- (void)_simulateLongPressActionAtLocation:(CGPoint)location
+{
+    RetainPtr<WKContentView> protectedSelf = self;
+    [self doAfterPositionInformationUpdate:[location, protectedSelf] (InteractionInformationAtPosition) {
+        if (SEL action = "" _actionForLongPress])
+            [protectedSelf performSelector:action];
+    } forRequest:InteractionInformationRequest(roundedIntPoint(location))];
+}
+
 @end
 
 @implementation WKContentView (WKTesting)

Modified: trunk/Tools/ChangeLog (218578 => 218579)


--- trunk/Tools/ChangeLog	2017-06-20 10:00:09 UTC (rev 218578)
+++ trunk/Tools/ChangeLog	2017-06-20 10:09:04 UTC (rev 218579)
@@ -1,3 +1,17 @@
+2017-06-20  Wenson Hsieh  <[email protected]>
+
+        [iOS DnD] [WK2] Remove custom logic for disambiguating long press action sheet gestures and drag lift
+        https://bugs.webkit.org/show_bug.cgi?id=173578
+        <rdar://problem/32825028>
+
+        Reviewed by Tim Horton.
+
+        Slight tweak to ensure that DataInteractionTests.CustomActionSheetPopover still passes and verifies that showing
+        a custom popover does not cause dragging to fail when the popover is presented.
+
+        * TestWebKitAPI/ios/DataInteractionSimulator.mm:
+        (-[DataInteractionSimulator _advanceProgress]):
+
 2017-06-20  Carlos Garcia Campos  <[email protected]>
 
         [WPE] Add initial implementation of glib API

Modified: trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm (218578 => 218579)


--- trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm	2017-06-20 10:00:09 UTC (rev 218578)
+++ trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm	2017-06-20 10:09:04 UTC (rev 218579)
@@ -406,6 +406,8 @@
         _sourceItemProviders = itemProviders;
         if (self.showCustomActionSheetBlock) {
             // Defer progress until the custom action sheet is dismissed.
+            auto startLocationInView = [[_webView window] convertPoint:_startLocation toView:_webView.get()];
+            [_webView _simulateLongPressActionAtLocation:startLocationInView];
             return;
         }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to