Changeset 63454 in webkit
- Timestamp:
- Jul 15, 2010 1:36:40 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r63452 r63454 1 2010-07-07 John Gregg <johnnyg@google.com> 2 3 Reviewed by Jian Li. 4 5 Layout test for experimental directory upload feature. Only enabled on chromium since that's where the feature is compiled in. 6 https://bugs.webkit.org/show_bug.cgi?id=40872 7 8 * fast/forms/input-file-directory-upload-expected.txt: Added. 9 * fast/forms/input-file-directory-upload.html: Added. 10 * platform/gtk/Skipped: 11 * platform/mac/Skipped: 12 * platform/qt/Skipped: 13 * platform/win/Skipped: 14 1 15 2010-07-15 Simon Fraser <simon.fraser@apple.com> 2 16 -
trunk/LayoutTests/platform/gtk/Skipped
r63409 r63454 5859 5859 # Missing DRT API. 5860 5860 http/tests/loading/preload-slow-loading.php 5861 5862 # Directory upload is not enabled. 5863 fast/forms/input-file-directory-upload.html -
trunk/LayoutTests/platform/mac/Skipped
r63445 r63454 289 289 fast/images/large-size-image-crash.html 290 290 291 # Directory upload is not enabled. 292 fast/forms/input-file-directory-upload.html -
trunk/LayoutTests/platform/qt/Skipped
r63409 r63454 5461 5461 inspector/timeline-parse-html.html 5462 5462 inspector/timeline-recalculate-styles.html 5463 5464 # Directory upload is not enabled. 5465 fast/forms/input-file-directory-upload.html -
trunk/LayoutTests/platform/win/Skipped
r63409 r63454 954 954 userscripts/user-style-all-frames.html 955 955 userscripts/user-style-top-frame-only.html 956 957 # Directory upload is not enabled. 958 fast/forms/input-file-directory-upload.html -
trunk/WebCore/ChangeLog
r63452 r63454 1 2010-07-07 John Gregg <johnnyg@google.com> 2 3 Reviewed by Jian Li. 4 5 Experimental directory upload feature. 6 https://bugs.webkit.org/show_bug.cgi?id=40872 7 8 This patch adds a new HTML attribute webkitdirectory which applies to 9 <input type="file"> tags and allows the user to specify a folder 10 which is recursively enumerated so that all the files in that folder 11 are added to the file list. 12 13 The files chosen in that way have a .webkitRelativePath attribute which contains 14 the relative path starting from the chosen folder. The relative path is 15 also appended to each item in the FormData when uploaded. 16 17 All the code is behind an ENABLE_DIRECTORY_UPLOAD flag. 18 19 Test: fast/forms/input-file-directory-upload.html 20 21 * html/Blob.cpp: 22 (WebCore::Blob::Blob): 23 * html/Blob.h: 24 * html/File.cpp: 25 (WebCore::File::File): 26 (WebCore::File::Init): 27 (WebCore::File::webkitRelativePath): 28 * html/File.h: 29 (WebCore::File::create): 30 * html/File.idl: 31 * html/HTMLAttributeNames.in: add webkitdirectory attribute 32 * html/HTMLInputElement.cpp: 33 (WebCore::HTMLInputElement::setFileListFromRenderer): 34 (WebCore::HTMLInputElement::webkitdirectory): 35 * html/HTMLInputElement.h: 36 * html/HTMLInputElement.idl: 37 * platform/BlobItem.cpp: 38 (WebCore::FileBlobItem::create): 39 (WebCore::FileBlobItem::FileBlobItem): 40 * platform/BlobItem.h: 41 (WebCore::FileBlobItem::relativePath): 42 * platform/FileChooser.h: 43 (WebCore::FileChooser::allowsDirectoryUpload): 44 * platform/network/FormData.cpp: 45 (WebCore::FormData::appendKeyValuePairItems): 46 * rendering/RenderFileUploadControl.cpp: 47 (WebCore::RenderFileUploadControl::allowsMultipleFiles): 48 (WebCore::RenderFileUploadControl::allowsDirectoryUpload): 49 * rendering/RenderFileUploadControl.h: 50 1 51 2010-07-15 Simon Fraser <simon.fraser@apple.com> 2 52 -
trunk/WebCore/html/Blob.cpp
r61343 r63454 42 42 for (size_t i = 0; i < items.size(); ++i) 43 43 m_items.append(items[i]); 44 } 45 46 Blob::Blob(const PassRefPtr<BlobItem>& item) 47 { 48 m_items.append(item); 44 49 } 45 50 -
trunk/WebCore/html/Blob.h
r61343 r63454 72 72 protected: 73 73 Blob(const String& type, const BlobItemList&); 74 Blob(const PassRefPtr<BlobItem>&); 74 75 75 76 // FIXME: Deprecated constructor. See also the comment for Blob::create(path). -
trunk/WebCore/html/File.cpp
r60799 r63454 35 35 : Blob(path) 36 36 { 37 Init(); 38 } 39 40 #if ENABLE(DIRECTORY_UPLOAD) 41 File::File(const String& relativePath, const String& filePath) 42 : Blob(FileBlobItem::create(filePath, relativePath)) 43 { 44 Init(); 45 } 46 #endif 47 48 void File::Init() 49 { 37 50 // We don't use MIMETypeRegistry::getMIMETypeForPath() because it returns "application/octet-stream" upon failure. 38 51 const String& fileName = name(); … … 47 60 } 48 61 62 #if ENABLE(DIRECTORY_UPLOAD) 63 const String& File::webkitRelativePath() const 64 { 65 return items().at(0)->toFileBlobItem()->relativePath(); 66 } 67 #endif 68 49 69 } // namespace WebCore -
trunk/WebCore/html/File.h
r60799 r63454 40 40 } 41 41 42 #if ENABLE(DIRECTORY_UPLOAD) 43 static PassRefPtr<File> create(const String& relativePath, const String& path) 44 { 45 return adoptRef(new File(relativePath, path)); 46 } 47 #endif 48 42 49 virtual bool isFile() const { return true; } 43 50 44 51 const String& name() const; 52 #if ENABLE(DIRECTORY_UPLOAD) 53 // Returns the relative path of this file in the context of a directory selection. 54 const String& webkitRelativePath() const; 55 #endif 45 56 46 57 // FIXME: obsolete attributes. To be removed. … … 50 61 private: 51 62 File(const String& path); 63 void Init(); 64 65 #if ENABLE(DIRECTORY_UPLOAD) 66 File(const String& relativePath, const String& path); 67 #endif 52 68 }; 53 69 -
trunk/WebCore/html/File.idl
r61223 r63454 31 31 ] File : Blob { 32 32 readonly attribute DOMString name; 33 #if defined(ENABLE_DIRECTORY_UPLOAD) && ENABLE_DIRECTORY_UPLOAD 34 readonly attribute DOMString webkitRelativePath; 35 #endif 33 36 34 37 // FIXME: obsolete attributes. To be removed. -
trunk/WebCore/html/HTMLAttributeNames.in
r61964 r63454 282 282 vlink 283 283 vspace 284 webkitdirectory 284 285 width 285 286 wrap -
trunk/WebCore/html/HTMLInputElement.cpp
r62596 r63454 41 41 #include "File.h" 42 42 #include "FileList.h" 43 #include "FileSystem.h" 43 44 #include "FocusController.h" 44 45 #include "FormDataList.h" … … 1968 1969 m_fileList->clear(); 1969 1970 int size = paths.size(); 1971 1972 #if ENABLE(DIRECTORY_UPLOAD) 1973 // If a directory is being selected, the UI allows a directory to be chosen 1974 // and the paths provided here share a root directory somewhere up the tree; 1975 // we want to store only the relative paths from that point. 1976 if (webkitdirectory() && size > 0) { 1977 String rootPath = directoryName(paths[0]); 1978 // Find the common root path. 1979 for (int i = 1; i < size; i++) { 1980 while (!paths[i].startsWith(rootPath)) 1981 rootPath = directoryName(rootPath); 1982 } 1983 rootPath = directoryName(rootPath); 1984 ASSERT(rootPath.length()); 1985 for (int i = 0; i < size; i++) 1986 m_fileList->append(File::create(paths[i].substring(1 + rootPath.length()), paths[i])); 1987 } else { 1988 for (int i = 0; i < size; i++) 1989 m_fileList->append(File::create(paths[i])); 1990 } 1991 #else 1970 1992 for (int i = 0; i < size; i++) 1971 1993 m_fileList->append(File::create(paths[i])); 1994 #endif 1972 1995 1973 1996 setFormControlValueMatchesRenderer(true); … … 2449 2472 } 2450 2473 2474 #if ENABLE(DIRECTORY_UPLOAD) 2475 bool HTMLInputElement::webkitdirectory() const 2476 { 2477 return !getAttribute(webkitdirectoryAttr).isNull(); 2478 } 2479 #endif 2480 2451 2481 void HTMLInputElement::setSize(unsigned size) 2452 2482 { -
trunk/WebCore/html/HTMLInputElement.h
r62705 r63454 181 181 bool multiple() const; 182 182 183 #if ENABLE(DIRECTORY_UPLOAD) 184 bool webkitdirectory() const; 185 #endif 186 183 187 virtual bool isAutofilled() const { return m_autofilled; } 184 188 void setAutofilled(bool value = true); -
trunk/WebCore/html/HTMLInputElement.idl
r63057 r63454 41 41 attribute [Reflect] DOMString min; 42 42 attribute [Reflect] boolean multiple; 43 #if defined(ENABLE_DIRECTORY_UPLOAD) && ENABLE_DIRECTORY_UPLOAD 44 attribute [Reflect] boolean webkitdirectory; 45 #endif 43 46 attribute [Reflect] DOMString name; 44 47 attribute [Reflect] DOMString pattern; -
trunk/WebCore/platform/BlobItem.cpp
r63343 r63454 78 78 { 79 79 } 80 81 #if ENABLE(DIRECTORY_UPLOAD) 82 PassRefPtr<BlobItem> FileBlobItem::create(const String& path, const String& relativePath) 83 { 84 return adoptRef(static_cast<BlobItem*>(new FileBlobItem(path, relativePath))); 85 } 86 87 FileBlobItem::FileBlobItem(const String& path, const String& relativePath) 88 : m_path(path) 89 , m_fileName(pathGetFileName(m_path)) 90 , m_relativePath(relativePath) 91 { 92 } 93 #endif 80 94 81 95 unsigned long long FileBlobItem::size() const -
trunk/WebCore/platform/BlobItem.h
r63343 r63454 99 99 public: 100 100 static PassRefPtr<BlobItem> create(const String& path); 101 #if ENABLE(DIRECTORY_UPLOAD) 102 static PassRefPtr<BlobItem> create(const String& path, const String& relativePath); 103 #endif 101 104 virtual const String& name() const { return m_fileName; } 102 105 virtual const String& path() const { return m_path; } 106 #if ENABLE(DIRECTORY_UPLOAD) 107 const String& relativePath() const { return m_relativePath; } 108 #endif 103 109 104 110 // BlobItem methods. … … 111 117 protected: 112 118 FileBlobItem(const String& path); 119 #if ENABLE(DIRECTORY_UPLOAD) 120 FileBlobItem(const String& path, const String& relativePath); 121 #endif 113 122 String m_path; 114 123 String m_fileName; 124 #if ENABLE(DIRECTORY_UPLOAD) 125 String m_relativePath; 126 #endif 115 127 }; 116 128 -
trunk/WebCore/platform/FileChooser.h
r56824 r63454 45 45 virtual void repaint() = 0; 46 46 virtual bool allowsMultipleFiles() = 0; 47 #if ENABLE(DIRECTORY_UPLOAD) 48 virtual bool allowsDirectoryUpload() = 0; 49 #endif 47 50 virtual String acceptTypes() = 0; 48 51 virtual void chooseIconForFiles(FileChooser*, const Vector<String>&) = 0; … … 71 74 72 75 bool allowsMultipleFiles() const { return m_client ? m_client->allowsMultipleFiles() : false; } 76 #if ENABLE(DIRECTORY_UPLOAD) 77 bool allowsDirectoryUpload() const { return m_client ? m_client->allowsDirectoryUpload() : false; } 78 #endif 73 79 // Acceptable MIME types. It's an 'accept' attribute value of the corresponding INPUT element. 74 80 String acceptTypes() const { return m_client ? m_client->acceptTypes() : String(); } -
trunk/WebCore/platform/network/FormData.cpp
r61618 r63454 225 225 if (fileItem) { 226 226 const String& path = fileItem->path(); 227 228 #if ENABLE(DIRECTORY_UPLOAD) 229 String fileName = !fileItem->relativePath().isEmpty() ? fileItem->relativePath() : fileItem->name(); 230 #else 227 231 String fileName = fileItem->name(); 232 #endif 228 233 229 234 // Let the application specify a filename if it's going to generate a replacement file for the upload. -
trunk/WebCore/rendering/RenderFileUploadControl.cpp
r61293 r63454 95 95 bool RenderFileUploadControl::allowsMultipleFiles() 96 96 { 97 #if ENABLE(DIRECTORY_UPLOAD) 98 if (allowsDirectoryUpload()) 99 return true; 100 #endif 101 97 102 HTMLInputElement* input = static_cast<HTMLInputElement*>(node()); 98 103 return !input->getAttribute(multipleAttr).isNull(); 99 104 } 105 106 #if ENABLE(DIRECTORY_UPLOAD) 107 bool RenderFileUploadControl::allowsDirectoryUpload() 108 { 109 HTMLInputElement* input = static_cast<HTMLInputElement*>(node()); 110 return !input->getAttribute(webkitdirectoryAttr).isNull(); 111 } 112 #endif 100 113 101 114 String RenderFileUploadControl::acceptTypes() -
trunk/WebCore/rendering/RenderFileUploadControl.h
r59876 r63454 63 63 void repaint() { RenderBlock::repaint(); } 64 64 bool allowsMultipleFiles(); 65 #if ENABLE(DIRECTORY_UPLOAD) 66 bool allowsDirectoryUpload(); 67 #endif 65 68 String acceptTypes(); 66 69 void chooseIconForFiles(FileChooser*, const Vector<String>&);
Note: See TracChangeset
for help on using the changeset viewer.