[iOS DnD] For cross-app drags, 'drop' event handlers are never invoked if dataTransfe...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Jul 2017 21:59:25 +0000 (21:59 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Jul 2017 21:59:25 +0000 (21:59 +0000)
commit07d9fe277e90fd3c3e63b6ee5a2bcf14ec759735
treed9caa6b4569a8169e905631cb97db449674b8f09
parent11a8c3303c5550fc9ac1aaf95d4a793901b2a1ff
[iOS DnD] For cross-app drags, 'drop' event handlers are never invoked if dataTransfer.dropEffect is not set while dragging
https://bugs.webkit.org/show_bug.cgi?id=174219
<rdar://problem/32083177>

Reviewed by Ryosuke Niwa.

Source/WebCore:

Currently, in DragController.cpp, defaultOperationForDrag maps a drag source operation mask of
DragOperationGeneric to DragOperationMove across all platforms. However, on iOS, where cross-app drag moves do
not trigger a drop, this means drop handlers won't fire unless the dropEffect is explicitly set to copy.

To fix this, we introduce DragController::platformGenericDragOperation(), which returns DragOperationCopy on iOS
and DragOperationMove (the existing behavior) elsewhere. defaultOperationForDrag then maps a drag source
operation mask of DragOperationGeneric to platformGenericDragOperation().

Tests:  DataInteractionTests.ExternalSourceHTMLToUploadArea
        DataInteractionTests.ExternalSourceImageAndHTMLToUploadArea
        DataInteractionTests.ExternalSourceMoveOperationNotAllowed

* page/DragController.cpp:
(WebCore::DragController::platformGenericDragOperation):
(WebCore::defaultOperationForDrag):
* page/DragController.h:
* page/mac/DragControllerMac.mm:
(WebCore::DragController::platformGenericDragOperation):

Source/WebKit2:

Tweak some testing SPI to return a drop operation flag instead of whether or not the drop operation was not
UIDropOperationCancel.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _simulateDataInteractionUpdated:]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _simulateDataInteractionUpdated:]):

Tools:

Add plumbing and support to mock the value of -allowsMoveOperation on the simulated UIDragDropSession objects.
Setting the DataInteractionSimulator's shouldAllowMoveOperation property to NO simulates a drag operation coming
in from another app out-of-process, for which move operations won't cause a drop to be performed in the first
place.

Also tweaks 2 existing unit tests regarding file uploads via JavaScript to simulate items coming in from a
different application, and adds a new test to check that if a drop area specifically requests a MOVE operation,
no action is taken when dropping.

* TestWebKitAPI/Tests/WebKit2Cocoa/file-uploading.html:
* TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
(TestWebKitAPI::TEST):
* TestWebKitAPI/ios/DataInteractionSimulator.h:
* TestWebKitAPI/ios/DataInteractionSimulator.mm:
(-[MockDragDropSession initWithItems:location:window:allowMove:]):
(-[MockDragDropSession allowsMoveOperation]):
(-[MockDataOperationSession initWithProviders:location:window:allowMove:]):
(-[MockDataInteractionSession initWithWindow:allowMove:]):
(-[DataInteractionSimulator initWithWebView:]):
(-[DataInteractionSimulator runFrom:to:]):
(-[DataInteractionSimulator _advanceProgress]):
(-[MockDragDropSession initWithItems:location:window:]): Deleted.
(-[MockDataOperationSession initWithProviders:location:window:]): Deleted.
(-[MockDataInteractionSession initWithWindow:]): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219271 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/DragController.cpp
Source/WebCore/page/DragController.h
Source/WebCore/page/mac/DragControllerMac.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h
Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/file-uploading.html
Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm
Tools/TestWebKitAPI/ios/DataInteractionSimulator.h
Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm