Title: [221177] trunk
Revision
221177
Author
cdu...@apple.com
Date
2017-08-24 19:05:54 -0700 (Thu, 24 Aug 2017)

Log Message

[Directory Upload] Add basic support for input.webkitdirectory
https://bugs.webkit.org/show_bug.cgi?id=175950
<rdar://problem/33951915>

Reviewed by Geoffrey Garen.

Source/WebCore:

Add basic support for input.webkitdirectory attribute, as per:
- https://wicg.github.io/entries-api/#html-forms

The following is supported:
- input.webkitdirectory IDL and content attributes
- The webkitdirectory content attribute is properly consulted
  to communicate to the client that the file picker should
  allow selecting directories.
- When WebCore gets the list of selected files from the file picker,
  it properly resolves folders in a background thread to properly
  initialize input.files before firing the 'change' event at the
  input element.
- When resolving files in a directory, we ignore both hidden files and
  symbolic links for security reasons. I did not check symlinks but Firefox
  and Chrome both seem to upload hidden files (such as .DS_Store files).
- File.webkitRelativePath IDL attribute is properly populated for
  files coming from a selected directory.
- Form submission just works because it relies on input.files being
  properly populated. No change needed in this area.

What is not supported:
- input.webkitEntries IDL attribute.
- FileSystemEntry / FileSystemDirectoryEntry / FileSystemDirectoryReader
  /  FileSystemFileEntry / FileSystem IDL interfaces.
- dataTransferItem.webkitGetAsEntry() for proper drag and drop support.

Those will be taken care of in follow-up patches.

The feature is currently behind an experimental feature flag, disabled by
default.

Tests: fast/forms/file/webkitdirectory-drag-folder.html
       fast/forms/file/webkitdirectory-open-panel.html

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* fileapi/File.cpp:
(WebCore::File::createWithRelativePath):
* fileapi/File.h:
* fileapi/File.idl:
* html/FileInputType.cpp:
(WebCore::FileInputType::~FileInputType):
(WebCore::FileInputType::handleDOMActivateEvent):
(WebCore::FileInputType::allowsDirectories const):
(WebCore::FileInputType::filesChosen):
* html/FileInputType.h:
* html/FileListCreator.cpp: Added.
(WebCore::appendDirectoryFiles):
(WebCore::FileListCreator::FileListCreator):
(WebCore::FileListCreator::createFileList):
(WebCore::FileListCreator::cancel):
* html/FileListCreator.h: Copied from Source/WebKit/UIProcess/API/APIOpenPanelParameters.h.
(WebCore::FileListCreator::create):
* html/HTMLAttributeNames.in:
* html/HTMLInputElement.idl:
* page/Settings.in:
* platform/FileChooser.h:
(WebCore::FileChooserFileInfo::isolatedCopy const):
* platform/FileMetadata.h:
* platform/FileSystem.cpp:
(WebCore::fileIsDirectory):
* platform/FileSystem.h:
* platform/glib/FileSystemGlib.cpp:
(WebCore::getFileMetadata):
* platform/posix/FileSystemPOSIX.cpp:
(WebCore::getFileMetadata):
* platform/win/FileSystemWin.cpp:
(WebCore::getFileMetadata):

Source/WebKit:

Add private API to toggle Directory Upload support.

Add new member to WKOpenPanelParameters to communicate to the
client that the file picker should allow selecting directories.

* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<FileChooserSettings>::encode):
(IPC::ArgumentCoder<FileChooserSettings>::decode):
* Shared/WebPreferencesDefinitions.h:
* UIProcess/API/APIOpenPanelParameters.h:
(API::OpenPanelParameters::allowDirectories const):
* UIProcess/API/C/WKOpenPanelParametersRef.cpp:
(WKOpenPanelParametersGetAllowsDirectories):
* UIProcess/API/C/WKOpenPanelParametersRef.h:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetDirectoryUploadEnabled):
(WKPreferencesGetDirectoryUploadEnabled):
* UIProcess/API/C/WKPreferencesRefPrivate.h:
* UIProcess/API/Cocoa/WKOpenPanelParameters.h:
* UIProcess/API/Cocoa/WKOpenPanelParameters.mm:
(-[WKOpenPanelParameters allowsDirectories]):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):

Source/WebKitLegacy/mac:

Add private API to toggle Directory Upload support on Mac WebKit1.

* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(+[WebPreferences initialize]):
(-[WebPreferences setDirectoryUploadEnabled:]):
(-[WebPreferences directoryUploadEnabled]):
* WebView/WebPreferencesPrivate.h:
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):

Tools:

* DumpRenderTree/mac/DumpRenderTree.mm:
(resetWebPreferencesToConsistentValues):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetPreferencesToConsistentValues):
Enable Directory Upload feature for testing, given that it is currently disabled by default.

(WTR::runOpenPanel):
Print additional text when directories are allowed to extend testing coverage.

LayoutTests:

Add layout test coverage for input.webkitdirectory. It covers both
the file picker and the drag and drop code paths.

* fast/forms/file/resources/testFiles/file1.txt: Added.
* fast/forms/file/resources/testFiles/file2.txt: Added.
* fast/forms/file/resources/testFiles/subfolder1/file3.txt: Added.
* fast/forms/file/resources/testFiles/subfolder2/file4.txt: Added.
* fast/forms/file/resources/testFiles/subfolder2/subfolder2a/file5.txt: Added.
* fast/forms/file/webkitdirectory-drag-folder-expected.txt: Added.
* fast/forms/file/webkitdirectory-drag-folder.html: Added.
* fast/forms/file/webkitdirectory-open-panel-expected.txt: Added.
* fast/forms/file/webkitdirectory-open-panel.html: Added.
* platform/mac-wk1/fast/forms/file/webkitdirectory-open-panel-expected.txt: Added.
* platform/wk2/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (221176 => 221177)


--- trunk/LayoutTests/ChangeLog	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/LayoutTests/ChangeLog	2017-08-25 02:05:54 UTC (rev 221177)
@@ -1,3 +1,26 @@
+2017-08-24  Chris Dumez  <cdu...@apple.com>
+
+        [Directory Upload] Add basic support for input.webkitdirectory
+        https://bugs.webkit.org/show_bug.cgi?id=175950
+        <rdar://problem/33951915>
+
+        Reviewed by Geoffrey Garen.
+
+        Add layout test coverage for input.webkitdirectory. It covers both
+        the file picker and the drag and drop code paths.
+
+        * fast/forms/file/resources/testFiles/file1.txt: Added.
+        * fast/forms/file/resources/testFiles/file2.txt: Added.
+        * fast/forms/file/resources/testFiles/subfolder1/file3.txt: Added.
+        * fast/forms/file/resources/testFiles/subfolder2/file4.txt: Added.
+        * fast/forms/file/resources/testFiles/subfolder2/subfolder2a/file5.txt: Added.
+        * fast/forms/file/webkitdirectory-drag-folder-expected.txt: Added.
+        * fast/forms/file/webkitdirectory-drag-folder.html: Added.
+        * fast/forms/file/webkitdirectory-open-panel-expected.txt: Added.
+        * fast/forms/file/webkitdirectory-open-panel.html: Added.
+        * platform/mac-wk1/fast/forms/file/webkitdirectory-open-panel-expected.txt: Added.
+        * platform/wk2/TestExpectations:
+
 2017-08-24  Ryan Haddad  <ryanhad...@apple.com>
 
         Unreviewed, rolling out r221139.

Added: trunk/LayoutTests/fast/forms/file/resources/testFiles/file1.txt (0 => 221177)


--- trunk/LayoutTests/fast/forms/file/resources/testFiles/file1.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/file/resources/testFiles/file1.txt	2017-08-25 02:05:54 UTC (rev 221177)
@@ -0,0 +1 @@
+1

Added: trunk/LayoutTests/fast/forms/file/resources/testFiles/file2.txt (0 => 221177)


--- trunk/LayoutTests/fast/forms/file/resources/testFiles/file2.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/file/resources/testFiles/file2.txt	2017-08-25 02:05:54 UTC (rev 221177)
@@ -0,0 +1 @@
+2

Added: trunk/LayoutTests/fast/forms/file/resources/testFiles/subfolder1/file3.txt (0 => 221177)


--- trunk/LayoutTests/fast/forms/file/resources/testFiles/subfolder1/file3.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/file/resources/testFiles/subfolder1/file3.txt	2017-08-25 02:05:54 UTC (rev 221177)
@@ -0,0 +1 @@
+3

Added: trunk/LayoutTests/fast/forms/file/resources/testFiles/subfolder2/file4.txt (0 => 221177)


--- trunk/LayoutTests/fast/forms/file/resources/testFiles/subfolder2/file4.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/file/resources/testFiles/subfolder2/file4.txt	2017-08-25 02:05:54 UTC (rev 221177)
@@ -0,0 +1 @@
+4

Added: trunk/LayoutTests/fast/forms/file/resources/testFiles/subfolder2/subfolder2a/file5.txt (0 => 221177)


--- trunk/LayoutTests/fast/forms/file/resources/testFiles/subfolder2/subfolder2a/file5.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/file/resources/testFiles/subfolder2/subfolder2a/file5.txt	2017-08-25 02:05:54 UTC (rev 221177)
@@ -0,0 +1 @@
+5

Added: trunk/LayoutTests/fast/forms/file/webkitdirectory-drag-folder-expected.txt (0 => 221177)


--- trunk/LayoutTests/fast/forms/file/webkitdirectory-drag-folder-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/file/webkitdirectory-drag-folder-expected.txt	2017-08-25 02:05:54 UTC (rev 221177)
@@ -0,0 +1,21 @@
+Tests dragging a folder onto a file input with webkitdirectory set.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS inputElement.webkitdirectory is true
+PASS fileList.length is 5
+PASS fileList[0].name is "file1.txt"
+PASS fileList[0].webkitRelativePath is "testFiles/file1.txt"
+PASS fileList[1].name is "file2.txt"
+PASS fileList[1].webkitRelativePath is "testFiles/file2.txt"
+PASS fileList[2].name is "file3.txt"
+PASS fileList[2].webkitRelativePath is "testFiles/subfolder1/file3.txt"
+PASS fileList[3].name is "file4.txt"
+PASS fileList[3].webkitRelativePath is "testFiles/subfolder2/file4.txt"
+PASS fileList[4].name is "file5.txt"
+PASS fileList[4].webkitRelativePath is "testFiles/subfolder2/subfolder2a/file5.txt"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/forms/file/webkitdirectory-drag-folder.html (0 => 221177)


--- trunk/LayoutTests/fast/forms/file/webkitdirectory-drag-folder.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/file/webkitdirectory-drag-folder.html	2017-08-25 02:05:54 UTC (rev 221177)
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<input type="file" _onchange_="changed(event)" webkitdirectory></input>
+<script>
+description("Tests dragging a folder onto a file input with webkitdirectory set.");
+jsTestIsAsync = true;
+
+function runTest()
+{
+    inputElement = document.getElementsByTagName('input')[0];
+    shouldBeTrue("inputElement.webkitdirectory");
+    dragFilesOntoInput(inputElement, ['resources/testFiles']);
+}
+
+function moveMouseToCenterOfElement(element) {
+    var centerX = element.offsetLeft + element.offsetWidth / 2;
+    var centerY = element.offsetTop + element.offsetHeight / 2;
+    eventSender.mouseMoveTo(centerX, centerY);
+}
+
+function dragFilesOntoInput(input, files) {
+    eventSender.beginDragWithFiles(files);
+    moveMouseToCenterOfElement(input);
+    eventSender.mouseUp();
+}
+
+function changed(event)
+{
+    fileList = event.target.files;
+    shouldBe("fileList.length", "5");
+    shouldBeEqualToString("fileList[0].name", "file1.txt");
+    shouldBeEqualToString("fileList[0].webkitRelativePath", "testFiles/file1.txt");
+    shouldBeEqualToString("fileList[1].name", "file2.txt");
+    shouldBeEqualToString("fileList[1].webkitRelativePath", "testFiles/file2.txt");
+    shouldBeEqualToString("fileList[2].name", "file3.txt");
+    shouldBeEqualToString("fileList[2].webkitRelativePath", "testFiles/subfolder1/file3.txt");
+    shouldBeEqualToString("fileList[3].name", "file4.txt");
+    shouldBeEqualToString("fileList[3].webkitRelativePath", "testFiles/subfolder2/file4.txt");
+    shouldBeEqualToString("fileList[4].name", "file5.txt");
+    shouldBeEqualToString("fileList[4].webkitRelativePath", "testFiles/subfolder2/subfolder2a/file5.txt");
+
+    finishJSTest();
+}
+
+runTest();
+
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/file/webkitdirectory-open-panel-expected.txt (0 => 221177)


--- trunk/LayoutTests/fast/forms/file/webkitdirectory-open-panel-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/file/webkitdirectory-open-panel-expected.txt	2017-08-25 02:05:54 UTC (rev 221177)
@@ -0,0 +1,23 @@
+OPEN FILE PANEL
+-> DIRECTORIES ARE ALLOWED
+Tests choosing a folder via the file picker when using webkitdirectory.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS inputElement.webkitdirectory is true
+PASS fileList.length is 5
+PASS fileList[0].name is "file1.txt"
+PASS fileList[0].webkitRelativePath is "testFiles/file1.txt"
+PASS fileList[1].name is "file2.txt"
+PASS fileList[1].webkitRelativePath is "testFiles/file2.txt"
+PASS fileList[2].name is "file3.txt"
+PASS fileList[2].webkitRelativePath is "testFiles/subfolder1/file3.txt"
+PASS fileList[3].name is "file4.txt"
+PASS fileList[3].webkitRelativePath is "testFiles/subfolder2/file4.txt"
+PASS fileList[4].name is "file5.txt"
+PASS fileList[4].webkitRelativePath is "testFiles/subfolder2/subfolder2a/file5.txt"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/forms/file/webkitdirectory-open-panel.html (0 => 221177)


--- trunk/LayoutTests/fast/forms/file/webkitdirectory-open-panel.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/file/webkitdirectory-open-panel.html	2017-08-25 02:05:54 UTC (rev 221177)
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<input type="file" _onchange_="changed(event)" webkitdirectory></input>
+<script>
+description("Tests choosing a folder via the file picker when using webkitdirectory.");
+jsTestIsAsync = true;
+
+function runTest()
+{
+    testRunner.setOpenPanelFiles(['resources/testFiles']);
+
+    inputElement = document.getElementsByTagName('input')[0];
+    shouldBeTrue("inputElement.webkitdirectory");
+    UIHelper.activateAt(inputElement.offsetLeft + inputElement.offsetWidth / 2,
+        inputElement.offsetTop + inputElement.offsetHeight / 2);
+}
+
+function changed(event)
+{
+    fileList = event.target.files;
+    shouldBe("fileList.length", "5");
+    shouldBeEqualToString("fileList[0].name", "file1.txt");
+    shouldBeEqualToString("fileList[0].webkitRelativePath", "testFiles/file1.txt");
+    shouldBeEqualToString("fileList[1].name", "file2.txt");
+    shouldBeEqualToString("fileList[1].webkitRelativePath", "testFiles/file2.txt");
+    shouldBeEqualToString("fileList[2].name", "file3.txt");
+    shouldBeEqualToString("fileList[2].webkitRelativePath", "testFiles/subfolder1/file3.txt");
+    shouldBeEqualToString("fileList[3].name", "file4.txt");
+    shouldBeEqualToString("fileList[3].webkitRelativePath", "testFiles/subfolder2/file4.txt");
+    shouldBeEqualToString("fileList[4].name", "file5.txt");
+    shouldBeEqualToString("fileList[4].webkitRelativePath", "testFiles/subfolder2/subfolder2a/file5.txt");
+
+    finishJSTest();
+}
+
+runTest();
+
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/platform/mac-wk1/fast/forms/file/webkitdirectory-open-panel-expected.txt (0 => 221177)


--- trunk/LayoutTests/platform/mac-wk1/fast/forms/file/webkitdirectory-open-panel-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-wk1/fast/forms/file/webkitdirectory-open-panel-expected.txt	2017-08-25 02:05:54 UTC (rev 221177)
@@ -0,0 +1,22 @@
+OPEN FILE PANEL
+Tests choosing a folder via the file picker when using webkitdirectory.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS inputElement.webkitdirectory is true
+PASS fileList.length is 5
+PASS fileList[0].name is "file1.txt"
+PASS fileList[0].webkitRelativePath is "testFiles/file1.txt"
+PASS fileList[1].name is "file2.txt"
+PASS fileList[1].webkitRelativePath is "testFiles/file2.txt"
+PASS fileList[2].name is "file3.txt"
+PASS fileList[2].webkitRelativePath is "testFiles/subfolder1/file3.txt"
+PASS fileList[3].name is "file4.txt"
+PASS fileList[3].webkitRelativePath is "testFiles/subfolder2/file4.txt"
+PASS fileList[4].name is "file5.txt"
+PASS fileList[4].webkitRelativePath is "testFiles/subfolder2/subfolder2a/file5.txt"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Modified: trunk/LayoutTests/platform/wk2/TestExpectations (221176 => 221177)


--- trunk/LayoutTests/platform/wk2/TestExpectations	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/LayoutTests/platform/wk2/TestExpectations	2017-08-25 02:05:54 UTC (rev 221177)
@@ -603,6 +603,7 @@
 fast/forms/file/input-file-write-files.html
 fast/forms/file/recover-file-input-in-unposted-form.html
 fast/forms/file/selected-files-from-history-state.html
+fast/forms/file/webkitdirectory-drag-folder.html
 fast/history/page-cache-createObjectURL.html
 fast/workers/worker-copy-shared-blob-url.html
 http/tests/local/blob/send-hybrid-blob.html

Modified: trunk/Source/WebCore/CMakeLists.txt (221176 => 221177)


--- trunk/Source/WebCore/CMakeLists.txt	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebCore/CMakeLists.txt	2017-08-25 02:05:54 UTC (rev 221177)
@@ -1739,6 +1739,7 @@
     html/DateTimeLocalInputType.cpp
     html/EmailInputType.cpp
     html/FTPDirectoryDocument.cpp
+    html/FileListCreator.cpp
     html/FileInputType.cpp
     html/FormAssociatedElement.cpp
     html/FormController.cpp

Modified: trunk/Source/WebCore/ChangeLog (221176 => 221177)


--- trunk/Source/WebCore/ChangeLog	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebCore/ChangeLog	2017-08-25 02:05:54 UTC (rev 221177)
@@ -1,3 +1,80 @@
+2017-08-24  Chris Dumez  <cdu...@apple.com>
+
+        [Directory Upload] Add basic support for input.webkitdirectory
+        https://bugs.webkit.org/show_bug.cgi?id=175950
+        <rdar://problem/33951915>
+
+        Reviewed by Geoffrey Garen.
+
+        Add basic support for input.webkitdirectory attribute, as per:
+        - https://wicg.github.io/entries-api/#html-forms
+
+        The following is supported:
+        - input.webkitdirectory IDL and content attributes
+        - The webkitdirectory content attribute is properly consulted
+          to communicate to the client that the file picker should
+          allow selecting directories.
+        - When WebCore gets the list of selected files from the file picker,
+          it properly resolves folders in a background thread to properly
+          initialize input.files before firing the 'change' event at the
+          input element.
+        - When resolving files in a directory, we ignore both hidden files and
+          symbolic links for security reasons. I did not check symlinks but Firefox
+          and Chrome both seem to upload hidden files (such as .DS_Store files).
+        - File.webkitRelativePath IDL attribute is properly populated for
+          files coming from a selected directory.
+        - Form submission just works because it relies on input.files being
+          properly populated. No change needed in this area.
+
+        What is not supported:
+        - input.webkitEntries IDL attribute.
+        - FileSystemEntry / FileSystemDirectoryEntry / FileSystemDirectoryReader
+          /  FileSystemFileEntry / FileSystem IDL interfaces.
+        - dataTransferItem.webkitGetAsEntry() for proper drag and drop support.
+
+        Those will be taken care of in follow-up patches.
+
+        The feature is currently behind an experimental feature flag, disabled by
+        default.
+
+        Tests: fast/forms/file/webkitdirectory-drag-folder.html
+               fast/forms/file/webkitdirectory-open-panel.html
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * fileapi/File.cpp:
+        (WebCore::File::createWithRelativePath):
+        * fileapi/File.h:
+        * fileapi/File.idl:
+        * html/FileInputType.cpp:
+        (WebCore::FileInputType::~FileInputType):
+        (WebCore::FileInputType::handleDOMActivateEvent):
+        (WebCore::FileInputType::allowsDirectories const):
+        (WebCore::FileInputType::filesChosen):
+        * html/FileInputType.h:
+        * html/FileListCreator.cpp: Added.
+        (WebCore::appendDirectoryFiles):
+        (WebCore::FileListCreator::FileListCreator):
+        (WebCore::FileListCreator::createFileList):
+        (WebCore::FileListCreator::cancel):
+        * html/FileListCreator.h: Copied from Source/WebKit/UIProcess/API/APIOpenPanelParameters.h.
+        (WebCore::FileListCreator::create):
+        * html/HTMLAttributeNames.in:
+        * html/HTMLInputElement.idl:
+        * page/Settings.in:
+        * platform/FileChooser.h:
+        (WebCore::FileChooserFileInfo::isolatedCopy const):
+        * platform/FileMetadata.h:
+        * platform/FileSystem.cpp:
+        (WebCore::fileIsDirectory):
+        * platform/FileSystem.h:
+        * platform/glib/FileSystemGlib.cpp:
+        (WebCore::getFileMetadata):
+        * platform/posix/FileSystemPOSIX.cpp:
+        (WebCore::getFileMetadata):
+        * platform/win/FileSystemWin.cpp:
+        (WebCore::getFileMetadata):
+
 2017-08-24  Ryan Haddad  <ryanhad...@apple.com>
 
         Unreviewed, rolling out r221139.

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (221176 => 221177)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-08-25 02:05:54 UTC (rev 221177)
@@ -3425,6 +3425,8 @@
 		8358CB6F1C53277200E0C2D8 /* JSXMLDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83F570AE1C53268E007FD6CB /* JSXMLDocument.cpp */; };
 		8358CB701C53277500E0C2D8 /* JSXMLDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = 83F570AD1C53268E007FD6CB /* JSXMLDocument.h */; };
 		835D363719FF6193004C93AB /* StyleBuilderCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = 835D363619FF6193004C93AB /* StyleBuilderCustom.h */; };
+		835D54C41F4DE53800E60671 /* FileListCreator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 835D54C11F4DE53400E60671 /* FileListCreator.cpp */; };
+		835D54C51F4DE53800E60671 /* FileListCreator.h in Headers */ = {isa = PBXBuildFile; fileRef = 835D54C21F4DE53400E60671 /* FileListCreator.h */; };
 		8367587E1C56E99B008A1087 /* JSHTMLDataElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 834B86A91C56E93E00F3F0E3 /* JSHTMLDataElement.cpp */; };
 		8367587F1C56E99B008A1087 /* JSHTMLDataElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 834B86A81C56E93E00F3F0E3 /* JSHTMLDataElement.h */; };
 		836ACEC21ECA62C8004BD012 /* DOMMatrixReadOnly.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 836ACEBF1ECA62B0004BD012 /* DOMMatrixReadOnly.cpp */; };
@@ -11547,6 +11549,8 @@
 		83520C7D1A71BFCC006BD2AA /* CSSFontFamily.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontFamily.h; sourceTree = "<group>"; };
 		835657C61ECAB0E800CDE72D /* JSDOMMatrixInit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMMatrixInit.cpp; sourceTree = "<group>"; };
 		835D363619FF6193004C93AB /* StyleBuilderCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleBuilderCustom.h; sourceTree = "<group>"; };
+		835D54C11F4DE53400E60671 /* FileListCreator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileListCreator.cpp; sourceTree = "<group>"; };
+		835D54C21F4DE53400E60671 /* FileListCreator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileListCreator.h; sourceTree = "<group>"; };
 		835F8B261D2D90BA00E408EC /* Slotable.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Slotable.idl; sourceTree = "<group>"; };
 		8369E58F1AFDD0300087DF68 /* NonDocumentTypeChildNode.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = NonDocumentTypeChildNode.idl; sourceTree = "<group>"; };
 		836ACEBF1ECA62B0004BD012 /* DOMMatrixReadOnly.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMMatrixReadOnly.cpp; sourceTree = "<group>"; };
@@ -20289,6 +20293,8 @@
 				F55B3D881251F12D003EF269 /* EmailInputType.h */,
 				F55B3D891251F12D003EF269 /* FileInputType.cpp */,
 				F55B3D8A1251F12D003EF269 /* FileInputType.h */,
+				835D54C11F4DE53400E60671 /* FileListCreator.cpp */,
+				835D54C21F4DE53400E60671 /* FileListCreator.h */,
 				4A0DA2FC129B241900AB61E1 /* FormAssociatedElement.cpp */,
 				4A0DA2FD129B241900AB61E1 /* FormAssociatedElement.h */,
 				F50664F5157F52DC00AC226F /* FormController.cpp */,
@@ -27397,6 +27403,7 @@
 				1A88A90517553CD7000C74F9 /* FileIconLoader.h in Headers */,
 				F55B3DBE1251F12D003EF269 /* FileInputType.h in Headers */,
 				976D6C86122B8A3D001FD1F7 /* FileList.h in Headers */,
+				835D54C51F4DE53800E60671 /* FileListCreator.h in Headers */,
 				4689F1AF1267BAE100E8D380 /* FileMetadata.h in Headers */,
 				7A09CEF11F02069B00E93BDB /* FileMonitor.h in Headers */,
 				976D6C89122B8A3D001FD1F7 /* FileReader.h in Headers */,
@@ -31394,6 +31401,7 @@
 				1A88A90417553CD7000C74F9 /* FileIconLoader.cpp in Sources */,
 				F55B3DBD1251F12D003EF269 /* FileInputType.cpp in Sources */,
 				976D6C85122B8A3D001FD1F7 /* FileList.cpp in Sources */,
+				835D54C41F4DE53800E60671 /* FileListCreator.cpp in Sources */,
 				7A32D7481F020EFF00162C44 /* FileMonitor.cpp in Sources */,
 				7A32D7471F020EED00162C44 /* FileMonitorCocoa.mm in Sources */,
 				976D6C88122B8A3D001FD1F7 /* FileReader.cpp in Sources */,

Modified: trunk/Source/WebCore/fileapi/File.cpp (221176 => 221177)


--- trunk/Source/WebCore/fileapi/File.cpp	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebCore/fileapi/File.cpp	2017-08-25 02:05:54 UTC (rev 221177)
@@ -37,6 +37,13 @@
 
 namespace WebCore {
 
+Ref<File> File::createWithRelativePath(const String& path, const String& relativePath)
+{
+    auto file = File::create(path);
+    file->setRelativePath(relativePath);
+    return file;
+}
+
 File::File(const String& path)
     : Blob(uninitializedContructor)
     , m_path(path)

Modified: trunk/Source/WebCore/fileapi/File.h (221176 => 221177)


--- trunk/Source/WebCore/fileapi/File.h	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebCore/fileapi/File.h	2017-08-25 02:05:54 UTC (rev 221177)
@@ -65,9 +65,13 @@
         return adoptRef(*new File(path, nameOverride));
     }
 
+    static Ref<File> createWithRelativePath(const String& path, const String& relativePath);
+
     bool isFile() const override { return true; }
 
     const String& path() const { return m_path; }
+    const String& relativePath() const { return m_relativePath; }
+    void setRelativePath(const String& relativePath) { m_relativePath = relativePath; }
     const String& name() const { return m_name; }
     WEBCORE_EXPORT double lastModified() const;
 
@@ -90,6 +94,7 @@
 #endif
 
     String m_path;
+    String m_relativePath;
     String m_name;
 
     std::optional<int64_t> m_overrideLastModifiedDate;

Modified: trunk/Source/WebCore/fileapi/File.idl (221176 => 221177)


--- trunk/Source/WebCore/fileapi/File.idl	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebCore/fileapi/File.idl	2017-08-25 02:05:54 UTC (rev 221177)
@@ -35,6 +35,9 @@
 ] interface File : Blob {
     readonly attribute DOMString name;
     readonly attribute long long lastModified;
+
+    // https://wicg.github.io/entries-api/#file-interface
+    [EnabledAtRuntime=DirectoryUpload, ImplementedAs=relativePath] readonly attribute USVString webkitRelativePath;
 };
 
 dictionary FilePropertyBag : BlobPropertyBag {

Modified: trunk/Source/WebCore/html/FileInputType.cpp (221176 => 221177)


--- trunk/Source/WebCore/html/FileInputType.cpp	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebCore/html/FileInputType.cpp	2017-08-25 02:05:54 UTC (rev 221177)
@@ -28,6 +28,7 @@
 #include "Event.h"
 #include "File.h"
 #include "FileList.h"
+#include "FileListCreator.h"
 #include "FileSystem.h"
 #include "FormController.h"
 #include "FormDataList.h"
@@ -38,7 +39,9 @@
 #include "InputTypeNames.h"
 #include "LocalizedStrings.h"
 #include "RenderFileUploadControl.h"
+#include "RuntimeEnabledFeatures.h"
 #include "ScriptController.h"
+#include "Settings.h"
 #include "ShadowRoot.h"
 #include <wtf/TypeCasts.h>
 #include <wtf/text/StringBuilder.h>
@@ -97,6 +100,9 @@
 
 FileInputType::~FileInputType()
 {
+    if (m_fileListCreator)
+        m_fileListCreator->cancel();
+
     if (m_fileChooser)
         m_fileChooser->invalidate();
 
@@ -191,6 +197,7 @@
     if (auto* chrome = this->chrome()) {
         FileChooserSettings settings;
         HTMLInputElement& input = element();
+        settings.allowsDirectories = allowsDirectories();
         settings.allowsMultipleFiles = input.hasAttributeWithoutSynchronization(multipleAttr);
         settings.acceptMIMETypes = input.acceptMIMETypes();
         settings.acceptFileExtensions = input.acceptFileExtensions();
@@ -254,15 +261,6 @@
     element().invalidateStyleForSubtree();
 }
 
-Ref<FileList> FileInputType::createFileList(const Vector<FileChooserFileInfo>& files)
-{
-    Vector<RefPtr<File>> fileObjects;
-    fileObjects.reserveInitialCapacity(files.size());
-    for (auto& info : files)
-        fileObjects.uncheckedAppend(File::createWithName(info.path, info.displayName));
-    return FileList::create(WTFMove(fileObjects));
-}
-
 bool FileInputType::isFileUpload() const
 {
     return true;
@@ -328,6 +326,13 @@
     m_fileChooser = FileChooser::create(this, settings);
 }
 
+bool FileInputType::allowsDirectories() const
+{
+    if (!RuntimeEnabledFeatures::sharedFeatures().directoryUploadEnabled())
+        return false;
+    return element().hasAttributeWithoutSynchronization(webkitdirectoryAttr);
+}
+
 void FileInputType::setFiles(RefPtr<FileList>&& files)
 {
     setFiles(WTFMove(files), RequestIcon::Yes);
@@ -383,8 +388,16 @@
     if (!displayString.isEmpty())
         m_displayString = displayString;
 
-    setFiles(createFileList(paths), icon ? RequestIcon::No : RequestIcon::Yes);
+    if (m_fileListCreator)
+        m_fileListCreator->cancel();
 
+    auto shouldResolveDirectories = allowsDirectories() ? FileListCreator::ShouldResolveDirectories::Yes : FileListCreator::ShouldResolveDirectories::No;
+    auto shouldRequestIcon = icon ? RequestIcon::Yes : RequestIcon::No;
+    m_fileListCreator = FileListCreator::create(paths, shouldResolveDirectories, [this, shouldRequestIcon](Ref<FileList>&& fileList) {
+        setFiles(WTFMove(fileList), shouldRequestIcon);
+        m_fileListCreator = nullptr;
+    });
+
     if (icon)
         iconLoaded(icon);
 }

Modified: trunk/Source/WebCore/html/FileInputType.h (221176 => 221177)


--- trunk/Source/WebCore/html/FileInputType.h	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebCore/html/FileInputType.h	2017-08-25 02:05:54 UTC (rev 221177)
@@ -40,6 +40,7 @@
 
 class DragData;
 class FileList;
+class FileListCreator;
 class Icon;
 
 class FileInputType final : public BaseClickableWithKeyInputType, private FileChooserClient, private FileIconLoaderClient {
@@ -84,15 +85,17 @@
     // FileIconLoaderClient implementation.
     void iconLoaded(RefPtr<Icon>&&) final;
 
-    static Ref<FileList> createFileList(const Vector<FileChooserFileInfo>&);
     void requestIcon(const Vector<String>&);
 
     void applyFileChooserSettings(const FileChooserSettings&);
 
+    bool allowsDirectories() const;
+
     RefPtr<FileChooser> m_fileChooser;
     std::unique_ptr<FileIconLoader> m_fileIconLoader;
 
     Ref<FileList> m_fileList;
+    RefPtr<FileListCreator> m_fileListCreator;
     RefPtr<Icon> m_icon;
     String m_displayString;
 };

Added: trunk/Source/WebCore/html/FileListCreator.cpp (0 => 221177)


--- trunk/Source/WebCore/html/FileListCreator.cpp	                        (rev 0)
+++ trunk/Source/WebCore/html/FileListCreator.cpp	2017-08-25 02:05:54 UTC (rev 221177)
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "FileListCreator.h"
+
+#include "FileChooser.h"
+#include "FileList.h"
+#include "FileMetadata.h"
+#include "FileSystem.h"
+#include <wtf/CrossThreadCopier.h>
+
+namespace WebCore {
+
+FileListCreator::~FileListCreator()
+{
+    ASSERT(!m_completionHander);
+}
+
+static void appendDirectoryFiles(const String& directory, const String& relativePath, Vector<RefPtr<File>>& fileObjects)
+{
+    for (auto& childPath : listDirectory(directory, "*")) {
+        FileMetadata metadata;
+        if (!getFileMetadata(childPath, metadata))
+            continue;
+
+        if (metadata.isHidden)
+            continue;
+
+        String childRelativePath = relativePath + "/" + pathGetFileName(childPath);
+        if (metadata.type == FileMetadata::TypeDirectory)
+            appendDirectoryFiles(childPath, childRelativePath, fileObjects);
+        else if (metadata.type == FileMetadata::TypeFile)
+            fileObjects.append(File::createWithRelativePath(childPath, childRelativePath));
+    }
+}
+
+FileListCreator::FileListCreator(const Vector<FileChooserFileInfo>& paths, ShouldResolveDirectories shouldResolveDirectories, CompletionHandler&& completionHandler)
+{
+    if (shouldResolveDirectories == ShouldResolveDirectories::No)
+        completionHandler(createFileList<ShouldResolveDirectories::No>(paths));
+    else {
+        // Resolve directories on a background thread to avoid blocking the main thread.
+        m_completionHander = WTFMove(completionHandler);
+        m_workQueue = WorkQueue::create("FileListCreator Work Queue");
+        m_workQueue->dispatch([this, protectedThis = makeRef(*this), paths = CrossThreadCopier<Vector<FileChooserFileInfo>>::copy(paths)]() mutable {
+            auto fileList = createFileList<ShouldResolveDirectories::Yes>(paths);
+            callOnMainThread([this, protectedThis = WTFMove(protectedThis), fileList = WTFMove(fileList)]() mutable {
+                if (auto completionHander = WTFMove(m_completionHander))
+                    completionHander(WTFMove(fileList));
+            });
+        });
+    }
+}
+
+template<FileListCreator::ShouldResolveDirectories shouldResolveDirectories>
+Ref<FileList> FileListCreator::createFileList(const Vector<FileChooserFileInfo>& paths)
+{
+    Vector<RefPtr<File>> fileObjects;
+    for (auto& info : paths) {
+        if (shouldResolveDirectories == ShouldResolveDirectories::Yes && fileIsDirectory(info.path))
+            appendDirectoryFiles(info.path, pathGetFileName(info.path), fileObjects);
+        else
+            fileObjects.append(File::createWithName(info.path, info.displayName));
+    }
+    return FileList::create(WTFMove(fileObjects));
+}
+
+void FileListCreator::cancel()
+{
+    m_completionHander = nullptr;
+    m_workQueue = nullptr;
+}
+
+} // namespace WebCore

Copied: trunk/Source/WebCore/html/FileListCreator.h (from rev 221176, trunk/Source/WebKit/UIProcess/API/APIOpenPanelParameters.h) (0 => 221177)


--- trunk/Source/WebCore/html/FileListCreator.h	                        (rev 0)
+++ trunk/Source/WebCore/html/FileListCreator.h	2017-08-25 02:05:54 UTC (rev 221177)
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/Function.h>
+#include <wtf/Ref.h>
+#include <wtf/ThreadSafeRefCounted.h>
+#include <wtf/Vector.h>
+#include <wtf/WorkQueue.h>
+
+namespace WebCore {
+
+struct FileChooserFileInfo;
+class FileList;
+
+class FileListCreator : public ThreadSafeRefCounted<FileListCreator> {
+public:
+    using CompletionHandler = WTF::Function<void(Ref<FileList>&&)>;
+
+    enum class ShouldResolveDirectories { No, Yes };
+    static Ref<FileListCreator> create(const Vector<FileChooserFileInfo>& paths, ShouldResolveDirectories shouldResolveDirectories, CompletionHandler&& completionHandler)
+    {
+        return adoptRef(*new FileListCreator(paths, shouldResolveDirectories, WTFMove(completionHandler)));
+    }
+
+    ~FileListCreator();
+
+    void cancel();
+
+private:
+    FileListCreator(const Vector<FileChooserFileInfo>& paths, ShouldResolveDirectories, CompletionHandler&&);
+
+    template<ShouldResolveDirectories shouldResolveDirectories>
+    static Ref<FileList> createFileList(const Vector<FileChooserFileInfo>&);
+
+    RefPtr<WorkQueue> m_workQueue;
+    CompletionHandler m_completionHander;
+};
+
+}

Modified: trunk/Source/WebCore/html/HTMLAttributeNames.in (221176 => 221177)


--- trunk/Source/WebCore/html/HTMLAttributeNames.in	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebCore/html/HTMLAttributeNames.in	2017-08-25 02:05:54 UTC (rev 221177)
@@ -381,6 +381,7 @@
 vspace
 webkitallowfullscreen
 webkitattachmentpath
+webkitdirectory
 width
 wrap
 

Modified: trunk/Source/WebCore/html/HTMLInputElement.idl (221176 => 221177)


--- trunk/Source/WebCore/html/HTMLInputElement.idl	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebCore/html/HTMLInputElement.idl	2017-08-25 02:05:54 UTC (rev 221177)
@@ -92,4 +92,10 @@
 
     // See http://www.w3.org/TR/html-media-capture/
     [Conditional=MEDIA_CAPTURE, Reflect] attribute DOMString capture;
+
+    // https://wicg.github.io/entries-api/#dom-htmlinputelement-webkitdirectory
+    [Reflect, EnabledAtRuntime=DirectoryUpload] attribute boolean webkitdirectory;
+    // In Chrome & Firefox, webkitEntries is only populated if webkitdirectory is not set and the files were
+    // dragged and dropped (not when the element is clicked).
+    // [EnabledAtRuntime=DirectoryUpload] readonly attribute FrozenArray<FileSystemEntry> webkitEntries;
 };

Modified: trunk/Source/WebCore/page/RuntimeEnabledFeatures.h (221176 => 221177)


--- trunk/Source/WebCore/page/RuntimeEnabledFeatures.h	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebCore/page/RuntimeEnabledFeatures.h	2017-08-25 02:05:54 UTC (rev 221177)
@@ -73,6 +73,9 @@
     void setCustomElementsEnabled(bool areEnabled) { m_areCustomElementsEnabled = areEnabled; }
     bool customElementsEnabled() const { return m_areCustomElementsEnabled; }
 
+    void setDirectoryUploadEnabled(bool isEnabled) { m_isDirectoryUploadEnabled = isEnabled; }
+    bool directoryUploadEnabled() const { return m_isDirectoryUploadEnabled; }
+
     void setDataTransferItemsEnabled(bool areEnabled) { m_areDataTransferItemsEnabled = areEnabled; }
     bool dataTransferItemsEnabled() const { return m_areDataTransferItemsEnabled; }
 
@@ -231,6 +234,7 @@
     bool m_isDisplayContentsEnabled { false };
     bool m_isShadowDOMEnabled { true };
     bool m_areCustomElementsEnabled { true };
+    bool m_isDirectoryUploadEnabled { false };
     bool m_areDataTransferItemsEnabled { false };
     bool m_inputEventsEnabled { true };
 

Modified: trunk/Source/WebCore/platform/FileChooser.h (221176 => 221177)


--- trunk/Source/WebCore/platform/FileChooser.h	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebCore/platform/FileChooser.h	2017-08-25 02:05:54 UTC (rev 221177)
@@ -52,17 +52,23 @@
     {
     }
 
+    FileChooserFileInfo isolatedCopy() const
+    {
+        return { path.isolatedCopy(), displayName.isolatedCopy() };
+    }
+
     const String path;
     const String displayName;
 };
 
 struct FileChooserSettings {
-    bool allowsMultipleFiles;
+    bool allowsDirectories { false };
+    bool allowsMultipleFiles { false };
     Vector<String> acceptMIMETypes;
     Vector<String> acceptFileExtensions;
     Vector<String> selectedFiles;
 #if ENABLE(MEDIA_CAPTURE)
-    MediaCaptureType mediaCaptureType;
+    MediaCaptureType mediaCaptureType { MediaCaptureTypeNone };
 #endif
 };
 

Modified: trunk/Source/WebCore/platform/FileMetadata.h (221176 => 221177)


--- trunk/Source/WebCore/platform/FileMetadata.h	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebCore/platform/FileMetadata.h	2017-08-25 02:05:54 UTC (rev 221177)
@@ -37,23 +37,20 @@
 namespace WebCore {
 
 struct FileMetadata {
+    FileMetadata() = default;
+
     // The last modification time of the file, in seconds.
     // The value 0.0 means that the time is not set.
-    double modificationTime;
+    double modificationTime { invalidFileTime() };
 
     // The length of the file in bytes.
     // The value -1 means that the length is not set.
-    long long length;
+    long long length { -1 };
 
-    enum Type {
-        TypeUnknown = 0,
-        TypeFile,
-        TypeDirectory
-    };
+    bool isHidden { false };
 
-    Type type;
-
-    FileMetadata() : modificationTime(invalidFileTime()), length(-1), type(TypeUnknown) { }
+    enum Type { TypeUnknown, TypeFile, TypeDirectory, TypeSymbolicLink };
+    Type type { TypeUnknown };
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/FileSystem.cpp (221176 => 221177)


--- trunk/Source/WebCore/platform/FileSystem.cpp	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebCore/platform/FileSystem.cpp	2017-08-25 02:05:54 UTC (rev 221177)
@@ -27,6 +27,7 @@
 #include "config.h"
 #include "FileSystem.h"
 
+#include "FileMetadata.h"
 #include "ScopeGuard.h"
 #include <wtf/HexNumber.h>
 #include <wtf/text/CString.h>
@@ -350,4 +351,12 @@
     closeFile(handle);
 }
 
+bool fileIsDirectory(const String& path)
+{
+    FileMetadata metadata;
+    if (!getFileMetadata(path, metadata))
+        return false;
+    return metadata.type == FileMetadata::TypeDirectory;
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/FileSystem.h (221176 => 221177)


--- trunk/Source/WebCore/platform/FileSystem.h	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebCore/platform/FileSystem.h	2017-08-25 02:05:54 UTC (rev 221177)
@@ -99,6 +99,7 @@
 WEBCORE_EXPORT bool getFileModificationTime(const String&, time_t& result);
 WEBCORE_EXPORT bool getFileCreationTime(const String&, time_t& result); // Not all platforms store file creation time.
 bool getFileMetadata(const String&, FileMetadata&);
+bool fileIsDirectory(const String&);
 WEBCORE_EXPORT String pathByAppendingComponent(const String& path, const String& component);
 String lastComponentOfPathIgnoringTrailingSlash(const String& path);
 WEBCORE_EXPORT bool makeAllDirectories(const String& path);

Modified: trunk/Source/WebCore/platform/glib/FileSystemGlib.cpp (221176 => 221177)


--- trunk/Source/WebCore/platform/glib/FileSystemGlib.cpp	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebCore/platform/glib/FileSystemGlib.cpp	2017-08-25 02:05:54 UTC (rev 221177)
@@ -160,9 +160,16 @@
     if (!getFileStat(path, &statResult))
         return false;
 
+    String filename = pathGetFileName(path);
+    metadata.isHidden = !filename.isEmpty() && filename[0] == '.';
     metadata.modificationTime = statResult.st_mtime;
     metadata.length = statResult.st_size;
-    metadata.type = S_ISDIR(statResult.st_mode) ? FileMetadata::TypeDirectory : FileMetadata::TypeFile;
+    if (S_ISDIR(statResult.st_mode))
+        metadata.type = FileMetadata::TypeDirectory;
+    else if (S_ISLNK(statResult.st_mode))
+        metadata.type = FileMetadata::TypeSymbolicLink;
+    else
+        metadata.type = FileMetadata::TypeFile;
     return true;
 }
 

Modified: trunk/Source/WebCore/platform/posix/FileSystemPOSIX.cpp (221176 => 221177)


--- trunk/Source/WebCore/platform/posix/FileSystemPOSIX.cpp	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebCore/platform/posix/FileSystemPOSIX.cpp	2017-08-25 02:05:54 UTC (rev 221177)
@@ -249,9 +249,17 @@
     if (stat(fsRep.data(), &fileInfo))
         return false;
 
+    String filename = pathGetFileName(path);
+
     metadata.modificationTime = fileInfo.st_mtime;
+    metadata.isHidden = !filename.isEmpty() && filename[0] == '.';
     metadata.length = fileInfo.st_size;
-    metadata.type = S_ISDIR(fileInfo.st_mode) ? FileMetadata::TypeDirectory : FileMetadata::TypeFile;
+    if (S_ISDIR(fileInfo.st_mode))
+        metadata.type = FileMetadata::TypeDirectory;
+    else if (S_ISLNK(fileInfo.st_mode))
+        metadata.type = FileMetadata::TypeSymbolicLink;
+    else
+        metadata.type = FileMetadata::TypeFile;
     return true;
 }
 

Modified: trunk/Source/WebCore/platform/win/FileSystemWin.cpp (221176 => 221177)


--- trunk/Source/WebCore/platform/win/FileSystemWin.cpp	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebCore/platform/win/FileSystemWin.cpp	2017-08-25 02:05:54 UTC (rev 221177)
@@ -152,7 +152,7 @@
     time_t modificationTime;
     getFileModificationTimeFromFindData(findData, modificationTime);
     metadata.modificationTime = modificationTime;
-
+    metadata.isHidden = findData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN;
     metadata.type = (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? FileMetadata::TypeDirectory : FileMetadata::TypeFile;
 
     return true;

Modified: trunk/Source/WebKit/ChangeLog (221176 => 221177)


--- trunk/Source/WebKit/ChangeLog	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebKit/ChangeLog	2017-08-25 02:05:54 UTC (rev 221177)
@@ -1,3 +1,35 @@
+2017-08-24  Chris Dumez  <cdu...@apple.com>
+
+        [Directory Upload] Add basic support for input.webkitdirectory
+        https://bugs.webkit.org/show_bug.cgi?id=175950
+        <rdar://problem/33951915>
+
+        Reviewed by Geoffrey Garen.
+
+        Add private API to toggle Directory Upload support.
+
+        Add new member to WKOpenPanelParameters to communicate to the
+        client that the file picker should allow selecting directories.
+
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::ArgumentCoder<FileChooserSettings>::encode):
+        (IPC::ArgumentCoder<FileChooserSettings>::decode):
+        * Shared/WebPreferencesDefinitions.h:
+        * UIProcess/API/APIOpenPanelParameters.h:
+        (API::OpenPanelParameters::allowDirectories const):
+        * UIProcess/API/C/WKOpenPanelParametersRef.cpp:
+        (WKOpenPanelParametersGetAllowsDirectories):
+        * UIProcess/API/C/WKOpenPanelParametersRef.h:
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetDirectoryUploadEnabled):
+        (WKPreferencesGetDirectoryUploadEnabled):
+        * UIProcess/API/C/WKPreferencesRefPrivate.h:
+        * UIProcess/API/Cocoa/WKOpenPanelParameters.h:
+        * UIProcess/API/Cocoa/WKOpenPanelParameters.mm:
+        (-[WKOpenPanelParameters allowsDirectories]):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+
 2017-08-24  Youenn Fablet  <you...@apple.com>
 
         [Cache API] UIProcess should provide the directory path where to store Cache Storage data

Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp (221176 => 221177)


--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp	2017-08-25 02:05:54 UTC (rev 221177)
@@ -1712,6 +1712,7 @@
 
 void ArgumentCoder<FileChooserSettings>::encode(Encoder& encoder, const FileChooserSettings& settings)
 {
+    encoder << settings.allowsDirectories;
     encoder << settings.allowsMultipleFiles;
     encoder << settings.acceptMIMETypes;
     encoder << settings.acceptFileExtensions;
@@ -1723,6 +1724,8 @@
 
 bool ArgumentCoder<FileChooserSettings>::decode(Decoder& decoder, FileChooserSettings& settings)
 {
+    if (!decoder.decode(settings.allowsDirectories))
+        return false;
     if (!decoder.decode(settings.allowsMultipleFiles))
         return false;
     if (!decoder.decode(settings.acceptMIMETypes))

Modified: trunk/Source/WebKit/Shared/WebPreferencesDefinitions.h (221176 => 221177)


--- trunk/Source/WebKit/Shared/WebPreferencesDefinitions.h	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebKit/Shared/WebPreferencesDefinitions.h	2017-08-25 02:05:54 UTC (rev 221177)
@@ -375,6 +375,7 @@
     macro(WebAnimationsEnabled, webAnimationsEnabled, Bool, bool, false, "Web Animations", "Web Animations prototype") \
     macro(WebGL2Enabled, webGL2Enabled, Bool, bool, false, "WebGL 2.0", "WebGL 2 prototype") \
     macro(WebGPUEnabled, webGPUEnabled, Bool, bool, false, "WebGPU", "WebGPU prototype") \
+    macro(DirectoryUploadEnabled, directoryUploadEnabled, Bool, bool, false, "Directory Upload", "input.webkitdirectory") \
     macro(AsyncFrameScrollingEnabled, asyncFrameScrollingEnabled, Bool, bool, false, "Async Frame Scrolling", "Perform frame scrolling in a dedicated thread or process") \
     \
 

Modified: trunk/Source/WebKit/UIProcess/API/APIOpenPanelParameters.h (221176 => 221177)


--- trunk/Source/WebKit/UIProcess/API/APIOpenPanelParameters.h	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebKit/UIProcess/API/APIOpenPanelParameters.h	2017-08-25 02:05:54 UTC (rev 221177)
@@ -38,6 +38,7 @@
     static Ref<OpenPanelParameters> create(const WebCore::FileChooserSettings&);
     ~OpenPanelParameters();
 
+    bool allowDirectories() const { return m_settings.allowsDirectories; }
     bool allowMultipleFiles() const { return m_settings.allowsMultipleFiles; }
     Ref<API::Array> acceptMIMETypes() const;
     Ref<API::Array> acceptFileExtensions() const;

Modified: trunk/Source/WebKit/UIProcess/API/C/WKOpenPanelParametersRef.cpp (221176 => 221177)


--- trunk/Source/WebKit/UIProcess/API/C/WKOpenPanelParametersRef.cpp	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebKit/UIProcess/API/C/WKOpenPanelParametersRef.cpp	2017-08-25 02:05:54 UTC (rev 221177)
@@ -38,6 +38,11 @@
     return toAPI(API::OpenPanelParameters::APIType);
 }
 
+bool WKOpenPanelParametersGetAllowsDirectories(WKOpenPanelParametersRef parametersRef)
+{
+    return toImpl(parametersRef)->allowDirectories();
+}
+
 bool WKOpenPanelParametersGetAllowsMultipleFiles(WKOpenPanelParametersRef parametersRef)
 {
     return toImpl(parametersRef)->allowMultipleFiles();

Modified: trunk/Source/WebKit/UIProcess/API/C/WKOpenPanelParametersRef.h (221176 => 221177)


--- trunk/Source/WebKit/UIProcess/API/C/WKOpenPanelParametersRef.h	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebKit/UIProcess/API/C/WKOpenPanelParametersRef.h	2017-08-25 02:05:54 UTC (rev 221177)
@@ -39,6 +39,7 @@
 
 WK_EXPORT WKTypeID WKOpenPanelParametersGetTypeID();
 
+WK_EXPORT bool WKOpenPanelParametersGetAllowsDirectories(WKOpenPanelParametersRef parameters);
 WK_EXPORT bool WKOpenPanelParametersGetAllowsMultipleFiles(WKOpenPanelParametersRef parameters);
 
 WK_EXPORT WKArrayRef WKOpenPanelParametersCopyAcceptedMIMETypes(WKOpenPanelParametersRef parameters);

Modified: trunk/Source/WebKit/UIProcess/API/C/WKPreferences.cpp (221176 => 221177)


--- trunk/Source/WebKit/UIProcess/API/C/WKPreferences.cpp	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPreferences.cpp	2017-08-25 02:05:54 UTC (rev 221177)
@@ -840,6 +840,16 @@
 #endif
 }
 
+void WKPreferencesSetDirectoryUploadEnabled(WKPreferencesRef preferencesRef, bool flag)
+{
+    toImpl(preferencesRef)->setDirectoryUploadEnabled(flag);
+}
+
+bool WKPreferencesGetDirectoryUploadEnabled(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->directoryUploadEnabled();
+}
+
 void WKPreferencesSetMediaControlsScaleWithPageZoom(WKPreferencesRef preferencesRef, bool flag)
 {
     toImpl(preferencesRef)->setMediaControlsScaleWithPageZoom(flag);

Modified: trunk/Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h (221176 => 221177)


--- trunk/Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h	2017-08-25 02:05:54 UTC (rev 221177)
@@ -207,6 +207,10 @@
 WK_EXPORT void WKPreferencesSetBeaconAPIEnabled(WKPreferencesRef, bool flag);
 WK_EXPORT bool WKPreferencesGetBeaconAPIEnabled(WKPreferencesRef);
 
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetDirectoryUploadEnabled(WKPreferencesRef, bool flag);
+WK_EXPORT bool WKPreferencesGetDirectoryUploadEnabled(WKPreferencesRef);
+
 // Defaults to false on iOS, true elsewhere.
 WK_EXPORT void WKPreferencesSetMediaControlsScaleWithPageZoom(WKPreferencesRef preferencesRef, bool flag);
 WK_EXPORT bool WKPreferencesGetMediaControlsScaleWithPageZoom(WKPreferencesRef preferencesRef);

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKOpenPanelParameters.h (221176 => 221177)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKOpenPanelParameters.h	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKOpenPanelParameters.h	2017-08-25 02:05:54 UTC (rev 221177)
@@ -40,6 +40,10 @@
  */
 @property (nonatomic, readonly) BOOL allowsMultipleSelection;
 
+/*! @abstract Whether the file upload control supports selecting directories.
+ */
+@property (nonatomic, readonly) BOOL allowsDirectories WK_API_AVAILABLE(macosx(WK_MAC_TBA));
+
 @end
 
 NS_ASSUME_NONNULL_END

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKOpenPanelParameters.mm (221176 => 221177)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKOpenPanelParameters.mm	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKOpenPanelParameters.mm	2017-08-25 02:05:54 UTC (rev 221177)
@@ -35,6 +35,11 @@
     return _openPanelParameters->allowMultipleFiles();
 }
 
+- (BOOL)allowsDirectories
+{
+    return _openPanelParameters->allowDirectories();
+}
+
 #pragma mark WKObject protocol implementation
 
 - (API::Object&)_apiObject

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (221176 => 221177)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2017-08-25 02:05:54 UTC (rev 221177)
@@ -3367,6 +3367,7 @@
     RuntimeEnabledFeatures::sharedFeatures().setMediaPreloadingEnabled(store.getBoolValueForKey(WebPreferencesKey::mediaPreloadingEnabledKey()));
     RuntimeEnabledFeatures::sharedFeatures().setCredentialManagementEnabled(store.getBoolValueForKey(WebPreferencesKey::credentialManagementEnabledKey()));
     RuntimeEnabledFeatures::sharedFeatures().setIsSecureContextAttributeEnabled(store.getBoolValueForKey(WebPreferencesKey::isSecureContextAttributeEnabledKey()));
+    RuntimeEnabledFeatures::sharedFeatures().setDirectoryUploadEnabled(store.getBoolValueForKey(WebPreferencesKey::directoryUploadEnabledKey()));
 
     bool processSuppressionEnabled = store.getBoolValueForKey(WebPreferencesKey::pageVisibilityBasedProcessSuppressionEnabledKey());
     if (m_processSuppressionEnabled != processSuppressionEnabled) {

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (221176 => 221177)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2017-08-25 02:05:54 UTC (rev 221177)
@@ -1,3 +1,22 @@
+2017-08-24  Chris Dumez  <cdu...@apple.com>
+
+        [Directory Upload] Add basic support for input.webkitdirectory
+        https://bugs.webkit.org/show_bug.cgi?id=175950
+        <rdar://problem/33951915>
+
+        Reviewed by Geoffrey Garen.
+
+        Add private API to toggle Directory Upload support on Mac WebKit1.
+
+        * WebView/WebPreferenceKeysPrivate.h:
+        * WebView/WebPreferences.mm:
+        (+[WebPreferences initialize]):
+        (-[WebPreferences setDirectoryUploadEnabled:]):
+        (-[WebPreferences directoryUploadEnabled]):
+        * WebView/WebPreferencesPrivate.h:
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]):
+
 2017-08-22  Wenson Hsieh  <wenson_hs...@apple.com>
 
         [WK2] EditorState updates should be rolled into the layer update lifecycle when possible

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h (221176 => 221177)


--- trunk/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h	2017-08-25 02:05:54 UTC (rev 221177)
@@ -176,6 +176,7 @@
 #define WebKitWritableStreamAPIEnabledPreferenceKey @"WebKitWritableStreamAPIEnabled"
 #define WebKitReadableByteStreamAPIEnabledPreferenceKey @"WebKitReadableByteStreamAPIEnabled"
 #define WebKitDownloadAttributeEnabledPreferenceKey @"WebKitDownloadAttributeEnabled"
+#define WebKitDirectoryUploadEnabledPreferenceKey @"WebKitDirectoryUploadEnabled"
 #define WebKitCSSGridLayoutEnabledPreferenceKey @"WebKitCSSGridLayoutEnabled"
 #define WebKitVisualViewportEnabledPreferenceKey @"WebKitVisualViewportEnabled"
 #define WebKitModernMediaControlsEnabledPreferenceKey @"WebKitModernMediaControlsEnabled"

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm (221176 => 221177)


--- trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm	2017-08-25 02:05:54 UTC (rev 221177)
@@ -642,6 +642,7 @@
 #if ENABLE(DOWNLOAD_ATTRIBUTE)
         [NSNumber numberWithBool:NO], WebKitDownloadAttributeEnabledPreferenceKey,
 #endif
+        [NSNumber numberWithBool:NO], WebKitDirectoryUploadEnabledPreferenceKey,
         [NSNumber numberWithBool:YES], WebKitCSSGridLayoutEnabledPreferenceKey,
 #if ENABLE(WEB_ANIMATIONS)
         [NSNumber numberWithBool:NO], WebKitWebAnimationsEnabledPreferenceKey,
@@ -3035,6 +3036,16 @@
     [self _setBoolValue:flag forKey:WebKitDownloadAttributeEnabledPreferenceKey];
 }
 
+- (void)setDirectoryUploadEnabled:(BOOL)flag
+{
+    [self _setBoolValue:flag forKey:WebKitDirectoryUploadEnabledPreferenceKey];
+}
+
+- (BOOL)directoryUploadEnabled
+{
+    return [self _boolValueForKey:WebKitDirectoryUploadEnabledPreferenceKey];
+}
+
 - (BOOL)isCSSGridLayoutEnabled
 {
     return [self _boolValueForKey:WebKitCSSGridLayoutEnabledPreferenceKey];

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h (221176 => 221177)


--- trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h	2017-08-25 02:05:54 UTC (rev 221177)
@@ -552,6 +552,9 @@
 - (void)setDownloadAttributeEnabled:(BOOL)flag;
 - (BOOL)downloadAttributeEnabled;
 
+- (void)setDirectoryUploadEnabled:(BOOL)flag;
+- (BOOL)directoryUploadEnabled;
+
 - (void)setCSSGridLayoutEnabled:(BOOL)flag;
 - (BOOL)isCSSGridLayoutEnabled;
 

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (221176 => 221177)


--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2017-08-25 02:05:54 UTC (rev 221177)
@@ -3033,6 +3033,7 @@
     RuntimeEnabledFeatures::sharedFeatures().setMediaPreloadingEnabled(preferences.mediaPreloadingEnabled);
     RuntimeEnabledFeatures::sharedFeatures().setCredentialManagementEnabled(preferences.credentialManagementEnabled);
     RuntimeEnabledFeatures::sharedFeatures().setIsSecureContextAttributeEnabled(preferences.isSecureContextAttributeEnabled);
+    RuntimeEnabledFeatures::sharedFeatures().setDirectoryUploadEnabled([preferences directoryUploadEnabled]);
 
 #if ENABLE(LEGACY_ENCRYPTED_MEDIA)
     RuntimeEnabledFeatures::sharedFeatures().setLegacyEncryptedMediaAPIEnabled(preferences.legacyEncryptedMediaAPIEnabled);

Modified: trunk/Tools/ChangeLog (221176 => 221177)


--- trunk/Tools/ChangeLog	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Tools/ChangeLog	2017-08-25 02:05:54 UTC (rev 221177)
@@ -1,3 +1,20 @@
+2017-08-24  Chris Dumez  <cdu...@apple.com>
+
+        [Directory Upload] Add basic support for input.webkitdirectory
+        https://bugs.webkit.org/show_bug.cgi?id=175950
+        <rdar://problem/33951915>
+
+        Reviewed by Geoffrey Garen.
+
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (resetWebPreferencesToConsistentValues):
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::resetPreferencesToConsistentValues):
+        Enable Directory Upload feature for testing, given that it is currently disabled by default.
+
+        (WTR::runOpenPanel):
+        Print additional text when directories are allowed to extend testing coverage.
+
 2017-08-24  Alex Christensen  <achristen...@webkit.org>
 
         Add WKUIDelegatePrivate equivalent of WKPageUIClient's handleAutoplayEvent

Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (221176 => 221177)


--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2017-08-25 02:05:54 UTC (rev 221177)
@@ -957,6 +957,7 @@
     [preferences setWebGPUEnabled:YES];
 
     [preferences setDownloadAttributeEnabled:YES];
+    [preferences setDirectoryUploadEnabled:YES];
 
     [preferences setHiddenPageDOMTimerThrottlingEnabled:NO];
     [preferences setHiddenPageCSSAnimationSuspensionEnabled:NO];

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (221176 => 221177)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2017-08-25 01:55:53 UTC (rev 221176)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2017-08-25 02:05:54 UTC (rev 221177)
@@ -151,6 +151,8 @@
 static void runOpenPanel(WKPageRef page, WKFrameRef frame, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef resultListenerRef, const void*)
 {
     printf("OPEN FILE PANEL\n");
+    if (WKOpenPanelParametersGetAllowsDirectories(parameters))
+        printf("-> DIRECTORIES ARE ALLOWED\n");
     WKArrayRef fileURLs = TestController::singleton().openPanelFileURLs();
     if (!fileURLs || !WKArrayGetSize(fileURLs)) {
         WKOpenPanelResultListenerCancel(resultListenerRef);
@@ -722,6 +724,7 @@
     WKPreferencesSetMediaPlaybackAllowsInline(preferences, true);
     WKPreferencesSetInlineMediaPlaybackRequiresPlaysInlineAttribute(preferences, false);
     WKPreferencesSetBeaconAPIEnabled(preferences, true);
+    WKPreferencesSetDirectoryUploadEnabled(preferences, true);
 
     WKCookieManagerDeleteAllCookies(WKContextGetCookieManager(m_context.get()));
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to