Title: [255391] trunk/Source/WebCore
Revision
255391
Author
ross.kirsl...@sony.com
Date
2020-01-29 15:09:51 -0800 (Wed, 29 Jan 2020)

Log Message

[PlayStation] Fix MIMETypeRegistry
https://bugs.webkit.org/show_bug.cgi?id=206960

Reviewed by Don Olmstead.

* platform/playstation/MIMETypeRegistryPlayStation.cpp:
(WebCore::platformMediaTypes):
(WebCore::MIMETypeRegistry::getMIMETypeForExtension):
(WebCore::MIMETypeRegistry::getPreferredExtensionForMIMEType):
Address redeclarations, then fix key/value order of platform-specific MIME type map and make it a static local.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (255390 => 255391)


--- trunk/Source/WebCore/ChangeLog	2020-01-29 23:02:28 UTC (rev 255390)
+++ trunk/Source/WebCore/ChangeLog	2020-01-29 23:09:51 UTC (rev 255391)
@@ -1,3 +1,16 @@
+2020-01-29  Ross Kirsling  <ross.kirsl...@sony.com>
+
+        [PlayStation] Fix MIMETypeRegistry
+        https://bugs.webkit.org/show_bug.cgi?id=206960
+
+        Reviewed by Don Olmstead.
+
+        * platform/playstation/MIMETypeRegistryPlayStation.cpp:
+        (WebCore::platformMediaTypes):
+        (WebCore::MIMETypeRegistry::getMIMETypeForExtension):
+        (WebCore::MIMETypeRegistry::getPreferredExtensionForMIMEType):
+        Address redeclarations, then fix key/value order of platform-specific MIME type map and make it a static local.
+
 2020-01-29  Ryan Haddad  <ryanhad...@apple.com>
 
         Unreviewed, rolling out r255338.

Modified: trunk/Source/WebCore/platform/playstation/MIMETypeRegistryPlayStation.cpp (255390 => 255391)


--- trunk/Source/WebCore/platform/playstation/MIMETypeRegistryPlayStation.cpp	2020-01-29 23:02:28 UTC (rev 255390)
+++ trunk/Source/WebCore/platform/playstation/MIMETypeRegistryPlayStation.cpp	2020-01-29 23:09:51 UTC (rev 255391)
@@ -28,39 +28,38 @@
 
 namespace WebCore {
 
-struct TypeExtensionPair {
-    ASCIILiteral type;
-    ASCIILiteral extension;
-};
+static const std::initializer_list<TypeExtensionPair>& platformMediaTypes()
+{
+    static std::initializer_list<TypeExtensionPair> platformMediaTypes = {
+        { "image/bmp"_s, "bmp"_s },
+        { "text/css"_s, "css"_s },
+        { "image/gif"_s, "gif"_s },
+        { "text/html"_s, "htm"_s },
+        { "text/html"_s, "html"_s },
+        { "image/x-icon"_s, "ico"_s },
+        { "image/jpeg"_s, "jpeg"_s },
+        { "image/jpeg"_s, "jpg"_s },
+        { "application/x-_javascript_"_s, "js"_s },
+        { "application/pdf"_s, "pdf"_s },
+        { "image/png"_s, "png"_s },
+        { "application/rss+xml"_s, "rss"_s },
+        { "image/svg+xml"_s, "svg"_s },
+        { "application/x-shockwave-flash"_s, "swf"_s },
+        { "text/plain"_s, "text"_s },
+        { "text/plain"_s, "txt"_s },
+        { "text/vnd.wap.wml"_s, "wml"_s },
+        { "application/vnd.wap.wmlc"_s, "wmlc"_s },
+        { "image/x-xbitmap"_s, "xbm"_s },
+        { "application/xhtml+xml"_s, "xhtml"_s },
+        { "text/xml"_s, "xml"_s },
+        { "text/xsl"_s, "xsl"_s },
+    };
+    return platformMediaTypes;
+}
 
-const TypeExtensionPair commonMediaTypes[] = {
-    { "bmp"_s, "image/bmp"_s },
-    { "css"_s, "text/css"_s },
-    { "gif"_s, "image/gif"_s },
-    { "html"_s, "text/html"_s },
-    { "htm"_s, "text/html"_s },
-    { "ico"_s, "image/x-icon"_s },
-    { "jpeg"_s, "image/jpeg"_s },
-    { "jpg"_s, "image/jpeg"_s },
-    { "js"_s, "application/x-_javascript_"_s },
-    { "pdf"_s, "application/pdf"_s },
-    { "png"_s, "image/png"_s },
-    { "rss"_s, "application/rss+xml"_s },
-    { "svg"_s, "image/svg+xml"_s },
-    { "swf"_s, "application/x-shockwave-flash"_s },
-    { "text"_s, "text/plain"_s },
-    { "txt"_s, "text/plain"_s },
-    { "xbm"_s, "image/x-xbitmap"_s },
-    { "xml"_s, "text/xml"_s },
-    { "xsl"_s, "text/xsl"_s },
-    { "xhtml"_s, "application/xhtml+xml"_s },
-    { "wml"_s, "text/vnd.wap.wml"_s },
-    { "wmlc"_s, "application/vnd.wap.wmlc"_s },
-};
-
 String MIMETypeRegistry::getMIMETypeForExtension(const String& extension)
 {
-    for (auto& entry : commonMediaTypes) {
+    for (auto& entry : platformMediaTypes()) {
         if (equalIgnoringASCIICase(extension, entry.extension.characters()))
             return entry.type;
     }
@@ -74,7 +73,7 @@
 
 String MIMETypeRegistry::getPreferredExtensionForMIMEType(const String& mimeType)
 {
-    for (auto& entry : commonMediaTypes) {
+    for (auto& entry : platformMediaTypes()) {
         if (equalIgnoringASCIICase(mimeType, entry.type.characters()))
             return entry.extension;
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to