Make DataTransferItemList work with plain text entries
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Aug 2017 02:23:41 +0000 (02:23 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Aug 2017 02:23:41 +0000 (02:23 +0000)
commit1b8181eaecc34e3338f800a2f7df8916713f1694
tree447a78ffda4031c41bfff9b2ceabac8739342d05
parent881de6913b28c8053f9a2ad88cb340bc84390619
Make DataTransferItemList work with plain text entries
https://bugs.webkit.org/show_bug.cgi?id=175596

Reviewed by Wenson Hsieh.

Source/JavaScriptCore:

Added DataTransferItem as a common identifier since it's a runtime enabled feature.

* runtime/CommonIdentifiers.h:

Source/WebCore:

Added the basic machinery to get the list of plain text items to DataTransferItemList and DataTransferItem.

Each DataTransferItem now depends on DataTransfer so it does ref-forwarding like DataTransferItemList to make
DataTransfer alive as long as any DataTransferItem is alive.

Specifications: https://html.spec.whatwg.org/multipage/dnd.html#the-datatransferitem-interface
                https://html.spec.whatwg.org/multipage/dnd.html#the-datatransferitemlist-interface

Tests: editing/pasteboard/datatransfer-items-drop-plaintext-file.html
       editing/pasteboard/datatransfer-items-paste-plaintext.html

* dom/DataTransferItem.cpp:
(WebCore::DataTransferItem::DataTransferItem): Added two variants one for plain text and another one for a file.
(WebCore::DataTransferItem::kind const): Rewritten.
(WebCore::DataTransferItem::getAsString const): Implemented.
(WebCore::DataTransferItem::getAsFile const): Implemented.
* dom/DataTransferItem.h:
(WebCore::DataTransferItem::ref): Added.
(WebCore::DataTransferItem::deref): Added.
(WebCore::DataTransferItem::type const): Returns String instead of AtomicString.
(WebCore::DataTransferItem::kind const): Moved to cpp.
* dom/DataTransferItem.idl: Removed NoInterfaceObject since the interface object should exist on DOMWindow.
* dom/DataTransferItemList.cpp:
(WebCore::DataTransferItemList::length): Implemented.
(WebCore::DataTransferItemList::item): Ditto.
(WebCore::isSupportedType): Added. For now, we only support text/plain.
(WebCore::DataTransferItemList::ensureItems): Added. Constructs the list of DataTransferItems.
* dom/DataTransferItemList.h:
(DataTransferItemList): Added m_items. The list is filled lazily by ensureItems.
* dom/DataTransferItemList.idl: Removed NoInterfaceObject since the interface object should exist on DOMWindow.

LayoutTests:

Rebaselined the tests and added two regression tests for pasting plain text and dropping a plain text file.

Unfortunately, dropping a file is only supported by DumpRenderTree on Mac :( so it's disabled elsewhere.

* editing/pasteboard/datatransfer-idl-expected.txt: Rebaselined now that NoInterfaceObject has been dropped from
DataTransferItem.idl and DataTransferItemList.idl as expected.
* editing/pasteboard/datatransfer-idl.html: Fixed the bug that it wasn't testing IDL for DataTransferItem.
* editing/pasteboard/datatransfer-items-drop-plaintext-file-expected.txt: Added.
* editing/pasteboard/datatransfer-items-drop-plaintext-file.html: Added.
* editing/pasteboard/datatransfer-items-paste-plaintext-expected.txt: Added.
* editing/pasteboard/datatransfer-items-paste-plaintext.html: Added.
* editing/resources/text-pasteboard-data.txt: Added.
* platform/gtk/js/dom/global-constructors-attributes-expected.txt:
* platform/ios/TestExpectations:
* platform/mac-elcapitan-wk2/js/dom/global-constructors-attributes-expected.txt:
* platform/mac-elcapitan/js/dom/global-constructors-attributes-expected.txt:
* platform/mac-highsierra-wk1/js/dom/global-constructors-attributes-expected.txt:
* platform/mac-highsierra/js/dom/global-constructors-attributes-expected.txt:
* platform/mac/js/dom/global-constructors-attributes-expected.txt:
* platform/win/TestExpectations:
* platform/wk2/TestExpectations:
* platform/wpe/js/dom/global-constructors-attributes-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220782 268f45cc-cd09-0410-ab3c-d52691b4dbfc
27 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/pasteboard/datatransfer-idl-expected.txt
LayoutTests/editing/pasteboard/datatransfer-idl.html
LayoutTests/editing/pasteboard/datatransfer-items-drop-plaintext-file-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/datatransfer-items-drop-plaintext-file.html [new file with mode: 0644]
LayoutTests/editing/pasteboard/datatransfer-items-paste-plaintext-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/datatransfer-items-paste-plaintext.html [new file with mode: 0644]
LayoutTests/editing/resources/text-pasteboard-data.txt [new file with mode: 0644]
LayoutTests/platform/gtk/js/dom/global-constructors-attributes-expected.txt
LayoutTests/platform/ios/TestExpectations
LayoutTests/platform/mac-elcapitan-wk2/js/dom/global-constructors-attributes-expected.txt
LayoutTests/platform/mac-elcapitan/js/dom/global-constructors-attributes-expected.txt
LayoutTests/platform/mac-highsierra-wk1/js/dom/global-constructors-attributes-expected.txt
LayoutTests/platform/mac-highsierra/js/dom/global-constructors-attributes-expected.txt
LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt
LayoutTests/platform/win/TestExpectations
LayoutTests/platform/wk2/TestExpectations
LayoutTests/platform/wpe/js/dom/global-constructors-attributes-expected.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/CommonIdentifiers.h
Source/WebCore/ChangeLog
Source/WebCore/dom/DataTransferItem.cpp
Source/WebCore/dom/DataTransferItem.h
Source/WebCore/dom/DataTransferItem.idl
Source/WebCore/dom/DataTransferItemList.cpp
Source/WebCore/dom/DataTransferItemList.h
Source/WebCore/dom/DataTransferItemList.idl