Diff
Modified: trunk/Source/WebCore/ChangeLog (292975 => 292976)
--- trunk/Source/WebCore/ChangeLog 2022-04-18 22:10:41 UTC (rev 292975)
+++ trunk/Source/WebCore/ChangeLog 2022-04-18 22:24:22 UTC (rev 292976)
@@ -1,3 +1,19 @@
+2022-04-18 Chris Dumez <cdu...@apple.com>
+
+ Use convertToASCIILowercase() less and more SortedArrayMap / SortedArraySet
+ https://bugs.webkit.org/show_bug.cgi?id=239453
+
+ Reviewed by Darin Adler.
+
+ * Modules/applicationmanifest/ApplicationManifestParser.cpp:
+ (WebCore::ApplicationManifestParser::parseDisplay):
+ * platform/graphics/MediaPlayer.cpp:
+ (WebCore::MediaPlayer::supportsType):
+ * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
+ (WebCore::MediaPlayerPrivateAVFoundation::isUnsupportedMIMEType):
+ * platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.mm:
+ (WebCore::AVAssetMIMETypeCache::isUnsupportedContainerType):
+
2022-04-18 Matt Woodrow <mattwood...@apple.com>
Implement support for aligning baselines through subgrids
Modified: trunk/Source/WebCore/Modules/applicationmanifest/ApplicationManifestParser.cpp (292975 => 292976)
--- trunk/Source/WebCore/Modules/applicationmanifest/ApplicationManifestParser.cpp 2022-04-18 22:10:41 UTC (rev 292975)
+++ trunk/Source/WebCore/Modules/applicationmanifest/ApplicationManifestParser.cpp 2022-04-18 22:24:22 UTC (rev 292976)
@@ -33,6 +33,7 @@
#include "Document.h"
#include "SecurityOrigin.h"
#include <_javascript_Core/ConsoleMessage.h>
+#include <wtf/SortedArrayMap.h>
namespace WebCore {
@@ -145,16 +146,16 @@
return ApplicationManifest::Display::Browser;
}
- stringValue = StringView(stringValue).stripWhiteSpace().convertToASCIILowercase();
+ static constexpr std::pair<ComparableLettersLiteral, ApplicationManifest::Display> displayValueMappings[] = {
+ { "browser", ApplicationManifest::Display::Browser },
+ { "fullscreen", ApplicationManifest::Display::Fullscreen },
+ { "minimal-ui", ApplicationManifest::Display::MinimalUI },
+ { "standalone", ApplicationManifest::Display::Standalone },
+ };
+ static constexpr SortedArrayMap displayValues { displayValueMappings };
- if (stringValue == "fullscreen")
- return ApplicationManifest::Display::Fullscreen;
- if (stringValue == "standalone")
- return ApplicationManifest::Display::Standalone;
- if (stringValue == "minimal-ui")
- return ApplicationManifest::Display::MinimalUI;
- if (stringValue == "browser")
- return ApplicationManifest::Display::Browser;
+ if (auto* displayValue = displayValues.tryGet(StringView(stringValue).stripWhiteSpace()))
+ return *displayValue;
logDeveloperWarning(makeString("\""_s, stringValue, "\" is not a valid display mode."_s));
return ApplicationManifest::Display::Browser;
Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp (292975 => 292976)
--- trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp 2022-04-18 22:10:41 UTC (rev 292975)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp 2022-04-18 22:24:22 UTC (rev 292976)
@@ -1113,8 +1113,7 @@
if (containerType == applicationOctetStream())
return SupportsType::IsNotSupported;
- auto lowercaseType = containerType.convertToASCIILowercase();
- if (!lowercaseType.startsWith("video/") && !lowercaseType.startsWith("audio/") && !lowercaseType.startsWith("application/"))
+ if (!containerType.startsWithIgnoringASCIICase("video/") && !containerType.startsWithIgnoringASCIICase("audio/") && !containerType.startsWithIgnoringASCIICase("application/"))
return SupportsType::IsNotSupported;
const MediaPlayerFactory* engine = bestMediaEngineForSupportParameters(parameters);
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp (292975 => 292976)
--- trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp 2022-04-18 22:10:41 UTC (rev 292975)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp 2022-04-18 22:24:22 UTC (rev 292976)
@@ -48,6 +48,7 @@
#include <wtf/MainThread.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/SoftLinking.h>
+#include <wtf/SortedArrayMap.h>
#include <wtf/StringPrintStream.h>
#include <wtf/URL.h>
#include <wtf/text/CString.h>
@@ -1070,19 +1071,9 @@
return true;
// Reject types we know AVFoundation does not support that sites commonly ask about.
- if (lowerCaseType == "video/webm" || lowerCaseType == "audio/webm" || lowerCaseType == "video/x-webm")
- return true;
-
- if (lowerCaseType == "video/x-flv")
- return true;
-
- if (lowerCaseType == "audio/ogg" || lowerCaseType == "video/ogg" || lowerCaseType == "application/ogg")
- return true;
-
- if (lowerCaseType == "video/h264")
- return true;
-
- return false;
+ static constexpr ComparableASCIILiteral unsupportedTypesArray[] = { "application/ogg", "audio/ogg", "audio/webm", "video/h264", "video/ogg", "video/webm", "video/x-flv", "video/x-webm" };
+ static constexpr SortedArraySet unsupportedTypesSet { unsupportedTypesArray };
+ return unsupportedTypesSet.contains(lowerCaseType);
}
bool MediaPlayerPrivateAVFoundation::shouldEnableInheritURIQueryComponent() const
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.mm (292975 => 292976)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.mm 2022-04-18 22:10:41 UTC (rev 292975)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.mm 2022-04-18 22:24:22 UTC (rev 292976)
@@ -82,16 +82,9 @@
return true;
// Reject types we know AVFoundation does not support that sites commonly ask about.
- if (lowerCaseType == "video/x-flv")
- return true;
-
- if (lowerCaseType == "audio/ogg" || lowerCaseType == "video/ogg" || lowerCaseType == "application/ogg")
- return true;
-
- if (lowerCaseType == "video/h264")
- return true;
-
- return false;
+ static constexpr ComparableASCIILiteral unsupportedTypesArray[] = { "application/ogg", "audio/ogg", "video/h264", "video/ogg", "video/x-flv" };
+ static constexpr SortedArraySet unsupportedTypesSet { unsupportedTypesArray };
+ return unsupportedTypesSet.contains(lowerCaseType);
}
bool AVAssetMIMETypeCache::isStaticContainerType(StringView type)
Modified: trunk/Source/WebDriver/ChangeLog (292975 => 292976)
--- trunk/Source/WebDriver/ChangeLog 2022-04-18 22:10:41 UTC (rev 292975)
+++ trunk/Source/WebDriver/ChangeLog 2022-04-18 22:24:22 UTC (rev 292976)
@@ -1,3 +1,13 @@
+2022-04-18 Chris Dumez <cdu...@apple.com>
+
+ Use convertToASCIILowercase() less and more SortedArrayMap / SortedArraySet
+ https://bugs.webkit.org/show_bug.cgi?id=239453
+
+ Reviewed by Darin Adler.
+
+ * WebDriverService.cpp:
+ (WebDriver::WebDriverService::toCommandHTTPMethod):
+
2022-04-13 Chris Dumez <cdu...@apple.com>
Replace calls to substring(0, x) with the more concise left(x)
Modified: trunk/Source/WebDriver/WebDriverService.cpp (292975 => 292976)
--- trunk/Source/WebDriver/WebDriverService.cpp 2022-04-18 22:10:41 UTC (rev 292975)
+++ trunk/Source/WebDriver/WebDriverService.cpp 2022-04-18 22:24:22 UTC (rev 292976)
@@ -30,6 +30,7 @@
#include "CommandResult.h"
#include "SessionHost.h"
#include <wtf/RunLoop.h>
+#include <wtf/SortedArrayMap.h>
#include <wtf/text/StringToIntegerConversion.h>
#include <wtf/text/WTFString.h>
@@ -218,14 +219,16 @@
std::optional<WebDriverService::HTTPMethod> WebDriverService::toCommandHTTPMethod(const String& method)
{
- auto lowerCaseMethod = method.convertToASCIILowercase();
- if (lowerCaseMethod == "get")
- return WebDriverService::HTTPMethod::Get;
- if (lowerCaseMethod == "post" || lowerCaseMethod == "put")
- return WebDriverService::HTTPMethod::Post;
- if (lowerCaseMethod == "delete")
- return WebDriverService::HTTPMethod::Delete;
+ static constexpr std::pair<ComparableLettersLiteral, WebDriverService::HTTPMethod> httpMethodMappings[] = {
+ { "delete", WebDriverService::HTTPMethod::Delete },
+ { "get", WebDriverService::HTTPMethod::Get },
+ { "post", WebDriverService::HTTPMethod::Post },
+ { "put", WebDriverService::HTTPMethod::Post },
+ };
+ static constexpr SortedArrayMap httpMethods { httpMethodMappings };
+ if (auto* methodValue = httpMethods.tryGet(method))
+ return *methodValue;
return std::nullopt;
}