Title: [120667] trunk
Revision
120667
Author
[email protected]
Date
2012-06-18 21:13:44 -0700 (Mon, 18 Jun 2012)

Log Message

Support File/DirectoryEntry access for <input type=file> if FileSystem API is enabled
https://bugs.webkit.org/show_bug.cgi?id=88293

Reviewed by Tony Chang.

Source/WebCore:

Proposal email on whatwg: http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2011-November/033814.html
Proposal draft: http://wiki.whatwg.org/wiki/DragAndDropEntries

Test: fast/forms/file/input-file-entries.html

* Modules/filesystem/HTMLInputElementFileSystem.cpp: Added.
* Modules/filesystem/HTMLInputElementFileSystem.h: Added.
* Modules/filesystem/HTMLInputElementFileSystem.idl: Added.
* WebCore.gypi:
* html/FileInputType.cpp:
(WebCore::FileInputType::receiveDroppedFiles): Retrieves dropped file
system Id if the given DragData has it.
(WebCore::FileInputType::droppedFileSystemId): Added. This returns
dropped file system Id retrieved in receiveDroppedFiles, or an empty
string if the platform does not support isolated file system for
dropped files.
* html/FileInputType.h:
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::droppedFileSystemId): Added.
* html/HTMLInputElement.h:
* html/InputType.cpp:
(WebCore::InputType::droppedFileSystemId): Added.
* html/InputType.h:
* platform/DragData.cpp:
* platform/DragData.h:
* platform/chromium/DragDataChromium.cpp:
(WebCore::DragData::droppedFileSystemId): Added.

LayoutTests:

* fast/forms/file/input-file-entries-expected.txt: Added.
* fast/forms/file/input-file-entries.html: Added.
* fast/forms/resources/dir1/UTF8-2.txt: Added.
* fast/forms/resources/dir1/UTF8.txt: Added.
* fast/forms/resources/dir2/green.jpg: Added.
* platform/efl/Skipped:
* platform/efl/TestExpectations:
* platform/gtk/TestExpectations:
* platform/mac/Skipped:
* platform/qt/Skipped:
* platform/win/Skipped:
* platform/wincairo/Skipped:
* platform/wk2/Skipped:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (120666 => 120667)


--- trunk/LayoutTests/ChangeLog	2012-06-19 04:02:48 UTC (rev 120666)
+++ trunk/LayoutTests/ChangeLog	2012-06-19 04:13:44 UTC (rev 120667)
@@ -1,3 +1,24 @@
+2012-06-12  Kinuko Yasuda  <[email protected]>
+
+        Support File/DirectoryEntry access for <input type=file> if FileSystem API is enabled
+        https://bugs.webkit.org/show_bug.cgi?id=88293
+
+        Reviewed by Tony Chang.
+
+        * fast/forms/file/input-file-entries-expected.txt: Added.
+        * fast/forms/file/input-file-entries.html: Added.
+        * fast/forms/resources/dir1/UTF8-2.txt: Added.
+        * fast/forms/resources/dir1/UTF8.txt: Added.
+        * fast/forms/resources/dir2/green.jpg: Added.
+        * platform/efl/Skipped:
+        * platform/efl/TestExpectations:
+        * platform/gtk/TestExpectations:
+        * platform/mac/Skipped:
+        * platform/qt/Skipped:
+        * platform/win/Skipped:
+        * platform/wincairo/Skipped:
+        * platform/wk2/Skipped:
+
 2012-06-18  Shinya Kawanaka  <[email protected]>
 
         [Crash][Editing] VisibleSelection::adjustSelectionToAvoidCrossingEditingBoundaries() crashes in some Shadow DOM case.

Added: trunk/LayoutTests/fast/forms/file/input-file-entries-expected.txt (0 => 120667)


--- trunk/LayoutTests/fast/forms/file/input-file-entries-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/file/input-file-entries-expected.txt	2012-06-19 04:13:44 UTC (rev 120667)
@@ -0,0 +1,83 @@
+
+Tests the webkitEntries attribute of <input type="file">
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+* Testing testCases[0]
+PASS droppedEntries.length is 1
+Verifying entry (0/1):/UTF8.txt
+PASS verifyingEntry.fullPath is "/UTF8.txt"
+PASS typeof verifyingEntry.isDirectory is 'boolean'
+PASS verifyingEntry.isDirectory is false
+PASS returnedMetadata.size is 5
+* Testing testCases[1]
+PASS droppedEntries.length is 1
+Verifying entry (0/1):/dir1
+PASS verifyingEntry.fullPath is "/dir1"
+PASS typeof verifyingEntry.isDirectory is 'boolean'
+PASS verifyingEntry.isDirectory is true
+PASS returnedEntries.length is 2
+/dir1/UTF8-2.txt
+/dir1/UTF8.txt
+* Testing testCases[2]
+PASS droppedEntries.length is 3
+Verifying entry (0/3):/apple.gif
+PASS verifyingEntry.fullPath is "/apple.gif"
+PASS typeof verifyingEntry.isDirectory is 'boolean'
+PASS verifyingEntry.isDirectory is false
+PASS returnedMetadata.size is 3340
+Verifying entry (1/3):/UTF8.txt
+PASS verifyingEntry.fullPath is "/UTF8.txt"
+PASS typeof verifyingEntry.isDirectory is 'boolean'
+PASS verifyingEntry.isDirectory is false
+PASS returnedMetadata.size is 5
+Verifying entry (2/3):/green.jpg
+PASS verifyingEntry.fullPath is "/green.jpg"
+PASS typeof verifyingEntry.isDirectory is 'boolean'
+PASS verifyingEntry.isDirectory is false
+PASS returnedMetadata.size is 764
+* Testing testCases[3]
+PASS droppedEntries.length is 2
+Verifying entry (0/2):/dir1
+PASS verifyingEntry.fullPath is "/dir1"
+PASS typeof verifyingEntry.isDirectory is 'boolean'
+PASS verifyingEntry.isDirectory is true
+PASS returnedEntries.length is 2
+/dir1/UTF8-2.txt
+/dir1/UTF8.txt
+Verifying entry (1/2):/dir2
+PASS verifyingEntry.fullPath is "/dir2"
+PASS typeof verifyingEntry.isDirectory is 'boolean'
+PASS verifyingEntry.isDirectory is true
+PASS returnedEntries.length is 1
+/dir2/green.jpg
+* Testing testCases[4]
+PASS droppedEntries.length is 4
+Verifying entry (0/4):/dir1
+PASS verifyingEntry.fullPath is "/dir1"
+PASS typeof verifyingEntry.isDirectory is 'boolean'
+PASS verifyingEntry.isDirectory is true
+PASS returnedEntries.length is 2
+/dir1/UTF8-2.txt
+/dir1/UTF8.txt
+Verifying entry (1/4):/UTF8.txt
+PASS verifyingEntry.fullPath is "/UTF8.txt"
+PASS typeof verifyingEntry.isDirectory is 'boolean'
+PASS verifyingEntry.isDirectory is false
+PASS returnedMetadata.size is 5
+Verifying entry (2/4):/test.txt
+PASS verifyingEntry.fullPath is "/test.txt"
+PASS typeof verifyingEntry.isDirectory is 'boolean'
+PASS verifyingEntry.isDirectory is false
+PASS returnedMetadata.size is 5
+Verifying entry (3/4):/dir2
+PASS verifyingEntry.fullPath is "/dir2"
+PASS typeof verifyingEntry.isDirectory is 'boolean'
+PASS verifyingEntry.isDirectory is true
+PASS returnedEntries.length is 1
+/dir2/green.jpg
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/fast/forms/file/input-file-entries-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/fast/forms/file/input-file-entries.html (0 => 120667)


--- trunk/LayoutTests/fast/forms/file/input-file-entries.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/file/input-file-entries.html	2012-06-19 04:13:44 UTC (rev 120667)
@@ -0,0 +1,133 @@
+<!DOCTYPE html>
+<html>
+<body>
+<input type="file" name="files" id="files">
+<pre id="console"></pre>
+<script src=""
+<script>
+description('Tests the webkitEntries attribute of &lt;input type="file"&gt;');
+
+var testCases = [
+  // Single file.
+  ['dir1/UTF8.txt'],
+  // Single directory.
+  ['dir1'],
+  // Multiple files.
+  ['apple.gif', 'dir1/UTF8.txt', 'dir2/green.jpg'],
+  // Multiple directories.
+  ['dir1', 'dir2'],
+  // Mixed case.
+  ['dir1', 'dir1/UTF8.txt', 'test.txt', 'dir2']
+];
+
+// The expected directories/files info in the actual resources directory.
+var expectedFileAttributes = {
+  'dir1': { 'directory': true, 'files':[ '/dir1/UTF8.txt', '/dir1/UTF8-2.txt' ] },
+  'dir2': { 'directory': true, 'files':[ '/dir2/green.jpg' ] },
+  'apple.gif':       { 'directory': false, 'size': 3340 },
+  'test.txt':        { 'directory': false, 'size': 5 },
+  'dir1/UTF8.txt':   { 'directory': false, 'size': 5 },
+  'dir1/UTF8-2.txt': { 'directory': false, 'size': 9 },
+  'dir2/green.jpg':  { 'directory': false, 'size': 764 }
+};
+
+var droppedEntries, verifyingEntry, returnedMetadata, returnedEntries;
+
+var jsTestIsAsync = true;
+if (window.layoutTestController) {
+    layoutTestController.waitUntilDone();
+    doTest(0);
+}
+
+function doTest(index)
+{
+    if (index >= testCases.length) {
+      finishJSTest();
+      return;
+    }
+
+    debug('* Testing testCases[' + index + ']');
+    var paths = testCases[index];
+    var input = document.getElementById('files');
+    input._onchange_ = function() { onInputFileChange(index); };
+    if (paths.length > 1)
+        input.setAttribute('multiple', 'multiple')
+    else
+        input.removeAttribute('multiple')
+    var testPaths = paths.map(function(path) { return '../resources/' + path });
+    eventSender.beginDragWithFiles(testPaths);
+    var centerX = input.offsetLeft + input.offsetWidth / 2;
+    var centerY = input.offsetTop + input.offsetHeight / 2;
+    eventSender.mouseMoveTo(centerX, centerY);
+    eventSender.mouseUp();
+}
+
+function onInputFileChange(index)
+{
+    droppedEntries = document.getElementById('files').webkitEntries;
+    shouldEvaluateTo('droppedEntries.length', testCases[index].length);
+    verifyEntry(index, 0);
+}
+
+function verifyEntry(testIndex, entryIndex)
+{
+    if (entryIndex == testCases[testIndex].length) {
+        doTest(testIndex + 1);
+        return;
+    }
+
+    var entry = verifyingEntry = droppedEntries[entryIndex];
+    debug('Verifying entry (' + entryIndex + '/' + testCases[testIndex].length + '):' + entry.fullPath);
+
+    var path = testCases[testIndex][entryIndex];
+    var expected = expectedFileAttributes[path];
+    var expectedPath = '/' + getBaseName(path);
+
+    shouldBeEqualToString('verifyingEntry.fullPath', expectedPath);
+    shouldEvaluateTo('verifyingEntry.isDirectory', expected.directory);
+
+    var callback = function() { verifyEntry(testIndex, entryIndex + 1); };
+    if (entry.isFile) {
+        entry.getMetadata(verifyFile.bind(this, expected, callback), onError);
+    } else {
+        var reader = entry.createReader();
+        reader.readEntries(verifyDirectory.bind(this, expected, callback), onError);
+    }
+}
+
+function verifyFile(expected, callback, metadata)
+{
+    returnedMetadata = metadata;
+    shouldEvaluateTo('returnedMetadata.size', expected.size);
+    callback();
+}
+
+function verifyDirectory(expected, callback, entries)
+{
+    returnedEntries = entries;
+    shouldEvaluateTo('returnedEntries.length', expected.files.length);
+    var foundPaths = [];
+    for (var i = 0; i < returnedEntries.length; i++)
+        foundPaths.push(returnedEntries[i].fullPath);
+    foundPaths.sort();
+    for (var i = 0; i < foundPaths.length; i++)
+        debug(foundPaths[i]);
+    callback();
+}
+
+function getBaseName(path)
+{
+    var components = path.split('/');
+    return components[components.length - 1];
+}
+
+function onError(error)
+{
+    testFailed('Test finished with unexpected error: ' + error.code);
+    finishJSTest();
+}
+
+</script>
+<script src=""
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/forms/file/input-file-entries.html
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/fast/forms/resources/dir1/UTF8-2.txt (0 => 120667)


--- trunk/LayoutTests/fast/forms/resources/dir1/UTF8-2.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/resources/dir1/UTF8-2.txt	2012-06-19 04:13:44 UTC (rev 120667)
@@ -0,0 +1 @@
+Wonderful
\ No newline at end of file
Property changes on: trunk/LayoutTests/fast/forms/resources/dir1/UTF8-2.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/fast/forms/resources/dir1/UTF8.txt (0 => 120667)


--- trunk/LayoutTests/fast/forms/resources/dir1/UTF8.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/resources/dir1/UTF8.txt	2012-06-19 04:13:44 UTC (rev 120667)
@@ -0,0 +1 @@
+Hello
\ No newline at end of file
Property changes on: trunk/LayoutTests/fast/forms/resources/dir1/UTF8.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/fast/forms/resources/dir2/green.jpg


(Binary files differ)
Property changes on: trunk/LayoutTests/fast/forms/resources/dir2/green.jpg ___________________________________________________________________

Added: svn:mime-type

Modified: trunk/LayoutTests/platform/efl/Skipped (120666 => 120667)


--- trunk/LayoutTests/platform/efl/Skipped	2012-06-19 04:02:48 UTC (rev 120666)
+++ trunk/LayoutTests/platform/efl/Skipped	2012-06-19 04:13:44 UTC (rev 120667)
@@ -1132,6 +1132,9 @@
 # Requires ENABLE(MEDIA_CAPTURE)
 fast/forms/file/file-input-capture.html
 
+# Requires ENABLE(FILE_SYSTEM)
+fast/forms/file/input-file-entries.html
+
 # Transparent image being produced
 fast/frames/transparent-scrollbar.html
 

Modified: trunk/LayoutTests/platform/efl/TestExpectations (120666 => 120667)


--- trunk/LayoutTests/platform/efl/TestExpectations	2012-06-19 04:02:48 UTC (rev 120666)
+++ trunk/LayoutTests/platform/efl/TestExpectations	2012-06-19 04:13:44 UTC (rev 120667)
@@ -218,6 +218,7 @@
 BUGWK84333 : fast/forms/file/file-input-reset.html = IMAGE
 BUGWK84333 : fast/forms/file/get-file-upload.html = TEXT
 BUGWK84333 : fast/forms/file/input-file-directory-upload.html = TEXT
+BUGWK84333 : fast/forms/file/input-file-entries.html = TEXT
 BUGWK84333 : fast/forms/file/input-file-re-render.html = MISSING
 BUGWK84333 : fast/forms/file/input-file-write-files.html = TEXT
 BUGWK84333 : fast/forms/file/recover-file-input-in-unposted-form.html = TEXT

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (120666 => 120667)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2012-06-19 04:02:48 UTC (rev 120666)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2012-06-19 04:13:44 UTC (rev 120667)
@@ -159,6 +159,7 @@
 BUGWKGTK SKIP : http/tests/websocket/tests/hybi/send-file-blob-fail.html = TEXT
 BUGWKGTK SKIP : http/tests/workers/terminate-during-sync-operation.html = TEXT
 BUGWKGTK SKIP : fast/mutation/filesystem-callback-delivery.html = TEXT
+BUGWKGTK SKIP : fast/forms/file/input-file-entries.html = TEXT
 
 // Requires WebP support.
 BUGWKGTK SKIP : fast/canvas/canvas-toDataURL-webp.html = TEXT

Modified: trunk/LayoutTests/platform/mac/Skipped (120666 => 120667)


--- trunk/LayoutTests/platform/mac/Skipped	2012-06-19 04:02:48 UTC (rev 120666)
+++ trunk/LayoutTests/platform/mac/Skipped	2012-06-19 04:13:44 UTC (rev 120667)
@@ -243,6 +243,9 @@
 # Directory upload is not enabled.
 fast/forms/file/input-file-directory-upload.html
 
+# Requires ENABLE(FILE_SYSTEM)
+fast/forms/file/input-file-entries.html
+
 # Web Timing is not enabled.
 # https://bugs.webkit.org/show_bug.cgi?id=42434
 fast/dom/Window/window-properties-performance.html

Modified: trunk/LayoutTests/platform/qt/Skipped (120666 => 120667)


--- trunk/LayoutTests/platform/qt/Skipped	2012-06-19 04:02:48 UTC (rev 120666)
+++ trunk/LayoutTests/platform/qt/Skipped	2012-06-19 04:13:44 UTC (rev 120667)
@@ -100,6 +100,9 @@
 # ENABLE(DIRECTORY_UPLOAD) is disabled.
 fast/forms/file/input-file-directory-upload.html
 
+# ENABLE(FILE_SYSTEM) is disabled.
+fast/forms/file/input-file-entries.html
+
 # ENABLE(INDEXED_DATABASE) is disabled.
 storage/indexeddb
 http/tests/inspector/indexeddb

Modified: trunk/LayoutTests/platform/win/Skipped (120666 => 120667)


--- trunk/LayoutTests/platform/win/Skipped	2012-06-19 04:02:48 UTC (rev 120666)
+++ trunk/LayoutTests/platform/win/Skipped	2012-06-19 04:13:44 UTC (rev 120667)
@@ -259,6 +259,7 @@
 fast/forms/file/file-input-reset.html
 fast/forms/file/file-reset-in-change.html
 fast/forms/file/input-file-directory-upload.html
+fast/forms/file/input-file-entries.html
 fast/forms/file/input-file-re-render.html
 fast/forms/file/recover-file-input-in-unposted-form.html
 http/tests/security/clipboard/clipboard-file-access.html

Modified: trunk/LayoutTests/platform/wincairo/Skipped (120666 => 120667)


--- trunk/LayoutTests/platform/wincairo/Skipped	2012-06-19 04:02:48 UTC (rev 120666)
+++ trunk/LayoutTests/platform/wincairo/Skipped	2012-06-19 04:13:44 UTC (rev 120667)
@@ -1808,6 +1808,7 @@
 http/tests/websocket/tests/hybi/send-file-blob.html
 http/tests/websocket/tests/hybi/send-file-blob-fail.html
 fast/mutation/filesystem-callback-delivery.html
+fast/forms/file/input-file-entries.html
 
 # LayoutTestController::nodesFromRect is not supported.
 fast/dom/nodesFromRect-basic.html

Modified: trunk/LayoutTests/platform/wk2/Skipped (120666 => 120667)


--- trunk/LayoutTests/platform/wk2/Skipped	2012-06-19 04:02:48 UTC (rev 120666)
+++ trunk/LayoutTests/platform/wk2/Skipped	2012-06-19 04:13:44 UTC (rev 120667)
@@ -1397,6 +1397,7 @@
 fast/forms/file/file-input-reset.html
 fast/forms/file/get-file-upload.html
 fast/forms/file/input-file-re-render.html
+fast/forms/file/input-file-entries.html
 fast/forms/file/recover-file-input-in-unposted-form.html
 http/tests/local/fileapi/file-last-modified-after-delete.html
 http/tests/local/fileapi/file-last-modified.html

Modified: trunk/Source/WebCore/ChangeLog (120666 => 120667)


--- trunk/Source/WebCore/ChangeLog	2012-06-19 04:02:48 UTC (rev 120666)
+++ trunk/Source/WebCore/ChangeLog	2012-06-19 04:13:44 UTC (rev 120667)
@@ -1,3 +1,38 @@
+2012-06-12  Kinuko Yasuda  <[email protected]>
+
+        Support File/DirectoryEntry access for <input type=file> if FileSystem API is enabled
+        https://bugs.webkit.org/show_bug.cgi?id=88293
+
+        Reviewed by Tony Chang.
+
+        Proposal email on whatwg: http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2011-November/033814.html
+        Proposal draft: http://wiki.whatwg.org/wiki/DragAndDropEntries
+
+        Test: fast/forms/file/input-file-entries.html
+
+        * Modules/filesystem/HTMLInputElementFileSystem.cpp: Added.
+        * Modules/filesystem/HTMLInputElementFileSystem.h: Added.
+        * Modules/filesystem/HTMLInputElementFileSystem.idl: Added.
+        * WebCore.gypi:
+        * html/FileInputType.cpp:
+        (WebCore::FileInputType::receiveDroppedFiles): Retrieves dropped file
+        system Id if the given DragData has it.
+        (WebCore::FileInputType::droppedFileSystemId): Added. This returns
+        dropped file system Id retrieved in receiveDroppedFiles, or an empty
+        string if the platform does not support isolated file system for
+        dropped files.
+        * html/FileInputType.h:
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::droppedFileSystemId): Added.
+        * html/HTMLInputElement.h:
+        * html/InputType.cpp:
+        (WebCore::InputType::droppedFileSystemId): Added.
+        * html/InputType.h:
+        * platform/DragData.cpp:
+        * platform/DragData.h:
+        * platform/chromium/DragDataChromium.cpp:
+        (WebCore::DragData::droppedFileSystemId): Added.
+
 2012-06-18  Shinya Kawanaka  <[email protected]>
 
         [Crash][Editing] VisibleSelection::adjustSelectionToAvoidCrossingEditingBoundaries() crashes in some Shadow DOM case.

Modified: trunk/Source/WebCore/Modules/filesystem/DOMFileSystem.cpp (120666 => 120667)


--- trunk/Source/WebCore/Modules/filesystem/DOMFileSystem.cpp	2012-06-19 04:02:48 UTC (rev 120666)
+++ trunk/Source/WebCore/Modules/filesystem/DOMFileSystem.cpp	2012-06-19 04:13:44 UTC (rev 120667)
@@ -64,11 +64,12 @@
 
 PassRefPtr<DOMFileSystem> DOMFileSystem::createIsolatedFileSystem(ScriptExecutionContext* context, const String& filesystemId)
 {
+    if (filesystemId.isEmpty())
+        return 0;
+
     StringBuilder filesystemName;
     filesystemName.append(context->securityOrigin()->databaseIdentifier());
-    filesystemName.append(":");
-    filesystemName.append(isolatedPathPrefix);
-    filesystemName.append("_");
+    filesystemName.append(":Isolated_");
     filesystemName.append(filesystemId);
 
     // The rootURL created here is going to be attached to each filesystem request and

Added: trunk/Source/WebCore/Modules/filesystem/HTMLInputElementFileSystem.cpp (0 => 120667)


--- trunk/Source/WebCore/Modules/filesystem/HTMLInputElementFileSystem.cpp	                        (rev 0)
+++ trunk/Source/WebCore/Modules/filesystem/HTMLInputElementFileSystem.cpp	2012-06-19 04:13:44 UTC (rev 120667)
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2012 Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 "HTMLInputElementFileSystem.h"
+
+#if ENABLE(FILE_SYSTEM)
+
+#include "DOMFilePath.h"
+#include "DOMFileSystem.h"
+#include "DirectoryEntry.h"
+#include "EntryArray.h"
+#include "FileEntry.h"
+#include "FileList.h"
+#include "FileMetadata.h"
+#include "FileSystem.h"
+#include "HTMLInputElement.h"
+
+namespace WebCore {
+
+// static
+PassRefPtr<EntryArray> HTMLInputElementFileSystem::webkitEntries(HTMLInputElement* input, ScriptExecutionContext* scriptExecutionContext)
+{
+    RefPtr<EntryArray> array = EntryArray::create();
+
+    RefPtr<DOMFileSystem> filesystem = DOMFileSystem::createIsolatedFileSystem(scriptExecutionContext, input->droppedFileSystemId());
+    if (!filesystem) {
+        // Drag-drop isolated filesystem is not available.
+        return array;
+    }
+
+    FileList* files = input->files();
+    ASSERT(files);
+    for (unsigned i = 0; i < files->length(); ++i) {
+        File* file = files->item(i);
+
+        // FIXME: This involves synchronous file operation.
+        FileMetadata metadata;
+        if (!getFileMetadata(file->path(), metadata))
+            continue;
+
+        // The dropped entries are mapped as top-level entries in the isolated filesystem.
+        String virtualPath = DOMFilePath::append("/", file->name());
+        if (metadata.type == FileMetadata::TypeDirectory)
+            array->append(DirectoryEntry::create(filesystem, virtualPath));
+        else
+            array->append(FileEntry::create(filesystem, virtualPath));
+    }
+    return array;
+}
+
+HTMLInputElementFileSystem::HTMLInputElementFileSystem()
+{
+}
+
+HTMLInputElementFileSystem::~HTMLInputElementFileSystem()
+{
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(FILE_SYSTEM)
Property changes on: trunk/Source/WebCore/Modules/filesystem/HTMLInputElementFileSystem.cpp
___________________________________________________________________

Added: svn:eol-style

Added: trunk/Source/WebCore/Modules/filesystem/HTMLInputElementFileSystem.h (0 => 120667)


--- trunk/Source/WebCore/Modules/filesystem/HTMLInputElementFileSystem.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/filesystem/HTMLInputElementFileSystem.h	2012-06-19 04:13:44 UTC (rev 120667)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2012 Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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.
+ */
+
+#ifndef HTMLInputElementFileSystem_h
+#define HTMLInputElementFileSystem_h
+
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+
+class EntryArray;
+class HTMLInputElement;
+class ScriptExecutionContext;
+
+class HTMLInputElementFileSystem {
+public:
+    static PassRefPtr<EntryArray> webkitEntries(HTMLInputElement*, ScriptExecutionContext*);
+
+private:
+    HTMLInputElementFileSystem();
+    ~HTMLInputElementFileSystem();
+};
+
+} // namespace WebCore
+
+#endif // HTMLInputElementFileSystem_h
Property changes on: trunk/Source/WebCore/Modules/filesystem/HTMLInputElementFileSystem.h
___________________________________________________________________

Added: svn:eol-style

Added: trunk/Source/WebCore/Modules/filesystem/HTMLInputElementFileSystem.idl (0 => 120667)


--- trunk/Source/WebCore/Modules/filesystem/HTMLInputElementFileSystem.idl	                        (rev 0)
+++ trunk/Source/WebCore/Modules/filesystem/HTMLInputElementFileSystem.idl	2012-06-19 04:13:44 UTC (rev 120667)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2012 Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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.
+ */
+
+module core {
+
+    interface [
+        Conditional=FILE_SYSTEM,
+        Supplemental=HTMLInputElement
+    ] HTMLInputElementFileSystem {
+        readonly attribute [V8EnabledAtRuntime=FileSystem,CallWith=ScriptExecutionContext] EntryArray webkitEntries;
+    };
+
+}
+
Property changes on: trunk/Source/WebCore/Modules/filesystem/HTMLInputElementFileSystem.idl
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/WebCore.gypi (120666 => 120667)


--- trunk/Source/WebCore/WebCore.gypi	2012-06-19 04:02:48 UTC (rev 120666)
+++ trunk/Source/WebCore/WebCore.gypi	2012-06-19 04:13:44 UTC (rev 120667)
@@ -785,6 +785,7 @@
             'Modules/filesystem/FileWriter.idl',
             'Modules/filesystem/FileWriterCallback.idl',
             'Modules/filesystem/FileWriterSync.idl',
+            'Modules/filesystem/HTMLInputElementFileSystem.idl',
             'Modules/filesystem/Metadata.idl',
             'Modules/filesystem/MetadataCallback.idl',
             'Modules/filesystem/WorkerContextFileSystem.idl',
@@ -1412,6 +1413,8 @@
             'Modules/filesystem/FileWriterCallback.h',
             'Modules/filesystem/FileWriterSync.cpp',
             'Modules/filesystem/FileWriterSync.h',
+            'Modules/filesystem/HTMLInputElementFileSystem.cpp',
+            'Modules/filesystem/HTMLInputElementFileSystem.h',
             'Modules/filesystem/LocalFileSystem.cpp',
             'Modules/filesystem/LocalFileSystem.h',
             'Modules/filesystem/Metadata.h',

Modified: trunk/Source/WebCore/html/FileInputType.cpp (120666 => 120667)


--- trunk/Source/WebCore/html/FileInputType.cpp	2012-06-19 04:02:48 UTC (rev 120666)
+++ trunk/Source/WebCore/html/FileInputType.cpp	2012-06-19 04:13:44 UTC (rev 120667)
@@ -407,6 +407,10 @@
     }
 #endif
 
+#if ENABLE(FILE_SYSTEM)
+    m_droppedFileSystemId = dragData->droppedFileSystemId();
+#endif
+
     Vector<FileChooserFileInfo> files;
     for (unsigned i = 0; i < paths.size(); ++i)
         files.append(FileChooserFileInfo(paths[i]));
@@ -421,6 +425,13 @@
     return true;
 }
 
+#if ENABLE(FILE_SYSTEM)
+String FileInputType::droppedFileSystemId()
+{
+    return m_droppedFileSystemId;
+}
+#endif
+
 Icon* FileInputType::icon() const
 {
     return m_icon.get();

Modified: trunk/Source/WebCore/html/FileInputType.h (120666 => 120667)


--- trunk/Source/WebCore/html/FileInputType.h	2012-06-19 04:02:48 UTC (rev 120666)
+++ trunk/Source/WebCore/html/FileInputType.h	2012-06-19 04:13:44 UTC (rev 120667)
@@ -64,6 +64,9 @@
     virtual bool getTypeSpecificValue(String&) OVERRIDE; // Checked first, before internal storage or the value attribute.
     virtual void setValue(const String&, bool valueChanged, TextFieldEventBehavior) OVERRIDE;
     virtual bool receiveDroppedFiles(const DragData*) OVERRIDE;
+#if ENABLE(FILE_SYSTEM)
+    virtual String droppedFileSystemId() OVERRIDE;
+#endif
     virtual Icon* icon() const OVERRIDE;
     virtual bool isFileUpload() const OVERRIDE;
     virtual void createShadowSubtree() OVERRIDE;
@@ -84,6 +87,10 @@
 
     RefPtr<FileList> m_fileList;
     RefPtr<Icon> m_icon;
+
+#if ENABLE(FILE_SYSTEM)
+    String m_droppedFileSystemId;
+#endif
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (120666 => 120667)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2012-06-19 04:02:48 UTC (rev 120666)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2012-06-19 04:13:44 UTC (rev 120667)
@@ -1235,6 +1235,13 @@
     return m_inputType->receiveDroppedFiles(dragData);
 }
 
+#if ENABLE(FILE_SYSTEM)
+String HTMLInputElement::droppedFileSystemId()
+{
+    return m_inputType->droppedFileSystemId();
+}
+#endif
+
 Icon* HTMLInputElement::icon() const
 {
     return m_inputType->icon();

Modified: trunk/Source/WebCore/html/HTMLInputElement.h (120666 => 120667)


--- trunk/Source/WebCore/html/HTMLInputElement.h	2012-06-19 04:02:48 UTC (rev 120666)
+++ trunk/Source/WebCore/html/HTMLInputElement.h	2012-06-19 04:13:44 UTC (rev 120667)
@@ -219,6 +219,10 @@
     // Returns true if the given DragData has more than one dropped files.
     bool receiveDroppedFiles(const DragData*);
 
+#if ENABLE(FILE_SYSTEM)
+    String droppedFileSystemId();
+#endif
+
     Icon* icon() const;
     // These functions are used for rendering the input active during a
     // drag-and-drop operation.

Modified: trunk/Source/WebCore/html/InputType.cpp (120666 => 120667)


--- trunk/Source/WebCore/html/InputType.cpp	2012-06-19 04:02:48 UTC (rev 120666)
+++ trunk/Source/WebCore/html/InputType.cpp	2012-06-19 04:13:44 UTC (rev 120667)
@@ -677,6 +677,14 @@
     return false;
 }
 
+#if ENABLE(FILE_SYSTEM)
+String InputType::droppedFileSystemId()
+{
+    ASSERT_NOT_REACHED();
+    return String();
+}
+#endif
+
 Icon* InputType::icon() const
 {
     ASSERT_NOT_REACHED();

Modified: trunk/Source/WebCore/html/InputType.h (120666 => 120667)


--- trunk/Source/WebCore/html/InputType.h	2012-06-19 04:02:48 UTC (rev 120666)
+++ trunk/Source/WebCore/html/InputType.h	2012-06-19 04:13:44 UTC (rev 120667)
@@ -235,6 +235,9 @@
     virtual void setFiles(PassRefPtr<FileList>);
     // Should return true if the given DragData has more than one dropped files.
     virtual bool receiveDroppedFiles(const DragData*);
+#if ENABLE(FILE_SYSTEM)
+    virtual String droppedFileSystemId();
+#endif
     virtual Icon* icon() const;
     // Should return true if the corresponding renderer for a type can display a suggested value.
     virtual bool canSetSuggestedValue();

Modified: trunk/Source/WebCore/platform/DragData.cpp (120666 => 120667)


--- trunk/Source/WebCore/platform/DragData.cpp	2012-06-19 04:02:48 UTC (rev 120666)
+++ trunk/Source/WebCore/platform/DragData.cpp	2012-06-19 04:13:44 UTC (rev 120667)
@@ -70,9 +70,16 @@
         keyState = keyState | PlatformEvent::MetaKey;
     return keyState;
 }
+
+#if ENABLE(FILE_SYSTEM)
+String DragData::droppedFileSystemId() const
+{
+    return String();
+}
 #endif
+#endif
 
-
 } // namespace WebCore
 
+
 #endif // ENABLE(DRAG_SUPPORT)

Modified: trunk/Source/WebCore/platform/DragData.h (120666 => 120667)


--- trunk/Source/WebCore/platform/DragData.h	2012-06-19 04:02:48 UTC (rev 120666)
+++ trunk/Source/WebCore/platform/DragData.h	2012-06-19 04:13:44 UTC (rev 120667)
@@ -123,6 +123,10 @@
     const String& pasteboardName() { return m_pasteboardName; }
 #endif
 
+#if ENABLE(FILE_SYSTEM)
+    String droppedFileSystemId() const;
+#endif
+
 #if PLATFORM(QT) || PLATFORM(GTK)
     // This constructor should used only by WebKit2 IPC because DragData
     // is initialized by the decoder and not in the constructor.
@@ -156,4 +160,3 @@
 }
 
 #endif // !DragData_h
-

Modified: trunk/Source/WebCore/platform/chromium/DragDataChromium.cpp (120666 => 120667)


--- trunk/Source/WebCore/platform/chromium/DragDataChromium.cpp	2012-06-19 04:02:48 UTC (rev 120666)
+++ trunk/Source/WebCore/platform/chromium/DragDataChromium.cpp	2012-06-19 04:13:44 UTC (rev 120667)
@@ -43,6 +43,10 @@
 #include <public/Platform.h>
 #include <public/WebFileUtilities.h>
 
+#if ENABLE(FILE_SYSTEM)
+#include "DraggedIsolatedFileSystem.h"
+#endif
+
 namespace WebCore {
 
 static bool containsHTML(const ChromiumDataObject* dropData)
@@ -162,4 +166,15 @@
     return Color();
 }
 
+#if ENABLE(FILE_SYSTEM)
+String DragData::droppedFileSystemId() const
+{
+    DraggedIsolatedFileSystem* filesystem = DraggedIsolatedFileSystem::from(m_platformDragData);
+    if (!filesystem)
+        return String();
+    return filesystem->filesystemId();
+}
+#endif
+
+
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to