Changeset 221177 in webkit
- Timestamp:
- Aug 24, 2017 7:05:54 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 17 added
- 39 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r221173 r221177 1 2017-08-24 Chris Dumez <cdumez@apple.com> 2 3 [Directory Upload] Add basic support for input.webkitdirectory 4 https://bugs.webkit.org/show_bug.cgi?id=175950 5 <rdar://problem/33951915> 6 7 Reviewed by Geoffrey Garen. 8 9 Add layout test coverage for input.webkitdirectory. It covers both 10 the file picker and the drag and drop code paths. 11 12 * fast/forms/file/resources/testFiles/file1.txt: Added. 13 * fast/forms/file/resources/testFiles/file2.txt: Added. 14 * fast/forms/file/resources/testFiles/subfolder1/file3.txt: Added. 15 * fast/forms/file/resources/testFiles/subfolder2/file4.txt: Added. 16 * fast/forms/file/resources/testFiles/subfolder2/subfolder2a/file5.txt: Added. 17 * fast/forms/file/webkitdirectory-drag-folder-expected.txt: Added. 18 * fast/forms/file/webkitdirectory-drag-folder.html: Added. 19 * fast/forms/file/webkitdirectory-open-panel-expected.txt: Added. 20 * fast/forms/file/webkitdirectory-open-panel.html: Added. 21 * platform/mac-wk1/fast/forms/file/webkitdirectory-open-panel-expected.txt: Added. 22 * platform/wk2/TestExpectations: 23 1 24 2017-08-24 Ryan Haddad <ryanhaddad@apple.com> 2 25 -
trunk/LayoutTests/platform/wk2/TestExpectations
r221101 r221177 604 604 fast/forms/file/recover-file-input-in-unposted-form.html 605 605 fast/forms/file/selected-files-from-history-state.html 606 fast/forms/file/webkitdirectory-drag-folder.html 606 607 fast/history/page-cache-createObjectURL.html 607 608 fast/workers/worker-copy-shared-blob-url.html -
trunk/Source/WebCore/CMakeLists.txt
r221135 r221177 1740 1740 html/EmailInputType.cpp 1741 1741 html/FTPDirectoryDocument.cpp 1742 html/FileListCreator.cpp 1742 1743 html/FileInputType.cpp 1743 1744 html/FormAssociatedElement.cpp -
trunk/Source/WebCore/ChangeLog
r221173 r221177 1 2017-08-24 Chris Dumez <cdumez@apple.com> 2 3 [Directory Upload] Add basic support for input.webkitdirectory 4 https://bugs.webkit.org/show_bug.cgi?id=175950 5 <rdar://problem/33951915> 6 7 Reviewed by Geoffrey Garen. 8 9 Add basic support for input.webkitdirectory attribute, as per: 10 - https://wicg.github.io/entries-api/#html-forms 11 12 The following is supported: 13 - input.webkitdirectory IDL and content attributes 14 - The webkitdirectory content attribute is properly consulted 15 to communicate to the client that the file picker should 16 allow selecting directories. 17 - When WebCore gets the list of selected files from the file picker, 18 it properly resolves folders in a background thread to properly 19 initialize input.files before firing the 'change' event at the 20 input element. 21 - When resolving files in a directory, we ignore both hidden files and 22 symbolic links for security reasons. I did not check symlinks but Firefox 23 and Chrome both seem to upload hidden files (such as .DS_Store files). 24 - File.webkitRelativePath IDL attribute is properly populated for 25 files coming from a selected directory. 26 - Form submission just works because it relies on input.files being 27 properly populated. No change needed in this area. 28 29 What is not supported: 30 - input.webkitEntries IDL attribute. 31 - FileSystemEntry / FileSystemDirectoryEntry / FileSystemDirectoryReader 32 / FileSystemFileEntry / FileSystem IDL interfaces. 33 - dataTransferItem.webkitGetAsEntry() for proper drag and drop support. 34 35 Those will be taken care of in follow-up patches. 36 37 The feature is currently behind an experimental feature flag, disabled by 38 default. 39 40 Tests: fast/forms/file/webkitdirectory-drag-folder.html 41 fast/forms/file/webkitdirectory-open-panel.html 42 43 * CMakeLists.txt: 44 * WebCore.xcodeproj/project.pbxproj: 45 * fileapi/File.cpp: 46 (WebCore::File::createWithRelativePath): 47 * fileapi/File.h: 48 * fileapi/File.idl: 49 * html/FileInputType.cpp: 50 (WebCore::FileInputType::~FileInputType): 51 (WebCore::FileInputType::handleDOMActivateEvent): 52 (WebCore::FileInputType::allowsDirectories const): 53 (WebCore::FileInputType::filesChosen): 54 * html/FileInputType.h: 55 * html/FileListCreator.cpp: Added. 56 (WebCore::appendDirectoryFiles): 57 (WebCore::FileListCreator::FileListCreator): 58 (WebCore::FileListCreator::createFileList): 59 (WebCore::FileListCreator::cancel): 60 * html/FileListCreator.h: Copied from Source/WebKit/UIProcess/API/APIOpenPanelParameters.h. 61 (WebCore::FileListCreator::create): 62 * html/HTMLAttributeNames.in: 63 * html/HTMLInputElement.idl: 64 * page/Settings.in: 65 * platform/FileChooser.h: 66 (WebCore::FileChooserFileInfo::isolatedCopy const): 67 * platform/FileMetadata.h: 68 * platform/FileSystem.cpp: 69 (WebCore::fileIsDirectory): 70 * platform/FileSystem.h: 71 * platform/glib/FileSystemGlib.cpp: 72 (WebCore::getFileMetadata): 73 * platform/posix/FileSystemPOSIX.cpp: 74 (WebCore::getFileMetadata): 75 * platform/win/FileSystemWin.cpp: 76 (WebCore::getFileMetadata): 77 1 78 2017-08-24 Ryan Haddad <ryanhaddad@apple.com> 2 79 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r221112 r221177 3426 3426 8358CB701C53277500E0C2D8 /* JSXMLDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = 83F570AD1C53268E007FD6CB /* JSXMLDocument.h */; }; 3427 3427 835D363719FF6193004C93AB /* StyleBuilderCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = 835D363619FF6193004C93AB /* StyleBuilderCustom.h */; }; 3428 835D54C41F4DE53800E60671 /* FileListCreator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 835D54C11F4DE53400E60671 /* FileListCreator.cpp */; }; 3429 835D54C51F4DE53800E60671 /* FileListCreator.h in Headers */ = {isa = PBXBuildFile; fileRef = 835D54C21F4DE53400E60671 /* FileListCreator.h */; }; 3428 3430 8367587E1C56E99B008A1087 /* JSHTMLDataElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 834B86A91C56E93E00F3F0E3 /* JSHTMLDataElement.cpp */; }; 3429 3431 8367587F1C56E99B008A1087 /* JSHTMLDataElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 834B86A81C56E93E00F3F0E3 /* JSHTMLDataElement.h */; }; … … 11548 11550 835657C61ECAB0E800CDE72D /* JSDOMMatrixInit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMMatrixInit.cpp; sourceTree = "<group>"; }; 11549 11551 835D363619FF6193004C93AB /* StyleBuilderCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleBuilderCustom.h; sourceTree = "<group>"; }; 11552 835D54C11F4DE53400E60671 /* FileListCreator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileListCreator.cpp; sourceTree = "<group>"; }; 11553 835D54C21F4DE53400E60671 /* FileListCreator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileListCreator.h; sourceTree = "<group>"; }; 11550 11554 835F8B261D2D90BA00E408EC /* Slotable.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Slotable.idl; sourceTree = "<group>"; }; 11551 11555 8369E58F1AFDD0300087DF68 /* NonDocumentTypeChildNode.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = NonDocumentTypeChildNode.idl; sourceTree = "<group>"; }; … … 20290 20294 F55B3D891251F12D003EF269 /* FileInputType.cpp */, 20291 20295 F55B3D8A1251F12D003EF269 /* FileInputType.h */, 20296 835D54C11F4DE53400E60671 /* FileListCreator.cpp */, 20297 835D54C21F4DE53400E60671 /* FileListCreator.h */, 20292 20298 4A0DA2FC129B241900AB61E1 /* FormAssociatedElement.cpp */, 20293 20299 4A0DA2FD129B241900AB61E1 /* FormAssociatedElement.h */, … … 27398 27404 F55B3DBE1251F12D003EF269 /* FileInputType.h in Headers */, 27399 27405 976D6C86122B8A3D001FD1F7 /* FileList.h in Headers */, 27406 835D54C51F4DE53800E60671 /* FileListCreator.h in Headers */, 27400 27407 4689F1AF1267BAE100E8D380 /* FileMetadata.h in Headers */, 27401 27408 7A09CEF11F02069B00E93BDB /* FileMonitor.h in Headers */, … … 31395 31402 F55B3DBD1251F12D003EF269 /* FileInputType.cpp in Sources */, 31396 31403 976D6C85122B8A3D001FD1F7 /* FileList.cpp in Sources */, 31404 835D54C41F4DE53800E60671 /* FileListCreator.cpp in Sources */, 31397 31405 7A32D7481F020EFF00162C44 /* FileMonitor.cpp in Sources */, 31398 31406 7A32D7471F020EED00162C44 /* FileMonitorCocoa.mm in Sources */, -
trunk/Source/WebCore/fileapi/File.cpp
r209184 r221177 37 37 38 38 namespace WebCore { 39 40 Ref<File> File::createWithRelativePath(const String& path, const String& relativePath) 41 { 42 auto file = File::create(path); 43 file->setRelativePath(relativePath); 44 return file; 45 } 39 46 40 47 File::File(const String& path) -
trunk/Source/WebCore/fileapi/File.h
r209184 r221177 66 66 } 67 67 68 static Ref<File> createWithRelativePath(const String& path, const String& relativePath); 69 68 70 bool isFile() const override { return true; } 69 71 70 72 const String& path() const { return m_path; } 73 const String& relativePath() const { return m_relativePath; } 74 void setRelativePath(const String& relativePath) { m_relativePath = relativePath; } 71 75 const String& name() const { return m_name; } 72 76 WEBCORE_EXPORT double lastModified() const; … … 91 95 92 96 String m_path; 97 String m_relativePath; 93 98 String m_name; 94 99 -
trunk/Source/WebCore/fileapi/File.idl
r218495 r221177 36 36 readonly attribute DOMString name; 37 37 readonly attribute long long lastModified; 38 39 // https://wicg.github.io/entries-api/#file-interface 40 [EnabledAtRuntime=DirectoryUpload, ImplementedAs=relativePath] readonly attribute USVString webkitRelativePath; 38 41 }; 39 42 -
trunk/Source/WebCore/html/FileInputType.cpp
r215385 r221177 29 29 #include "File.h" 30 30 #include "FileList.h" 31 #include "FileListCreator.h" 31 32 #include "FileSystem.h" 32 33 #include "FormController.h" … … 39 40 #include "LocalizedStrings.h" 40 41 #include "RenderFileUploadControl.h" 42 #include "RuntimeEnabledFeatures.h" 41 43 #include "ScriptController.h" 44 #include "Settings.h" 42 45 #include "ShadowRoot.h" 43 46 #include <wtf/TypeCasts.h> … … 98 101 FileInputType::~FileInputType() 99 102 { 103 if (m_fileListCreator) 104 m_fileListCreator->cancel(); 105 100 106 if (m_fileChooser) 101 107 m_fileChooser->invalidate(); … … 192 198 FileChooserSettings settings; 193 199 HTMLInputElement& input = element(); 200 settings.allowsDirectories = allowsDirectories(); 194 201 settings.allowsMultipleFiles = input.hasAttributeWithoutSynchronization(multipleAttr); 195 202 settings.acceptMIMETypes = input.acceptMIMETypes(); … … 255 262 } 256 263 257 Ref<FileList> FileInputType::createFileList(const Vector<FileChooserFileInfo>& files)258 {259 Vector<RefPtr<File>> fileObjects;260 fileObjects.reserveInitialCapacity(files.size());261 for (auto& info : files)262 fileObjects.uncheckedAppend(File::createWithName(info.path, info.displayName));263 return FileList::create(WTFMove(fileObjects));264 }265 266 264 bool FileInputType::isFileUpload() const 267 265 { … … 327 325 328 326 m_fileChooser = FileChooser::create(this, settings); 327 } 328 329 bool FileInputType::allowsDirectories() const 330 { 331 if (!RuntimeEnabledFeatures::sharedFeatures().directoryUploadEnabled()) 332 return false; 333 return element().hasAttributeWithoutSynchronization(webkitdirectoryAttr); 329 334 } 330 335 … … 384 389 m_displayString = displayString; 385 390 386 setFiles(createFileList(paths), icon ? RequestIcon::No : RequestIcon::Yes); 391 if (m_fileListCreator) 392 m_fileListCreator->cancel(); 393 394 auto shouldResolveDirectories = allowsDirectories() ? FileListCreator::ShouldResolveDirectories::Yes : FileListCreator::ShouldResolveDirectories::No; 395 auto shouldRequestIcon = icon ? RequestIcon::Yes : RequestIcon::No; 396 m_fileListCreator = FileListCreator::create(paths, shouldResolveDirectories, [this, shouldRequestIcon](Ref<FileList>&& fileList) { 397 setFiles(WTFMove(fileList), shouldRequestIcon); 398 m_fileListCreator = nullptr; 399 }); 387 400 388 401 if (icon) -
trunk/Source/WebCore/html/FileInputType.h
r215385 r221177 41 41 class DragData; 42 42 class FileList; 43 class FileListCreator; 43 44 class Icon; 44 45 … … 85 86 void iconLoaded(RefPtr<Icon>&&) final; 86 87 87 static Ref<FileList> createFileList(const Vector<FileChooserFileInfo>&);88 88 void requestIcon(const Vector<String>&); 89 89 90 90 void applyFileChooserSettings(const FileChooserSettings&); 91 92 bool allowsDirectories() const; 91 93 92 94 RefPtr<FileChooser> m_fileChooser; … … 94 96 95 97 Ref<FileList> m_fileList; 98 RefPtr<FileListCreator> m_fileListCreator; 96 99 RefPtr<Icon> m_icon; 97 100 String m_displayString; -
trunk/Source/WebCore/html/FileListCreator.h
r221176 r221177 1 1 /* 2 * Copyright (C) 2010 Apple Inc. All rights reserved. 3 * Copyright (C) 2012 Samsung Electronics. All rights reserved. 2 * Copyright (C) 2017 Apple Inc. All rights reserved. 4 3 * 5 4 * Redistribution and use in source and binary forms, with or without … … 27 26 #pragma once 28 27 29 #include "APIObject.h" 30 #include <WebCore/FileChooser.h> 28 #include <wtf/Function.h> 29 #include <wtf/Ref.h> 30 #include <wtf/ThreadSafeRefCounted.h> 31 #include <wtf/Vector.h> 32 #include <wtf/WorkQueue.h> 31 33 32 namespace API{34 namespace WebCore { 33 35 34 class Array; 36 struct FileChooserFileInfo; 37 class FileList; 35 38 36 class OpenPanelParameters : public API::ObjectImpl<API::Object::Type::OpenPanelParameters> {39 class FileListCreator : public ThreadSafeRefCounted<FileListCreator> { 37 40 public: 38 static Ref<OpenPanelParameters> create(const WebCore::FileChooserSettings&); 39 ~OpenPanelParameters(); 41 using CompletionHandler = WTF::Function<void(Ref<FileList>&&)>; 40 42 41 bool allowMultipleFiles() const { return m_settings.allowsMultipleFiles; } 42 Ref<API::Array> acceptMIMETypes() const; 43 Ref<API::Array> acceptFileExtensions() const; 44 Ref<API::Array> selectedFileNames() const; 45 #if ENABLE(MEDIA_CAPTURE) 46 WebCore::MediaCaptureType mediaCaptureType() const; 47 #endif 43 enum class ShouldResolveDirectories { No, Yes }; 44 static Ref<FileListCreator> create(const Vector<FileChooserFileInfo>& paths, ShouldResolveDirectories shouldResolveDirectories, CompletionHandler&& completionHandler) 45 { 46 return adoptRef(*new FileListCreator(paths, shouldResolveDirectories, WTFMove(completionHandler))); 47 } 48 49 ~FileListCreator(); 50 51 void cancel(); 48 52 49 53 private: 50 explicit OpenPanelParameters(const WebCore::FileChooserSettings&);54 FileListCreator(const Vector<FileChooserFileInfo>& paths, ShouldResolveDirectories, CompletionHandler&&); 51 55 52 WebCore::FileChooserSettings m_settings; 56 template<ShouldResolveDirectories shouldResolveDirectories> 57 static Ref<FileList> createFileList(const Vector<FileChooserFileInfo>&); 58 59 RefPtr<WorkQueue> m_workQueue; 60 CompletionHandler m_completionHander; 53 61 }; 54 62 55 } // namespace API63 } -
trunk/Source/WebCore/html/HTMLAttributeNames.in
r218809 r221177 382 382 webkitallowfullscreen 383 383 webkitattachmentpath 384 webkitdirectory 384 385 width 385 386 wrap -
trunk/Source/WebCore/html/HTMLInputElement.idl
r215330 r221177 93 93 // See http://www.w3.org/TR/html-media-capture/ 94 94 [Conditional=MEDIA_CAPTURE, Reflect] attribute DOMString capture; 95 96 // https://wicg.github.io/entries-api/#dom-htmlinputelement-webkitdirectory 97 [Reflect, EnabledAtRuntime=DirectoryUpload] attribute boolean webkitdirectory; 98 // In Chrome & Firefox, webkitEntries is only populated if webkitdirectory is not set and the files were 99 // dragged and dropped (not when the element is clicked). 100 // [EnabledAtRuntime=DirectoryUpload] readonly attribute FrozenArray<FileSystemEntry> webkitEntries; 95 101 }; -
trunk/Source/WebCore/page/RuntimeEnabledFeatures.h
r220627 r221177 74 74 bool customElementsEnabled() const { return m_areCustomElementsEnabled; } 75 75 76 void setDirectoryUploadEnabled(bool isEnabled) { m_isDirectoryUploadEnabled = isEnabled; } 77 bool directoryUploadEnabled() const { return m_isDirectoryUploadEnabled; } 78 76 79 void setDataTransferItemsEnabled(bool areEnabled) { m_areDataTransferItemsEnabled = areEnabled; } 77 80 bool dataTransferItemsEnabled() const { return m_areDataTransferItemsEnabled; } … … 232 235 bool m_isShadowDOMEnabled { true }; 233 236 bool m_areCustomElementsEnabled { true }; 237 bool m_isDirectoryUploadEnabled { false }; 234 238 bool m_areDataTransferItemsEnabled { false }; 235 239 bool m_inputEventsEnabled { true }; -
trunk/Source/WebCore/platform/FileChooser.h
r220135 r221177 53 53 } 54 54 55 FileChooserFileInfo isolatedCopy() const 56 { 57 return { path.isolatedCopy(), displayName.isolatedCopy() }; 58 } 59 55 60 const String path; 56 61 const String displayName; … … 58 63 59 64 struct FileChooserSettings { 60 bool allowsMultipleFiles; 65 bool allowsDirectories { false }; 66 bool allowsMultipleFiles { false }; 61 67 Vector<String> acceptMIMETypes; 62 68 Vector<String> acceptFileExtensions; 63 69 Vector<String> selectedFiles; 64 70 #if ENABLE(MEDIA_CAPTURE) 65 MediaCaptureType mediaCaptureType ;71 MediaCaptureType mediaCaptureType { MediaCaptureTypeNone }; 66 72 #endif 67 73 }; -
trunk/Source/WebCore/platform/FileMetadata.h
r156692 r221177 38 38 39 39 struct FileMetadata { 40 FileMetadata() = default; 41 40 42 // The last modification time of the file, in seconds. 41 43 // The value 0.0 means that the time is not set. 42 double modificationTime ;44 double modificationTime { invalidFileTime() }; 43 45 44 46 // The length of the file in bytes. 45 47 // The value -1 means that the length is not set. 46 long long length ;48 long long length { -1 }; 47 49 48 enum Type { 49 TypeUnknown = 0, 50 TypeFile, 51 TypeDirectory 52 }; 50 bool isHidden { false }; 53 51 54 Type type; 55 56 FileMetadata() : modificationTime(invalidFileTime()), length(-1), type(TypeUnknown) { } 52 enum Type { TypeUnknown, TypeFile, TypeDirectory, TypeSymbolicLink }; 53 Type type { TypeUnknown }; 57 54 }; 58 55 -
trunk/Source/WebCore/platform/FileSystem.cpp
r219297 r221177 28 28 #include "FileSystem.h" 29 29 30 #include "FileMetadata.h" 30 31 #include "ScopeGuard.h" 31 32 #include <wtf/HexNumber.h> … … 351 352 } 352 353 354 bool fileIsDirectory(const String& path) 355 { 356 FileMetadata metadata; 357 if (!getFileMetadata(path, metadata)) 358 return false; 359 return metadata.type == FileMetadata::TypeDirectory; 360 } 361 353 362 } // namespace WebCore -
trunk/Source/WebCore/platform/FileSystem.h
r219297 r221177 100 100 WEBCORE_EXPORT bool getFileCreationTime(const String&, time_t& result); // Not all platforms store file creation time. 101 101 bool getFileMetadata(const String&, FileMetadata&); 102 bool fileIsDirectory(const String&); 102 103 WEBCORE_EXPORT String pathByAppendingComponent(const String& path, const String& component); 103 104 String lastComponentOfPathIgnoringTrailingSlash(const String& path); -
trunk/Source/WebCore/platform/glib/FileSystemGlib.cpp
r219384 r221177 161 161 return false; 162 162 163 String filename = pathGetFileName(path); 164 metadata.isHidden = !filename.isEmpty() && filename[0] == '.'; 163 165 metadata.modificationTime = statResult.st_mtime; 164 166 metadata.length = statResult.st_size; 165 metadata.type = S_ISDIR(statResult.st_mode) ? FileMetadata::TypeDirectory : FileMetadata::TypeFile; 167 if (S_ISDIR(statResult.st_mode)) 168 metadata.type = FileMetadata::TypeDirectory; 169 else if (S_ISLNK(statResult.st_mode)) 170 metadata.type = FileMetadata::TypeSymbolicLink; 171 else 172 metadata.type = FileMetadata::TypeFile; 166 173 return true; 167 174 } -
trunk/Source/WebCore/platform/posix/FileSystemPOSIX.cpp
r218901 r221177 250 250 return false; 251 251 252 String filename = pathGetFileName(path); 253 252 254 metadata.modificationTime = fileInfo.st_mtime; 255 metadata.isHidden = !filename.isEmpty() && filename[0] == '.'; 253 256 metadata.length = fileInfo.st_size; 254 metadata.type = S_ISDIR(fileInfo.st_mode) ? FileMetadata::TypeDirectory : FileMetadata::TypeFile; 257 if (S_ISDIR(fileInfo.st_mode)) 258 metadata.type = FileMetadata::TypeDirectory; 259 else if (S_ISLNK(fileInfo.st_mode)) 260 metadata.type = FileMetadata::TypeSymbolicLink; 261 else 262 metadata.type = FileMetadata::TypeFile; 255 263 return true; 256 264 } -
trunk/Source/WebCore/platform/win/FileSystemWin.cpp
r219858 r221177 153 153 getFileModificationTimeFromFindData(findData, modificationTime); 154 154 metadata.modificationTime = modificationTime; 155 155 metadata.isHidden = findData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN; 156 156 metadata.type = (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? FileMetadata::TypeDirectory : FileMetadata::TypeFile; 157 157 -
trunk/Source/WebKit/ChangeLog
r221175 r221177 1 2017-08-24 Chris Dumez <cdumez@apple.com> 2 3 [Directory Upload] Add basic support for input.webkitdirectory 4 https://bugs.webkit.org/show_bug.cgi?id=175950 5 <rdar://problem/33951915> 6 7 Reviewed by Geoffrey Garen. 8 9 Add private API to toggle Directory Upload support. 10 11 Add new member to WKOpenPanelParameters to communicate to the 12 client that the file picker should allow selecting directories. 13 14 * Shared/WebCoreArgumentCoders.cpp: 15 (IPC::ArgumentCoder<FileChooserSettings>::encode): 16 (IPC::ArgumentCoder<FileChooserSettings>::decode): 17 * Shared/WebPreferencesDefinitions.h: 18 * UIProcess/API/APIOpenPanelParameters.h: 19 (API::OpenPanelParameters::allowDirectories const): 20 * UIProcess/API/C/WKOpenPanelParametersRef.cpp: 21 (WKOpenPanelParametersGetAllowsDirectories): 22 * UIProcess/API/C/WKOpenPanelParametersRef.h: 23 * UIProcess/API/C/WKPreferences.cpp: 24 (WKPreferencesSetDirectoryUploadEnabled): 25 (WKPreferencesGetDirectoryUploadEnabled): 26 * UIProcess/API/C/WKPreferencesRefPrivate.h: 27 * UIProcess/API/Cocoa/WKOpenPanelParameters.h: 28 * UIProcess/API/Cocoa/WKOpenPanelParameters.mm: 29 (-[WKOpenPanelParameters allowsDirectories]): 30 * WebProcess/WebPage/WebPage.cpp: 31 (WebKit::WebPage::updatePreferences): 32 1 33 2017-08-24 Youenn Fablet <youenn@apple.com> 2 34 -
trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp
r221165 r221177 1713 1713 void ArgumentCoder<FileChooserSettings>::encode(Encoder& encoder, const FileChooserSettings& settings) 1714 1714 { 1715 encoder << settings.allowsDirectories; 1715 1716 encoder << settings.allowsMultipleFiles; 1716 1717 encoder << settings.acceptMIMETypes; … … 1724 1725 bool ArgumentCoder<FileChooserSettings>::decode(Decoder& decoder, FileChooserSettings& settings) 1725 1726 { 1727 if (!decoder.decode(settings.allowsDirectories)) 1728 return false; 1726 1729 if (!decoder.decode(settings.allowsMultipleFiles)) 1727 1730 return false; -
trunk/Source/WebKit/Shared/WebPreferencesDefinitions.h
r221041 r221177 376 376 macro(WebGL2Enabled, webGL2Enabled, Bool, bool, false, "WebGL 2.0", "WebGL 2 prototype") \ 377 377 macro(WebGPUEnabled, webGPUEnabled, Bool, bool, false, "WebGPU", "WebGPU prototype") \ 378 macro(DirectoryUploadEnabled, directoryUploadEnabled, Bool, bool, false, "Directory Upload", "input.webkitdirectory") \ 378 379 macro(AsyncFrameScrollingEnabled, asyncFrameScrollingEnabled, Bool, bool, false, "Async Frame Scrolling", "Perform frame scrolling in a dedicated thread or process") \ 379 380 \ -
trunk/Source/WebKit/UIProcess/API/APIOpenPanelParameters.h
r220135 r221177 39 39 ~OpenPanelParameters(); 40 40 41 bool allowDirectories() const { return m_settings.allowsDirectories; } 41 42 bool allowMultipleFiles() const { return m_settings.allowsMultipleFiles; } 42 43 Ref<API::Array> acceptMIMETypes() const; -
trunk/Source/WebKit/UIProcess/API/C/WKOpenPanelParametersRef.cpp
r220135 r221177 39 39 } 40 40 41 bool WKOpenPanelParametersGetAllowsDirectories(WKOpenPanelParametersRef parametersRef) 42 { 43 return toImpl(parametersRef)->allowDirectories(); 44 } 45 41 46 bool WKOpenPanelParametersGetAllowsMultipleFiles(WKOpenPanelParametersRef parametersRef) 42 47 { -
trunk/Source/WebKit/UIProcess/API/C/WKOpenPanelParametersRef.h
r220135 r221177 40 40 WK_EXPORT WKTypeID WKOpenPanelParametersGetTypeID(); 41 41 42 WK_EXPORT bool WKOpenPanelParametersGetAllowsDirectories(WKOpenPanelParametersRef parameters); 42 43 WK_EXPORT bool WKOpenPanelParametersGetAllowsMultipleFiles(WKOpenPanelParametersRef parameters); 43 44 -
trunk/Source/WebKit/UIProcess/API/C/WKPreferences.cpp
r220787 r221177 841 841 } 842 842 843 void WKPreferencesSetDirectoryUploadEnabled(WKPreferencesRef preferencesRef, bool flag) 844 { 845 toImpl(preferencesRef)->setDirectoryUploadEnabled(flag); 846 } 847 848 bool WKPreferencesGetDirectoryUploadEnabled(WKPreferencesRef preferencesRef) 849 { 850 return toImpl(preferencesRef)->directoryUploadEnabled(); 851 } 852 843 853 void WKPreferencesSetMediaControlsScaleWithPageZoom(WKPreferencesRef preferencesRef, bool flag) 844 854 { -
trunk/Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h
r220787 r221177 208 208 WK_EXPORT bool WKPreferencesGetBeaconAPIEnabled(WKPreferencesRef); 209 209 210 // Defaults to false. 211 WK_EXPORT void WKPreferencesSetDirectoryUploadEnabled(WKPreferencesRef, bool flag); 212 WK_EXPORT bool WKPreferencesGetDirectoryUploadEnabled(WKPreferencesRef); 213 210 214 // Defaults to false on iOS, true elsewhere. 211 215 WK_EXPORT void WKPreferencesSetMediaControlsScaleWithPageZoom(WKPreferencesRef preferencesRef, bool flag); -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKOpenPanelParameters.h
r205559 r221177 41 41 @property (nonatomic, readonly) BOOL allowsMultipleSelection; 42 42 43 /*! @abstract Whether the file upload control supports selecting directories. 44 */ 45 @property (nonatomic, readonly) BOOL allowsDirectories WK_API_AVAILABLE(macosx(WK_MAC_TBA)); 46 43 47 @end 44 48 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKOpenPanelParameters.mm
r202793 r221177 36 36 } 37 37 38 - (BOOL)allowsDirectories 39 { 40 return _openPanelParameters->allowDirectories(); 41 } 42 38 43 #pragma mark WKObject protocol implementation 39 44 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r221068 r221177 3368 3368 RuntimeEnabledFeatures::sharedFeatures().setCredentialManagementEnabled(store.getBoolValueForKey(WebPreferencesKey::credentialManagementEnabledKey())); 3369 3369 RuntimeEnabledFeatures::sharedFeatures().setIsSecureContextAttributeEnabled(store.getBoolValueForKey(WebPreferencesKey::isSecureContextAttributeEnabledKey())); 3370 RuntimeEnabledFeatures::sharedFeatures().setDirectoryUploadEnabled(store.getBoolValueForKey(WebPreferencesKey::directoryUploadEnabledKey())); 3370 3371 3371 3372 bool processSuppressionEnabled = store.getBoolValueForKey(WebPreferencesKey::pageVisibilityBasedProcessSuppressionEnabledKey()); -
trunk/Source/WebKitLegacy/mac/ChangeLog
r221064 r221177 1 2017-08-24 Chris Dumez <cdumez@apple.com> 2 3 [Directory Upload] Add basic support for input.webkitdirectory 4 https://bugs.webkit.org/show_bug.cgi?id=175950 5 <rdar://problem/33951915> 6 7 Reviewed by Geoffrey Garen. 8 9 Add private API to toggle Directory Upload support on Mac WebKit1. 10 11 * WebView/WebPreferenceKeysPrivate.h: 12 * WebView/WebPreferences.mm: 13 (+[WebPreferences initialize]): 14 (-[WebPreferences setDirectoryUploadEnabled:]): 15 (-[WebPreferences directoryUploadEnabled]): 16 * WebView/WebPreferencesPrivate.h: 17 * WebView/WebView.mm: 18 (-[WebView _preferencesChanged:]): 19 1 20 2017-08-22 Wenson Hsieh <wenson_hsieh@apple.com> 2 21 -
trunk/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h
r220627 r221177 177 177 #define WebKitReadableByteStreamAPIEnabledPreferenceKey @"WebKitReadableByteStreamAPIEnabled" 178 178 #define WebKitDownloadAttributeEnabledPreferenceKey @"WebKitDownloadAttributeEnabled" 179 #define WebKitDirectoryUploadEnabledPreferenceKey @"WebKitDirectoryUploadEnabled" 179 180 #define WebKitCSSGridLayoutEnabledPreferenceKey @"WebKitCSSGridLayoutEnabled" 180 181 #define WebKitVisualViewportEnabledPreferenceKey @"WebKitVisualViewportEnabled" -
trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm
r220627 r221177 643 643 [NSNumber numberWithBool:NO], WebKitDownloadAttributeEnabledPreferenceKey, 644 644 #endif 645 [NSNumber numberWithBool:NO], WebKitDirectoryUploadEnabledPreferenceKey, 645 646 [NSNumber numberWithBool:YES], WebKitCSSGridLayoutEnabledPreferenceKey, 646 647 #if ENABLE(WEB_ANIMATIONS) … … 3036 3037 } 3037 3038 3039 - (void)setDirectoryUploadEnabled:(BOOL)flag 3040 { 3041 [self _setBoolValue:flag forKey:WebKitDirectoryUploadEnabledPreferenceKey]; 3042 } 3043 3044 - (BOOL)directoryUploadEnabled 3045 { 3046 return [self _boolValueForKey:WebKitDirectoryUploadEnabledPreferenceKey]; 3047 } 3048 3038 3049 - (BOOL)isCSSGridLayoutEnabled 3039 3050 { -
trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h
r220627 r221177 553 553 - (BOOL)downloadAttributeEnabled; 554 554 555 - (void)setDirectoryUploadEnabled:(BOOL)flag; 556 - (BOOL)directoryUploadEnabled; 557 555 558 - (void)setCSSGridLayoutEnabled:(BOOL)flag; 556 559 - (BOOL)isCSSGridLayoutEnabled; -
trunk/Source/WebKitLegacy/mac/WebView/WebView.mm
r220979 r221177 3034 3034 RuntimeEnabledFeatures::sharedFeatures().setCredentialManagementEnabled(preferences.credentialManagementEnabled); 3035 3035 RuntimeEnabledFeatures::sharedFeatures().setIsSecureContextAttributeEnabled(preferences.isSecureContextAttributeEnabled); 3036 RuntimeEnabledFeatures::sharedFeatures().setDirectoryUploadEnabled([preferences directoryUploadEnabled]); 3036 3037 3037 3038 #if ENABLE(LEGACY_ENCRYPTED_MEDIA) -
trunk/Tools/ChangeLog
r221172 r221177 1 2017-08-24 Chris Dumez <cdumez@apple.com> 2 3 [Directory Upload] Add basic support for input.webkitdirectory 4 https://bugs.webkit.org/show_bug.cgi?id=175950 5 <rdar://problem/33951915> 6 7 Reviewed by Geoffrey Garen. 8 9 * DumpRenderTree/mac/DumpRenderTree.mm: 10 (resetWebPreferencesToConsistentValues): 11 * WebKitTestRunner/TestController.cpp: 12 (WTR::TestController::resetPreferencesToConsistentValues): 13 Enable Directory Upload feature for testing, given that it is currently disabled by default. 14 15 (WTR::runOpenPanel): 16 Print additional text when directories are allowed to extend testing coverage. 17 1 18 2017-08-24 Alex Christensen <achristensen@webkit.org> 2 19 -
trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm
r220627 r221177 958 958 959 959 [preferences setDownloadAttributeEnabled:YES]; 960 [preferences setDirectoryUploadEnabled:YES]; 960 961 961 962 [preferences setHiddenPageDOMTimerThrottlingEnabled:NO]; -
trunk/Tools/WebKitTestRunner/TestController.cpp
r220787 r221177 152 152 { 153 153 printf("OPEN FILE PANEL\n"); 154 if (WKOpenPanelParametersGetAllowsDirectories(parameters)) 155 printf("-> DIRECTORIES ARE ALLOWED\n"); 154 156 WKArrayRef fileURLs = TestController::singleton().openPanelFileURLs(); 155 157 if (!fileURLs || !WKArrayGetSize(fileURLs)) { … … 723 725 WKPreferencesSetInlineMediaPlaybackRequiresPlaysInlineAttribute(preferences, false); 724 726 WKPreferencesSetBeaconAPIEnabled(preferences, true); 727 WKPreferencesSetDirectoryUploadEnabled(preferences, true); 725 728 726 729 WKCookieManagerDeleteAllCookies(WKContextGetCookieManager(m_context.get()));
Note: See TracChangeset
for help on using the changeset viewer.