File inputs only accept UTI types that can be inserted into contenteditable areas...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 23 Apr 2017 03:52:12 +0000 (03:52 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 23 Apr 2017 03:52:12 +0000 (03:52 +0000)
commit03e074730f31cfd0e7cb1dadb587185e4ebbdc51
tree0557233ebaebd363ac7ad07a0005bcdce2a37b8e
parenta06cc40ec2dfd82c96aa1b072687fcb60f594c17
File inputs only accept UTI types that can be inserted into contenteditable areas when dropping
https://bugs.webkit.org/show_bug.cgi?id=171177
<rdar://problem/31765379>

Reviewed by Andy Estes.

Source/WebCore:

Currently, DragController::canProcessDrag bails immediately with `false` if the drag data does not contain
compatible content. However, if we are dragging over a file input, we want the presence of files in the drag
data to take priority. To fix this, we teach DragData::containsCompatibleContent to take the purpose of the drag
into account (by default, this is Editing, but when dragging over a file input, this becomes FileUpload). We
then consider DragData to have compatible content for the purpose of file uploading if it contains any files.

Test: DataInteractionTests.ExternalSourceJSONToFileInput.

* page/DragController.cpp:
(WebCore::DragController::canProcessDrag):
* platform/DragData.h:
* platform/gtk/DragDataGtk.cpp:
(WebCore::DragData::containsCompatibleContent):
* platform/mac/DragDataMac.mm:
(WebCore::DragData::containsCompatibleContent):
* platform/win/DragDataWin.cpp:
(WebCore::DragData::containsCompatibleContent):

Tools:

Tests uploading a JSON file to a file input.

* TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
(TestWebKitAPI::TEST):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@215669 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/page/DragController.cpp
Source/WebCore/platform/DragData.h
Source/WebCore/platform/gtk/DragDataGtk.cpp
Source/WebCore/platform/mac/DragDataMac.mm
Source/WebCore/platform/win/DragDataWin.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm