[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
johnnyg at google.com
johnnyg at google.com
Wed Dec 22 11:14:26 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 4b0a455b8fab92a7ad6f0c26a808902c12cf479e
Author: johnnyg at google.com <johnnyg at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Jul 15 20:36:40 2010 +0000
2010-07-07 John Gregg <johnnyg at 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 at 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/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 92ec98d..adfac59 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,17 @@
+2010-07-07 John Gregg <johnnyg at 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:
+
2010-07-15 Simon Fraser <simon.fraser at apple.com>
Reviewed by Dan Bernstein.
diff --git a/LayoutTests/fast/forms/input-file-directory-upload-expected.txt b/LayoutTests/fast/forms/input-file-directory-upload-expected.txt
new file mode 100644
index 0000000..eeb91fa
--- /dev/null
+++ b/LayoutTests/fast/forms/input-file-directory-upload-expected.txt
@@ -0,0 +1,19 @@
+
+PASS: name is file1; path is dirupload/path1/file1
+PASS: name is file2; path is dirupload/path1/file2
+PASS: name is file1; path is dirupload/path1/subpath1/file1
+PASS: name is file1; path is dirupload/path2/file1
+PASS: name is file1; path is dirupload/path2/subpath1/subpath2/file1
+PASS: name is file2; path is dirupload/path2/file2
+PASS: name is file1; path is dirupload/path3/file1
+PASS: name is file1; path is dirupload/file1
+
+PASS: name is file1; path is path1/file1
+PASS: name is file2; path is path1/file2
+
+PASS: name is file1; path is dirupload/path1/file1
+PASS: name is file1; path is dirupload/path2/file1
+
+PASS: name is file1; path is path1/file1
+PASS: name is file1; path is path1/subpath1/file1
+
diff --git a/LayoutTests/fast/forms/input-file-directory-upload.html b/LayoutTests/fast/forms/input-file-directory-upload.html
new file mode 100644
index 0000000..0123ee4
--- /dev/null
+++ b/LayoutTests/fast/forms/input-file-directory-upload.html
@@ -0,0 +1,78 @@
+<!DOCTYPE html>
+<html>
+<body>
+<input type="file" name="files" id="files" webkitdirectory>
+<pre id='output'></pre>
+
+<script>
+var testFileList1 = [
+ {'path': 'resources/dirupload/path1/file1', 'expect-relpath': 'dirupload/path1/file1'},
+ {'path': 'resources/dirupload/path1/file2', 'expect-relpath': 'dirupload/path1/file2' },
+ {'path': 'resources/dirupload/path1/subpath1/file1', 'expect-relpath': 'dirupload/path1/subpath1/file1'},
+ {'path': 'resources/dirupload/path2/file1', 'expect-relpath': 'dirupload/path2/file1'},
+ {'path': 'resources/dirupload/path2/subpath1/subpath2/file1', 'expect-relpath': 'dirupload/path2/subpath1/subpath2/file1'},
+ {'path': 'resources/dirupload/path2/file2', 'expect-relpath': 'dirupload/path2/file2'},
+ {'path': 'resources/dirupload/path3/file1', 'expect-relpath': 'dirupload/path3/file1'},
+ {'path': 'resources/dirupload/file1', 'expect-relpath': 'dirupload/file1'},
+];
+
+var testFileList2 = [
+ {'path': 'resources/dirupload/path1/file1', 'expect-relpath': 'path1/file1'},
+ {'path': 'resources/dirupload/path1/file2', 'expect-relpath': 'path1/file2' },
+];
+
+var testFileList3 = [
+ {'path': 'resources/dirupload/path1/file1', 'expect-relpath': 'dirupload/path1/file1'},
+ {'path': 'resources/dirupload/path2/file1', 'expect-relpath': 'dirupload/path2/file1' },
+];
+
+var testFileList4 = [
+ {'path': 'resources/dirupload/path1/file1', 'expect-relpath': 'path1/file1'},
+ {'path': 'resources/dirupload/path1/subpath1/file1', 'expect-relpath': 'path1/subpath1/file1' },
+];
+
+function log(message)
+{
+ document.getElementById('output').appendChild(document.createTextNode(message + "\n"));
+}
+
+function onInputFileChange(currentFileList, lastTest)
+{
+ var files = document.getElementById("files").files;
+ for (var i = 0; i < files.length; i++) {
+ if (files[i].webkitRelativePath != currentFileList[i]['expect-relpath'])
+ log("FAIL: name is " + files[i].name + "; path is " + files[i].webkitRelativePath + " but should be " + currentFileList[i]['expect-relpath']);
+ else
+ log("PASS: name is " + files[i].name + "; path is " + files[i].webkitRelativePath);
+ }
+
+ if (lastTest && layoutTestController)
+ layoutTestController.notifyDone();
+ else
+ log("");
+}
+
+function doTest(fileList, last)
+{
+ var pathsOnly = fileList.map(function(item) { return item['path'];});
+ var f = function() { onInputFileChange(fileList, last); };
+ document.getElementById("files").onchange = f;
+ eventSender.beginDragWithFiles(pathsOnly);
+ eventSender.mouseMoveTo(10, 10);
+ eventSender.mouseUp();
+}
+
+if (layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+if (window.eventSender) {
+ doTest(testFileList1);
+ doTest(testFileList2);
+ doTest(testFileList3);
+ doTest(testFileList4, true);
+}
+</script>
+</body>
+</html>
diff --git a/LayoutTests/platform/gtk/Skipped b/LayoutTests/platform/gtk/Skipped
index 8241a29..0cf3a82 100644
--- a/LayoutTests/platform/gtk/Skipped
+++ b/LayoutTests/platform/gtk/Skipped
@@ -5858,3 +5858,6 @@ editing/selection/extend-forward-after-set-base-and-extent.html
# Missing DRT API.
http/tests/loading/preload-slow-loading.php
+
+# Directory upload is not enabled.
+fast/forms/input-file-directory-upload.html
diff --git a/LayoutTests/platform/mac/Skipped b/LayoutTests/platform/mac/Skipped
index aabdad3..b65fd8f 100644
--- a/LayoutTests/platform/mac/Skipped
+++ b/LayoutTests/platform/mac/Skipped
@@ -288,3 +288,5 @@ fast/forms/input-appearance-speechbutton.html
# Needs to be fixed at image decoder layer for Safari.
fast/images/large-size-image-crash.html
+# Directory upload is not enabled.
+fast/forms/input-file-directory-upload.html
diff --git a/LayoutTests/platform/qt/Skipped b/LayoutTests/platform/qt/Skipped
index e1756b3..1e4acd8 100644
--- a/LayoutTests/platform/qt/Skipped
+++ b/LayoutTests/platform/qt/Skipped
@@ -5460,3 +5460,6 @@ fast/dom/beforeload/remove-video-in-beforeload-listener.html
inspector/timeline-layout.html
inspector/timeline-parse-html.html
inspector/timeline-recalculate-styles.html
+
+# Directory upload is not enabled.
+fast/forms/input-file-directory-upload.html
diff --git a/LayoutTests/platform/win/Skipped b/LayoutTests/platform/win/Skipped
index efd7c2f..e5ea19f 100644
--- a/LayoutTests/platform/win/Skipped
+++ b/LayoutTests/platform/win/Skipped
@@ -953,3 +953,6 @@ userscripts/user-script-all-frames.html
userscripts/user-script-top-frame-only.html
userscripts/user-style-all-frames.html
userscripts/user-style-top-frame-only.html
+
+# Directory upload is not enabled.
+fast/forms/input-file-directory-upload.html
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index c5e85a3..f34d77d 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,53 @@
+2010-07-07 John Gregg <johnnyg at 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-15 Simon Fraser <simon.fraser at apple.com>
Reviewed by Dan Bernstein.
diff --git a/WebCore/html/Blob.cpp b/WebCore/html/Blob.cpp
index baf3d49..0680d82 100644
--- a/WebCore/html/Blob.cpp
+++ b/WebCore/html/Blob.cpp
@@ -43,6 +43,11 @@ Blob::Blob(const String& type, const BlobItemList& items)
m_items.append(items[i]);
}
+Blob::Blob(const PassRefPtr<BlobItem>& item)
+{
+ m_items.append(item);
+}
+
Blob::Blob(const String& path)
{
// Note: this doesn't initialize the type unlike File(path).
diff --git a/WebCore/html/Blob.h b/WebCore/html/Blob.h
index ad6c7a6..f5526c7 100644
--- a/WebCore/html/Blob.h
+++ b/WebCore/html/Blob.h
@@ -71,6 +71,7 @@ public:
protected:
Blob(const String& type, const BlobItemList&);
+ Blob(const PassRefPtr<BlobItem>&);
// FIXME: Deprecated constructor. See also the comment for Blob::create(path).
Blob(const String& path);
diff --git a/WebCore/html/File.cpp b/WebCore/html/File.cpp
index 2c9ce53..4000dcb 100644
--- a/WebCore/html/File.cpp
+++ b/WebCore/html/File.cpp
@@ -34,6 +34,19 @@ namespace WebCore {
File::File(const String& path)
: Blob(path)
{
+ Init();
+}
+
+#if ENABLE(DIRECTORY_UPLOAD)
+File::File(const String& relativePath, const String& filePath)
+ : Blob(FileBlobItem::create(filePath, relativePath))
+{
+ Init();
+}
+#endif
+
+void File::Init()
+{
// We don't use MIMETypeRegistry::getMIMETypeForPath() because it returns "application/octet-stream" upon failure.
const String& fileName = name();
int index = fileName.reverseFind('.');
@@ -46,4 +59,11 @@ const String& File::name() const
return items().at(0)->toFileBlobItem()->name();
}
+#if ENABLE(DIRECTORY_UPLOAD)
+const String& File::webkitRelativePath() const
+{
+ return items().at(0)->toFileBlobItem()->relativePath();
+}
+#endif
+
} // namespace WebCore
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 @@ public:
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 @@ public:
private:
File(const String& path);
+ void Init();
+
+#if ENABLE(DIRECTORY_UPLOAD)
+ File(const String& relativePath, const String& path);
+#endif
};
} // namespace WebCore
diff --git a/WebCore/html/File.idl b/WebCore/html/File.idl
index 2632a4d..5626c8e 100644
--- a/WebCore/html/File.idl
+++ b/WebCore/html/File.idl
@@ -30,6 +30,9 @@ module html {
GenerateToJS
] File : Blob {
readonly attribute DOMString name;
+#if defined(ENABLE_DIRECTORY_UPLOAD) && ENABLE_DIRECTORY_UPLOAD
+ readonly attribute DOMString webkitRelativePath;
+#endif
// FIXME: obsolete attributes. To be removed.
readonly attribute DOMString fileName;
diff --git a/WebCore/html/HTMLAttributeNames.in b/WebCore/html/HTMLAttributeNames.in
index 36770e2..b4cdb02 100644
--- a/WebCore/html/HTMLAttributeNames.in
+++ b/WebCore/html/HTMLAttributeNames.in
@@ -281,5 +281,6 @@ version
viewsource
vlink
vspace
+webkitdirectory
width
wrap
diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp
index f6636c9..2d1cee1 100644
--- a/WebCore/html/HTMLInputElement.cpp
+++ b/WebCore/html/HTMLInputElement.cpp
@@ -40,6 +40,7 @@
#include "ExceptionCode.h"
#include "File.h"
#include "FileList.h"
+#include "FileSystem.h"
#include "FocusController.h"
#include "FormDataList.h"
#include "Frame.h"
@@ -1967,8 +1968,30 @@ void HTMLInputElement::setFileListFromRenderer(const Vector<String>& paths)
{
m_fileList->clear();
int size = paths.size();
+
+#if ENABLE(DIRECTORY_UPLOAD)
+ // If a directory is being selected, the UI allows a directory to be chosen
+ // and the paths provided here share a root directory somewhere up the tree;
+ // we want to store only the relative paths from that point.
+ if (webkitdirectory() && size > 0) {
+ String rootPath = directoryName(paths[0]);
+ // Find the common root path.
+ for (int i = 1; i < size; i++) {
+ while (!paths[i].startsWith(rootPath))
+ rootPath = directoryName(rootPath);
+ }
+ rootPath = directoryName(rootPath);
+ ASSERT(rootPath.length());
+ for (int i = 0; i < size; i++)
+ m_fileList->append(File::create(paths[i].substring(1 + rootPath.length()), paths[i]));
+ } else {
+ for (int i = 0; i < size; i++)
+ m_fileList->append(File::create(paths[i]));
+ }
+#else
for (int i = 0; i < size; i++)
m_fileList->append(File::create(paths[i]));
+#endif
setFormControlValueMatchesRenderer(true);
InputElement::notifyFormStateChanged(this);
@@ -2448,6 +2471,13 @@ bool HTMLInputElement::multiple() const
return !getAttribute(multipleAttr).isNull();
}
+#if ENABLE(DIRECTORY_UPLOAD)
+bool HTMLInputElement::webkitdirectory() const
+{
+ return !getAttribute(webkitdirectoryAttr).isNull();
+}
+#endif
+
void HTMLInputElement::setSize(unsigned size)
{
setAttribute(sizeAttr, String::number(size));
diff --git a/WebCore/html/HTMLInputElement.h b/WebCore/html/HTMLInputElement.h
index b055e73..49cf3c9 100644
--- a/WebCore/html/HTMLInputElement.h
+++ b/WebCore/html/HTMLInputElement.h
@@ -180,6 +180,10 @@ public:
bool multiple() const;
+#if ENABLE(DIRECTORY_UPLOAD)
+ bool webkitdirectory() const;
+#endif
+
virtual bool isAutofilled() const { return m_autofilled; }
void setAutofilled(bool value = true);
diff --git a/WebCore/html/HTMLInputElement.idl b/WebCore/html/HTMLInputElement.idl
index b93f05c..667358a 100644
--- a/WebCore/html/HTMLInputElement.idl
+++ b/WebCore/html/HTMLInputElement.idl
@@ -40,6 +40,9 @@ module html {
attribute long maxLength setter raises(DOMException);
attribute [Reflect] DOMString min;
attribute [Reflect] boolean multiple;
+#if defined(ENABLE_DIRECTORY_UPLOAD) && ENABLE_DIRECTORY_UPLOAD
+ attribute [Reflect] boolean webkitdirectory;
+#endif
attribute [Reflect] DOMString name;
attribute [Reflect] DOMString pattern;
attribute [Reflect] DOMString placeholder;
diff --git a/WebCore/platform/BlobItem.cpp b/WebCore/platform/BlobItem.cpp
index 9eeebcd..cc5e6c7 100644
--- a/WebCore/platform/BlobItem.cpp
+++ b/WebCore/platform/BlobItem.cpp
@@ -78,6 +78,20 @@ FileBlobItem::FileBlobItem(const String& path)
{
}
+#if ENABLE(DIRECTORY_UPLOAD)
+PassRefPtr<BlobItem> FileBlobItem::create(const String& path, const String& relativePath)
+{
+ return adoptRef(static_cast<BlobItem*>(new FileBlobItem(path, relativePath)));
+}
+
+FileBlobItem::FileBlobItem(const String& path, const String& relativePath)
+ : m_path(path)
+ , m_fileName(pathGetFileName(m_path))
+ , m_relativePath(relativePath)
+{
+}
+#endif
+
unsigned long long FileBlobItem::size() const
{
// FIXME: synchronized file call
diff --git a/WebCore/platform/BlobItem.h b/WebCore/platform/BlobItem.h
index e6cc2dc..3741f3f 100644
--- a/WebCore/platform/BlobItem.h
+++ b/WebCore/platform/BlobItem.h
@@ -98,8 +98,14 @@ public:
class FileBlobItem : public BlobItem {
public:
static PassRefPtr<BlobItem> create(const String& path);
+#if ENABLE(DIRECTORY_UPLOAD)
+ static PassRefPtr<BlobItem> create(const String& path, const String& relativePath);
+#endif
virtual const String& name() const { return m_fileName; }
virtual const String& path() const { return m_path; }
+#if ENABLE(DIRECTORY_UPLOAD)
+ const String& relativePath() const { return m_relativePath; }
+#endif
// BlobItem methods.
virtual unsigned long long size() const;
@@ -110,8 +116,14 @@ public:
protected:
FileBlobItem(const String& path);
+#if ENABLE(DIRECTORY_UPLOAD)
+ FileBlobItem(const String& path, const String& relativePath);
+#endif
String m_path;
String m_fileName;
+#if ENABLE(DIRECTORY_UPLOAD)
+ String m_relativePath;
+#endif
};
class StringBlobItem : public DataBlobItem {
diff --git a/WebCore/platform/FileChooser.h b/WebCore/platform/FileChooser.h
index e93b9ac..fa25406 100644
--- a/WebCore/platform/FileChooser.h
+++ b/WebCore/platform/FileChooser.h
@@ -44,6 +44,9 @@ public:
virtual void valueChanged() = 0;
virtual void repaint() = 0;
virtual bool allowsMultipleFiles() = 0;
+#if ENABLE(DIRECTORY_UPLOAD)
+ virtual bool allowsDirectoryUpload() = 0;
+#endif
virtual String acceptTypes() = 0;
virtual void chooseIconForFiles(FileChooser*, const Vector<String>&) = 0;
virtual ~FileChooserClient();
@@ -70,6 +73,9 @@ public:
void iconLoaded(PassRefPtr<Icon>);
bool allowsMultipleFiles() const { return m_client ? m_client->allowsMultipleFiles() : false; }
+#if ENABLE(DIRECTORY_UPLOAD)
+ bool allowsDirectoryUpload() const { return m_client ? m_client->allowsDirectoryUpload() : false; }
+#endif
// Acceptable MIME types. It's an 'accept' attribute value of the corresponding INPUT element.
String acceptTypes() const { return m_client ? m_client->acceptTypes() : String(); }
diff --git a/WebCore/platform/network/FormData.cpp b/WebCore/platform/network/FormData.cpp
index 9e4a227..80f17da 100644
--- a/WebCore/platform/network/FormData.cpp
+++ b/WebCore/platform/network/FormData.cpp
@@ -224,7 +224,12 @@ void FormData::appendKeyValuePairItems(const BlobItemList& items, const TextEnco
const FileBlobItem* fileItem = value->toFileBlobItem();
if (fileItem) {
const String& path = fileItem->path();
+
+#if ENABLE(DIRECTORY_UPLOAD)
+ String fileName = !fileItem->relativePath().isEmpty() ? fileItem->relativePath() : fileItem->name();
+#else
String fileName = fileItem->name();
+#endif
// Let the application specify a filename if it's going to generate a replacement file for the upload.
if (!path.isEmpty()) {
diff --git a/WebCore/rendering/RenderFileUploadControl.cpp b/WebCore/rendering/RenderFileUploadControl.cpp
index c652276..f31ca20 100644
--- a/WebCore/rendering/RenderFileUploadControl.cpp
+++ b/WebCore/rendering/RenderFileUploadControl.cpp
@@ -94,10 +94,23 @@ void RenderFileUploadControl::valueChanged()
bool RenderFileUploadControl::allowsMultipleFiles()
{
+#if ENABLE(DIRECTORY_UPLOAD)
+ if (allowsDirectoryUpload())
+ return true;
+#endif
+
HTMLInputElement* input = static_cast<HTMLInputElement*>(node());
return !input->getAttribute(multipleAttr).isNull();
}
+#if ENABLE(DIRECTORY_UPLOAD)
+bool RenderFileUploadControl::allowsDirectoryUpload()
+{
+ HTMLInputElement* input = static_cast<HTMLInputElement*>(node());
+ return !input->getAttribute(webkitdirectoryAttr).isNull();
+}
+#endif
+
String RenderFileUploadControl::acceptTypes()
{
return static_cast<HTMLInputElement*>(node())->accept();
diff --git a/WebCore/rendering/RenderFileUploadControl.h b/WebCore/rendering/RenderFileUploadControl.h
index 25d2639..205ba47 100644
--- a/WebCore/rendering/RenderFileUploadControl.h
+++ b/WebCore/rendering/RenderFileUploadControl.h
@@ -62,6 +62,9 @@ private:
void valueChanged();
void repaint() { RenderBlock::repaint(); }
bool allowsMultipleFiles();
+#if ENABLE(DIRECTORY_UPLOAD)
+ bool allowsDirectoryUpload();
+#endif
String acceptTypes();
void chooseIconForFiles(FileChooser*, const Vector<String>&);
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list