2010-07-07 John Gregg <johnnyg@google.com>
Reviewed by Jian Li.
Experimental directory upload feature.
https://bugs.webkit.org/show_bug.cgi?id=40872
This patch adds a new HTML attribute webkitdirectory which applies to
<input type="file"> tags and allows the user to specify a folder
which is recursively enumerated so that all the files in that folder
are added to the file list.
The files chosen in that way have a .webkitRelativePath attribute which contains
the relative path starting from the chosen folder. The relative path is
also appended to each item in the FormData when uploaded.
All the code is behind an ENABLE_DIRECTORY_UPLOAD flag.
Test: fast/forms/input-file-directory-upload.html
* html/Blob.cpp:
(WebCore::Blob::Blob):
* html/Blob.h:
* html/File.cpp:
(WebCore::File::File):
(WebCore::File::Init):
(WebCore::File::webkitRelativePath):
* html/File.h:
(WebCore::File::create):
* html/File.idl:
* html/HTMLAttributeNames.in: add webkitdirectory attribute
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::setFileListFromRenderer):
(WebCore::HTMLInputElement::webkitdirectory):
* html/HTMLInputElement.h:
* html/HTMLInputElement.idl:
* platform/BlobItem.cpp:
(WebCore::FileBlobItem::create):
(WebCore::FileBlobItem::FileBlobItem):
* platform/BlobItem.h:
(WebCore::FileBlobItem::relativePath):
* platform/FileChooser.h:
(WebCore::FileChooser::allowsDirectoryUpload):
* platform/network/FormData.cpp:
(WebCore::FormData::appendKeyValuePairItems):
* rendering/RenderFileUploadControl.cpp:
(WebCore::RenderFileUploadControl::allowsMultipleFiles):
(WebCore::RenderFileUploadControl::allowsDirectoryUpload):
* rendering/RenderFileUploadControl.h:
2010-07-07 John Gregg <johnnyg@google.com>
Reviewed by Jian Li.
Layout test for experimental directory upload feature. Only enabled on chromium since that's where the feature is compiled in.
https://bugs.webkit.org/show_bug.cgi?id=40872
* fast/forms/input-file-directory-upload-expected.txt: Added.
* fast/forms/input-file-directory-upload.html: Added.
* platform/gtk/Skipped:
* platform/mac/Skipped:
* platform/qt/Skipped:
* platform/win/Skipped:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63454 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/html/File.h b/WebCore/html/File.h
index 582db28..d685472 100644
--- a/WebCore/html/File.h
+++ b/WebCore/html/File.h
@@ -39,9 +39,20 @@
return adoptRef(new File(path));
}
+#if ENABLE(DIRECTORY_UPLOAD)
+ static PassRefPtr<File> create(const String& relativePath, const String& path)
+ {
+ return adoptRef(new File(relativePath, path));
+ }
+#endif
+
virtual bool isFile() const { return true; }
const String& name() const;
+#if ENABLE(DIRECTORY_UPLOAD)
+ // Returns the relative path of this file in the context of a directory selection.
+ const String& webkitRelativePath() const;
+#endif
// FIXME: obsolete attributes. To be removed.
const String& fileName() const { return name(); }
@@ -49,6 +60,11 @@
private:
File(const String& path);
+ void Init();
+
+#if ENABLE(DIRECTORY_UPLOAD)
+ File(const String& relativePath, const String& path);
+#endif
};
} // namespace WebCore