Summary: | single-file input elements should refuse multi-file drags | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Eric Seidel (no email) <eric> | ||||||||
Component: | Forms | Assignee: | Rakesh <rakeshchaitan> | ||||||||
Status: | RESOLVED FIXED | ||||||||||
Severity: | Normal | CC: | adele, ap, jonlee, oliver, rakeshchaitan, sam, webkit.review.bot | ||||||||
Priority: | P2 | ||||||||||
Version: | 528+ (Nightly build) | ||||||||||
Hardware: | Mac | ||||||||||
OS: | OS X 10.5 | ||||||||||
Bug Depends on: | 25879, 25924 | ||||||||||
Bug Blocks: | |||||||||||
Attachments: |
|
Description
Eric Seidel (no email)
2009-05-21 00:49:42 PDT
The check which needs to change here is in: bool DragController::canProcessDrag(DragData* dragData) if (dragData->containsFiles() && asFileInput(result.innerNonSharedNode())) return true; probably we should pass the DragData off to the HTMLInputElement and ask it if it can handle the drag. DragData will need to be extended to be able to return the number of files on the clipboard for HTMLInputElement to be able to make this decision. Created attachment 118761 [details]
Proposed patch
Refuse the multiple file drags on single-file input element. Setting the dragSession.operation as DragOperationNone when input element is multiple and number of files are more than 1. I think DragController::canProcessDrag may not be the right place to refuse the drag as if canProcessDrag fails then tryDocumentDrag will fail which may lead to the loading of the file in the browser.
Comment on attachment 118761 [details] Proposed patch View in context: https://bugs.webkit.org/attachment.cgi?id=118761&action=review > Source/WebCore/page/DragController.cpp:358 > + if (!dragSession.numberOfItemsToBeAccepted || (!m_fileInputElementUnderMouse->multiple() && (numberOfFiles > 1))) Although this is correct, I think it would be better to move this check into the if..else chain starting in line 351 (as penultimate "else if" check). This way the check for setting the operation to None remains simple and comprehensible. Created attachment 118960 [details]
Updated patch
Check moved to if...else chain.
Comment on attachment 118960 [details] Updated patch View in context: https://bugs.webkit.org/attachment.cgi?id=118960&action=review > Source/WebCore/page/DragController.cpp:355 > + else if (!m_fileInputElementUnderMouse->multiple() && (numberOfFiles > 1)) The first check is unnecessary. By this point we already know that the file input is not multiple. Created attachment 119069 [details]
Updated Patch
Modified if check.
Comment on attachment 119069 [details]
Updated Patch
Seems good to me. I believe Oliver has also worked in drag and drop more recently than I.
Did you test against any operating systems?
(In reply to comment #7) > (From update of attachment 119069 [details]) > Seems good to me. I believe Oliver has also worked in drag and drop more recently than I. > > Did you test against any operating systems? This fix works fine on MAC and GTK. On Windows DragData::numberOfFiles() returns 0, so this fix does not have any effect on Windows. Comment on attachment 119069 [details]
Updated Patch
LGTM.
Comment on attachment 119069 [details] Updated Patch Clearing flags on attachment: 119069 Committed r106301: <http://trac.webkit.org/changeset/106301> All reviewed patches have been landed. Closing bug. |