Title: [219113] trunk/Source/WebKit2
Revision
219113
Author
[email protected]
Date
2017-07-03 21:33:21 -0700 (Mon, 03 Jul 2017)

Log Message

[iOS DnD] [WK2] Callout bar should reappear after dragging ends for a text selection
https://bugs.webkit.org/show_bug.cgi?id=174116
<rdar://problem/33017845>

Reviewed by Ryosuke Niwa.

-willStartScrollingOverflow -didEndScrollingOverflow are helper methods on both the UIWKTextInteractionAssistant
and UIWebSelectionAssistant that handle hiding selection and callout bar UI during overflow scrolling and making
it reappear after scrolling ends. However, these hooks do not contain logic specific to scrolling, and simply
tell the inner UIWebSelectionView to either show or hide and are safe to invoke outside of the context of
scrolling.

This patch invokes these hooks when beginning a drag on a selection, and when a dragging ends, if it called
-willStartScrollingOverflow to begin with. We should rename these in the future to be something along the lines
of -hideSelectionViewAndControls and -showSelectionViewAndControls, respectively, and adopt these new names in
WebKit. We also move logic to hide the callout out of -itemsForBeginningSession: and into
-willAnimateLiftWithAnimator:, when the lift actually begins.

* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView cleanUpDragSourceSessionState]):
(-[WKContentView _restoreCalloutBarIfNeeded]):
(-[WKContentView dragInteraction:itemsForBeginningSession:]):
(-[WKContentView dragInteraction:willAnimateLiftWithAnimator:session:]):
(-[WKContentView dragInteraction:session:didEndWithOperation:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (219112 => 219113)


--- trunk/Source/WebKit2/ChangeLog	2017-07-04 04:08:16 UTC (rev 219112)
+++ trunk/Source/WebKit2/ChangeLog	2017-07-04 04:33:21 UTC (rev 219113)
@@ -1,3 +1,31 @@
+2017-07-03  Wenson Hsieh  <[email protected]>
+
+        [iOS DnD] [WK2] Callout bar should reappear after dragging ends for a text selection
+        https://bugs.webkit.org/show_bug.cgi?id=174116
+        <rdar://problem/33017845>
+
+        Reviewed by Ryosuke Niwa.
+
+        -willStartScrollingOverflow -didEndScrollingOverflow are helper methods on both the UIWKTextInteractionAssistant
+        and UIWebSelectionAssistant that handle hiding selection and callout bar UI during overflow scrolling and making
+        it reappear after scrolling ends. However, these hooks do not contain logic specific to scrolling, and simply
+        tell the inner UIWebSelectionView to either show or hide and are safe to invoke outside of the context of
+        scrolling.
+
+        This patch invokes these hooks when beginning a drag on a selection, and when a dragging ends, if it called
+        -willStartScrollingOverflow to begin with. We should rename these in the future to be something along the lines
+        of -hideSelectionViewAndControls and -showSelectionViewAndControls, respectively, and adopt these new names in
+        WebKit. We also move logic to hide the callout out of -itemsForBeginningSession: and into
+        -willAnimateLiftWithAnimator:, when the lift actually begins.
+
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView cleanUpDragSourceSessionState]):
+        (-[WKContentView _restoreCalloutBarIfNeeded]):
+        (-[WKContentView dragInteraction:itemsForBeginningSession:]):
+        (-[WKContentView dragInteraction:willAnimateLiftWithAnimator:session:]):
+        (-[WKContentView dragInteraction:session:didEndWithOperation:]):
+
 2017-07-03  Matt Rajca  <[email protected]>
 
         Add/remove appropriate media element behavior restrictions when updateWebsitePolicies is called

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (219112 => 219113)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2017-07-04 04:08:16 UTC (rev 219112)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2017-07-04 04:33:21 UTC (rev 219113)
@@ -125,6 +125,7 @@
     BOOL didBeginDragging { NO };
     BOOL isPerformingOperation { NO };
     BOOL isAnimatingConcludeEditDrag { NO };
+    BOOL shouldRestoreCalloutBar { NO };
     RetainPtr<id <UIDragSession>> dragSession;
     RetainPtr<id <UIDropSession>> dropSession;
     BlockPtr<void()> dragStartCompletionBlock;

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (219112 => 219113)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2017-07-04 04:08:16 UTC (rev 219112)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2017-07-04 04:33:21 UTC (rev 219113)
@@ -4376,6 +4376,7 @@
         completionBlock();
     }
 
+    [self _restoreCalloutBarIfNeeded];
     [_dataInteractionState.caretView remove];
     [_dataInteractionState.visibleContentViewSnapshot removeFromSuperview];
 
@@ -4506,6 +4507,17 @@
     return _dataInteractionState.dragSession.get();
 }
 
+- (void)_restoreCalloutBarIfNeeded
+{
+    if (!_dataInteractionState.shouldRestoreCalloutBar)
+        return;
+
+    // FIXME: This SPI should be renamed in UIKit to reflect a more general purpose of revealing hidden interaction assistant controls.
+    [_webSelectionAssistant didEndScrollingOverflow];
+    [_textSelectionAssistant didEndScrollingOverflow];
+    _dataInteractionState.shouldRestoreCalloutBar = NO;
+}
+
 #pragma mark - UIDragInteractionDelegate
 
 - (void)_dragInteraction:(UIDragInteraction *)interaction prepareForSession:(id <UIDragSession>)session completion:(dispatch_block_t)completion
@@ -4552,8 +4564,6 @@
         return @[ ];
     }
 
-    [UICalloutBar fadeSharedCalloutBar];
-
     // Give internal clients such as Mail one final chance to augment the contents of each UIItemProvider before sending the drag items off to UIKit.
     id <WKUIDelegatePrivate> uiDelegate = self.webViewUIDelegate;
     if ([uiDelegate respondsToSelector:@selector(_webView:adjustedDataInteractionItemProvidersForItemProvider:representingObjects:additionalData:)]) {
@@ -4600,6 +4610,13 @@
 
 - (void)dragInteraction:(UIDragInteraction *)interaction willAnimateLiftWithAnimator:(id <UIDragAnimating>)animator session:(id <UIDragSession>)session
 {
+    if (!_dataInteractionState.shouldRestoreCalloutBar && (_dataInteractionState.sourceAction & DragSourceActionSelection)) {
+        // FIXME: This SPI should be renamed in UIKit to reflect a more general purpose of hiding interaction assistant controls.
+        [_webSelectionAssistant willStartScrollingOverflow];
+        [_textSelectionAssistant willStartScrollingOverflow];
+        _dataInteractionState.shouldRestoreCalloutBar = YES;
+    }
+
     auto adjustedOrigin = _dataInteractionState.adjustedOrigin;
     RetainPtr<WKContentView> protectedSelf(self);
     [animator addCompletion:[session, adjustedOrigin, protectedSelf, page = _page] (UIViewAnimatingPosition finalPosition) {
@@ -4631,6 +4648,9 @@
 - (void)dragInteraction:(UIDragInteraction *)interaction session:(id <UIDragSession>)session didEndWithOperation:(UIDropOperation)operation
 {
     RELEASE_LOG(DragAndDrop, "Drag session ended: %p (with operation: %tu, performing operation: %d, began dragging: %d)", session, operation, _dataInteractionState.isPerformingOperation, _dataInteractionState.didBeginDragging);
+
+    [self _restoreCalloutBarIfNeeded];
+
     id <WKUIDelegatePrivate> uiDelegate = self.webViewUIDelegate;
     if ([uiDelegate respondsToSelector:@selector(_webView:dataInteraction:session:didEndWithOperation:)])
         [uiDelegate _webView:_webView dataInteraction:interaction session:session didEndWithOperation:operation];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to