Diff
Modified: trunk/Source/WebCore/ChangeLog (291340 => 291341)
--- trunk/Source/WebCore/ChangeLog 2022-03-16 12:52:33 UTC (rev 291340)
+++ trunk/Source/WebCore/ChangeLog 2022-03-16 12:54:06 UTC (rev 291341)
@@ -1,3 +1,30 @@
+2022-03-16 Youenn Fablet <[email protected]>
+
+ Make MIMETypeRegistry::mimeTypeForPath take a StringView
+ https://bugs.webkit.org/show_bug.cgi?id=236441
+ <rdar://problem/89084526>
+
+ Reviewed by Chris Dumez.
+
+ Passing a StringView is more efficient for some code paths.
+ Covered by existing tests.
+
+ * editing/cocoa/WebArchiveResourceFromNSAttributedString.mm:
+ (WebCore::if):
+ * fileapi/File.cpp:
+ (WebCore::File::computeNameAndContentType):
+ * loader/cocoa/BundleResourceLoader.mm:
+ (WebCore::BundleResourceLoader::loadResourceFromBundle):
+ * platform/MIMETypeRegistry.cpp:
+ (WebCore::commonMimeTypesMap):
+ * platform/MIMETypeRegistry.h:
+ * platform/cocoa/MIMETypeRegistryCocoa.mm:
+ (WebCore::MIMETypeRegistry::mimeTypeForExtension):
+ * platform/win/MIMETypeRegistryWin.cpp:
+ (WebCore::MIMETypeRegistry::mimeTypeForExtension):
+ * platform/xdg/MIMETypeRegistryXdg.cpp:
+ (WebCore::MIMETypeRegistry::mimeTypeForExtension):
+
2022-03-16 Nikolas Zimmermann <[email protected]>
Extract transform-origin handling out of RenderStyle::applyTransform()
Modified: trunk/Source/WebCore/editing/cocoa/WebArchiveResourceFromNSAttributedString.mm (291340 => 291341)
--- trunk/Source/WebCore/editing/cocoa/WebArchiveResourceFromNSAttributedString.mm 2022-03-16 12:52:33 UTC (rev 291340)
+++ trunk/Source/WebCore/editing/cocoa/WebArchiveResourceFromNSAttributedString.mm 2022-03-16 12:54:06 UTC (rev 291341)
@@ -45,7 +45,7 @@
if ([MIMEType isEqualToString:@"application/octet-stream"]) {
// FIXME: This is a workaround for <rdar://problem/36074429>, and can be removed once that is fixed.
- auto mimeTypeFromURL = MIMETypeRegistry::mimeTypeForExtension(URL.pathExtension);
+ auto mimeTypeFromURL = MIMETypeRegistry::mimeTypeForExtension(String(URL.pathExtension));
if (!mimeTypeFromURL.isEmpty())
MIMEType = mimeTypeFromURL;
}
Modified: trunk/Source/WebCore/fileapi/File.cpp (291340 => 291341)
--- trunk/Source/WebCore/fileapi/File.cpp 2022-03-16 12:52:33 UTC (rev 291340)
+++ trunk/Source/WebCore/fileapi/File.cpp 2022-03-16 12:54:06 UTC (rev 291341)
@@ -130,7 +130,7 @@
size_t index = effectiveName.reverseFind('.');
if (index != notFound) {
callOnMainThreadAndWait([&effectiveContentType, &effectiveName, index] {
- effectiveContentType = MIMETypeRegistry::mimeTypeForExtension(effectiveName.substring(index + 1)).isolatedCopy();
+ effectiveContentType = MIMETypeRegistry::mimeTypeForExtension(StringView(effectiveName).substring(index + 1)).isolatedCopy();
});
}
}
Modified: trunk/Source/WebCore/loader/cocoa/BundleResourceLoader.mm (291340 => 291341)
--- trunk/Source/WebCore/loader/cocoa/BundleResourceLoader.mm 2022-03-16 12:52:33 UTC (rev 291340)
+++ trunk/Source/WebCore/loader/cocoa/BundleResourceLoader.mm 2022-03-16 12:54:06 UTC (rev 291341)
@@ -64,7 +64,7 @@
}
RunLoop::main().dispatch([protectedLoader = WTFMove(protectedLoader), url = "" buffer = SharedBuffer::create(data)]() mutable {
- auto mimeType = MIMETypeRegistry::mimeTypeForPath(url.path().toString());
+ auto mimeType = MIMETypeRegistry::mimeTypeForPath(url.path());
ResourceResponse response { url, mimeType, static_cast<long long>(buffer->size()), MIMETypeRegistry::isTextMIMEType(mimeType) ? "UTF-8"_s : nullptr };
response.setHTTPStatusCode(200);
response.setHTTPStatusText("OK"_s);
Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.cpp (291340 => 291341)
--- trunk/Source/WebCore/platform/MIMETypeRegistry.cpp 2022-03-16 12:52:33 UTC (rev 291340)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.cpp 2022-03-16 12:54:06 UTC (rev 291341)
@@ -368,7 +368,7 @@
// First type in the vector must always be the one from mimeTypeForExtension,
// so we can use the map without also calling mimeTypeForExtension each time.
Vector<String> synonyms;
- String systemType = MIMETypeRegistry::mimeTypeForExtension(extension);
+ String systemType = MIMETypeRegistry::mimeTypeForExtension(StringView(extension));
if (!systemType.isEmpty() && type != systemType)
synonyms.append(systemType);
return synonyms;
@@ -395,12 +395,11 @@
return mimeTypeForExtension(extension);
}
-String MIMETypeRegistry::mimeTypeForPath(const String& path)
+String MIMETypeRegistry::mimeTypeForPath(StringView path)
{
- size_t pos = path.reverseFind('.');
- if (pos != notFound) {
- String extension = path.substring(pos + 1);
- String result = mimeTypeForExtension(extension);
+ auto position = path.reverseFind('.');
+ if (position != notFound) {
+ auto result = mimeTypeForExtension(path.substring(position + 1));
if (result.length())
return result;
}
Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.h (291340 => 291341)
--- trunk/Source/WebCore/platform/MIMETypeRegistry.h 2022-03-16 12:52:33 UTC (rev 291340)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.h 2022-03-16 12:54:06 UTC (rev 291341)
@@ -53,12 +53,12 @@
class MIMETypeRegistry {
public:
- WEBCORE_EXPORT static String mimeTypeForExtension(const String& extension);
+ WEBCORE_EXPORT static String mimeTypeForExtension(StringView);
WEBCORE_EXPORT static Vector<String> extensionsForMIMEType(const String& type);
WEBCORE_EXPORT static String preferredExtensionForMIMEType(const String& type);
WEBCORE_EXPORT static String mediaMIMETypeForExtension(const String& extension);
- WEBCORE_EXPORT static String mimeTypeForPath(const String& path);
+ WEBCORE_EXPORT static String mimeTypeForPath(StringView);
static std::unique_ptr<MIMETypeRegistryThreadGlobalData> createMIMETypeRegistryThreadGlobalData();
Modified: trunk/Source/WebCore/platform/cocoa/MIMETypeRegistryCocoa.mm (291340 => 291341)
--- trunk/Source/WebCore/platform/cocoa/MIMETypeRegistryCocoa.mm 2022-03-16 12:52:33 UTC (rev 291340)
+++ trunk/Source/WebCore/platform/cocoa/MIMETypeRegistryCocoa.mm 2022-03-16 12:54:06 UTC (rev 291341)
@@ -89,9 +89,10 @@
return extensions;
}
-String MIMETypeRegistry::mimeTypeForExtension(const String& extension)
+String MIMETypeRegistry::mimeTypeForExtension(StringView extension)
{
- return [[NSURLFileTypeMappings sharedMappings] MIMETypeForExtension:(NSString *)extension];
+ auto string = extension.createNSStringWithoutCopying();
+ return [[NSURLFileTypeMappings sharedMappings] MIMETypeForExtension:string.get()];
}
Vector<String> MIMETypeRegistry::extensionsForMIMEType(const String& type)
Modified: trunk/Source/WebCore/platform/win/MIMETypeRegistryWin.cpp (291340 => 291341)
--- trunk/Source/WebCore/platform/win/MIMETypeRegistryWin.cpp 2022-03-16 12:52:33 UTC (rev 291340)
+++ trunk/Source/WebCore/platform/win/MIMETypeRegistryWin.cpp 2022-03-16 12:54:06 UTC (rev 291341)
@@ -63,13 +63,14 @@
return String();
}
-String MIMETypeRegistry::mimeTypeForExtension(const String &ext)
+String MIMETypeRegistry::mimeTypeForExtension(StringView string)
{
ASSERT(isMainThread());
- if (ext.isEmpty())
+ if (string.isEmpty())
return String();
+ auto ext = string.toString();
static HashMap<String, String> mimetypeMap;
if (mimetypeMap.isEmpty()) {
//fill with initial values
Modified: trunk/Source/WebCore/platform/xdg/MIMETypeRegistryXdg.cpp (291340 => 291341)
--- trunk/Source/WebCore/platform/xdg/MIMETypeRegistryXdg.cpp 2022-03-16 12:52:33 UTC (rev 291340)
+++ trunk/Source/WebCore/platform/xdg/MIMETypeRegistryXdg.cpp 2022-03-16 12:54:06 UTC (rev 291341)
@@ -31,13 +31,13 @@
namespace WebCore {
-String MIMETypeRegistry::mimeTypeForExtension(const String& extension)
+String MIMETypeRegistry::mimeTypeForExtension(StringView string)
{
- if (extension.isEmpty())
+ if (string.isEmpty())
return String();
// Build any filename with the given extension.
- String filename = "a." + extension;
+ String filename = "a." + string;
if (const char* mimeType = xdg_mime_get_mime_type_from_file_name(filename.utf8().data())) {
if (mimeType != XDG_MIME_TYPE_UNKNOWN)
return String::fromUTF8(mimeType);
Modified: trunk/Source/WebKit/ChangeLog (291340 => 291341)
--- trunk/Source/WebKit/ChangeLog 2022-03-16 12:52:33 UTC (rev 291340)
+++ trunk/Source/WebKit/ChangeLog 2022-03-16 12:54:06 UTC (rev 291341)
@@ -1,5 +1,21 @@
2022-03-16 Youenn Fablet <[email protected]>
+ Make MIMETypeRegistry::mimeTypeForPath take a StringView
+ https://bugs.webkit.org/show_bug.cgi?id=236441
+ <rdar://problem/89084526>
+
+ Reviewed by Chris Dumez.
+
+ * UIProcess/API/Cocoa/APIAttachmentCocoa.mm:
+ (API::mimeTypeInferredFromFileExtension):
+ (API::Attachment::setFileWrapperAndUpdateContentType):
+ * UIProcess/Inspector/mac/WKInspectorResourceURLSchemeHandler.mm:
+ (-[WKInspectorResourceURLSchemeHandler webView:startURLSchemeTask:]):
+ * UIProcess/ios/forms/WKFileUploadPanel.mm:
+ (-[WKFileUploadPanel presentWithParameters:resultListener:]):
+
+2022-03-16 Youenn Fablet <[email protected]>
+
redirectCount returns 0 when using a Service Worker
https://bugs.webkit.org/show_bug.cgi?id=235710
<rdar://problem/88432190>
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/APIAttachmentCocoa.mm (291340 => 291341)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/APIAttachmentCocoa.mm 2022-03-16 12:52:33 UTC (rev 291340)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/APIAttachmentCocoa.mm 2022-03-16 12:54:06 UTC (rev 291341)
@@ -41,7 +41,7 @@
static WTF::String mimeTypeInferredFromFileExtension(const API::Attachment& attachment)
{
if (NSString *fileExtension = [(NSString *)attachment.fileName() pathExtension])
- return WebCore::MIMETypeRegistry::mimeTypeForExtension(fileExtension);
+ return WebCore::MIMETypeRegistry::mimeTypeForExtension(WTF::String(fileExtension));
return { };
}
@@ -111,7 +111,7 @@
contentType = (NSString *)kUTTypeDirectory;
else if (fileWrapper.regularFile) {
if (NSString *pathExtension = (fileWrapper.filename.length ? fileWrapper.filename : fileWrapper.preferredFilename).pathExtension)
- contentType = WebCore::MIMETypeRegistry::mimeTypeForExtension(pathExtension);
+ contentType = WebCore::MIMETypeRegistry::mimeTypeForExtension(WTF::String(pathExtension));
if (!contentType.length)
contentType = (NSString *)kUTTypeData;
}
Modified: trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorResourceURLSchemeHandler.mm (291340 => 291341)
--- trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorResourceURLSchemeHandler.mm 2022-03-16 12:52:33 UTC (rev 291340)
+++ trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorResourceURLSchemeHandler.mm 2022-03-16 12:54:06 UTC (rev 291341)
@@ -98,7 +98,7 @@
return;
}
- NSString *mimeType = WebCore::MIMETypeRegistry::mimeTypeForExtension(fileURLForRequest.pathExtension);
+ NSString *mimeType = WebCore::MIMETypeRegistry::mimeTypeForExtension(String(fileURLForRequest.pathExtension));
if (!mimeType)
mimeType = @"application/octet-stream";
Modified: trunk/Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm (291340 => 291341)
--- trunk/Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm 2022-03-16 12:52:33 UTC (rev 291340)
+++ trunk/Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm 2022-03-16 12:54:06 UTC (rev 291341)
@@ -459,7 +459,7 @@
Ref<API::Array> acceptFileExtensions = parameters->acceptFileExtensions();
for (auto extension : acceptFileExtensions->elementsOfType<API::String>()) {
- String mimeType = WebCore::MIMETypeRegistry::mimeTypeForExtension(extension->stringView().substring(1).toString());
+ String mimeType = WebCore::MIMETypeRegistry::mimeTypeForExtension(extension->stringView().substring(1));
if (!mimeType.isEmpty())
[mimeTypes addObject:mimeType];
}
Modified: trunk/Source/WebKitLegacy/ios/ChangeLog (291340 => 291341)
--- trunk/Source/WebKitLegacy/ios/ChangeLog 2022-03-16 12:52:33 UTC (rev 291340)
+++ trunk/Source/WebKitLegacy/ios/ChangeLog 2022-03-16 12:54:06 UTC (rev 291341)
@@ -1,3 +1,14 @@
+2022-03-16 Youenn Fablet <[email protected]>
+
+ Make MIMETypeRegistry::mimeTypeForPath take a StringView
+ https://bugs.webkit.org/show_bug.cgi?id=236441
+ <rdar://problem/89084526>
+
+ Reviewed by Chris Dumez.
+
+ * WebCoreSupport/WebMIMETypeRegistry.mm:
+ (+[WebMIMETypeRegistry mimeTypeForExtension:]):
+
2022-03-01 Wenson Hsieh <[email protected]>
focus({preventScroll: true}) does not prevent scrolling on iOS
Modified: trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebMIMETypeRegistry.mm (291340 => 291341)
--- trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebMIMETypeRegistry.mm 2022-03-16 12:52:33 UTC (rev 291340)
+++ trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebMIMETypeRegistry.mm 2022-03-16 12:54:06 UTC (rev 291341)
@@ -35,7 +35,7 @@
+ (NSString *)mimeTypeForExtension:(NSString *)extension
{
- return MIMETypeRegistry::mimeTypeForExtension(extension);
+ return MIMETypeRegistry::mimeTypeForExtension(String(extension));
}
+ (NSString *)preferredExtensionForMIMEType:(NSString *)mimeType
Modified: trunk/Tools/ChangeLog (291340 => 291341)
--- trunk/Tools/ChangeLog 2022-03-16 12:52:33 UTC (rev 291340)
+++ trunk/Tools/ChangeLog 2022-03-16 12:54:06 UTC (rev 291341)
@@ -1,3 +1,14 @@
+2022-03-16 Youenn Fablet <[email protected]>
+
+ Make MIMETypeRegistry::mimeTypeForPath take a StringView
+ https://bugs.webkit.org/show_bug.cgi?id=236441
+ <rdar://problem/89084526>
+
+ Reviewed by Chris Dumez.
+
+ * TestWebKitAPI/cocoa/TestInspectorURLSchemeHandler.mm:
+ (-[TestInspectorURLSchemeHandler webView:startURLSchemeTask:]):
+
2022-03-15 Diego Pino Garcia <[email protected]>
[GLIB] Unreviewed, fix build for Ubuntu 18.04 and Debian Stable after r291229
Modified: trunk/Tools/TestWebKitAPI/cocoa/TestInspectorURLSchemeHandler.mm (291340 => 291341)
--- trunk/Tools/TestWebKitAPI/cocoa/TestInspectorURLSchemeHandler.mm 2022-03-16 12:52:33 UTC (rev 291340)
+++ trunk/Tools/TestWebKitAPI/cocoa/TestInspectorURLSchemeHandler.mm 2022-03-16 12:54:06 UTC (rev 291341)
@@ -79,7 +79,7 @@
return;
}
- NSString *mimeType = WebCore::MIMETypeRegistry::mimeTypeForExtension(fileURLForRequest.pathExtension);
+ NSString *mimeType = WebCore::MIMETypeRegistry::mimeTypeForExtension(String(fileURLForRequest.pathExtension));
if (!mimeType)
mimeType = @"application/octet-stream";