[Mac] Number of drop items is always 0 when performing a DHTML drag
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Apr 2018 18:35:43 +0000 (18:35 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Apr 2018 18:35:43 +0000 (18:35 +0000)
commitc032387bcc7aa274376f3ec70daf5b1f0c328458
tree5ed0d2712ce44baf903f3d92d49b57046ee6b39f
parentac00c7b882fb9e44aa28a7f622c38cfccb260b01
[Mac] Number of drop items is always 0 when performing a DHTML drag
https://bugs.webkit.org/show_bug.cgi?id=184943

Reviewed by Ryosuke Niwa.

Source/WebCore:

New API test: DragAndDropPasteboardTests.NumberOfValidItemsForDrop

DragController tracks the number of items to be accepted by a file input element, taking
into account whether the control is disabled or accepts multiple files. When this number
changes, WebKit informs the NSDraggingInfo-conforming object passed to -draggingUpdated by
calling -setNumberOfValidItemsForDrop:. This number is presented to the user in a badge
rendered next to the dragging item thumbnails.

When performing a DHTML drag, we don't know how many items the page will accept, so prior
to this patch we would render a "0" in the badge. This is misleading, because the page is
more likely to accept all the items (or at least one of them) rather than none of them.

Let's do the straightforward thing and set numberOfValidItemsForDrop to equal the number of
files in the drag operation when performing a DHTML file drag.

* page/DragController.cpp:
(WebCore::DragController::tryDocumentDrag):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/mac/DragAndDropPasteboardTests.mm:
(-[DragInfo numberOfValidItemsForDrop]):
(-[DragInfo setNumberOfValidItemsForDrop:]):
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/mac/full-page-dropzone.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231003 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/page/DragController.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/mac/DragAndDropPasteboardTests.mm
Tools/TestWebKitAPI/Tests/mac/full-page-dropzone.html [new file with mode: 0644]