- Revision
- 213100
- Author
- [email protected]
- Date
- 2017-02-27 16:13:24 -0800 (Mon, 27 Feb 2017)
Log Message
[iOS] Enable file replacement
https://bugs.webkit.org/show_bug.cgi?id=168907
<rdar://problem/22258242>
Reviewed by David Kilzer.
Source/WebCore:
Covered by existing tests.
* fileapi/FileMac.mm:
(WebCore::File::shouldReplaceFile): Stop using Carbon and AppKit API for determining if a
file path is a file package. Use NSURL and CoreServices instead, which exist on Mac and iOS.
Source/WTF:
* wtf/FeatureDefines.h: Set ENABLE_FILE_REPLACEMENT to 1 on all Cocoa platforms.
LayoutTests:
* platform/ios-simulator/TestExpectations: Un-skipped file replacement tests on iOS.
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (213099 => 213100)
--- trunk/LayoutTests/ChangeLog 2017-02-28 00:01:28 UTC (rev 213099)
+++ trunk/LayoutTests/ChangeLog 2017-02-28 00:13:24 UTC (rev 213100)
@@ -1,3 +1,13 @@
+2017-02-27 Andy Estes <[email protected]>
+
+ [iOS] Enable file replacement
+ https://bugs.webkit.org/show_bug.cgi?id=168907
+ <rdar://problem/22258242>
+
+ Reviewed by David Kilzer.
+
+ * platform/ios-simulator/TestExpectations: Un-skipped file replacement tests on iOS.
+
2017-02-27 Antoine Quint <[email protected]>
[Modern Media Controls] Use a solid background for <audio> controls on macOS
Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (213099 => 213100)
--- trunk/LayoutTests/platform/ios-simulator/TestExpectations 2017-02-28 00:01:28 UTC (rev 213099)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations 2017-02-28 00:13:24 UTC (rev 213100)
@@ -2887,7 +2887,3 @@
[ Debug ] fast/frames/exponential-frames.html [ Skip ]
webkit.org/b/168053 pageoverlay/overlay-remove-reinsert-view.html [ Pass Failure ]
-
-# Bundle upload is not supported on iOS
-fast/files/filereader-zip-bundle-using-open-panel.html [ Skip ]
-http/tests/local/fileapi/upload-zip-bundle-as-blob-using-open-panel.html [ Skip ]
Modified: trunk/Source/WTF/ChangeLog (213099 => 213100)
--- trunk/Source/WTF/ChangeLog 2017-02-28 00:01:28 UTC (rev 213099)
+++ trunk/Source/WTF/ChangeLog 2017-02-28 00:13:24 UTC (rev 213100)
@@ -1,3 +1,13 @@
+2017-02-27 Andy Estes <[email protected]>
+
+ [iOS] Enable file replacement
+ https://bugs.webkit.org/show_bug.cgi?id=168907
+ <rdar://problem/22258242>
+
+ Reviewed by David Kilzer.
+
+ * wtf/FeatureDefines.h: Set ENABLE_FILE_REPLACEMENT to 1 on all Cocoa platforms.
+
2017-02-27 Myles C. Maxfield <[email protected]>
Rename ICU cursor iterator to caret iterator
Modified: trunk/Source/WTF/wtf/FeatureDefines.h (213099 => 213100)
--- trunk/Source/WTF/wtf/FeatureDefines.h 2017-02-28 00:01:28 UTC (rev 213099)
+++ trunk/Source/WTF/wtf/FeatureDefines.h 2017-02-28 00:13:24 UTC (rev 213100)
@@ -239,10 +239,6 @@
#define ENABLE_INPUT_TYPE_COLOR_POPOVER 1
#endif
-#if !defined(ENABLE_FILE_REPLACEMENT)
-#define ENABLE_FILE_REPLACEMENT 1
-#endif
-
#if !defined(ENABLE_PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
#define ENABLE_PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC 1
#endif
@@ -259,6 +255,10 @@
#define ENABLE_DATA_DETECTION 1
#endif
+#if !defined(ENABLE_FILE_REPLACEMENT)
+#define ENABLE_FILE_REPLACEMENT 1
+#endif
+
#if !defined(ENABLE_KEYBOARD_KEY_ATTRIBUTE)
#define ENABLE_KEYBOARD_KEY_ATTRIBUTE 1
#endif
Modified: trunk/Source/WebCore/ChangeLog (213099 => 213100)
--- trunk/Source/WebCore/ChangeLog 2017-02-28 00:01:28 UTC (rev 213099)
+++ trunk/Source/WebCore/ChangeLog 2017-02-28 00:13:24 UTC (rev 213100)
@@ -1,3 +1,17 @@
+2017-02-27 Andy Estes <[email protected]>
+
+ [iOS] Enable file replacement
+ https://bugs.webkit.org/show_bug.cgi?id=168907
+ <rdar://problem/22258242>
+
+ Reviewed by David Kilzer.
+
+ Covered by existing tests.
+
+ * fileapi/FileMac.mm:
+ (WebCore::File::shouldReplaceFile): Stop using Carbon and AppKit API for determining if a
+ file path is a file package. Use NSURL and CoreServices instead, which exist on Mac and iOS.
+
2017-02-27 Antoine Quint <[email protected]>
[Modern Media Controls] Use a solid background for <audio> controls on macOS
Modified: trunk/Source/WebCore/fileapi/FileMac.mm (213099 => 213100)
--- trunk/Source/WebCore/fileapi/FileMac.mm 2017-02-28 00:01:28 UTC (rev 213099)
+++ trunk/Source/WebCore/fileapi/FileMac.mm 2017-02-28 00:13:24 UTC (rev 213100)
@@ -23,42 +23,39 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "config.h"
-#include "File.h"
+#import "config.h"
+#import "File.h"
#if ENABLE(FILE_REPLACEMENT)
-#include "FileSystem.h"
+#import "FileSystem.h"
+#if PLATFORM(IOS)
+#import <MobileCoreServices/MobileCoreServices.h>
+#endif
+
namespace WebCore {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
bool File::shouldReplaceFile(const String& path)
{
if (path.isEmpty())
return false;
- FSRef pathRef;
- Boolean targetIsFolder;
- Boolean wasAliased;
- NSString *aliasedPath = path;
+ NSError *error;
+ NSURL *pathURL = [NSURL URLByResolvingAliasFileAtURL:[NSURL fileURLWithPath:path isDirectory:NO] options:NSURLBookmarkResolutionWithoutUI error:&error];
+ if (!pathURL) {
+ LOG_ERROR("Failed to resolve alias at path %s with error %@.\n", path.utf8().data(), error);
+ return false;
+ }
- // Determine if the file is an alias, and if so, get the target path.
- if (FSPathMakeRef((UInt8 *)[path fileSystemRepresentation], &pathRef, NULL) == noErr) {
- if (FSResolveAliasFileWithMountFlags(&pathRef, TRUE, &targetIsFolder, &wasAliased, kResolveAliasFileNoUI) == noErr && wasAliased) {
- char pathFromPathRef[PATH_MAX + 1]; // +1 is for \0
- if (FSRefMakePath(&pathRef, (unsigned char *)pathFromPathRef, PATH_MAX) == noErr)
- aliasedPath = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:pathFromPathRef length:strlen(pathFromPathRef)];
- }
+ NSString *uti;
+ if (![pathURL getResourceValue:&uti forKey:NSURLTypeIdentifierKey error:&error]) {
+ LOG_ERROR("Failed to get type identifier of resource at URL %@ with error %@.\n", pathURL, error);
+ return false;
}
-
- if (!aliasedPath)
- return false;
- return [[NSWorkspace sharedWorkspace] isFilePackageAtPath:aliasedPath];
+ return UTTypeConformsTo((CFStringRef)uti, kUTTypePackage);
}
-#pragma clang diagnostic pop
void File::computeNameAndContentTypeForReplacedFile(const String& path, const String& nameOverride, String& effectiveName, String& effectiveContentType)
{