Log Message
Cleanup: MIMETypeRegistry functions https://bugs.webkit.org/show_bug.cgi?id=190838
Patch by Said Abou-Hallawa <[email protected]> on 2018-10-24 Reviewed by Simon Fraser. Source/WebCore: Modernize the initialization of the lists in MIMETypeRegistry. Make the functions that return these list be self-contained. Use NeverDestroy<> to allocate the local static variable. Use std::initializer_list() and makeNeverDestroyed() to initialize NeverDestroy<> variables only once. supportedImageResourceMIMETypes will be deleted and all the calls to it will be replaced by supportedImageMIMETypes because they are identical. * loader/archive/ArchiveFactory.cpp: (WebCore::ArchiveFactory::registerKnownArchiveMIMETypes): This function is called while initializing the supportedNonImageMIMETypes(). So it should not have a direct call to it. Instead, supportedNonImageMIMETypes is passed to it. * loader/archive/ArchiveFactory.h: * platform/MIMETypeRegistry.cpp: (WebCore::MIMETypeRegistry::supportedImageMIMETypes): (WebCore::supportedImageMIMETypesForEncoding): (WebCore::supportedJavaScriptMIMETypes): (WebCore::MIMETypeRegistry::supportedNonImageMIMETypes): (WebCore::MIMETypeRegistry::supportedMediaMIMETypes): (WebCore::pdfMIMETypes): (WebCore::MIMETypeRegistry::unsupportedTextMIMETypes): (WebCore::MIMETypeRegistry::isSupportedImageMIMEType): (WebCore::MIMETypeRegistry::isSupportedImageMIMETypeForEncoding): (WebCore::MIMETypeRegistry::isSupportedJavaScriptMIMEType): (WebCore::MIMETypeRegistry::isSupportedNonImageMIMEType): (WebCore::MIMETypeRegistry::isSupportedMediaMIMEType): (WebCore::MIMETypeRegistry::isUnsupportedTextMIMEType): (WebCore::MIMETypeRegistry::isPDFMIMEType): (WebCore::MIMETypeRegistry::systemPreviewMIMETypes): (WebCore::MIMETypeRegistry::isSystemPreviewMIMEType): (WebCore::initializeSupportedImageMIMETypes): Deleted. (WebCore::initializeSupportedImageMIMETypesForEncoding): Deleted. (WebCore::initializeSupportedJavaScriptMIMETypes): Deleted. (WebCore::initializePDFMIMETypes): Deleted. (WebCore::initializeSupportedNonImageMimeTypes): Deleted. (WebCore::initializeSupportedMediaMIMETypes): Deleted. (WebCore::initializeUnsupportedTextMIMETypes): Deleted. (WebCore::MIMETypeRegistry::isSupportedImageResourceMIMEType): Deleted. (WebCore::MIMETypeRegistry::getSupportedImageMIMETypes): Deleted. (WebCore::MIMETypeRegistry::getSupportedImageResourceMIMETypes): Deleted. (WebCore::MIMETypeRegistry::getSupportedNonImageMIMETypes): Deleted. (WebCore::MIMETypeRegistry::getSupportedMediaMIMETypes): Deleted. (WebCore::MIMETypeRegistry::getPDFMIMETypes): Deleted. (WebCore::MIMETypeRegistry::getUnsupportedTextMIMETypes): Deleted. (WebCore::MIMETypeRegistry::getSystemPreviewMIMETypes): Deleted. * platform/MIMETypeRegistry.h: * platform/graphics/Image.cpp: (WebCore::Image::supportsType): * platform/graphics/cg/ImageDecoderCG.cpp: (WebCore::ImageDecoderCG::encodedDataStatus const): * platform/graphics/cg/UTIRegistry.cpp: (WebCore::supportedDefaultImageSourceTypes): (WebCore::isSupportImageSourceType): (WebCore::allowedImageUTIs): Deleted. (WebCore::isAllowedImageUTI): Deleted. * platform/graphics/cg/UTIRegistry.h: * platform/mac/PasteboardMac.mm: (WebCore::Pasteboard::write): Source/WebKit: * UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm: (-[WKWebViewContentProviderRegistry initWithConfiguration:]): Source/WebKitLegacy/mac: * Misc/WebNSPasteboardExtras.mm: (-[NSPasteboard _web_writePromisedRTFDFromArchive:containsImage:]): Replace isSupportedImageResourceMIMEType() by isSupportedImageMIMEType() because they were identical. * WebView/WebHTMLRepresentation.mm: (+[WebHTMLRepresentation supportedMediaMIMETypes]): (+[WebHTMLRepresentation supportedNonImageMIMETypes]): (+[WebHTMLRepresentation supportedImageMIMETypes]): (+[WebHTMLRepresentation unsupportedTextMIMETypes]): * WebView/WebView.mm: (+[WebView _unregisterViewClassAndRepresentationClassForMIMEType:]): (+[WebView _registerViewClass:representationClass:forURLScheme:]): (+[WebView registerViewClass:representationClass:forMIMEType:]):
Modified Paths
- trunk/Source/WebCore/ChangeLog
- trunk/Source/WebCore/loader/archive/ArchiveFactory.cpp
- trunk/Source/WebCore/loader/archive/ArchiveFactory.h
- trunk/Source/WebCore/platform/MIMETypeRegistry.cpp
- trunk/Source/WebCore/platform/MIMETypeRegistry.h
- trunk/Source/WebCore/platform/graphics/Image.cpp
- trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp
- trunk/Source/WebCore/platform/graphics/cg/UTIRegistry.cpp
- trunk/Source/WebCore/platform/graphics/cg/UTIRegistry.h
- trunk/Source/WebCore/platform/mac/PasteboardMac.mm
- trunk/Source/WebKit/ChangeLog
- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
- trunk/Source/WebKit/UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm
- trunk/Source/WebKitLegacy/mac/ChangeLog
- trunk/Source/WebKitLegacy/mac/Misc/WebNSPasteboardExtras.mm
- trunk/Source/WebKitLegacy/mac/WebView/WebHTMLRepresentation.mm
- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm
Diff
Modified: trunk/Source/WebCore/ChangeLog (237392 => 237393)
--- trunk/Source/WebCore/ChangeLog 2018-10-24 18:26:57 UTC (rev 237392)
+++ trunk/Source/WebCore/ChangeLog 2018-10-24 18:42:22 UTC (rev 237393)
@@ -1,3 +1,70 @@
+2018-10-24 Said Abou-Hallawa <[email protected]>
+
+ Cleanup: MIMETypeRegistry functions
+ https://bugs.webkit.org/show_bug.cgi?id=190838
+
+ Reviewed by Simon Fraser.
+
+ Modernize the initialization of the lists in MIMETypeRegistry. Make the
+ functions that return these list be self-contained. Use NeverDestroy<> to
+ allocate the local static variable. Use std::initializer_list() and
+ makeNeverDestroyed() to initialize NeverDestroy<> variables only once.
+
+ supportedImageResourceMIMETypes will be deleted and all the calls to it
+ will be replaced by supportedImageMIMETypes because they are identical.
+
+ * loader/archive/ArchiveFactory.cpp:
+ (WebCore::ArchiveFactory::registerKnownArchiveMIMETypes): This function
+ is called while initializing the supportedNonImageMIMETypes(). So it
+ should not have a direct call to it. Instead, supportedNonImageMIMETypes
+ is passed to it.
+ * loader/archive/ArchiveFactory.h:
+ * platform/MIMETypeRegistry.cpp:
+ (WebCore::MIMETypeRegistry::supportedImageMIMETypes):
+ (WebCore::supportedImageMIMETypesForEncoding):
+ (WebCore::supportedJavaScriptMIMETypes):
+ (WebCore::MIMETypeRegistry::supportedNonImageMIMETypes):
+ (WebCore::MIMETypeRegistry::supportedMediaMIMETypes):
+ (WebCore::pdfMIMETypes):
+ (WebCore::MIMETypeRegistry::unsupportedTextMIMETypes):
+ (WebCore::MIMETypeRegistry::isSupportedImageMIMEType):
+ (WebCore::MIMETypeRegistry::isSupportedImageMIMETypeForEncoding):
+ (WebCore::MIMETypeRegistry::isSupportedJavaScriptMIMEType):
+ (WebCore::MIMETypeRegistry::isSupportedNonImageMIMEType):
+ (WebCore::MIMETypeRegistry::isSupportedMediaMIMEType):
+ (WebCore::MIMETypeRegistry::isUnsupportedTextMIMEType):
+ (WebCore::MIMETypeRegistry::isPDFMIMEType):
+ (WebCore::MIMETypeRegistry::systemPreviewMIMETypes):
+ (WebCore::MIMETypeRegistry::isSystemPreviewMIMEType):
+ (WebCore::initializeSupportedImageMIMETypes): Deleted.
+ (WebCore::initializeSupportedImageMIMETypesForEncoding): Deleted.
+ (WebCore::initializeSupportedJavaScriptMIMETypes): Deleted.
+ (WebCore::initializePDFMIMETypes): Deleted.
+ (WebCore::initializeSupportedNonImageMimeTypes): Deleted.
+ (WebCore::initializeSupportedMediaMIMETypes): Deleted.
+ (WebCore::initializeUnsupportedTextMIMETypes): Deleted.
+ (WebCore::MIMETypeRegistry::isSupportedImageResourceMIMEType): Deleted.
+ (WebCore::MIMETypeRegistry::getSupportedImageMIMETypes): Deleted.
+ (WebCore::MIMETypeRegistry::getSupportedImageResourceMIMETypes): Deleted.
+ (WebCore::MIMETypeRegistry::getSupportedNonImageMIMETypes): Deleted.
+ (WebCore::MIMETypeRegistry::getSupportedMediaMIMETypes): Deleted.
+ (WebCore::MIMETypeRegistry::getPDFMIMETypes): Deleted.
+ (WebCore::MIMETypeRegistry::getUnsupportedTextMIMETypes): Deleted.
+ (WebCore::MIMETypeRegistry::getSystemPreviewMIMETypes): Deleted.
+ * platform/MIMETypeRegistry.h:
+ * platform/graphics/Image.cpp:
+ (WebCore::Image::supportsType):
+ * platform/graphics/cg/ImageDecoderCG.cpp:
+ (WebCore::ImageDecoderCG::encodedDataStatus const):
+ * platform/graphics/cg/UTIRegistry.cpp:
+ (WebCore::supportedDefaultImageSourceTypes):
+ (WebCore::isSupportImageSourceType):
+ (WebCore::allowedImageUTIs): Deleted.
+ (WebCore::isAllowedImageUTI): Deleted.
+ * platform/graphics/cg/UTIRegistry.h:
+ * platform/mac/PasteboardMac.mm:
+ (WebCore::Pasteboard::write):
+
2018-10-24 Chris Dumez <[email protected]>
[PSON] When navigating back and forth, 'about:blank' shows up in the back/forward list
Modified: trunk/Source/WebCore/loader/archive/ArchiveFactory.cpp (237392 => 237393)
--- trunk/Source/WebCore/loader/archive/ArchiveFactory.cpp 2018-10-24 18:26:57 UTC (rev 237392)
+++ trunk/Source/WebCore/loader/archive/ArchiveFactory.cpp 2018-10-24 18:42:22 UTC (rev 237393)
@@ -95,9 +95,8 @@
return function(url, *data);
}
-void ArchiveFactory::registerKnownArchiveMIMETypes()
+void ArchiveFactory::registerKnownArchiveMIMETypes(HashSet<String, ASCIICaseInsensitiveHash>& mimeTypes)
{
- auto& mimeTypes = MIMETypeRegistry::getSupportedNonImageMIMETypes();
for (auto& mimeType : archiveMIMETypes().keys())
mimeTypes.add(mimeType);
}
Modified: trunk/Source/WebCore/loader/archive/ArchiveFactory.h (237392 => 237393)
--- trunk/Source/WebCore/loader/archive/ArchiveFactory.h 2018-10-24 18:26:57 UTC (rev 237392)
+++ trunk/Source/WebCore/loader/archive/ArchiveFactory.h 2018-10-24 18:42:22 UTC (rev 237393)
@@ -40,7 +40,7 @@
public:
static bool isArchiveMIMEType(const String&);
static RefPtr<Archive> create(const URL&, SharedBuffer* data, const String& mimeType);
- static void registerKnownArchiveMIMETypes();
+ static void registerKnownArchiveMIMETypes(HashSet<String, ASCIICaseInsensitiveHash>&);
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.cpp (237392 => 237393)
--- trunk/Source/WebCore/platform/MIMETypeRegistry.cpp 2018-10-24 18:26:57 UTC (rev 237392)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.cpp 2018-10-24 18:42:22 UTC (rev 237393)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2018 Apple Inc. All rights reserved.
* Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
*
* Redistribution and use in source and binary forms, with or without
@@ -55,210 +55,235 @@
namespace WebCore {
-static HashSet<String, ASCIICaseInsensitiveHash>* supportedImageResourceMIMETypes;
-static HashSet<String, ASCIICaseInsensitiveHash>* supportedImageMIMETypes;
-static HashSet<String, ASCIICaseInsensitiveHash>* supportedImageMIMETypesForEncoding;
-static HashSet<String, ASCIICaseInsensitiveHash>* supportedJavaScriptMIMETypes;
-static HashSet<String, ASCIICaseInsensitiveHash>* supportedNonImageMIMETypes;
-static HashSet<String, ASCIICaseInsensitiveHash>* supportedMediaMIMETypes;
-static HashSet<String, ASCIICaseInsensitiveHash>* pdfMIMETypes;
-static HashSet<String, ASCIICaseInsensitiveHash>* unsupportedTextMIMETypes;
-
-static void initializeSupportedImageMIMETypes()
+const HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::supportedImageMIMETypes()
{
- supportedImageResourceMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>;
- supportedImageMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>;
-
+ static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> supportedImageMIMETypes = std::initializer_list<String> {
#if USE(CG)
- // This represents the subset of allowed image UTIs for which CoreServices has a corresponding MIME type. Keep this in sync with allowedImageUTIs().
- static const ASCIILiteral allowedImageMIMETypes[] = { "image/tiff"_s, "image/gif"_s, "image/jpeg"_s, "image/vnd.microsoft.icon"_s, "image/jp2"_s, "image/png"_s, "image/bmp"_s };
- for (auto& mimeType : allowedImageMIMETypes) {
- supportedImageMIMETypes->add(mimeType);
- supportedImageResourceMIMETypes->add(mimeType);
- }
+ // This represents the subset of allowed image UTIs for which CoreServices has a corresponding MIME type.
+ "image/tiff"_s,
+ "image/gif"_s,
+ "image/jpeg"_s,
+ "image/vnd.microsoft.icon"_s,
+ "image/jp2"_s,
+ "image/png"_s,
+ "image/bmp"_s,
-#ifndef NDEBUG
- for (auto& uti : allowedImageUTIs()) {
- auto mimeType = MIMETypeForImageSourceType(uti);
- if (!mimeType.isEmpty()) {
- ASSERT(supportedImageMIMETypes->contains(mimeType));
- ASSERT(supportedImageResourceMIMETypes->contains(mimeType));
- }
- }
+ "image/x-icon"_s, // Favicons don't have a MIME type in the registry either.
+ "image/pjpeg"_s, // We only get one MIME type per UTI, hence our need to add these manually
-#if PLATFORM(COCOA)
- for (auto& mime : *supportedImageMIMETypes)
- ASSERT_UNUSED(mime, allowedImageUTIs().contains(UTIFromMIMEType(mime)));
-#endif
-#endif
+#if PLATFORM(IOS_FAMILY)
+ // Add malformed image mimetype for compatibility with Mail and to handle malformed mimetypes from the net
+ // These were removed for <rdar://problem/6564538> Re-enable UTI code in WebCore now that MobileCoreServices exists
+ // But Mail relies on at least image/tif reported as being supported (should be image/tiff).
+ // This can be removed when Mail addresses:
+ // <rdar://problem/7879510> Mail should use standard image mimetypes
+ // and we fix sniffing so that it corrects items such as image/jpg -> image/jpeg.
- // Favicons don't have a MIME type in the registry either.
- supportedImageMIMETypes->add("image/x-icon");
- supportedImageResourceMIMETypes->add("image/x-icon");
+ // JPEG (image/jpeg)
+ "image/jpg"_s,
+ "image/jp_"_s,
+ "image/jpe_"_s,
+ "application/jpg"_s,
+ "application/x-jpg"_s,
+ "image/pipeg"_s,
+ "image/vnd.switfview-jpeg"_s,
+ "image/x-xbitmap"_s,
- // We only get one MIME type per UTI, hence our need to add these manually
- supportedImageMIMETypes->add("image/pjpeg");
- supportedImageResourceMIMETypes->add("image/pjpeg");
+ // GIF (image/gif)
+ "image/gi_"_s,
-#if PLATFORM(IOS_FAMILY)
- // Add malformed image mimetype for compatibility with Mail and to handle malformed mimetypes from the net
- // These were removed for <rdar://problem/6564538> Re-enable UTI code in WebCore now that MobileCoreServices exists
- // But Mail relies on at least image/tif reported as being supported (should be image/tiff).
- // This can be removed when Mail addresses:
- // <rdar://problem/7879510> Mail should use standard image mimetypes
- // and we fix sniffing so that it corrects items such as image/jpg -> image/jpeg.
- static const char* const malformedMIMETypes[] = {
- // JPEG (image/jpeg)
- "image/jpg", "image/jp_", "image/jpe_", "application/jpg", "application/x-jpg", "image/pipeg",
- "image/vnd.switfview-jpeg", "image/x-xbitmap",
- // GIF (image/gif)
- "image/gi_",
// PNG (image/png)
- "application/png", "application/x-png",
+ "application/png"_s,
+ "application/x-png"_s,
+
// TIFF (image/tiff)
- "image/x-tif", "image/tif", "image/x-tiff", "application/tif", "application/x-tif", "application/tiff",
- "application/x-tiff",
+ "image/x-tif"_s,
+ "image/tif"_s,
+ "image/x-tiff"_s,
+ "application/tif"_s,
+ "application/x-tif"_s,
+ "application/tiff"_s,
+ "application/x-tiff"_s,
+
// BMP (image/bmp, image/x-bitmap)
- "image/x-bmp", "image/x-win-bitmap", "image/x-windows-bmp", "image/ms-bmp", "image/x-ms-bmp",
- "application/bmp", "application/x-bmp", "application/x-win-bitmap",
- };
- for (auto& type : malformedMIMETypes) {
- supportedImageMIMETypes->add(type);
- supportedImageResourceMIMETypes->add(type);
- }
+ "image/x-bmp"_s,
+ "image/x-win-bitmap"_s,
+ "image/x-windows-bmp"_s,
+ "image/ms-bmp"_s,
+ "image/x-ms-bmp"_s,
+ "application/bmp"_s,
+ "application/x-bmp"_s,
+ "application/x-win-bitmap"_s,
#endif
-
#else
- // assume that all implementations at least support the following standard
- // image types:
- static const char* const types[] = {
- "image/jpeg",
- "image/png",
- "image/gif",
- "image/bmp",
- "image/vnd.microsoft.icon", // ico
- "image/x-icon", // ico
- "image/x-xbitmap" // xbm
+ // assume that all implementations at least support the following standard
+ // image types:
+ "image/jpeg"_s,
+ "image/png"_s,
+ "image/gif"_s,
+ "image/bmp"_s,
+ "image/vnd.microsoft.icon"_s, // ico
+ "image/x-icon"_s, // ico
+ "image/x-xbitmap"_s, // xbm
+#if USE(WEBP)
+ "image/webp"_s,
+#endif
+#endif
};
- for (auto& type : types) {
- supportedImageMIMETypes->add(type);
- supportedImageResourceMIMETypes->add(type);
- }
-#if USE(WEBP)
- supportedImageMIMETypes->add("image/webp");
- supportedImageResourceMIMETypes->add("image/webp");
+#if USE(CG)
+#ifndef NDEBUG
+ // Esnure supportedImageMIMETypes() is in sync with supportedDefaultImageSourceTypes().
+ static std::once_flag onceFlag;
+ std::call_once(onceFlag, [] {
+ for (auto& imageSourceType : supportedDefaultImageSourceTypes()) {
+ auto mimeType = MIMETypeForImageSourceType(imageSourceType);
+ ASSERT_IMPLIES(!mimeType.isEmpty(), supportedImageMIMETypes.get().contains(mimeType));
+ }
+ });
#endif
-
-#endif // USE(CG)
+#endif
+ return supportedImageMIMETypes;
}
-static void initializeSupportedImageMIMETypesForEncoding()
+static const HashSet<String, ASCIICaseInsensitiveHash>& supportedImageMIMETypesForEncoding()
{
- supportedImageMIMETypesForEncoding = new HashSet<String, ASCIICaseInsensitiveHash>;
-
-#if USE(CG)
#if PLATFORM(COCOA)
- RetainPtr<CFArrayRef> supportedTypes = adoptCF(CGImageDestinationCopyTypeIdentifiers());
- CFIndex count = CFArrayGetCount(supportedTypes.get());
- for (CFIndex i = 0; i < count; i++) {
- CFStringRef supportedType = reinterpret_cast<CFStringRef>(CFArrayGetValueAtIndex(supportedTypes.get(), i));
- String mimeType = MIMETypeForImageSourceType(supportedType);
- if (!mimeType.isEmpty())
- supportedImageMIMETypesForEncoding->add(mimeType);
- }
+ static const auto supportedImageMIMETypesForEncoding = makeNeverDestroyed([] {
+ RetainPtr<CFArrayRef> supportedTypes = adoptCF(CGImageDestinationCopyTypeIdentifiers());
+ HashSet<String, ASCIICaseInsensitiveHash> supportedImageMIMETypesForEncoding;
+ CFIndex count = CFArrayGetCount(supportedTypes.get());
+ for (CFIndex i = 0; i < count; i++) {
+ CFStringRef supportedType = reinterpret_cast<CFStringRef>(CFArrayGetValueAtIndex(supportedTypes.get(), i));
+ String mimeType = MIMETypeForImageSourceType(supportedType);
+ if (!mimeType.isEmpty())
+ supportedImageMIMETypesForEncoding.add(mimeType);
+ }
+ return supportedImageMIMETypesForEncoding;
+ }());
#else
- // FIXME: Add Windows support for all the supported UTI's when a way to convert from MIMEType to UTI reliably is found.
- // For now, only support PNG, JPEG and GIF. See <rdar://problem/6095286>.
- supportedImageMIMETypesForEncoding->add("image/png");
- supportedImageMIMETypesForEncoding->add("image/jpeg");
- supportedImageMIMETypesForEncoding->add("image/gif");
-#endif
+ static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> supportedImageMIMETypesForEncoding =std::initializer_list<String> {
+#if USE(CG)
+ // FIXME: Add Windows support for all the supported UTI's when a way to convert from MIMEType to UTI reliably is found.
+ // For now, only support PNG, JPEG and GIF. See <rdar://problem/6095286>.
+ "image/png"_s,
+ "image/jpeg"_s,
+ "image/gif"_s,
#elif PLATFORM(GTK)
- supportedImageMIMETypesForEncoding->add("image/png");
- supportedImageMIMETypesForEncoding->add("image/jpeg");
- supportedImageMIMETypesForEncoding->add("image/tiff");
- supportedImageMIMETypesForEncoding->add("image/bmp");
- supportedImageMIMETypesForEncoding->add("image/ico");
+ "image/png"_s,
+ "image/jpeg"_s,
+ "image/tiff"_s,
+ "image/bmp"_s,
+ "image/ico"_s,
#elif USE(CAIRO)
- supportedImageMIMETypesForEncoding->add("image/png");
+ "image/png"_s,
#endif
-}
-
-static void initializeSupportedJavaScriptMIMETypes()
-{
- // https://html.spec.whatwg.org/multipage/scripting.html#_javascript_-mime-type
- static const char* const types[] = {
- "text/_javascript_",
- "text/ecmascript",
- "application/_javascript_",
- "application/ecmascript",
- "application/x-_javascript_",
- "application/x-ecmascript",
- "text/_javascript_1.0",
- "text/_javascript_1.1",
- "text/_javascript_1.2",
- "text/_javascript_1.3",
- "text/_javascript_1.4",
- "text/_javascript_1.5",
- "text/jscript",
- "text/livescript",
- "text/x-_javascript_",
- "text/x-ecmascript"
};
-
- supportedJavaScriptMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>;
- for (auto* type : types)
- supportedJavaScriptMIMETypes->add(type);
+#endif
+ return supportedImageMIMETypesForEncoding;
}
-static void initializePDFMIMETypes()
+static const HashSet<String, ASCIICaseInsensitiveHash>& supportedJavaScriptMIMETypes()
{
- const char* const types[] = {
- "application/pdf",
- "text/pdf"
+ static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> supportedJavaScriptMIMETypes = std::initializer_list<String> {
+ // https://html.spec.whatwg.org/multipage/scripting.html#_javascript_-mime-type
+ "text/_javascript_"_s,
+ "text/ecmascript"_s,
+ "application/_javascript_"_s,
+ "application/ecmascript"_s,
+ "application/x-_javascript_"_s,
+ "application/x-ecmascript"_s,
+ "text/_javascript_1.0"_s,
+ "text/_javascript_1.1"_s,
+ "text/_javascript_1.2"_s,
+ "text/_javascript_1.3"_s,
+ "text/_javascript_1.4"_s,
+ "text/_javascript_1.5"_s,
+ "text/jscript"_s,
+ "text/livescript"_s,
+ "text/x-_javascript_"_s,
+ "text/x-ecmascript"_s,
};
-
- pdfMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>;
- for (auto& type : types)
- pdfMIMETypes->add(type);
+ return supportedJavaScriptMIMETypes;
}
-static void initializeSupportedNonImageMimeTypes()
+HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::supportedNonImageMIMETypes()
{
- static const char* const types[] = {
- "text/html",
- "text/xml",
- "text/xsl",
- "text/plain",
- "text/",
- "application/xml",
- "application/xhtml+xml",
+ static auto supportedNonImageMIMETypes = makeNeverDestroyed([] {
+ HashSet<String, ASCIICaseInsensitiveHash> supportedNonImageMIMETypes = std::initializer_list<String> {
+ "text/html"_s,
+ "text/xml"_s,
+ "text/xsl"_s,
+ "text/plain"_s,
+ "text/"_s,
+ "application/xml"_s,
+ "application/xhtml+xml"_s,
#if !PLATFORM(IOS_FAMILY)
- "application/vnd.wap.xhtml+xml",
- "application/rss+xml",
- "application/atom+xml",
+ "application/vnd.wap.xhtml+xml"_s,
+ "application/rss+xml"_s,
+ "application/atom+xml"_s,
#endif
- "application/json",
- "image/svg+xml",
+ "application/json"_s,
+ "image/svg+xml"_s,
#if ENABLE(FTPDIR)
- "application/x-ftp-directory",
+ "application/x-ftp-directory"_s,
#endif
- "multipart/x-mixed-replace"
+ "multipart/x-mixed-replace"_s,
// Note: Adding a new type here will probably render it as HTML.
// This can result in cross-site scripting vulnerabilities.
- };
+ };
+ supportedNonImageMIMETypes.add(supportedJavaScriptMIMETypes().begin(), supportedJavaScriptMIMETypes().end());
+#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
+ ArchiveFactory::registerKnownArchiveMIMETypes(supportedNonImageMIMETypes);
+#endif
+ return supportedNonImageMIMETypes;
+ }());
+ return supportedNonImageMIMETypes;
+}
- if (!supportedJavaScriptMIMETypes)
- initializeSupportedJavaScriptMIMETypes();
+const HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::supportedMediaMIMETypes()
+{
+ static const auto supportedMediaMIMETypes = makeNeverDestroyed([] {
+ HashSet<String, ASCIICaseInsensitiveHash> supportedMediaMIMETypes;
+#if ENABLE(VIDEO)
+ MediaPlayer::getSupportedTypes(supportedMediaMIMETypes);
+#endif
+ return supportedMediaMIMETypes;
+ }());
+ return supportedMediaMIMETypes;
+}
- supportedNonImageMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash> { *supportedJavaScriptMIMETypes };
- for (auto& type : types)
- supportedNonImageMIMETypes->add(type);
+const HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::pdfMIMETypes()
+{
+ static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> pdfMIMETypes = std::initializer_list<String> {
+ "application/pdf"_s,
+ "text/pdf"_s,
+ };
+ return pdfMIMETypes;
+}
-#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
- ArchiveFactory::registerKnownArchiveMIMETypes();
+const HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::unsupportedTextMIMETypes()
+{
+ static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> unsupportedTextMIMETypes = std::initializer_list<String> {
+ "text/calendar"_s,
+ "text/x-calendar"_s,
+ "text/x-vcalendar"_s,
+ "text/vcalendar"_s,
+ "text/vcard"_s,
+ "text/x-vcard"_s,
+ "text/directory"_s,
+ "text/ldif"_s,
+ "text/qif"_s,
+ "text/x-qif"_s,
+ "text/x-csv"_s,
+ "text/x-vcf"_s,
+#if !PLATFORM(IOS_FAMILY)
+ "text/rtf"_s,
+#else
+ "text/vnd.sun.j2me.app-descriptor"_s,
#endif
+ };
+ return unsupportedTextMIMETypes;
}
static const Vector<String>* typesForCommonExtension(const String& extension)
@@ -392,41 +417,6 @@
return { };
}
-static void initializeSupportedMediaMIMETypes()
-{
- supportedMediaMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>;
-#if ENABLE(VIDEO)
- MediaPlayer::getSupportedTypes(*supportedMediaMIMETypes);
-#endif
-}
-
-static void initializeUnsupportedTextMIMETypes()
-{
- static const char* const types[] = {
- "text/calendar"_s,
- "text/x-calendar"_s,
- "text/x-vcalendar"_s,
- "text/vcalendar"_s,
- "text/vcard"_s,
- "text/x-vcard"_s,
- "text/directory"_s,
- "text/ldif"_s,
- "text/qif"_s,
- "text/x-qif"_s,
- "text/x-csv"_s,
- "text/x-vcf"_s,
-#if !PLATFORM(IOS_FAMILY)
- "text/rtf"_s,
-#else
- "text/vnd.sun.j2me.app-descriptor"_s,
-#endif
- };
-
- unsupportedTextMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>;
- for (auto& type : types)
- unsupportedTextMIMETypes->add(type);
-}
-
String MIMETypeRegistry::getMIMETypeForPath(const String& path)
{
size_t pos = path.reverseFind('.');
@@ -443,9 +433,7 @@
{
if (mimeType.isEmpty())
return false;
- if (!supportedImageMIMETypes)
- initializeSupportedImageMIMETypes();
- return supportedImageMIMETypes->contains(getNormalizedMIMEType(mimeType));
+ return supportedImageMIMETypes().contains(getNormalizedMIMEType(mimeType));
}
bool MIMETypeRegistry::isSupportedImageVideoOrSVGMIMEType(const String& mimeType)
@@ -461,15 +449,6 @@
return false;
}
-bool MIMETypeRegistry::isSupportedImageResourceMIMEType(const String& mimeType)
-{
- if (mimeType.isEmpty())
- return false;
- if (!supportedImageResourceMIMETypes)
- initializeSupportedImageMIMETypes();
- return supportedImageResourceMIMETypes->contains(getNormalizedMIMEType(mimeType));
-}
-
bool MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(const String& mimeType)
{
ASSERT(isMainThread());
@@ -476,9 +455,7 @@
if (mimeType.isEmpty())
return false;
- if (!supportedImageMIMETypesForEncoding)
- initializeSupportedImageMIMETypesForEncoding();
- return supportedImageMIMETypesForEncoding->contains(mimeType);
+ return supportedImageMIMETypesForEncoding().contains(mimeType);
}
bool MIMETypeRegistry::isSupportedJavaScriptMIMEType(const String& mimeType)
@@ -494,9 +471,7 @@
return isSupported;
}
- if (!supportedJavaScriptMIMETypes)
- initializeSupportedNonImageMimeTypes();
- return supportedJavaScriptMIMETypes->contains(mimeType);
+ return supportedJavaScriptMIMETypes().contains(mimeType);
}
bool MIMETypeRegistry::isSupportedStyleSheetMIMEType(const String& mimeType)
@@ -539,9 +514,7 @@
{
if (mimeType.isEmpty())
return false;
- if (!supportedNonImageMIMETypes)
- initializeSupportedNonImageMimeTypes();
- return supportedNonImageMIMETypes->contains(mimeType);
+ return supportedNonImageMIMETypes().contains(mimeType);
}
bool MIMETypeRegistry::isSupportedMediaMIMEType(const String& mimeType)
@@ -548,9 +521,7 @@
{
if (mimeType.isEmpty())
return false;
- if (!supportedMediaMIMETypes)
- initializeSupportedMediaMIMETypes();
- return supportedMediaMIMETypes->contains(mimeType);
+ return supportedMediaMIMETypes().contains(mimeType);
}
bool MIMETypeRegistry::isSupportedTextTrackMIMEType(const String& mimeType)
@@ -562,9 +533,7 @@
{
if (mimeType.isEmpty())
return false;
- if (!unsupportedTextMIMETypes)
- initializeUnsupportedTextMIMETypes();
- return unsupportedTextMIMETypes->contains(mimeType);
+ return unsupportedTextMIMETypes().contains(mimeType);
}
bool MIMETypeRegistry::isTextMIMEType(const String& mimeType)
@@ -622,9 +591,7 @@
{
if (mimeType.isEmpty())
return false;
- if (!pdfMIMETypes)
- initializePDFMIMETypes();
- return pdfMIMETypes->contains(mimeType);
+ return pdfMIMETypes().contains(mimeType);
}
bool MIMETypeRegistry::isPostScriptMIMEType(const String& mimeType)
@@ -651,49 +618,6 @@
return false;
}
-const HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedImageMIMETypes()
-{
- if (!supportedImageMIMETypes)
- initializeSupportedImageMIMETypes();
- return *supportedImageMIMETypes;
-}
-
-const HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedImageResourceMIMETypes()
-{
- if (!supportedImageResourceMIMETypes)
- initializeSupportedImageMIMETypes();
- return *supportedImageResourceMIMETypes;
-}
-
-HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedNonImageMIMETypes()
-{
- if (!supportedNonImageMIMETypes)
- initializeSupportedNonImageMimeTypes();
- return *supportedNonImageMIMETypes;
-}
-
-const HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedMediaMIMETypes()
-{
- if (!supportedMediaMIMETypes)
- initializeSupportedMediaMIMETypes();
- return *supportedMediaMIMETypes;
-}
-
-
-const HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getPDFMIMETypes()
-{
- if (!pdfMIMETypes)
- initializePDFMIMETypes();
- return *pdfMIMETypes;
-}
-
-const HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getUnsupportedTextMIMETypes()
-{
- if (!unsupportedTextMIMETypes)
- initializeUnsupportedTextMIMETypes();
- return *unsupportedTextMIMETypes;
-}
-
const String& defaultMIMEType()
{
static NeverDestroyed<const String> defaultMIMEType(MAKE_STATIC_STRING_IMPL("application/octet-stream"));
@@ -701,7 +625,7 @@
}
#if USE(SYSTEM_PREVIEW)
-const HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSystemPreviewMIMETypes()
+const HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::systemPreviewMIMETypes()
{
static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> systemPreviewMIMETypes = std::initializer_list<String> {
// The official type: https://www.iana.org/assignments/media-types/model/vnd.usdz+zip
@@ -717,7 +641,7 @@
{
if (mimeType.isEmpty())
return false;
- return getSystemPreviewMIMETypes().contains(mimeType);
+ return systemPreviewMIMETypes().contains(mimeType);
}
#endif
Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.h (237392 => 237393)
--- trunk/Source/WebCore/platform/MIMETypeRegistry.h 2018-10-24 18:26:57 UTC (rev 237392)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.h 2018-10-24 18:42:22 UTC (rev 237393)
@@ -50,10 +50,6 @@
// Check to see if a MIME type is suitable for being loaded as an image, including SVG and Video (where supported).
WEBCORE_EXPORT static bool isSupportedImageVideoOrSVGMIMEType(const String& mimeType);
- // Check to see if a MIME type is suitable for being loaded as an image
- // document in a frame.
- WEBCORE_EXPORT static bool isSupportedImageResourceMIMEType(const String& mimeType);
-
// Check to see if a MIME type is suitable for being encoded.
static bool isSupportedImageMIMETypeForEncoding(const String& mimeType);
@@ -108,18 +104,15 @@
// makes this test is after many other tests are done on the MIME type.
WEBCORE_EXPORT static bool isTextMIMEType(const String& mimeType);
- // FIXME: WebKit coding style says we should not have the word "get" in the names of these functions.
// FIXME: Would be nice to find a way to avoid exposing these sets, even worse exposing non-const references.
- WEBCORE_EXPORT static HashSet<String, ASCIICaseInsensitiveHash>& getSupportedNonImageMIMETypes();
+ WEBCORE_EXPORT static const HashSet<String, ASCIICaseInsensitiveHash>& supportedImageMIMETypes();
+ WEBCORE_EXPORT static HashSet<String, ASCIICaseInsensitiveHash>& supportedNonImageMIMETypes();
+ WEBCORE_EXPORT static const HashSet<String, ASCIICaseInsensitiveHash>& supportedMediaMIMETypes();
+ WEBCORE_EXPORT static const HashSet<String, ASCIICaseInsensitiveHash>& pdfMIMETypes();
+ WEBCORE_EXPORT static const HashSet<String, ASCIICaseInsensitiveHash>& unsupportedTextMIMETypes();
- WEBCORE_EXPORT const static HashSet<String, ASCIICaseInsensitiveHash>& getSupportedImageMIMETypes();
- const static HashSet<String, ASCIICaseInsensitiveHash>& getSupportedImageResourceMIMETypes();
- WEBCORE_EXPORT const static HashSet<String, ASCIICaseInsensitiveHash>& getSupportedMediaMIMETypes();
- WEBCORE_EXPORT const static HashSet<String, ASCIICaseInsensitiveHash>& getPDFMIMETypes();
- WEBCORE_EXPORT const static HashSet<String, ASCIICaseInsensitiveHash>& getUnsupportedTextMIMETypes();
-
#if USE(SYSTEM_PREVIEW)
- WEBCORE_EXPORT const static HashSet<String, ASCIICaseInsensitiveHash>& getSystemPreviewMIMETypes();
+ WEBCORE_EXPORT const static HashSet<String, ASCIICaseInsensitiveHash>& systemPreviewMIMETypes();
#endif
// FIXME: WebKit coding style says we should not have the word "get" in the name of this function.
Modified: trunk/Source/WebCore/platform/graphics/Image.cpp (237392 => 237393)
--- trunk/Source/WebCore/platform/graphics/Image.cpp 2018-10-24 18:26:57 UTC (rev 237392)
+++ trunk/Source/WebCore/platform/graphics/Image.cpp 2018-10-24 18:42:22 UTC (rev 237393)
@@ -82,7 +82,7 @@
bool Image::supportsType(const String& type)
{
- return MIMETypeRegistry::isSupportedImageResourceMIMEType(type);
+ return MIMETypeRegistry::isSupportedImageMIMEType(type);
}
bool Image::isPDFResource(const String& mimeType, const URL& url)
Modified: trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp (237392 => 237393)
--- trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp 2018-10-24 18:26:57 UTC (rev 237392)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp 2018-10-24 18:42:22 UTC (rev 237393)
@@ -199,7 +199,7 @@
return EncodedDataStatus::Error;
case kCGImageStatusIncomplete: {
- if (!isAllowedImageUTI(uti))
+ if (!isSupportImageSourceType(uti))
return EncodedDataStatus::Error;
RetainPtr<CFDictionaryRef> image0Properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_nativeDecoder.get(), 0, imageSourceOptions().get()));
@@ -213,7 +213,7 @@
}
case kCGImageStatusComplete:
- if (!isAllowedImageUTI(uti))
+ if (!isSupportImageSourceType(uti))
return EncodedDataStatus::Error;
return EncodedDataStatus::Complete;
Modified: trunk/Source/WebCore/platform/graphics/cg/UTIRegistry.cpp (237392 => 237393)
--- trunk/Source/WebCore/platform/graphics/cg/UTIRegistry.cpp 2018-10-24 18:26:57 UTC (rev 237392)
+++ trunk/Source/WebCore/platform/graphics/cg/UTIRegistry.cpp 2018-10-24 18:42:22 UTC (rev 237393)
@@ -38,10 +38,10 @@
namespace WebCore {
-HashSet<String>& allowedImageUTIs()
+const HashSet<String>& supportedDefaultImageSourceTypes()
{
// CG at least supports the following standard image types:
- static NeverDestroyed<HashSet<String>> s_allowedImageUTIs = std::initializer_list<String> {
+ static NeverDestroyed<HashSet<String>> supportedDefaultImageSourceTypes = std::initializer_list<String> {
"com.compuserve.gif",
"com.microsoft.bmp",
"com.microsoft.cur",
@@ -54,25 +54,24 @@
};
#ifndef NDEBUG
- // But make sure that all of them are really supported.
- static bool checked = false;
- if (!checked) {
- RetainPtr<CFArrayRef> systemImageUTIs = adoptCF(CGImageSourceCopyTypeIdentifiers());
- CFIndex count = CFArrayGetCount(systemImageUTIs.get());
- for (auto& imageUTI : s_allowedImageUTIs.get()) {
- RetainPtr<CFStringRef> string = imageUTI.createCFString();
- ASSERT(CFArrayContainsValue(systemImageUTIs.get(), CFRangeMake(0, count), string.get()));
+ // Make sure that CG supports them.
+ static std::once_flag onceFlag;
+ std::call_once(onceFlag, [] {
+ RetainPtr<CFArrayRef> systemImageSourceTypes = adoptCF(CGImageSourceCopyTypeIdentifiers());
+ CFIndex count = CFArrayGetCount(systemImageSourceTypes.get());
+ for (auto& imageSourceType : supportedDefaultImageSourceTypes.get()) {
+ RetainPtr<CFStringRef> string = imageSourceType.createCFString();
+ ASSERT(CFArrayContainsValue(systemImageSourceTypes.get(), CFRangeMake(0, count), string.get()));
}
- checked = true;
- }
+ });
#endif
- return s_allowedImageUTIs.get();
+ return supportedDefaultImageSourceTypes;
}
-bool isAllowedImageUTI(const String& imageUTI)
+bool isSupportImageSourceType(const String& imageSourceType)
{
- return !imageUTI.isEmpty() && allowedImageUTIs().contains(imageUTI);
+ return !imageSourceType.isEmpty() && supportedDefaultImageSourceTypes().contains(imageSourceType);
}
}
Modified: trunk/Source/WebCore/platform/graphics/cg/UTIRegistry.h (237392 => 237393)
--- trunk/Source/WebCore/platform/graphics/cg/UTIRegistry.h 2018-10-24 18:26:57 UTC (rev 237392)
+++ trunk/Source/WebCore/platform/graphics/cg/UTIRegistry.h 2018-10-24 18:42:22 UTC (rev 237393)
@@ -30,7 +30,7 @@
namespace WebCore {
-HashSet<String>& allowedImageUTIs();
-bool isAllowedImageUTI(const String&);
+const HashSet<String>& supportedDefaultImageSourceTypes();
+bool isSupportImageSourceType(const String&);
}
Modified: trunk/Source/WebCore/platform/mac/PasteboardMac.mm (237392 => 237393)
--- trunk/Source/WebCore/platform/mac/PasteboardMac.mm 2018-10-24 18:26:57 UTC (rev 237392)
+++ trunk/Source/WebCore/platform/mac/PasteboardMac.mm 2018-10-24 18:42:22 UTC (rev 237393)
@@ -255,7 +255,7 @@
return;
// FIXME: Why can we assert this? It doesn't seem like it's guaranteed.
- ASSERT(MIMETypeRegistry::isSupportedImageResourceMIMEType(pasteboardImage.resourceMIMEType));
+ ASSERT(MIMETypeRegistry::isSupportedImageMIMEType(pasteboardImage.resourceMIMEType));
auto types = writableTypesForImage();
if (pasteboardImage.dataInWebArchiveFormat)
Modified: trunk/Source/WebKit/ChangeLog (237392 => 237393)
--- trunk/Source/WebKit/ChangeLog 2018-10-24 18:26:57 UTC (rev 237392)
+++ trunk/Source/WebKit/ChangeLog 2018-10-24 18:42:22 UTC (rev 237393)
@@ -1,3 +1,13 @@
+2018-10-24 Said Abou-Hallawa <[email protected]>
+
+ Cleanup: MIMETypeRegistry functions
+ https://bugs.webkit.org/show_bug.cgi?id=190838
+
+ Reviewed by Simon Fraser.
+
+ * UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm:
+ (-[WKWebViewContentProviderRegistry initWithConfiguration:]):
+
2018-10-24 Chris Dumez <[email protected]>
REGRESSION (r237257): [iOS] Crashes in com.apple.WebKit: WebKit::RemoteScrollingCoordinator::scheduleTreeStateCommit
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (237392 => 237393)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2018-10-24 18:26:57 UTC (rev 237392)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2018-10-24 18:42:22 UTC (rev 237393)
@@ -5682,7 +5682,7 @@
- (BOOL)_isDisplayingPDF
{
- for (auto& mimeType : WebCore::MIMETypeRegistry::getPDFMIMETypes()) {
+ for (auto& mimeType : WebCore::MIMETypeRegistry::pdfMIMETypes()) {
Class providerClass = [[_configuration _contentProviderRegistry] providerForMIMEType:mimeType];
if ([_customContentView isKindOfClass:providerClass])
return YES;
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm (237392 => 237393)
--- trunk/Source/WebKit/UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm 2018-10-24 18:26:57 UTC (rev 237392)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm 2018-10-24 18:42:22 UTC (rev 237393)
@@ -53,16 +53,16 @@
return nil;
#if ENABLE(WKPDFVIEW)
- for (auto& mimeType : WebCore::MIMETypeRegistry::getPDFMIMETypes())
+ for (auto& mimeType : WebCore::MIMETypeRegistry::pdfMIMETypes())
[self registerProvider:[WKPDFView class] forMIMEType:mimeType];
#elif ENABLE(WKLEGACYPDFVIEW)
- for (auto& mimeType : WebCore::MIMETypeRegistry::getPDFMIMETypes())
+ for (auto& mimeType : WebCore::MIMETypeRegistry::pdfMIMETypes())
[self registerProvider:[WKLegacyPDFView class] forMIMEType:mimeType];
#endif
#if USE(SYSTEM_PREVIEW)
if (configuration._systemPreviewEnabled) {
- for (auto& mimeType : WebCore::MIMETypeRegistry::getSystemPreviewMIMETypes())
+ for (auto& mimeType : WebCore::MIMETypeRegistry::systemPreviewMIMETypes())
[self registerProvider:[WKSystemPreviewView class] forMIMEType:mimeType];
}
#endif
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (237392 => 237393)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2018-10-24 18:26:57 UTC (rev 237392)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2018-10-24 18:42:22 UTC (rev 237393)
@@ -1,3 +1,25 @@
+2018-10-24 Said Abou-Hallawa <[email protected]>
+
+ Cleanup: MIMETypeRegistry functions
+ https://bugs.webkit.org/show_bug.cgi?id=190838
+
+ Reviewed by Simon Fraser.
+
+ * Misc/WebNSPasteboardExtras.mm:
+ (-[NSPasteboard _web_writePromisedRTFDFromArchive:containsImage:]):
+ Replace isSupportedImageResourceMIMEType() by isSupportedImageMIMEType()
+ because they were identical.
+
+ * WebView/WebHTMLRepresentation.mm:
+ (+[WebHTMLRepresentation supportedMediaMIMETypes]):
+ (+[WebHTMLRepresentation supportedNonImageMIMETypes]):
+ (+[WebHTMLRepresentation supportedImageMIMETypes]):
+ (+[WebHTMLRepresentation unsupportedTextMIMETypes]):
+ * WebView/WebView.mm:
+ (+[WebView _unregisterViewClassAndRepresentationClassForMIMEType:]):
+ (+[WebView _registerViewClass:representationClass:forURLScheme:]):
+ (+[WebView registerViewClass:representationClass:forMIMEType:]):
+
2018-10-23 David Kilzer <[email protected]>
Fix false positive leaks when using custom -init methods that don't start with -init
Modified: trunk/Source/WebKitLegacy/mac/Misc/WebNSPasteboardExtras.mm (237392 => 237393)
--- trunk/Source/WebKitLegacy/mac/Misc/WebNSPasteboardExtras.mm 2018-10-24 18:26:57 UTC (rev 237392)
+++ trunk/Source/WebKitLegacy/mac/Misc/WebNSPasteboardExtras.mm 2018-10-24 18:42:22 UTC (rev 237393)
@@ -214,13 +214,13 @@
if (containsImage && [subresources count] > 0) {
WebResource *subresource = [subresources objectAtIndex:0];
NSString *subresourceMIMEType = [subresource MIMEType];
- if (MIMETypeRegistry::isSupportedImageResourceMIMEType(subresourceMIMEType) || MIMETypeRegistry::isPDFOrPostScriptMIMEType(subresourceMIMEType))
+ if (MIMETypeRegistry::isSupportedImageMIMEType(subresourceMIMEType) || MIMETypeRegistry::isPDFOrPostScriptMIMEType(subresourceMIMEType))
resource = subresource;
}
ASSERT(resource != nil);
- ASSERT(!containsImage || MIMETypeRegistry::isSupportedImageResourceMIMEType([resource MIMEType]) || MIMETypeRegistry::isPDFOrPostScriptMIMEType([resource MIMEType]));
- if (!containsImage || MIMETypeRegistry::isSupportedImageResourceMIMEType([resource MIMEType]) || MIMETypeRegistry::isPDFOrPostScriptMIMEType([resource MIMEType]))
+ ASSERT(!containsImage || MIMETypeRegistry::isSupportedImageMIMEType([resource MIMEType]) || MIMETypeRegistry::isPDFOrPostScriptMIMEType([resource MIMEType]));
+ if (!containsImage || MIMETypeRegistry::isSupportedImageMIMEType([resource MIMEType]) || MIMETypeRegistry::isPDFOrPostScriptMIMEType([resource MIMEType]))
[self _web_writeFileWrapperAsRTFDAttachment:[resource _fileWrapperRepresentation]];
}
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebHTMLRepresentation.mm (237392 => 237393)
--- trunk/Source/WebKitLegacy/mac/WebView/WebHTMLRepresentation.mm 2018-10-24 18:26:57 UTC (rev 237392)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebHTMLRepresentation.mm 2018-10-24 18:42:22 UTC (rev 237393)
@@ -104,25 +104,25 @@
+ (NSArray *)supportedMediaMIMETypes
{
- static NSArray *staticSupportedMediaMIMETypes = newArrayWithStrings(MIMETypeRegistry::getSupportedMediaMIMETypes()).leakRef();
+ static NSArray *staticSupportedMediaMIMETypes = newArrayWithStrings(MIMETypeRegistry::supportedMediaMIMETypes()).leakRef();
return staticSupportedMediaMIMETypes;
}
+ (NSArray *)supportedNonImageMIMETypes
{
- static NSArray *staticSupportedNonImageMIMETypes = newArrayWithStrings(MIMETypeRegistry::getSupportedNonImageMIMETypes()).leakRef();
+ static NSArray *staticSupportedNonImageMIMETypes = newArrayWithStrings(MIMETypeRegistry::supportedNonImageMIMETypes()).leakRef();
return staticSupportedNonImageMIMETypes;
}
+ (NSArray *)supportedImageMIMETypes
{
- static NSArray *staticSupportedImageMIMETypes = newArrayWithStrings(MIMETypeRegistry::getSupportedImageMIMETypes()).leakRef();
+ static NSArray *staticSupportedImageMIMETypes = newArrayWithStrings(MIMETypeRegistry::supportedImageMIMETypes()).leakRef();
return staticSupportedImageMIMETypes;
}
+ (NSArray *)unsupportedTextMIMETypes
{
- static NSArray *staticUnsupportedTextMIMETypes = newArrayWithStrings(MIMETypeRegistry::getUnsupportedTextMIMETypes()).leakRef();
+ static NSArray *staticUnsupportedTextMIMETypes = newArrayWithStrings(MIMETypeRegistry::unsupportedTextMIMETypes()).leakRef();
return staticUnsupportedTextMIMETypes;
}
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (237392 => 237393)
--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2018-10-24 18:26:57 UTC (rev 237392)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2018-10-24 18:42:22 UTC (rev 237393)
@@ -3420,7 +3420,7 @@
// FIXME: We also need to maintain MIMEType registrations (which can be dynamically changed)
// in the WebCore MIMEType registry. For now we're doing this in a safe, limited manner
// to fix <rdar://problem/5372989> - a future revamping of the entire system is neccesary for future robustness
- MIMETypeRegistry::getSupportedNonImageMIMETypes().remove(MIMEType);
+ MIMETypeRegistry::supportedNonImageMIMETypes().remove(MIMEType);
}
+ (void)_registerViewClass:(Class)viewClass representationClass:(Class)representationClass forURLScheme:(NSString *)URLScheme
@@ -3432,7 +3432,7 @@
// in the WebCore MIMEType registry. For now we're doing this in a safe, limited manner
// to fix <rdar://problem/5372989> - a future revamping of the entire system is neccesary for future robustness
if ([viewClass class] == [WebHTMLView class])
- MIMETypeRegistry::getSupportedNonImageMIMETypes().add(MIMEType);
+ MIMETypeRegistry::supportedNonImageMIMETypes().add(MIMEType);
// This is used to make _representationExistsForURLScheme faster.
// Without this set, we'd have to create the MIME type each time.
@@ -6997,7 +6997,7 @@
// in the WebCore MIMEType registry. For now we're doing this in a safe, limited manner
// to fix <rdar://problem/5372989> - a future revamping of the entire system is neccesary for future robustness
if ([viewClass class] == [WebHTMLView class])
- MIMETypeRegistry::getSupportedNonImageMIMETypes().add(MIMEType);
+ MIMETypeRegistry::supportedNonImageMIMETypes().add(MIMEType);
}
- (void)setGroupName:(NSString *)groupName
_______________________________________________ webkit-changes mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-changes
