Add DataTransferItems support for drag-and-drop'ed files and texts
authorkinuko@chromium.org <kinuko@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jan 2012 12:08:56 +0000 (12:08 +0000)
committerkinuko@chromium.org <kinuko@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jan 2012 12:08:56 +0000 (12:08 +0000)
commitab9a9d3046868151354f6e4aaeb7ad2f47728515
tree86f84837fa43ac4633545d97201cbe57433b77bc
parent7971ed457f5db47cb77bf04d3d6a6fc20f46cc9d
Add DataTransferItems support for drag-and-drop'ed files and texts
https://bugs.webkit.org/show_bug.cgi?id=76367

Reviewed by Tony Chang.

WebKit-svn:

* ManualTests/data-transfer-items-file-dragout.html: Added.
* ManualTests/resources/test:lorem-text.html: Added.

WebKit-svn/LayoutTests:

* editing/pasteboard/data-transfer-items-drag-drop-file-expected.txt: Added.
* editing/pasteboard/data-transfer-items-drag-drop-file.html: Added.
* editing/pasteboard/data-transfer-items-drag-drop-string-expected.txt: Added.
* editing/pasteboard/data-transfer-items-drag-drop-string.html: Added.
* platform/gtk/Skipped: Added the new tests as the platform does not support dataTransferItems yet.
* platform/mac/Skipped: Ditto.
* platform/qt/Skipped: Ditto.
* platform/win/Skipped: Ditto.

WebKit-svn/Source/WebCore:

Per http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#the-datatransfer-interface
the new interface should also support drag-and-dropped files and texts in
addition to pasted texts/images.  The user apps should also be able to add
texts/files to the drag store by calling event.dataTransfer.items.add().

This patch adds drag-and-drop'ed items support in DataTransferItem and
DataTransferItemList so that they work for dropped files and texts (as well as
the copy-pasted texts/images).

This patch also adds customized toJS()/toV8() code to Blob/File javascript
binding so that the JS code can get either Blob or File underlying object
where the API returns Blob. This change is necessary since we return Blob
from DataTransferItem.getAsFile() for pasted images but want to return File
for dropped files.

Tests: editing/pasteboard/data-transfer-items-drag-drop-file.html
       editing/pasteboard/data-transfer-items-drag-drop-string.html

* GNUmakefile.list.am: Added entries for the new {JS,V8}BlobCustom.
* Target.pri: Ditto.
* UseJSC.cmake: Ditto.
* WebCore.gypi: Ditto.
* bindings/js/JSBindingsAllInOne.cpp: Ditto.
* bindings/js/JSBlobCustom.cpp: Added toJS custom code that returns File or
Blob depending on the return value of isFile().
(WebCore::toJS):
* bindings/v8/custom/V8BlobCustom.cpp: Added toV8 custom code.
(WebCore::toV8):
* dom/DataTransferItem.h: Added a new create() method which takes File.
* dom/DataTransferItemList.cpp: Added add(File) method.
(WebCore::DataTransferItemList::add):
* dom/DataTransferItemList.h: Ditto.
* dom/DataTransferItemList.idl: Ditto.
* fileapi/Blob.idl: Added CustomToJS for toJS/toV8.
* platform/chromium/ClipboardChromium.cpp: Added code for drag-and-drop'ed items.
(WebCore::ClipboardChromium::items): Revised.
(WebCore::ClipboardChromium::mayUpdateItems): Added.
(WebCore::ClipboardChromium::isStorageUpdated): Added.
* platform/chromium/ClipboardChromium.h:
* platform/chromium/DataTransferItemChromium.cpp: Added a new constructor that
takes File and updated getAsFile() to make it support dropped files.
(WebCore::DataTransferItem::create):
(WebCore::DataTransferItemChromium::DataTransferItemChromium):
(WebCore::DataTransferItemChromium::getAsFile):
* platform/chromium/DataTransferItemChromium.h:
* platform/chromium/DataTransferItemListChromium.cpp:
(WebCore::DataTransferItemListChromium::addInternalItem):
* platform/chromium/DataTransferItemListChromium.cpp: Added overrides implementation for m_item accessors to make them reflect the changes in the owner clipboard.
(WebCore::DataTransferItemListChromium::length):
(WebCore::DataTransferItemListChromium::item):
(WebCore::DataTransferItemListChromium::deleteItem):
(WebCore::DataTransferItemListChromium::clear):
(WebCore::DataTransferItemListChromium::add):
(WebCore::DataTransferItemListChromium::mayUpdateItems): Added.
* platform/qt/DataTransferItemQt.cpp: Added a new constructor that takes File and updated
getAsFile() to make it support dropped files.
(WebCore::DataTransferItem::create):
(WebCore::DataTransferItemQt::DataTransferItemQt):
(WebCore::DataTransferItemQt::getAsFile):
* platform/qt/DataTransferItemQt.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@105506 268f45cc-cd09-0410-ab3c-d52691b4dbfc
38 files changed:
ChangeLog
LayoutTests/ChangeLog
LayoutTests/editing/pasteboard/data-transfer-items-drag-drop-file-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/data-transfer-items-drag-drop-file.html [new file with mode: 0644]
LayoutTests/editing/pasteboard/data-transfer-items-drag-drop-string-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/data-transfer-items-drag-drop-string.html [new file with mode: 0644]
LayoutTests/editing/pasteboard/data-transfer-items-expected.txt
LayoutTests/platform/gtk/Skipped
LayoutTests/platform/mac/Skipped
LayoutTests/platform/qt/Skipped
LayoutTests/platform/win/Skipped
ManualTests/data-transfer-items-file-dragout.html [new file with mode: 0644]
ManualTests/resources/test:lorem-text.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/UseJSC.cmake
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
Source/WebCore/bindings/js/JSBlobCustom.cpp [new file with mode: 0644]
Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp [new file with mode: 0644]
Source/WebCore/dom/DataTransferItem.h
Source/WebCore/dom/DataTransferItemList.cpp
Source/WebCore/dom/DataTransferItemList.h
Source/WebCore/dom/DataTransferItemList.idl
Source/WebCore/fileapi/Blob.idl
Source/WebCore/platform/chromium/ChromiumDataObject.cpp
Source/WebCore/platform/chromium/ChromiumDataObject.h
Source/WebCore/platform/chromium/ClipboardChromium.cpp
Source/WebCore/platform/chromium/ClipboardChromium.h
Source/WebCore/platform/chromium/DataTransferItemChromium.cpp
Source/WebCore/platform/chromium/DataTransferItemChromium.h
Source/WebCore/platform/chromium/DataTransferItemListChromium.cpp
Source/WebCore/platform/chromium/DataTransferItemListChromium.h
Source/WebCore/platform/qt/DataTransferItemQt.cpp
Source/WebCore/platform/qt/DataTransferItemQt.h