Post review Weinig fix-ups
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Sep 2018 00:50:33 +0000 (00:50 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Sep 2018 00:50:33 +0000 (00:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189288

Reviewed by Sam Weinig.

Fix-ups from https://bugs.webkit.org/show_bug.cgi?id=189252

Source/WebCore:

* platform/MIMETypeRegistry.cpp:
(WebCore::MIMETypeRegistry::getSystemPreviewMIMETypes):
(WebCore::initializeSystemPreviewMIMETypes): Deleted.
* rendering/RenderThemeIOS.mm:
(WebCore::arKitBundle):
(WebCore::loadARKitPDFPage):
(WebCore::systemPreviewLogo):

Source/WebKit:

* UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:
(-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]):
(getUTIForMIMEType): Deleted.
* UIProcess/ios/WKSystemPreviewView.mm:
(getUTIForSystemPreviewMIMEType):
(-[WKSystemPreviewView web_setContentProviderData:suggestedFilename:]):
(getUTIForMIMEType): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235651 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/MIMETypeRegistry.cpp
Source/WebCore/rendering/RenderThemeIOS.mm
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm
Source/WebKit/UIProcess/ios/WKSystemPreviewView.mm

index af9d63b..f856786 100644 (file)
@@ -1,3 +1,20 @@
+2018-09-04  Dean Jackson  <dino@apple.com>
+
+        Post review Weinig fix-ups
+        https://bugs.webkit.org/show_bug.cgi?id=189288
+
+        Reviewed by Sam Weinig.
+
+        Fix-ups from https://bugs.webkit.org/show_bug.cgi?id=189252
+
+        * platform/MIMETypeRegistry.cpp:
+        (WebCore::MIMETypeRegistry::getSystemPreviewMIMETypes):
+        (WebCore::initializeSystemPreviewMIMETypes): Deleted.
+        * rendering/RenderThemeIOS.mm:
+        (WebCore::arKitBundle):
+        (WebCore::loadARKitPDFPage):
+        (WebCore::systemPreviewLogo):
+
 2018-09-04  Ryosuke Niwa  <rniwa@webkit.org>
 
         slotchange event doesn't get fired when inserting, removing, or renaming slot elements
index 829bf0d..f3dd14f 100644 (file)
@@ -64,10 +64,6 @@ static HashSet<String, ASCIICaseInsensitiveHash>* supportedMediaMIMETypes;
 static HashSet<String, ASCIICaseInsensitiveHash>* pdfMIMETypes;
 static HashSet<String, ASCIICaseInsensitiveHash>* unsupportedTextMIMETypes;
 
-#if USE(SYSTEM_PREVIEW)
-static HashSet<String, ASCIICaseInsensitiveHash>* systemPreviewMIMETypes;
-#endif
-
 static void initializeSupportedImageMIMETypes()
 {
     supportedImageResourceMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>;
@@ -705,26 +701,16 @@ const String& defaultMIMEType()
 }
 
 #if USE(SYSTEM_PREVIEW)
-static void initializeSystemPreviewMIMETypes()
+const HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSystemPreviewMIMETypes()
 {
-    const char* const types[] = {
+    static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> systemPreviewMIMETypes = std::initializer_list<String> {
         // The official type: https://www.iana.org/assignments/media-types/model/vnd.usdz+zip
         "model/vnd.usdz+zip",
         // Unofficial, but supported because we documented them.
         "model/usd",
         "model/vnd.pixar.usd"
     };
-
-    systemPreviewMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>;
-    for (auto& type : types)
-        systemPreviewMIMETypes->add(type);
-}
-
-const HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSystemPreviewMIMETypes()
-{
-    if (!systemPreviewMIMETypes)
-        initializeSystemPreviewMIMETypes();
-    return *systemPreviewMIMETypes;
+    return systemPreviewMIMETypes;
 }
 
 bool MIMETypeRegistry::isSystemPreviewMIMEType(const String& mimeType)
index 2737882..cb46644 100644 (file)
@@ -1855,16 +1855,14 @@ String RenderThemeIOS::extraDefaultStyleSheet()
 #if USE(SYSTEM_PREVIEW)
 static NSBundle *arKitBundle()
 {
-    static NSBundle *arKitBundle;
-    static dispatch_once_t onceToken;
-    dispatch_once(&onceToken, ^{
+    static NSBundle *arKitBundle = []() {
 #if PLATFORM(IOS_SIMULATOR)
         dlopen("/System/Library/PrivateFrameworks/AssetViewer.framework/AssetViewer", RTLD_NOW);
-        arKitBundle = [NSBundle bundleForClass:NSClassFromString(@"ASVThumbnailView")];
+        return [NSBundle bundleForClass:NSClassFromString(@"ASVThumbnailView")];
 #else
-        arKitBundle = [NSBundle bundleWithURL:[NSURL fileURLWithPath:@"/System/Library/PrivateFrameworks/AssetViewer.framework"]];
+        return [NSBundle bundleWithURL:[NSURL fileURLWithPath:@"/System/Library/PrivateFrameworks/AssetViewer.framework"]];
 #endif
-    });
+    }();
 
     return arKitBundle;
 }
@@ -1884,18 +1882,13 @@ static RetainPtr<CGPDFPageRef> loadARKitPDFPage(NSString *imageName)
         return nullptr;
 
     return CGPDFDocumentGetPage(document.get(), 1);
-};
+}
 
 static CGPDFPageRef systemPreviewLogo()
 {
-    static CGPDFPageRef logoPage;
-    static dispatch_once_t onceToken;
-    dispatch_once(&onceToken, ^{
-        logoPage = loadARKitPDFPage(@"ARKitBadge").leakRef();
-    });
-
+    static CGPDFPageRef logoPage = loadARKitPDFPage(@"ARKitBadge").leakRef();
     return logoPage;
-};
+}
 
 void RenderThemeIOS::paintSystemPreviewBadge(Image& image, const PaintInfo& paintInfo, const FloatRect& rect)
 {
index d3dc54a..690f39d 100644 (file)
@@ -1,3 +1,20 @@
+2018-09-04  Dean Jackson  <dino@apple.com>
+
+        Post review Weinig fix-ups
+        https://bugs.webkit.org/show_bug.cgi?id=189288
+
+        Reviewed by Sam Weinig.
+
+        Fix-ups from https://bugs.webkit.org/show_bug.cgi?id=189252
+
+        * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:
+        (-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]):
+        (getUTIForMIMEType): Deleted.
+        * UIProcess/ios/WKSystemPreviewView.mm:
+        (getUTIForSystemPreviewMIMEType):
+        (-[WKSystemPreviewView web_setContentProviderData:suggestedFilename:]):
+        (getUTIForMIMEType): Deleted.
+
 2018-09-04  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         Populate "text/uri-list" with multiple URLs when the pasteboard contains multiple URLs
index eb4af1d..a7dad48 100644 (file)
@@ -42,18 +42,6 @@ SOFT_LINK_FRAMEWORK(QuickLook)
 SOFT_LINK_CLASS(QuickLook, QLPreviewController);
 SOFT_LINK_CLASS(QuickLook, QLItem);
 
-// FIXME: At the moment we only have one supported UTI, but
-// if we start supporting more types, then we'll need a table.
-static String getUTIForMIMEType(const String& mimeType)
-{
-    static const NeverDestroyed<String> uti = adoptCF(UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, CFSTR("usdz"), nil)).get();
-
-    if (!WebCore::MIMETypeRegistry::isSystemPreviewMIMEType(mimeType))
-        return emptyString();
-
-    return uti;
-}
-
 @interface _WKPreviewControllerDataSource : NSObject <QLPreviewControllerDataSource> {
     RetainPtr<NSItemProvider> _itemProvider;
     RetainPtr<QLItem> _item;
@@ -95,8 +83,10 @@ static String getUTIForMIMEType(const String& mimeType)
 
     _itemProvider = adoptNS([[NSItemProvider alloc] init]);
     // FIXME: We are launching the preview controller before getting a response from the resource, which
-    // means we don't actually know the real MIME type yet. Assume it is one of those that we registered.
-    NSString *contentType = getUTIForMIMEType(*WebCore::MIMETypeRegistry::getSystemPreviewMIMETypes().begin());
+    // means we don't actually know the real MIME type yet.
+    // FIXME: At the moment we only have one supported UTI, but if we start supporting more types,
+    // then we'll need a table.
+    static NSString *contentType = (__bridge NSString *) UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, CFSTR("usdz"), nil);
 
     _item = adoptNS([allocQLItemInstance() initWithPreviewItemProvider:_itemProvider.get() contentType:contentType previewTitle:@"Preview" fileSize:@(0)]);
     [_item setUseLoadingTimeout:NO];
index b8a5405..7d6c81e 100644 (file)
@@ -50,12 +50,12 @@ SOFT_LINK_CLASS(AssetViewer, ASVThumbnailView);
 
 // FIXME: At the moment we only have one supported UTI, but
 // if we start supporting more types, then we'll need a table.
-static String getUTIForMIMEType(const String& mimeType)
+static NSString *getUTIForSystemPreviewMIMEType(const String& mimeType)
 {
-    static const NeverDestroyed<String> uti = adoptCF(UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, CFSTR("usdz"), nil)).get();
+    static NSString *uti = (__bridge NSString *) UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, CFSTR("usdz"), nil);
 
     if (!WebCore::MIMETypeRegistry::isSystemPreviewMIMEType(mimeType))
-        return emptyString();
+        return nil;
 
     return uti;
 }
@@ -103,8 +103,7 @@ static String getUTIForMIMEType(const String& mimeType)
     _suggestedFilename = adoptNS([filename copy]);
     _data = adoptNS([data copy]);
 
-    NSString *contentType;
-    contentType = getUTIForMIMEType(_mimeType.get());
+    NSString *contentType = getUTIForSystemPreviewMIMEType(_mimeType.get());
 
     _item = adoptNS([allocQLItemInstance() initWithDataProvider:self contentType:contentType previewTitle:_suggestedFilename.get()]);
     [_item setUseLoadingTimeout:NO];