Diff
Modified: trunk/Source/WebCore/ChangeLog (221290 => 221291)
--- trunk/Source/WebCore/ChangeLog 2017-08-29 07:46:13 UTC (rev 221290)
+++ trunk/Source/WebCore/ChangeLog 2017-08-29 09:10:52 UTC (rev 221291)
@@ -1,3 +1,19 @@
+2017-08-29 Andy Estes <aes...@apple.com>
+
+ [Mac] Upstream WKSetMetadataURL() from WebKitSystemInterface
+ https://bugs.webkit.org/show_bug.cgi?id=176046
+
+ Reviewed by Alex Christensen.
+
+ * platform/FileSystem.cpp:
+ (WebCore::setMetadataURL):
+ * platform/FileSystem.h:
+ (WebCore::setMetadataURL):
+ * platform/mac/FileSystemMac.mm:
+ (WebCore::setMetadataURL):
+ * platform/mac/WebCoreSystemInterface.h:
+ * platform/mac/WebCoreSystemInterface.mm:
+
2017-08-29 Zan Dobersek <zdober...@igalia.com>
Unreviewed WPE debug build fix.
Modified: trunk/Source/WebCore/PAL/ChangeLog (221290 => 221291)
--- trunk/Source/WebCore/PAL/ChangeLog 2017-08-29 07:46:13 UTC (rev 221290)
+++ trunk/Source/WebCore/PAL/ChangeLog 2017-08-29 09:10:52 UTC (rev 221291)
@@ -1,3 +1,13 @@
+2017-08-29 Andy Estes <aes...@apple.com>
+
+ [Mac] Upstream WKSetMetadataURL() from WebKitSystemInterface
+ https://bugs.webkit.org/show_bug.cgi?id=176046
+
+ Reviewed by Alex Christensen.
+
+ * PAL.xcodeproj/project.pbxproj:
+ * pal/spi/mac/MetadataSPI.h: Added.
+
2017-08-28 Eric Carlson <eric.carl...@apple.com>
Logger should use makeString instead of String::format
Modified: trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj (221290 => 221291)
--- trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj 2017-08-29 07:46:13 UTC (rev 221290)
+++ trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj 2017-08-29 09:10:52 UTC (rev 221291)
@@ -97,6 +97,7 @@
1C09D0531E31C44100725F18 /* CryptoDigest.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C09D0521E31C44100725F18 /* CryptoDigest.h */; };
1C09D0561E31C46500725F18 /* CryptoDigestCommonCrypto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C09D0551E31C46500725F18 /* CryptoDigestCommonCrypto.cpp */; };
1C09D0581E31C57E00725F18 /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C09D0571E31C57E00725F18 /* config.h */; };
+ A1F55DCF1F5528EC00EDB75F /* MetadataSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A1F55DCE1F5528EC00EDB75F /* MetadataSPI.h */; };
A30D41211F0DD0EA00B71954 /* KillRing.h in Headers */ = {isa = PBXBuildFile; fileRef = A30D411E1F0DD0EA00B71954 /* KillRing.h */; };
A30D41221F0DD0EA00B71954 /* KillRingNone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A30D411F1F0DD0EA00B71954 /* KillRingNone.cpp */; };
A30D41251F0DD12D00B71954 /* KillRingMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = A30D41241F0DD12D00B71954 /* KillRingMac.mm */; };
@@ -208,6 +209,7 @@
1C09D0631E31EC3100725F18 /* Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = "<group>"; };
1C67CEA11E32EDA800F80F2E /* FeatureDefines.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = FeatureDefines.xcconfig; sourceTree = "<group>"; };
1C67CEA21E32EE2600F80F2E /* Version.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; };
+ A1F55DCE1F5528EC00EDB75F /* MetadataSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = MetadataSPI.h; path = spi/mac/MetadataSPI.h; sourceTree = "<group>"; };
A30D411E1F0DD0EA00B71954 /* KillRing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KillRing.h; path = text/KillRing.h; sourceTree = "<group>"; };
A30D411F1F0DD0EA00B71954 /* KillRingNone.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KillRingNone.cpp; path = text/KillRingNone.cpp; sourceTree = "<group>"; };
A30D41241F0DD12D00B71954 /* KillRingMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = KillRingMac.mm; path = text/mac/KillRingMac.mm; sourceTree = "<group>"; };
@@ -331,6 +333,7 @@
0C7785711F45130F00F4EBB6 /* DataDetectorsSPI.h */,
0C7785721F45130F00F4EBB6 /* LookupSPI.h */,
0C7785731F45130F00F4EBB6 /* MediaRemoteSPI.h */,
+ A1F55DCE1F5528EC00EDB75F /* MetadataSPI.h */,
0C7785741F45130F00F4EBB6 /* NSAccessibilitySPI.h */,
0C7785751F45130F00F4EBB6 /* NSApplicationSPI.h */,
0C7785761F45130F00F4EBB6 /* NSEventSPI.h */,
@@ -511,6 +514,7 @@
0C2DA1481F3BEB4900DBC317 /* MachVMSPI.h in Headers */,
0C5AF91D1F43A4C7002EAC02 /* MediaPlayerSPI.h in Headers */,
0C77858C1F45130F00F4EBB6 /* MediaRemoteSPI.h in Headers */,
+ A1F55DCF1F5528EC00EDB75F /* MetadataSPI.h in Headers */,
0C5AF91E1F43A4C7002EAC02 /* MobileGestaltSPI.h in Headers */,
0C2DA1491F3BEB4900DBC317 /* NEFilterSourceSPI.h in Headers */,
0C77858D1F45130F00F4EBB6 /* NSAccessibilitySPI.h in Headers */,
Added: trunk/Source/WebCore/PAL/pal/spi/mac/MetadataSPI.h (0 => 221291)
--- trunk/Source/WebCore/PAL/pal/spi/mac/MetadataSPI.h (rev 0)
+++ trunk/Source/WebCore/PAL/pal/spi/mac/MetadataSPI.h 2017-08-29 09:10:52 UTC (rev 221291)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if USE(APPLE_INTERNAL_SDK)
+
+#include <Metadata/MetadataPriv.h>
+
+#endif
+
+WTF_EXTERN_C_BEGIN
+
+Boolean MDItemSetAttribute(MDItemRef, CFStringRef name, CFTypeRef attr);
+
+WTF_EXTERN_C_END
Modified: trunk/Source/WebCore/platform/FileSystem.cpp (221290 => 221291)
--- trunk/Source/WebCore/platform/FileSystem.cpp 2017-08-29 07:46:13 UTC (rev 221290)
+++ trunk/Source/WebCore/platform/FileSystem.cpp 2017-08-29 09:10:52 UTC (rev 221291)
@@ -256,7 +256,7 @@
#if !PLATFORM(MAC)
-void setMetadataURL(const String&, const String&)
+void setMetadataURL(const String&, const String&, const String&)
{
}
Modified: trunk/Source/WebCore/platform/FileSystem.h (221290 => 221291)
--- trunk/Source/WebCore/platform/FileSystem.h 2017-08-29 07:46:13 UTC (rev 221290)
+++ trunk/Source/WebCore/platform/FileSystem.h 2017-08-29 09:10:52 UTC (rev 221291)
@@ -109,7 +109,7 @@
WEBCORE_EXPORT bool getVolumeFreeSpace(const String&, uint64_t&);
WEBCORE_EXPORT std::optional<int32_t> getFileDeviceId(const CString&);
-WEBCORE_EXPORT void setMetadataURL(const String& path, const String& urlString);
+WEBCORE_EXPORT void setMetadataURL(const String& path, const String& urlString, const String& referrer = { });
bool canExcludeFromBackup(); // Returns true if any file can ever be excluded from backup.
bool excludeFromBackup(const String&); // Returns true if successful.
Modified: trunk/Source/WebCore/platform/mac/FileSystemMac.mm (221290 => 221291)
--- trunk/Source/WebCore/platform/mac/FileSystemMac.mm 2017-08-29 07:46:13 UTC (rev 221290)
+++ trunk/Source/WebCore/platform/mac/FileSystemMac.mm 2017-08-29 09:10:52 UTC (rev 221291)
@@ -30,6 +30,7 @@
#import "WebCoreNSURLExtras.h"
#import "WebCoreSystemInterface.h"
+#import <pal/spi/mac/MetadataSPI.h>
#import <wtf/text/WTFString.h>
namespace WebCore {
@@ -48,7 +49,7 @@
return !rmdir(fileSystemRepresentation(path).data());
}
-void setMetadataURL(const String& path, const String& metadataURLString)
+void setMetadataURL(const String& path, const String& metadataURLString, const String& referrer)
{
String urlString;
if (NSURL *url = "" nil))
@@ -56,9 +57,18 @@
else
urlString = metadataURLString;
- // Call WKSetMetadataURL on a background queue because it can take some time.
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), [path = path.isolatedCopy(), urlString = urlString.isolatedCopy()] {
- wkSetMetadataURL(urlString, nil, [NSString stringWithUTF8String:[path fileSystemRepresentation]]);
+ // Call Metadata API on a background queue because it can take some time.
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), [path = path.isolatedCopy(), urlString = urlString.isolatedCopy(), referrer = referrer.isolatedCopy()] {
+ auto item = adoptCF(MDItemCreate(kCFAllocatorDefault, path.createCFString().get()));
+ if (!item)
+ return;
+
+ auto whereFromAttribute = adoptNS([[NSMutableArray alloc] initWithObjects:urlString, nil]);
+ if (!referrer.isNull())
+ [whereFromAttribute addObject:referrer];
+
+ MDItemSetAttribute(item.get(), kMDItemWhereFroms, whereFromAttribute.get());
+ MDItemSetAttribute(item.get(), kMDItemDownloadedDate, @[ [NSDate date] ]);
});
}
Modified: trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h (221290 => 221291)
--- trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h 2017-08-29 07:46:13 UTC (rev 221290)
+++ trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h 2017-08-29 09:10:52 UTC (rev 221291)
@@ -215,7 +215,6 @@
typedef const struct __CFURLStorageSession* CFURLStorageSessionRef;
#if !PLATFORM(IOS)
-extern void (*wkSetMetadataURL)(NSString *urlString, NSString *referrer, NSString *path);
extern CGFloat (*wkNSElasticDeltaForTimeDelta)(CGFloat initialPosition, CGFloat initialVelocity, CGFloat elapsedTime);
extern CGFloat (*wkNSElasticDeltaForReboundDelta)(CGFloat delta);
extern CGFloat (*wkNSReboundDeltaForElasticDelta)(CGFloat delta);
Modified: trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm (221290 => 221291)
--- trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm 2017-08-29 07:46:13 UTC (rev 221290)
+++ trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm 2017-08-29 09:10:52 UTC (rev 221291)
@@ -92,8 +92,6 @@
BOOL (*wkGetBytesFromAXTextMarker)(CFTypeRef textMarker, void *bytes, size_t length);
AXUIElementRef (*wkCreateAXUIElementRef)(id element);
-void (*wkSetMetadataURL)(NSString *urlString, NSString *referrer, NSString *path);
-
#if !PLATFORM(IOS)
CGFloat (*wkNSElasticDeltaForTimeDelta)(CGFloat initialPosition, CGFloat initialVelocity, CGFloat elapsedTime);
CGFloat (*wkNSElasticDeltaForReboundDelta)(CGFloat delta);
Modified: trunk/Source/WebKit/ChangeLog (221290 => 221291)
--- trunk/Source/WebKit/ChangeLog 2017-08-29 07:46:13 UTC (rev 221290)
+++ trunk/Source/WebKit/ChangeLog 2017-08-29 09:10:52 UTC (rev 221291)
@@ -1,3 +1,15 @@
+2017-08-29 Andy Estes <aes...@apple.com>
+
+ [Mac] Upstream WKSetMetadataURL() from WebKitSystemInterface
+ https://bugs.webkit.org/show_bug.cgi?id=176046
+
+ Reviewed by Alex Christensen.
+
+ * UIProcess/mac/WebPageProxyMac.mm:
+ (WebKit::WebPageProxy::savePDFToTemporaryFolderAndOpenWithNativeApplicationRaw):
+ * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
+ (InitWebCoreSystemInterface):
+
2017-08-28 Andy Estes <aes...@apple.com>
[Cocoa] Upstream WKGetWebDefaultCFStringEncoding()
Modified: trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm (221290 => 221291)
--- trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm 2017-08-29 07:46:13 UTC (rev 221290)
+++ trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm 2017-08-29 09:10:52 UTC (rev 221291)
@@ -487,7 +487,7 @@
void WebPageProxy::savePDFToTemporaryFolderAndOpenWithNativeApplicationRaw(const String& suggestedFilename, const String& originatingURLString, const uint8_t* data, unsigned long size, const String& pdfUUID)
{
- // FIXME: Write originatingURLString to the file's originating URL metadata (perhaps WKSetMetadataURL?).
+ // FIXME: Write originatingURLString to the file's originating URL metadata (perhaps WebCore::setMetadataURL()?).
UNUSED_PARAM(originatingURLString);
if (!suggestedFilename.endsWith(".pdf", false)) {
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm (221290 => 221291)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm 2017-08-29 07:46:13 UTC (rev 221290)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm 2017-08-29 09:10:52 UTC (rev 221291)
@@ -76,7 +76,6 @@
#endif
#if !PLATFORM(IOS)
- INIT(SetMetadataURL);
INIT(ExecutableWasLinkedOnOrBeforeSnowLeopard);
INIT(CopyDefaultSearchProviderDisplayName);
INIT(Cursor);
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (221290 => 221291)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2017-08-29 07:46:13 UTC (rev 221290)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2017-08-29 09:10:52 UTC (rev 221291)
@@ -1,3 +1,19 @@
+2017-08-29 Andy Estes <aes...@apple.com>
+
+ [Mac] Upstream WKSetMetadataURL() from WebKitSystemInterface
+ https://bugs.webkit.org/show_bug.cgi?id=176046
+
+ Reviewed by Alex Christensen.
+
+ Removed the pthread logic from -_webkit_setMetadataURL:referrer:atPath: and replaced with
+ WebCore::setMetadataURL(), which uses dispatch_async() for the same purpose as the pthread.
+
+ * Misc/WebNSFileManagerExtras.mm:
+ (-[NSFileManager _webkit_setMetadataURL:referrer:atPath:]):
+ (setMetaData): Deleted.
+ * WebCoreSupport/WebSystemInterface.mm:
+ (InitWebCoreSystemInterface):
+
2017-08-28 Andy Estes <aes...@apple.com>
[Cocoa] Upstream WKGetWebDefaultCFStringEncoding()
Modified: trunk/Source/WebKitLegacy/mac/Misc/WebNSFileManagerExtras.mm (221290 => 221291)
--- trunk/Source/WebKitLegacy/mac/Misc/WebNSFileManagerExtras.mm 2017-08-29 07:46:13 UTC (rev 221290)
+++ trunk/Source/WebKitLegacy/mac/Misc/WebNSFileManagerExtras.mm 2017-08-29 09:10:52 UTC (rev 221291)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,9 +30,10 @@
#import "WebKitNSStringExtras.h"
#import "WebNSURLExtras.h"
-#import <wtf/Assertions.h>
+#import <WebCore/FileSystem.h>
#import <WebKitSystemInterface.h>
#import <sys/stat.h>
+#import <wtf/Assertions.h>
#import <wtf/ObjcRuntimeExtras.h>
#if PLATFORM(IOS)
@@ -43,57 +44,11 @@
#if !PLATFORM(IOS)
-typedef struct MetaDataInfo
-{
- CFStringRef URLString;
- CFStringRef referrer;
- CFStringRef path;
-} MetaDataInfo;
-
-static void *setMetaData(void* context)
-{
- MetaDataInfo *info = (MetaDataInfo *)context;
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- WKSetMetadataURL((NSString *)info->URLString, (NSString *)info->referrer, (NSString *)info->path);
-
- if (info->URLString)
- CFRelease(info->URLString);
- if (info->referrer)
- CFRelease(info->referrer);
- if (info->path)
- CFRelease(info->path);
-
- free(info);
- [pool drain];
-
- return 0;
-}
-
- (void)_webkit_setMetadataURL:(NSString *)URLString referrer:(NSString *)referrer atPath:(NSString *)path
{
ASSERT(URLString);
ASSERT(path);
-
- NSURL *URL = "" _webkit_URLWithUserTypedString:URLString];
- if (URL)
- URLString = [[URL _web_URLByRemovingUserInfo] _web_userVisibleString];
-
- // Spawn a background thread for WKSetMetadataURL because this function will not return until mds has
- // journaled the data we're're trying to set. Depending on what other I/O is going on, it can take some
- // time.
- pthread_t tid;
- pthread_attr_t attr;
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-
- MetaDataInfo *info = static_cast<MetaDataInfo *>(malloc(sizeof(MetaDataInfo)));
-
- info->URLString = URLString ? CFStringCreateCopy(0, (CFStringRef)URLString) : 0;
- info->referrer = referrer ? CFStringCreateCopy(0, (CFStringRef)referrer) : 0;
- info->path = path ? CFStringCreateCopy(0, (CFStringRef)path) : 0;
-
- pthread_create(&tid, &attr, setMetaData, info);
- pthread_attr_destroy(&attr);
+ WebCore::setMetadataURL(path, URLString, referrer);
}
#endif // !PLATFORM(IOS)
Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebSystemInterface.mm (221290 => 221291)
--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebSystemInterface.mm 2017-08-29 07:46:13 UTC (rev 221290)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebSystemInterface.mm 2017-08-29 09:10:52 UTC (rev 221291)
@@ -104,7 +104,6 @@
#endif
#if !PLATFORM(IOS)
- INIT(SetMetadataURL);
INIT(NSElasticDeltaForTimeDelta);
INIT(NSElasticDeltaForReboundDelta);
INIT(NSReboundDeltaForElasticDelta);