Add initial support for dataTransferItem.webkitGetAsEntry()
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Aug 2017 17:00:09 +0000 (17:00 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Aug 2017 17:00:09 +0000 (17:00 +0000)
commit858ee5f4461a06ae527aeb1b2248d233e8de3f08
treed8467d8ad45091501098ea6e76e7b4ed55e77be0
parent919bdcf5293cdad96e6881edcec13cd7868d0459
Add initial support for dataTransferItem.webkitGetAsEntry()
https://bugs.webkit.org/show_bug.cgi?id=176038
<rdar://problem/34121095>

Reviewed by Wenson Hsieh.

Source/JavaScriptCore:

Add CommonIdentifier needed by [EnabledAtRuntime].

* runtime/CommonIdentifiers.h:

Source/WebCore:

Add initial support for dataTransferItem.webkitGetAsEntry() as per:
- https://wicg.github.io/entries-api/#html-data

The method works as expected and returns a FileSystemEntry. The entry
can be either a file or a directory. All of the attributes exposed on
the FileSystemEntry return correct values.

What remains to be implemented for this new API to actually be useful:
- directory.getFile() / directory.getDirectory()
- file.file()
- entry.getParent()
- directoryReader.readEntries()

Test: editing/pasteboard/datatransfer-items-drop-getAsEntry.html

* CMakeLists.txt:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSBindingsAllInOne.cpp:
Add new files to projects.

* Modules/entriesapi/DOMFileSystem.cpp:
(WebCore::DOMFileSystem::DOMFileSystem):
* Modules/entriesapi/DOMFileSystem.h:
(WebCore::DOMFileSystem::create):
DOMFileSystem factory now takes a name parameter. This name is a UUID, as suggested in
the specification and implemented by Firefox.

* Modules/entriesapi/ErrorCallback.cpp: Added.
* Modules/entriesapi/ErrorCallback.h:
Add scheduleCallback() convenience method as we often need to call this callback
asynchronously.

* Modules/entriesapi/FileSystemDirectoryEntry.cpp:
(WebCore::FileSystemDirectoryEntry::FileSystemDirectoryEntry):
(WebCore::FileSystemDirectoryEntry::createReader):
(WebCore::FileSystemDirectoryEntry::getFile):
(WebCore::FileSystemDirectoryEntry::getDirectory):
* Modules/entriesapi/FileSystemDirectoryEntry.h:
- Add implementation for createReader().
- Update getFile() / getDirectory() to call the error callback for now as they are
  unimplemented.
- Have the factory take the virtual path of the entry so that it can be
  exposed via the fullPath attribute in IDL.

* Modules/entriesapi/FileSystemDirectoryEntry.idl:
Expose createReader() now that we have stubs for FileSystemDirectoryReader.

* Modules/entriesapi/FileSystemDirectoryReader.cpp: Added.
* Modules/entriesapi/FileSystemDirectoryReader.h: Added.
* Modules/entriesapi/FileSystemDirectoryReader.idl: Added.
* Modules/entriesapi/FileSystemEntriesCallback.cpp: Added.
* Modules/entriesapi/FileSystemEntriesCallback.h: Added.
* Modules/entriesapi/FileSystemEntriesCallback.idl: Added.
Land stubs for FileSystemDirectoryReader and its FileSystemEntriesCallback.

* Modules/entriesapi/FileSystemEntry.cpp:
(WebCore::FileSystemEntry::FileSystemEntry):
* Modules/entriesapi/FileSystemEntry.h:
(WebCore::FileSystemEntry::virtualPath const):
* Modules/entriesapi/FileSystemEntry.idl:
Update constructor to take a virtual path, which is exposed via fullPath
attribute in IDL.

* Modules/entriesapi/FileSystemFileEntry.cpp:
(WebCore::FileSystemFileEntry::FileSystemFileEntry):
(WebCore::FileSystemFileEntry::file):
* Modules/entriesapi/FileSystemFileEntry.h:
(isType):
* Modules/entriesapi/FileSystemFileEntry.idl:
- Update file() to call the error callback for now as they are
  unimplemented.
- Have the factory take the virtual path of the entry so that it can be
  exposed via the fullPath attribute in IDL.

* bindings/js/JSFileSystemEntryCustom.cpp: Added.
(WebCore::toJSNewlyCreated):
(WebCore::toJS):
Add custom implementation of FileSystemEntry's toJS() function. This is
needed because FileSystemEntry has 2 subclasses and we need to type check
at runtime to construct the right wrapper.

* dom/DataTransferItem.cpp:
(WebCore::DataTransferItem::getAsEntry const):
* dom/DataTransferItem.h:
* dom/DataTransferItem.idl:
Add initial implementation for getAsEntry(), currently exposed as
webkitGetAsEntry().

* dom/DataTransferItemList.cpp:
(WebCore::DataTransferItemList::ensureItems const):
Construct a DataTransferItem if the file is a directory now that we
support getAsEntry().

* fileapi/File.cpp:
(WebCore::File::isDirectory const):
* fileapi/File.h:
Add convenience method to query if a File is a directory.

Source/WebKit:

Make dataTransfer.items an experimental feature so that it can be easily
turned on from the Develop menu, for testing convenience.

* Shared/WebPreferencesDefinitions.h:

LayoutTests:

* editing/pasteboard/datatransfer-items-drop-getAsEntry-expected.txt: Added.
* editing/pasteboard/datatransfer-items-drop-getAsEntry.html: Added.
Add layout test coverage.

* http/wpt/entries-api/interfaces-expected.txt:
Rebaseline test now that we support more of the API.

* platform/wk2/TestExpectations:
Skip new test on WK2 because it relies on beginDragWithFiles().

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221302 268f45cc-cd09-0410-ab3c-d52691b4dbfc
40 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/pasteboard/datatransfer-items-drop-getAsEntry-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/datatransfer-items-drop-getAsEntry.html [new file with mode: 0644]
LayoutTests/http/wpt/entries-api/interfaces-expected.txt
LayoutTests/platform/wk2/TestExpectations
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/CommonIdentifiers.h
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp
Source/WebCore/Modules/entriesapi/DOMFileSystem.h
Source/WebCore/Modules/entriesapi/ErrorCallback.cpp [new file with mode: 0644]
Source/WebCore/Modules/entriesapi/ErrorCallback.h
Source/WebCore/Modules/entriesapi/FileSystemDirectoryEntry.cpp
Source/WebCore/Modules/entriesapi/FileSystemDirectoryEntry.h
Source/WebCore/Modules/entriesapi/FileSystemDirectoryEntry.idl
Source/WebCore/Modules/entriesapi/FileSystemDirectoryReader.cpp [new file with mode: 0644]
Source/WebCore/Modules/entriesapi/FileSystemDirectoryReader.h [new file with mode: 0644]
Source/WebCore/Modules/entriesapi/FileSystemDirectoryReader.idl [new file with mode: 0644]
Source/WebCore/Modules/entriesapi/FileSystemEntriesCallback.cpp [new file with mode: 0644]
Source/WebCore/Modules/entriesapi/FileSystemEntriesCallback.h [new file with mode: 0644]
Source/WebCore/Modules/entriesapi/FileSystemEntriesCallback.idl [new file with mode: 0644]
Source/WebCore/Modules/entriesapi/FileSystemEntry.cpp
Source/WebCore/Modules/entriesapi/FileSystemEntry.h
Source/WebCore/Modules/entriesapi/FileSystemEntry.idl
Source/WebCore/Modules/entriesapi/FileSystemFileEntry.cpp
Source/WebCore/Modules/entriesapi/FileSystemFileEntry.h
Source/WebCore/Modules/entriesapi/FileSystemFileEntry.idl
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
Source/WebCore/bindings/js/JSFileSystemEntryCustom.cpp [new file with mode: 0644]
Source/WebCore/dom/DataTransferItem.cpp
Source/WebCore/dom/DataTransferItem.h
Source/WebCore/dom/DataTransferItem.idl
Source/WebCore/dom/DataTransferItemList.cpp
Source/WebCore/fileapi/File.cpp
Source/WebCore/fileapi/File.h
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebPreferencesDefinitions.h