Title: [218899] trunk/Source/WebKit2
Revision
218899
Author
wenson_hs...@apple.com
Date
2017-06-28 15:58:16 -0700 (Wed, 28 Jun 2017)

Log Message

 2017-06-28  Wenson Hsieh  <wenson_hs...@apple.com>

Followup to r218885: adjust for further UIKit SPI changes
https://bugs.webkit.org/show_bug.cgi?id=173927
<rdar://problem/33020792>

Reviewed by Tim Horton.

On ToT, UIKit now invokes -_dragInteraction:item:shouldDelaySetDownAnimationWithCompletion: before the
completion block of -dragInteraction:willAnimateLiftWithAnimator:session: is called. This means we now need to
store the completion block in -shouldDelaySetDownAnimationWithCompletion: and wait until the UIDragAnimating
completion block in -willAnimateCancelWithAnimator: before invoking it.

* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView cleanUpDragSourceSessionState]):

Ensure that the set-down completion block is invoked when a drag session ends (e.g., if the web content process
crashes).

(-[WKContentView _dragInteraction:item:shouldDelaySetDownAnimationWithCompletion:]):
(-[WKContentView _api_dragInteraction:item:willAnimateCancelWithAnimator:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (218898 => 218899)


--- trunk/Source/WebKit2/ChangeLog	2017-06-28 22:53:22 UTC (rev 218898)
+++ trunk/Source/WebKit2/ChangeLog	2017-06-28 22:58:16 UTC (rev 218899)
@@ -1,3 +1,26 @@
+ 2017-06-28  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Followup to r218885: adjust for further UIKit SPI changes
+        https://bugs.webkit.org/show_bug.cgi?id=173927
+        <rdar://problem/33020792>
+
+        Reviewed by Tim Horton.
+
+        On ToT, UIKit now invokes -_dragInteraction:item:shouldDelaySetDownAnimationWithCompletion: before the
+        completion block of -dragInteraction:willAnimateLiftWithAnimator:session: is called. This means we now need to
+        store the completion block in -shouldDelaySetDownAnimationWithCompletion: and wait until the UIDragAnimating
+        completion block in -willAnimateCancelWithAnimator: before invoking it.
+
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView cleanUpDragSourceSessionState]):
+
+        Ensure that the set-down completion block is invoked when a drag session ends (e.g., if the web content process
+        crashes).
+
+        (-[WKContentView _dragInteraction:item:shouldDelaySetDownAnimationWithCompletion:]):
+        (-[WKContentView _api_dragInteraction:item:willAnimateCancelWithAnimator:]):
+
 2017-06-28  Wenson Hsieh  <wenson_hs...@apple.com>
 
         dropInteraction:sessionDidEnd: invokes dragEnded with a UIDragOperation rather than a WebCore::DragOperation

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (218898 => 218899)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2017-06-28 22:53:22 UTC (rev 218898)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2017-06-28 22:58:16 UTC (rev 218899)
@@ -128,6 +128,7 @@
     RetainPtr<id <UIDragSession>> dragSession;
     RetainPtr<id <UIDropSession>> dropSession;
     BlockPtr<void()> dragStartCompletionBlock;
+    BlockPtr<void()> dragCancelSetDownBlock;
     WebCore::DragSourceAction sourceAction { WebCore::DragSourceActionNone };
 
     String linkTitle;

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (218898 => 218899)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2017-06-28 22:53:22 UTC (rev 218898)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2017-06-28 22:58:16 UTC (rev 218899)
@@ -4375,6 +4375,11 @@
         [[WebItemProviderPasteboard sharedInstance] setItemProviders:nil];
     }
 
+    if (auto completionBlock = _dataInteractionState.dragCancelSetDownBlock) {
+        _dataInteractionState.dragCancelSetDownBlock = nil;
+        completionBlock();
+    }
+
     if (auto completionBlock = _dataInteractionState.dragStartCompletionBlock) {
         // If the previous drag session is still initializing, we need to ensure that its completion block is called to prevent UIKit from getting out of state.
         _dataInteractionState.dragStartCompletionBlock = nil;
@@ -4660,16 +4665,20 @@
 
 - (BOOL)_dragInteraction:(UIDragInteraction *)interaction item:(UIDragItem *)item shouldDelaySetDownAnimationWithCompletion:(void(^)(void))completion
 {
-    _page->callAfterNextPresentationUpdate([capturedBlock = makeBlockPtr(completion)] (CallbackBase::Error) {
-        capturedBlock();
-    });
+    _dataInteractionState.dragCancelSetDownBlock = completion;
     return YES;
 }
 
 - (void)_api_dragInteraction:(UIDragInteraction *)interaction item:(UIDragItem *)item willAnimateCancelWithAnimator:(id <UIDragAnimating>)animator
 {
-    [animator addCompletion:[page = _page] (UIViewAnimatingPosition finalPosition) {
+    [animator addCompletion:[protectedSelf = retainPtr(self), page = _page] (UIViewAnimatingPosition finalPosition) {
         page->dragCancelled();
+        if (auto completion = protectedSelf->_dataInteractionState.dragCancelSetDownBlock) {
+            protectedSelf->_dataInteractionState.dragCancelSetDownBlock = nil;
+            page->callAfterNextPresentationUpdate([completion] (CallbackBase::Error) {
+                completion();
+            });
+        }
     }];
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to