MIMETypeRegistry should return const HashSets
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Mar 2018 21:49:25 +0000 (21:49 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Mar 2018 21:49:25 +0000 (21:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184150

Reviewed by Per Arne Vollan.

Only getSupportedNonImageMIMETypes() needs to return a non-const HashSet so that
LegacyWebKit can modify the set of non-image MIME types.

* platform/MIMETypeRegistry.cpp:
(WebCore::MIMETypeRegistry::getSupportedImageMIMETypes):
(WebCore::MIMETypeRegistry::getSupportedImageResourceMIMETypes):
(WebCore::MIMETypeRegistry::getSupportedImageMIMETypesForEncoding):
(WebCore::MIMETypeRegistry::getSupportedMediaMIMETypes):
(WebCore::MIMETypeRegistry::getPDFMIMETypes):
(WebCore::MIMETypeRegistry::getUnsupportedTextMIMETypes):
* platform/MIMETypeRegistry.h:

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

Source/WebCore/ChangeLog
Source/WebCore/platform/MIMETypeRegistry.cpp
Source/WebCore/platform/MIMETypeRegistry.h

index b2a77ed..73111d9 100644 (file)
@@ -1,3 +1,22 @@
+2018-03-29  Daniel Bates  <dabates@apple.com>
+
+        MIMETypeRegistry should return const HashSets
+        https://bugs.webkit.org/show_bug.cgi?id=184150
+
+        Reviewed by Per Arne Vollan.
+
+        Only getSupportedNonImageMIMETypes() needs to return a non-const HashSet so that
+        LegacyWebKit can modify the set of non-image MIME types.
+
+        * platform/MIMETypeRegistry.cpp:
+        (WebCore::MIMETypeRegistry::getSupportedImageMIMETypes):
+        (WebCore::MIMETypeRegistry::getSupportedImageResourceMIMETypes):
+        (WebCore::MIMETypeRegistry::getSupportedImageMIMETypesForEncoding):
+        (WebCore::MIMETypeRegistry::getSupportedMediaMIMETypes):
+        (WebCore::MIMETypeRegistry::getPDFMIMETypes):
+        (WebCore::MIMETypeRegistry::getUnsupportedTextMIMETypes):
+        * platform/MIMETypeRegistry.h:
+
 2018-03-29  Brady Eidson  <beidson@apple.com>
 
         Update Service Worker feature status.
index c617b3a..f06c051 100644 (file)
@@ -651,21 +651,21 @@ bool MIMETypeRegistry::canShowMIMEType(const String& mimeType)
     return false;
 }
 
-HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedImageMIMETypes()
+const HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedImageMIMETypes()
 {
     if (!supportedImageMIMETypes)
         initializeSupportedImageMIMETypes();
     return *supportedImageMIMETypes;
 }
 
-HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedImageResourceMIMETypes()
+const HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedImageResourceMIMETypes()
 {
     if (!supportedImageResourceMIMETypes)
         initializeSupportedImageMIMETypes();
     return *supportedImageResourceMIMETypes;
 }
 
-HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedImageMIMETypesForEncoding()
+const HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedImageMIMETypesForEncoding()
 {
     if (!supportedImageMIMETypesForEncoding)
         initializeSupportedImageMIMETypesForEncoding();
@@ -679,7 +679,7 @@ HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedNonImag
     return *supportedNonImageMIMETypes;
 }
 
-HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedMediaMIMETypes()
+const HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedMediaMIMETypes()
 {
     if (!supportedMediaMIMETypes)
         initializeSupportedMediaMIMETypes();
@@ -687,14 +687,14 @@ HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedMediaMI
 }
 
 
-HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getPDFMIMETypes()
+const HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getPDFMIMETypes()
 {
     if (!pdfMIMETypes)
         initializePDFMIMETypes();
     return *pdfMIMETypes;
 }
 
-HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getUnsupportedTextMIMETypes()
+const HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getUnsupportedTextMIMETypes()
 {
     if (!unsupportedTextMIMETypes)
         initializeUnsupportedTextMIMETypes();
index 3bfc4e4..c706eea 100644 (file)
@@ -106,13 +106,14 @@ public:
 
     // 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>& getSupportedImageMIMETypes();
-    static HashSet<String, ASCIICaseInsensitiveHash>& getSupportedImageResourceMIMETypes();
-    static HashSet<String, ASCIICaseInsensitiveHash>& getSupportedImageMIMETypesForEncoding();
     WEBCORE_EXPORT static HashSet<String, ASCIICaseInsensitiveHash>& getSupportedNonImageMIMETypes();
-    WEBCORE_EXPORT static HashSet<String, ASCIICaseInsensitiveHash>& getSupportedMediaMIMETypes();
-    WEBCORE_EXPORT static HashSet<String, ASCIICaseInsensitiveHash>& getPDFMIMETypes();
-    WEBCORE_EXPORT static HashSet<String, ASCIICaseInsensitiveHash>& getUnsupportedTextMIMETypes();
+
+    WEBCORE_EXPORT const static HashSet<String, ASCIICaseInsensitiveHash>& getSupportedImageMIMETypes();
+    const static HashSet<String, ASCIICaseInsensitiveHash>& getSupportedImageResourceMIMETypes();
+    const static HashSet<String, ASCIICaseInsensitiveHash>& getSupportedImageMIMETypesForEncoding();
+    WEBCORE_EXPORT const static HashSet<String, ASCIICaseInsensitiveHash>& getSupportedMediaMIMETypes();
+    WEBCORE_EXPORT const static HashSet<String, ASCIICaseInsensitiveHash>& getPDFMIMETypes();
+    WEBCORE_EXPORT const static HashSet<String, ASCIICaseInsensitiveHash>& getUnsupportedTextMIMETypes();
 
     // FIXME: WebKit coding style says we should not have the word "get" in the name of this function.
     // FIXME: Unclear what the concept of a normalized MIME type is; currently it's a platform-specific notion.