Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (292476 => 292477)
--- trunk/Source/_javascript_Core/ChangeLog 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/_javascript_Core/ChangeLog 2022-04-06 17:48:44 UTC (rev 292477)
@@ -1,3 +1,14 @@
+2022-04-06 Chris Dumez <cdu...@apple.com>
+
+ Reduce number of conversions from StringView to String
+ https://bugs.webkit.org/show_bug.cgi?id=238841
+
+ Reviewed by Geoffrey Garen.
+
+ * runtime/RegExp.h:
+ * runtime/StringPrototype.cpp:
+ (JSC::substituteBackreferencesSlow):
+
2022-04-06 Justin Michaud <justin_mich...@apple.com>
CSE should be more careful with values that have WritesPinned, ExitsSideways, or are of different sizes
Modified: trunk/Source/_javascript_Core/runtime/RegExp.h (292476 => 292477)
--- trunk/Source/_javascript_Core/runtime/RegExp.h 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/_javascript_Core/runtime/RegExp.h 2022-04-06 17:48:44 UTC (rev 292477)
@@ -104,11 +104,11 @@
return m_rareData->m_captureGroupNames[i];
}
- unsigned subpatternForName(String groupName)
+ unsigned subpatternForName(StringView groupName)
{
if (!m_rareData)
return 0;
- auto it = m_rareData->m_namedGroupToParenIndex.find(groupName);
+ auto it = m_rareData->m_namedGroupToParenIndex.find<StringViewHashTranslator>(groupName);
if (it == m_rareData->m_namedGroupToParenIndex.end())
return 0;
return it->value;
Modified: trunk/Source/_javascript_Core/runtime/StringPrototype.cpp (292476 => 292477)
--- trunk/Source/_javascript_Core/runtime/StringPrototype.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/_javascript_Core/runtime/StringPrototype.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -215,7 +215,7 @@
continue;
unsigned nameLength = closingBracket - i - 2;
- unsigned backrefIndex = reg->subpatternForName(replacement.substring(i + 2, nameLength).toString());
+ unsigned backrefIndex = reg->subpatternForName(replacement.substring(i + 2, nameLength));
if (!backrefIndex || backrefIndex > reg->numSubpatterns()) {
backrefStart = 0;
Modified: trunk/Source/WTF/ChangeLog (292476 => 292477)
--- trunk/Source/WTF/ChangeLog 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WTF/ChangeLog 2022-04-06 17:48:44 UTC (rev 292477)
@@ -1,3 +1,16 @@
+2022-04-06 Chris Dumez <cdu...@apple.com>
+
+ Reduce number of conversions from StringView to String
+ https://bugs.webkit.org/show_bug.cgi?id=238841
+
+ Reviewed by Geoffrey Garen.
+
+ * wtf/URL.cpp:
+ (WTF::defaultPortForProtocol):
+ * wtf/text/StringHash.h:
+ (WTF::StringViewHashTranslator::hash):
+ (WTF::StringViewHashTranslator::equal):
+
2022-04-05 Chris Dumez <cdu...@apple.com>
Mark String(const char*) constructor as explicit
Modified: trunk/Source/WTF/wtf/URL.cpp (292476 => 292477)
--- trunk/Source/WTF/wtf/URL.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WTF/wtf/URL.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -317,7 +317,7 @@
{
Locker locker { defaultPortForProtocolMapForTestingLock };
if (auto* overrideMap = defaultPortForProtocolMapForTesting()) {
- auto iterator = overrideMap->find(protocol.toStringWithoutCopying());
+ auto iterator = overrideMap->find<StringViewHashTranslator>(protocol);
if (iterator != overrideMap->end())
return iterator->value;
}
Modified: trunk/Source/WTF/wtf/text/StringHash.h (292476 => 292477)
--- trunk/Source/WTF/wtf/text/StringHash.h 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WTF/wtf/text/StringHash.h 2022-04-06 17:48:44 UTC (rev 292477)
@@ -202,6 +202,20 @@
}
};
+ struct StringViewHashTranslator {
+ static unsigned hash(StringView key)
+ {
+ if (key.is8Bit())
+ return StringHasher::computeHashAndMaskTop8Bits(key.characters8(), key.length());
+ return StringHasher::computeHashAndMaskTop8Bits(key.characters16(), key.length());
+ }
+
+ static bool equal(const String& a, StringView b)
+ {
+ return a == b;
+ }
+ };
+
// FIXME: Find a way to incorporate this functionality into ASCIICaseInsensitiveHash and allow
// a HashMap whose keys are type String to perform operations when given a key of type StringView.
struct ASCIICaseInsensitiveStringViewHashTranslator {
@@ -228,3 +242,4 @@
using WTF::ASCIICaseInsensitiveStringViewHashTranslator;
using WTF::AlreadyHashed;
using WTF::StringHash;
+using WTF::StringViewHashTranslator;
Modified: trunk/Source/WebCore/ChangeLog (292476 => 292477)
--- trunk/Source/WebCore/ChangeLog 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/ChangeLog 2022-04-06 17:48:44 UTC (rev 292477)
@@ -1,3 +1,98 @@
+2022-04-06 Chris Dumez <cdu...@apple.com>
+
+ Reduce number of conversions from StringView to String
+ https://bugs.webkit.org/show_bug.cgi?id=238841
+
+ Reviewed by Geoffrey Garen.
+
+ * Modules/cache/DOMCacheEngine.cpp:
+ (WebCore::DOMCacheEngine::queryCacheMatch):
+ * dom/ViewportArguments.cpp:
+ (WebCore::viewportErrorMessage):
+ * inspector/agents/page/PageDebuggerAgent.cpp:
+ (WebCore::PageDebuggerAgent::sourceMapURLForScript):
+ * loader/CrossOriginAccessControl.cpp:
+ (WebCore::validateCrossOriginRedirectionURL):
+ * loader/DocumentLoader.cpp:
+ (WebCore::DocumentLoader::disallowWebArchive const):
+ (WebCore::DocumentLoader::maybeLoadEmpty):
+ * loader/DocumentThreadableLoader.cpp:
+ (WebCore::DocumentThreadableLoader::DocumentThreadableLoader):
+ (WebCore::DocumentThreadableLoader::checkURLSchemeAsCORSEnabled):
+ * loader/EmptyClients.cpp:
+ (WebCore::EmptyFrameLoaderClient::representationExistsForURLScheme const):
+ (WebCore::EmptyFrameLoaderClient::generatedMIMETypeForURLScheme const):
+ * loader/EmptyFrameLoaderClient.h:
+ * loader/FrameLoaderClient.h:
+ * loader/archive/mhtml/MHTMLArchive.cpp:
+ (WebCore::MHTMLArchive::create):
+ * loader/cache/CachedResource.cpp:
+ (WebCore::CachedResource::freshnessLifetime const):
+ * loader/soup/ResourceLoaderSoup.cpp:
+ (WebCore::ResourceLoader::loadGResource):
+ * page/Page.cpp:
+ (WebCore::Page::userStyleSheetLocationChanged):
+ (WebCore::Page::allowsLoadFromURL const):
+ * page/SecurityOrigin.cpp:
+ (WebCore::shouldTreatAsUniqueOrigin):
+ (WebCore::shouldTreatAsPotentiallyTrustworthy):
+ (WebCore::SecurityOrigin::isSecure):
+ (WebCore::SecurityOrigin::canDisplay const):
+ * page/csp/ContentSecurityPolicy.cpp:
+ (WebCore::ContentSecurityPolicy::allowObjectFromSource const):
+ (WebCore::ContentSecurityPolicy::allowChildFrameFromSource const):
+ (WebCore::ContentSecurityPolicy::allowResourceFromSource const):
+ (WebCore::ContentSecurityPolicy::allowWorkerFromSource const):
+ (WebCore::ContentSecurityPolicy::allowScriptFromSource const):
+ (WebCore::ContentSecurityPolicy::allowStyleFromSource const):
+ (WebCore::ContentSecurityPolicy::allowConnectToSource const):
+ (WebCore::ContentSecurityPolicy::allowBaseURI const):
+ * page/csp/ContentSecurityPolicySourceList.cpp:
+ (WebCore::schemeIsInHttpFamily):
+ (WebCore::ContentSecurityPolicySourceList::isValidSourceForExtensionMode):
+ * platform/LegacySchemeRegistry.cpp:
+ (WebCore::LegacySchemeRegistry::schemeIsHandledBySchemeHandler):
+ (WebCore::LegacySchemeRegistry::shouldTreatURLSchemeAsLocal):
+ (WebCore::LegacySchemeRegistry::shouldTreatURLSchemeAsNoAccess):
+ (WebCore::LegacySchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated):
+ (WebCore::LegacySchemeRegistry::shouldTreatURLSchemeAsSecure):
+ (WebCore::LegacySchemeRegistry::shouldLoadURLSchemeAsEmptyDocument):
+ (WebCore::LegacySchemeRegistry::canDisplayOnlyIfCanRequest):
+ (WebCore::LegacySchemeRegistry::shouldTreatURLSchemeAsCORSEnabled):
+ (WebCore::LegacySchemeRegistry::schemeShouldBypassContentSecurityPolicy):
+ (WebCore::LegacySchemeRegistry::shouldAlwaysRevalidateURLScheme):
+ (WebCore::LegacySchemeRegistry::isUserExtensionScheme):
+ * platform/LegacySchemeRegistry.h:
+ * platform/PublicSuffix.h:
+ * platform/mac/PublicSuffixMac.mm:
+ (WebCore::isPublicSuffix):
+ (WebCore::topPrivatelyControlledDomain):
+ * platform/network/BlobRegistryImpl.cpp:
+ (WebCore::BlobRegistryImpl::getBlobDataFromURL const):
+ * platform/network/CacheValidation.cpp:
+ (WebCore::headerValueForVary):
+ (WebCore::collectVaryingRequestHeadersInternal):
+ (WebCore::collectVaryingRequestHeaders):
+ * platform/network/HTTPHeaderMap.cpp:
+ (WebCore::HTTPHeaderMap::get const):
+ (WebCore::HTTPHeaderMap::getUncommonHeader const):
+ * platform/network/HTTPHeaderMap.h:
+ * platform/network/HTTPParsers.cpp:
+ (WebCore::isCrossOriginSafeHeader):
+ * platform/network/ResourceRequestBase.cpp:
+ (WebCore::ResourceRequestBase::httpHeaderField const):
+ * platform/network/ResourceRequestBase.h:
+ * platform/network/ResourceResponseBase.cpp:
+ (WebCore::ResourceResponseBase::sanitizeHTTPHeaderFieldsAccordingToTainting):
+ (WebCore::ResourceResponseBase::httpHeaderField const):
+ * platform/network/ResourceResponseBase.h:
+ * platform/network/curl/PublicSuffixCurl.cpp:
+ (WebCore::isPublicSuffix):
+ * platform/network/soup/SoupNetworkSession.cpp:
+ (WebCore::SoupNetworkSession::checkTLSErrors):
+ * platform/soup/PublicSuffixSoup.cpp:
+ (WebCore::isPublicSuffix):
+
2022-04-06 Brent Fulgham <bfulg...@apple.com>
Further clean-ups for features.json
Modified: trunk/Source/WebCore/Modules/cache/DOMCacheEngine.cpp (292476 => 292477)
--- trunk/Source/WebCore/Modules/cache/DOMCacheEngine.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/Modules/cache/DOMCacheEngine.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -102,8 +102,7 @@
isVarying = true;
return;
}
- auto name = nameView.toStringWithoutCopying();
- isVarying = cachedRequest.httpHeaderField(name) != request.httpHeaderField(name);
+ isVarying = cachedRequest.httpHeaderField(nameView) != request.httpHeaderField(nameView);
});
return !isVarying;
Modified: trunk/Source/WebCore/dom/ViewportArguments.cpp (292476 => 292477)
--- trunk/Source/WebCore/dom/ViewportArguments.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/dom/ViewportArguments.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -427,10 +427,10 @@
{
String message = viewportErrorMessageTemplate(errorCode);
if (!replacement1.isNull())
- message.replace("%replacement1", replacement1.toStringWithoutCopying());
+ message.replace("%replacement1", replacement1);
// FIXME: This will do the wrong thing if replacement1 contains the substring "%replacement2".
if (!replacement2.isNull())
- message.replace("%replacement2", replacement2.toStringWithoutCopying());
+ message.replace("%replacement2", replacement2);
if ((errorCode == UnrecognizedViewportArgumentValueError || errorCode == TruncatedViewportArgumentValueError) && replacement1.contains(';'))
message.append(" Note that ';' is not a separator in viewport values. The list should be comma-separated."_s);
Modified: trunk/Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp (292476 => 292477)
--- trunk/Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -94,17 +94,17 @@
String PageDebuggerAgent::sourceMapURLForScript(const JSC::Debugger::Script& script)
{
- static NeverDestroyed<String> sourceMapHTTPHeader(MAKE_STATIC_STRING_IMPL("SourceMap"));
- static NeverDestroyed<String> sourceMapHTTPHeaderDeprecated(MAKE_STATIC_STRING_IMPL("X-SourceMap"));
+ static constexpr auto sourceMapHTTPHeader = "SourceMap"_s;
+ static constexpr auto sourceMapHTTPHeaderDeprecated = "X-SourceMap"_s;
if (!script.url.isEmpty()) {
CachedResource* resource = InspectorPageAgent::cachedResource(&m_inspectedPage.mainFrame(), URL({ }, script.url));
if (resource) {
- String sourceMapHeader = resource->response().httpHeaderField(sourceMapHTTPHeader);
+ String sourceMapHeader = resource->response().httpHeaderField(StringView { sourceMapHTTPHeader });
if (!sourceMapHeader.isEmpty())
return sourceMapHeader;
- sourceMapHeader = resource->response().httpHeaderField(sourceMapHTTPHeaderDeprecated);
+ sourceMapHeader = resource->response().httpHeaderField(StringView { sourceMapHTTPHeaderDeprecated });
if (!sourceMapHeader.isEmpty())
return sourceMapHeader;
}
Modified: trunk/Source/WebCore/loader/CrossOriginAccessControl.cpp (292476 => 292477)
--- trunk/Source/WebCore/loader/CrossOriginAccessControl.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/loader/CrossOriginAccessControl.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -171,7 +171,7 @@
String validateCrossOriginRedirectionURL(const URL& redirectURL)
{
- if (!LegacySchemeRegistry::shouldTreatURLSchemeAsCORSEnabled(redirectURL.protocol().toStringWithoutCopying()))
+ if (!LegacySchemeRegistry::shouldTreatURLSchemeAsCORSEnabled(redirectURL.protocol()))
return makeString("not allowed to follow a cross-origin CORS redirection with non CORS scheme");
if (redirectURL.hasCredentials())
Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (292476 => 292477)
--- trunk/Source/WebCore/loader/DocumentLoader.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -1040,7 +1040,7 @@
if (m_substituteData.isValid())
return false;
- if (!LegacySchemeRegistry::shouldTreatURLSchemeAsLocal(m_request.url().protocol().toStringWithoutCopying()))
+ if (!LegacySchemeRegistry::shouldTreatURLSchemeAsLocal(m_request.url().protocol()))
return true;
if (!frame() || (frame()->isMainFrame() && m_allowsWebArchiveForMainFrame))
@@ -1994,8 +1994,8 @@
bool DocumentLoader::maybeLoadEmpty()
{
- bool shouldLoadEmpty = !m_substituteData.isValid() && (m_request.url().isEmpty() || LegacySchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(m_request.url().protocol().toStringWithoutCopying()));
- if (!shouldLoadEmpty && !frameLoader()->client().representationExistsForURLScheme(m_request.url().protocol().toStringWithoutCopying()))
+ bool shouldLoadEmpty = !m_substituteData.isValid() && (m_request.url().isEmpty() || LegacySchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(m_request.url().protocol()));
+ if (!shouldLoadEmpty && !frameLoader()->client().representationExistsForURLScheme(m_request.url().protocol()))
return false;
if (m_request.url().isEmpty() && !frameLoader()->stateMachine().creatingInitialEmptyDocument()) {
@@ -2004,7 +2004,7 @@
frameLoader()->client().dispatchDidChangeProvisionalURL();
}
- String mimeType = shouldLoadEmpty ? "text/html"_s : frameLoader()->client().generatedMIMETypeForURLScheme(m_request.url().protocol().toStringWithoutCopying());
+ String mimeType = shouldLoadEmpty ? "text/html"_s : frameLoader()->client().generatedMIMETypeForURLScheme(m_request.url().protocol());
m_response = ResourceResponse(m_request.url(), mimeType, 0, "UTF-8"_s);
if (!frameLoader()->stateMachine().isDisplayingInitialEmptyDocument()) {
Modified: trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp (292476 => 292477)
--- trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -156,7 +156,7 @@
if (shouldSetHTTPHeadersToKeep())
m_options.httpHeadersToKeep = httpHeadersToKeepFromCleaning(request.httpHeaderFields());
- bool shouldDisableCORS = document.isRunningUserScripts() && LegacySchemeRegistry::isUserExtensionScheme(request.url().protocol().toStringWithoutCopying());
+ bool shouldDisableCORS = document.isRunningUserScripts() && LegacySchemeRegistry::isUserExtensionScheme(request.url().protocol());
if (auto* page = document.page())
shouldDisableCORS |= page->shouldDisableCorsForRequestTo(request.url());
@@ -189,7 +189,7 @@
bool DocumentThreadableLoader::checkURLSchemeAsCORSEnabled(const URL& url)
{
// Cross-origin requests are only allowed for HTTP and registered schemes. We would catch this when checking response headers later, but there is no reason to send a request that's guaranteed to be denied.
- if (!LegacySchemeRegistry::shouldTreatURLSchemeAsCORSEnabled(url.protocol().toStringWithoutCopying())) {
+ if (!LegacySchemeRegistry::shouldTreatURLSchemeAsCORSEnabled(url.protocol())) {
logErrorAndFail(ResourceError(errorDomainWebKitInternal, 0, url, "Cross origin requests are only supported for HTTP."_s, ResourceError::Type::AccessControl));
return false;
}
Modified: trunk/Source/WebCore/loader/EmptyClients.cpp (292476 => 292477)
--- trunk/Source/WebCore/loader/EmptyClients.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/loader/EmptyClients.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -952,12 +952,12 @@
return false;
}
-bool EmptyFrameLoaderClient::representationExistsForURLScheme(const String&) const
+bool EmptyFrameLoaderClient::representationExistsForURLScheme(StringView) const
{
return false;
}
-String EmptyFrameLoaderClient::generatedMIMETypeForURLScheme(const String&) const
+String EmptyFrameLoaderClient::generatedMIMETypeForURLScheme(StringView) const
{
return emptyString();
}
Modified: trunk/Source/WebCore/loader/EmptyFrameLoaderClient.h (292476 => 292477)
--- trunk/Source/WebCore/loader/EmptyFrameLoaderClient.h 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/loader/EmptyFrameLoaderClient.h 2022-04-06 17:48:44 UTC (rev 292477)
@@ -140,8 +140,8 @@
bool canHandleRequest(const ResourceRequest&) const final;
bool canShowMIMEType(const String&) const final;
bool canShowMIMETypeAsHTML(const String&) const final;
- bool representationExistsForURLScheme(const String&) const final;
- String generatedMIMETypeForURLScheme(const String&) const final;
+ bool representationExistsForURLScheme(StringView) const final;
+ String generatedMIMETypeForURLScheme(StringView) const final;
void frameLoadCompleted() final;
void restoreViewState() final;
Modified: trunk/Source/WebCore/loader/FrameLoaderClient.h (292476 => 292477)
--- trunk/Source/WebCore/loader/FrameLoaderClient.h 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/loader/FrameLoaderClient.h 2022-04-06 17:48:44 UTC (rev 292477)
@@ -255,8 +255,8 @@
virtual bool canHandleRequest(const ResourceRequest&) const = 0;
virtual bool canShowMIMEType(const String& MIMEType) const = 0;
virtual bool canShowMIMETypeAsHTML(const String& MIMEType) const = 0;
- virtual bool representationExistsForURLScheme(const String& URLScheme) const = 0;
- virtual String generatedMIMETypeForURLScheme(const String& URLScheme) const = 0;
+ virtual bool representationExistsForURLScheme(StringView URLScheme) const = 0;
+ virtual String generatedMIMETypeForURLScheme(StringView URLScheme) const = 0;
virtual void frameLoadCompleted() = 0;
virtual void saveViewStateToItem(HistoryItem&) = 0;
Modified: trunk/Source/WebCore/loader/archive/mhtml/MHTMLArchive.cpp (292476 => 292477)
--- trunk/Source/WebCore/loader/archive/mhtml/MHTMLArchive.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/loader/archive/mhtml/MHTMLArchive.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -109,7 +109,7 @@
RefPtr<MHTMLArchive> MHTMLArchive::create(const URL& url, FragmentedSharedBuffer& data)
{
// For security reasons we only load MHTML pages from local URLs.
- if (!LegacySchemeRegistry::shouldTreatURLSchemeAsLocal(url.protocol().toString()))
+ if (!LegacySchemeRegistry::shouldTreatURLSchemeAsLocal(url.protocol()))
return nullptr;
MHTMLParser parser(&data);
Modified: trunk/Source/WebCore/loader/cache/CachedResource.cpp (292476 => 292477)
--- trunk/Source/WebCore/loader/cache/CachedResource.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -436,7 +436,7 @@
// Don't cache non-HTTP main resources since we can't check for freshness.
// FIXME: We should not cache subresources either, but when we tried this
// it caused performance and flakiness issues in our test infrastructure.
- if (m_type == Type::MainResource || LegacySchemeRegistry::shouldAlwaysRevalidateURLScheme(protocol.toStringWithoutCopying()))
+ if (m_type == Type::MainResource || LegacySchemeRegistry::shouldAlwaysRevalidateURLScheme(protocol))
return 0_us;
}
Modified: trunk/Source/WebCore/loader/soup/ResourceLoaderSoup.cpp (292476 => 292477)
--- trunk/Source/WebCore/loader/soup/ResourceLoaderSoup.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/loader/soup/ResourceLoaderSoup.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -78,7 +78,7 @@
g_task_run_in_thread(task.get(), [](GTask* task, gpointer, gpointer taskData, GCancellable*) {
URL url({ }, String::fromUTF8(static_cast<const char*>(taskData)));
GError* error = nullptr;
- GBytes* bytes = g_resources_lookup_data(url.protocolIs("webkit-pdfjs-viewer") ? makeString("/org/webkit/pdfjs", url.path().toString()).utf8().data() : url.path().utf8().data(),
+ GBytes* bytes = g_resources_lookup_data(url.protocolIs("webkit-pdfjs-viewer") ? makeString("/org/webkit/pdfjs", url.path()).utf8().data() : url.path().utf8().data(),
G_RESOURCE_LOOKUP_FLAGS_NONE, &error);
if (!bytes)
g_task_return_error(task, error);
Modified: trunk/Source/WebCore/page/Page.cpp (292476 => 292477)
--- trunk/Source/WebCore/page/Page.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/page/Page.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -2009,7 +2009,7 @@
URL url = ""
// Allow any local file URL scheme to be loaded.
- if (LegacySchemeRegistry::shouldTreatURLSchemeAsLocal(url.protocol().toStringWithoutCopying()))
+ if (LegacySchemeRegistry::shouldTreatURLSchemeAsLocal(url.protocol()))
m_userStyleSheetPath = url.fileSystemPath();
else
m_userStyleSheetPath = String();
@@ -3534,7 +3534,7 @@
return true;
if (!url.protocolIsInHTTPFamily() && !url.protocolIs("ws") && !url.protocolIs("wss"))
return true;
- return m_allowedNetworkHosts->contains(url.host().toStringWithoutCopying());
+ return m_allowedNetworkHosts->contains<StringViewHashTranslator>(url.host());
}
void Page::applicationWillResignActive()
Modified: trunk/Source/WebCore/page/SecurityOrigin.cpp (292476 => 292477)
--- trunk/Source/WebCore/page/SecurityOrigin.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/page/SecurityOrigin.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -107,7 +107,7 @@
if (schemeRequiresHost(innerURL) && innerURL.host().isEmpty())
return true;
- if (LegacySchemeRegistry::shouldTreatURLSchemeAsNoAccess(innerURL.protocol().toStringWithoutCopying()))
+ if (LegacySchemeRegistry::shouldTreatURLSchemeAsNoAccess(innerURL.protocol()))
return true;
// https://url.spec.whatwg.org/#origin with some additions
@@ -153,7 +153,7 @@
}
// https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy (Editor's Draft, 17 November 2016)
-static bool shouldTreatAsPotentiallyTrustworthy(const String& protocol, StringView host)
+static bool shouldTreatAsPotentiallyTrustworthy(StringView protocol, StringView host)
{
if (LegacySchemeRegistry::shouldTreatURLSchemeAsSecure(protocol))
return true;
@@ -172,7 +172,7 @@
bool shouldTreatAsPotentiallyTrustworthy(const URL& url)
{
- return shouldTreatAsPotentiallyTrustworthy(url.protocol().toStringWithoutCopying(), url.host());
+ return shouldTreatAsPotentiallyTrustworthy(url.protocol(), url.host());
}
SecurityOrigin::SecurityOrigin(const URL& url)
@@ -259,12 +259,12 @@
bool SecurityOrigin::isSecure(const URL& url)
{
// Invalid URLs are secure, as are URLs which have a secure protocol.
- if (!url.isValid() || LegacySchemeRegistry::shouldTreatURLSchemeAsSecure(url.protocol().toStringWithoutCopying()))
+ if (!url.isValid() || LegacySchemeRegistry::shouldTreatURLSchemeAsSecure(url.protocol()))
return true;
// URLs that wrap inner URLs are secure if those inner URLs are secure.
if (shouldUseInnerURL(url))
- return LegacySchemeRegistry::shouldTreatURLSchemeAsSecure(extractInnerURL(url).protocol().toStringWithoutCopying()) || BlobURL::isSecureBlobURL(url);
+ return LegacySchemeRegistry::shouldTreatURLSchemeAsSecure(extractInnerURL(url).protocol()) || BlobURL::isSecureBlobURL(url);
return false;
}
@@ -398,7 +398,7 @@
if (isFeedWithNestedProtocolInHTTPFamily(url))
return true;
- String protocol = url.protocol().toString();
+ auto protocol = url.protocol();
if (LegacySchemeRegistry::canDisplayOnlyIfCanRequest(protocol))
return canRequest(url);
Modified: trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp (292476 => 292477)
--- trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -559,7 +559,7 @@
bool ContentSecurityPolicy::allowObjectFromSource(const URL& url, RedirectResponseReceived redirectResponseReceived, const URL& preRedirectURL) const
{
- if (LegacySchemeRegistry::schemeShouldBypassContentSecurityPolicy(url.protocol().toStringWithoutCopying()))
+ if (LegacySchemeRegistry::schemeShouldBypassContentSecurityPolicy(url.protocol()))
return true;
// As per section object-src of the Content Security Policy Level 3 spec., <http://w3c.github.io/webappsec-csp> (Editor's Draft, 29 February 2016),
// "If plugin content is loaded without an associated URL (perhaps an object element lacks a data attribute, but loads some default plugin based
@@ -576,7 +576,7 @@
bool ContentSecurityPolicy::allowChildFrameFromSource(const URL& url, RedirectResponseReceived redirectResponseReceived) const
{
- if (LegacySchemeRegistry::schemeShouldBypassContentSecurityPolicy(url.protocol().toStringWithoutCopying()))
+ if (LegacySchemeRegistry::schemeShouldBypassContentSecurityPolicy(url.protocol()))
return true;
String sourceURL;
TextPosition sourcePosition(OrdinalNumber::beforeFirst(), OrdinalNumber());
@@ -589,7 +589,7 @@
bool ContentSecurityPolicy::allowResourceFromSource(const URL& url, RedirectResponseReceived redirectResponseReceived, ResourcePredicate resourcePredicate, const URL& preRedirectURL) const
{
- if (LegacySchemeRegistry::schemeShouldBypassContentSecurityPolicy(url.protocol().toStringWithoutCopying()))
+ if (LegacySchemeRegistry::schemeShouldBypassContentSecurityPolicy(url.protocol()))
return true;
String sourceURL;
const auto& blockedURL = !preRedirectURL.isNull() ? preRedirectURL : url;
@@ -603,7 +603,7 @@
bool ContentSecurityPolicy::allowWorkerFromSource(const URL& url, RedirectResponseReceived redirectResponseReceived, const URL& preRedirectURL) const
{
- if (LegacySchemeRegistry::schemeShouldBypassContentSecurityPolicy(url.protocol().toStringWithoutCopying()))
+ if (LegacySchemeRegistry::schemeShouldBypassContentSecurityPolicy(url.protocol()))
return true;
String sourceURL;
@@ -621,7 +621,7 @@
{
if (shouldPerformEarlyCSPCheck())
return true;
- if (LegacySchemeRegistry::schemeShouldBypassContentSecurityPolicy(url.protocol().toStringWithoutCopying()))
+ if (LegacySchemeRegistry::schemeShouldBypassContentSecurityPolicy(url.protocol()))
return true;
String sourceURL;
@@ -644,7 +644,7 @@
bool ContentSecurityPolicy::allowStyleFromSource(const URL& url, RedirectResponseReceived redirectResponseReceived, const URL& preRedirectURL, const String& nonce) const
{
- if (LegacySchemeRegistry::schemeShouldBypassContentSecurityPolicy(url.protocol().toStringWithoutCopying()))
+ if (LegacySchemeRegistry::schemeShouldBypassContentSecurityPolicy(url.protocol()))
return true;
String sourceURL;
const auto& blockedURL = !preRedirectURL.isNull() ? preRedirectURL : url;
@@ -677,7 +677,7 @@
bool ContentSecurityPolicy::allowConnectToSource(const URL& url, RedirectResponseReceived redirectResponseReceived, const URL& preRedirectURL) const
{
- if (LegacySchemeRegistry::schemeShouldBypassContentSecurityPolicy(url.protocol().toStringWithoutCopying()))
+ if (LegacySchemeRegistry::schemeShouldBypassContentSecurityPolicy(url.protocol()))
return true;
String sourceURL;
TextPosition sourcePosition(OrdinalNumber::beforeFirst(), OrdinalNumber());
@@ -697,7 +697,7 @@
{
if (overrideContentSecurityPolicy)
return true;
- if (LegacySchemeRegistry::schemeShouldBypassContentSecurityPolicy(url.protocol().toStringWithoutCopying()))
+ if (LegacySchemeRegistry::schemeShouldBypassContentSecurityPolicy(url.protocol()))
return true;
String sourceURL;
TextPosition sourcePosition(OrdinalNumber::beforeFirst(), OrdinalNumber());
Modified: trunk/Source/WebCore/page/csp/ContentSecurityPolicySourceList.cpp (292476 => 292477)
--- trunk/Source/WebCore/page/csp/ContentSecurityPolicySourceList.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/page/csp/ContentSecurityPolicySourceList.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -179,7 +179,7 @@
return m_nonces.contains(nonce);
}
-static bool schemeIsInHttpFamily(const String& scheme)
+static bool schemeIsInHttpFamily(StringView scheme)
{
return equalIgnoringASCIICase(scheme, "https") || equalIgnoringASCIICase(scheme, "http");
}
@@ -206,7 +206,7 @@
{
bool hostIsPublicSuffix = false;
#if ENABLE(PUBLIC_SUFFIX_LIST)
- hostIsPublicSuffix = isPublicSuffix(parsedSource.host.value.toStringWithoutCopying());
+ hostIsPublicSuffix = isPublicSuffix(parsedSource.host.value);
#endif
switch (m_contentSecurityPolicyModeForExtension) {
@@ -222,7 +222,7 @@
if (equalIgnoringASCIICase(parsedSource.scheme, "blob"))
return true;
- if (!equalIgnoringASCIICase(parsedSource.scheme.toString(), "https") || parsedSource.host.value.isEmpty())
+ if (!equalIgnoringASCIICase(parsedSource.scheme, "https") || parsedSource.host.value.isEmpty())
return false;
break;
case ContentSecurityPolicyModeForExtension::ManifestV3:
@@ -229,7 +229,7 @@
if (!isRestrictedDirectiveForMode(m_directiveName, ContentSecurityPolicyModeForExtension::ManifestV3))
return true;
- if (!schemeIsInHttpFamily(parsedSource.scheme.toStringWithoutCopying()) || !SecurityOrigin::isLocalHostOrLoopbackIPAddress(parsedSource.host.value))
+ if (!schemeIsInHttpFamily(parsedSource.scheme) || !SecurityOrigin::isLocalHostOrLoopbackIPAddress(parsedSource.host.value))
return false;
}
return true;
Modified: trunk/Source/WebCore/platform/LegacySchemeRegistry.cpp (292476 => 292477)
--- trunk/Source/WebCore/platform/LegacySchemeRegistry.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/platform/LegacySchemeRegistry.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -251,7 +251,7 @@
bool LegacySchemeRegistry::schemeIsHandledBySchemeHandler(StringView scheme)
{
Locker locker { schemeRegistryLock };
- return schemesHandledBySchemeHandler().contains(scheme.toStringWithoutCopying());
+ return schemesHandledBySchemeHandler().contains<StringViewHashTranslator>(scheme);
}
static URLSchemesMap& schemesAllowingDatabaseAccessInPrivateBrowsing()
@@ -296,13 +296,13 @@
return schemes;
}
-bool LegacySchemeRegistry::shouldTreatURLSchemeAsLocal(const String& scheme)
+bool LegacySchemeRegistry::shouldTreatURLSchemeAsLocal(StringView scheme)
{
if (scheme.isNull())
return false;
Locker locker { schemeRegistryLock };
- return localURLSchemes().contains(scheme);
+ return localURLSchemes().contains<StringViewHashTranslator>(scheme);
}
void LegacySchemeRegistry::registerURLSchemeAsNoAccess(const String& scheme)
@@ -314,13 +314,13 @@
schemesWithUniqueOrigins().add(scheme);
}
-bool LegacySchemeRegistry::shouldTreatURLSchemeAsNoAccess(const String& scheme)
+bool LegacySchemeRegistry::shouldTreatURLSchemeAsNoAccess(StringView scheme)
{
if (scheme.isNull())
return false;
Locker locker { schemeRegistryLock };
- return schemesWithUniqueOrigins().contains(scheme);
+ return schemesWithUniqueOrigins().contains<StringViewHashTranslator>(scheme);
}
void LegacySchemeRegistry::registerURLSchemeAsDisplayIsolated(const String& scheme)
@@ -332,13 +332,13 @@
displayIsolatedURLSchemes().add(scheme);
}
-bool LegacySchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated(const String& scheme)
+bool LegacySchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated(StringView scheme)
{
if (scheme.isNull())
return false;
Locker locker { schemeRegistryLock };
- return displayIsolatedURLSchemes().contains(scheme);
+ return displayIsolatedURLSchemes().contains<StringViewHashTranslator>(scheme);
}
void LegacySchemeRegistry::registerURLSchemeAsSecure(const String& scheme)
@@ -350,13 +350,13 @@
secureSchemes().add(scheme);
}
-bool LegacySchemeRegistry::shouldTreatURLSchemeAsSecure(const String& scheme)
+bool LegacySchemeRegistry::shouldTreatURLSchemeAsSecure(StringView scheme)
{
if (scheme.isNull())
return false;
Locker locker { schemeRegistryLock };
- return secureSchemes().contains(scheme);
+ return secureSchemes().contains<StringViewHashTranslator>(scheme);
}
void LegacySchemeRegistry::registerURLSchemeAsEmptyDocument(const String& scheme)
@@ -366,9 +366,9 @@
emptyDocumentSchemes().add(scheme);
}
-bool LegacySchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(const String& scheme)
+bool LegacySchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(StringView scheme)
{
- return !scheme.isNull() && emptyDocumentSchemes().contains(scheme);
+ return !scheme.isNull() && emptyDocumentSchemes().contains<StringViewHashTranslator>(scheme);
}
void LegacySchemeRegistry::setDomainRelaxationForbiddenForURLScheme(bool forbidden, const String& scheme)
@@ -387,7 +387,7 @@
return !scheme.isNull() && schemesForbiddenFromDomainRelaxation().contains(scheme);
}
-bool LegacySchemeRegistry::canDisplayOnlyIfCanRequest(const String& scheme)
+bool LegacySchemeRegistry::canDisplayOnlyIfCanRequest(StringView scheme)
{
ASSERT(!isInNetworkProcess());
if (scheme.isNull())
@@ -394,7 +394,7 @@
return false;
Locker locker { schemeRegistryLock };
- return canDisplayOnlyIfCanRequestSchemes().contains(scheme);
+ return canDisplayOnlyIfCanRequestSchemes().contains<StringViewHashTranslator>(scheme);
}
void LegacySchemeRegistry::registerAsCanDisplayOnlyIfCanRequest(const String& scheme)
@@ -439,10 +439,10 @@
CORSEnabledSchemes().add(scheme);
}
-bool LegacySchemeRegistry::shouldTreatURLSchemeAsCORSEnabled(const String& scheme)
+bool LegacySchemeRegistry::shouldTreatURLSchemeAsCORSEnabled(StringView scheme)
{
ASSERT(!isInNetworkProcess());
- return !scheme.isNull() && CORSEnabledSchemes().contains(scheme);
+ return !scheme.isNull() && CORSEnabledSchemes().contains<StringViewHashTranslator>(scheme);
}
Vector<String> LegacySchemeRegistry::allURLSchemesRegisteredAsCORSEnabled()
@@ -469,13 +469,13 @@
ContentSecurityPolicyBypassingSchemes().remove(scheme);
}
-bool LegacySchemeRegistry::schemeShouldBypassContentSecurityPolicy(const String& scheme)
+bool LegacySchemeRegistry::schemeShouldBypassContentSecurityPolicy(StringView scheme)
{
if (scheme.isNull())
return false;
Locker locker { schemeRegistryLock };
- return ContentSecurityPolicyBypassingSchemes().contains(scheme);
+ return ContentSecurityPolicyBypassingSchemes().contains<StringViewHashTranslator>(scheme);
}
void LegacySchemeRegistry::registerURLSchemeAsAlwaysRevalidated(const String& scheme)
@@ -485,9 +485,9 @@
alwaysRevalidatedSchemes().add(scheme);
}
-bool LegacySchemeRegistry::shouldAlwaysRevalidateURLScheme(const String& scheme)
+bool LegacySchemeRegistry::shouldAlwaysRevalidateURLScheme(StringView scheme)
{
- return !scheme.isNull() && alwaysRevalidatedSchemes().contains(scheme);
+ return !scheme.isNull() && alwaysRevalidatedSchemes().contains<StringViewHashTranslator>(scheme);
}
void LegacySchemeRegistry::registerURLSchemeAsCachePartitioned(const String& scheme)
@@ -508,7 +508,7 @@
return cachePartitioningSchemes().contains(scheme);
}
-bool LegacySchemeRegistry::isUserExtensionScheme(const String& scheme)
+bool LegacySchemeRegistry::isUserExtensionScheme(StringView scheme)
{
// FIXME: Remove this once Safari has adopted WKWebViewConfiguration._corsDisablingPatterns
#if PLATFORM(MAC)
Modified: trunk/Source/WebCore/platform/LegacySchemeRegistry.h (292476 => 292477)
--- trunk/Source/WebCore/platform/LegacySchemeRegistry.h 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/platform/LegacySchemeRegistry.h 2022-04-06 17:48:44 UTC (rev 292477)
@@ -40,7 +40,7 @@
WEBCORE_EXPORT static void registerURLSchemeAsLocal(const String&); // Thread safe.
static void removeURLSchemeRegisteredAsLocal(const String&); // Thread safe.
- WEBCORE_EXPORT static bool shouldTreatURLSchemeAsLocal(const String&); // Thread safe.
+ WEBCORE_EXPORT static bool shouldTreatURLSchemeAsLocal(StringView); // Thread safe.
WEBCORE_EXPORT static bool isBuiltinScheme(const String&);
// Secure schemes do not trigger mixed content warnings. For example,
@@ -47,18 +47,18 @@
// https and data are secure schemes because they cannot be corrupted by
// active network attackers.
WEBCORE_EXPORT static void registerURLSchemeAsSecure(const String&); // Thread safe.
- static bool shouldTreatURLSchemeAsSecure(const String&); // Thread safe.
+ static bool shouldTreatURLSchemeAsSecure(StringView); // Thread safe.
WEBCORE_EXPORT static void registerURLSchemeAsNoAccess(const String&); // Thread safe.
- static bool shouldTreatURLSchemeAsNoAccess(const String&); // Thread safe.
+ static bool shouldTreatURLSchemeAsNoAccess(StringView); // Thread safe.
// Display-isolated schemes can only be displayed (in the sense of
// SecurityOrigin::canDisplay) by documents from the same scheme.
WEBCORE_EXPORT static void registerURLSchemeAsDisplayIsolated(const String&); // Thread safe.
- static bool shouldTreatURLSchemeAsDisplayIsolated(const String&); // Thread safe.
+ static bool shouldTreatURLSchemeAsDisplayIsolated(StringView); // Thread safe.
WEBCORE_EXPORT static void registerURLSchemeAsEmptyDocument(const String&);
- WEBCORE_EXPORT static bool shouldLoadURLSchemeAsEmptyDocument(const String&);
+ WEBCORE_EXPORT static bool shouldLoadURLSchemeAsEmptyDocument(StringView);
WEBCORE_EXPORT static void setDomainRelaxationForbiddenForURLScheme(bool forbidden, const String&);
static bool isDomainRelaxationForbiddenForURLScheme(const String&);
@@ -65,7 +65,7 @@
// Such schemes should delegate to SecurityOrigin::canRequest for any URL
// passed to SecurityOrigin::canDisplay.
- static bool canDisplayOnlyIfCanRequest(const String& scheme); // Thread safe.
+ static bool canDisplayOnlyIfCanRequest(StringView scheme); // Thread safe.
WEBCORE_EXPORT static void registerAsCanDisplayOnlyIfCanRequest(const String& scheme); // Thread safe.
// Schemes against which _javascript_: URLs should not be allowed to run (stop
@@ -80,7 +80,7 @@
// Allow non-HTTP schemes to be registered to allow CORS requests.
WEBCORE_EXPORT static void registerURLSchemeAsCORSEnabled(const String& scheme);
- WEBCORE_EXPORT static bool shouldTreatURLSchemeAsCORSEnabled(const String& scheme);
+ WEBCORE_EXPORT static bool shouldTreatURLSchemeAsCORSEnabled(StringView scheme);
WEBCORE_EXPORT static Vector<String> allURLSchemesRegisteredAsCORSEnabled();
WEBCORE_EXPORT static void registerURLSchemeAsHandledBySchemeHandler(const String&);
@@ -90,17 +90,17 @@
// Content Security Policy.
WEBCORE_EXPORT static void registerURLSchemeAsBypassingContentSecurityPolicy(const String& scheme); // Thread safe.
WEBCORE_EXPORT static void removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(const String& scheme); // Thread safe.
- static bool schemeShouldBypassContentSecurityPolicy(const String& scheme); // Thread safe.
+ static bool schemeShouldBypassContentSecurityPolicy(StringView scheme); // Thread safe.
// Schemes whose responses should always be revalidated.
WEBCORE_EXPORT static void registerURLSchemeAsAlwaysRevalidated(const String&);
- static bool shouldAlwaysRevalidateURLScheme(const String&);
+ static bool shouldAlwaysRevalidateURLScheme(StringView);
// Schemes whose requests should be partitioned in the cache
WEBCORE_EXPORT static void registerURLSchemeAsCachePartitioned(const String& scheme); // Thread safe.
static bool shouldPartitionCacheForURLScheme(const String& scheme); // Thread safe.
- static bool isUserExtensionScheme(const String& scheme);
+ static bool isUserExtensionScheme(StringView scheme);
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/PublicSuffix.h (292476 => 292477)
--- trunk/Source/WebCore/platform/PublicSuffix.h 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/platform/PublicSuffix.h 2022-04-06 17:48:44 UTC (rev 292477)
@@ -31,7 +31,7 @@
namespace WebCore {
-WEBCORE_EXPORT bool isPublicSuffix(const String& domain);
+WEBCORE_EXPORT bool isPublicSuffix(StringView domain);
WEBCORE_EXPORT String topPrivatelyControlledDomain(const String& domain);
String decodeHostName(const String& domain);
Modified: trunk/Source/WebCore/platform/mac/PublicSuffixMac.mm (292476 => 292477)
--- trunk/Source/WebCore/platform/mac/PublicSuffixMac.mm 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/platform/mac/PublicSuffixMac.mm 2022-04-06 17:48:44 UTC (rev 292477)
@@ -36,10 +36,9 @@
namespace WebCore {
-bool isPublicSuffix(const String& domain)
+bool isPublicSuffix(StringView domain)
{
- // Explicitly cast the domain to a NSString before calling decodeHostName() so we get a NSString back instead of a String.
- NSString *host = decodeHostName((NSString *)domain);
+ NSString *host = decodeHostName(domain.createNSString().get());
return host && _CFHostIsDomainTopLevel((__bridge CFStringRef)host);
}
@@ -71,7 +70,7 @@
size_t separatorPosition;
for (unsigned labelStart = 0; (separatorPosition = lowercaseDomain.find('.', labelStart)) != notFound; labelStart = separatorPosition + 1) {
- if (isPublicSuffix(lowercaseDomain.substring(separatorPosition + 1)))
+ if (isPublicSuffix(StringView(lowercaseDomain).substring(separatorPosition + 1)))
return lowercaseDomain.substring(labelStart);
}
return String();
Modified: trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp (292476 => 292477)
--- trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -230,7 +230,7 @@
{
ASSERT(isMainThread());
if (url.hasFragmentIdentifier())
- return m_blobs.get(url.viewWithoutFragmentIdentifier().toStringWithoutCopying());
+ return m_blobs.get<StringViewHashTranslator>(url.viewWithoutFragmentIdentifier());
return m_blobs.get(url.string());
}
Modified: trunk/Source/WebCore/platform/network/CacheValidation.cpp (292476 => 292477)
--- trunk/Source/WebCore/platform/network/CacheValidation.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/platform/network/CacheValidation.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -350,7 +350,7 @@
return cookieJar->cookieRequestHeaderFieldValue(request.firstPartyForCookies(), SameSiteInfo::create(request), request.url(), std::nullopt, std::nullopt, request.url().protocolIs("https") ? IncludeSecureCookies::Yes : IncludeSecureCookies::No).first;
}
-static String headerValueForVary(const ResourceRequest& request, const String& headerName, Function<String()>&& cookieRequestHeaderFieldValueFunction)
+static String headerValueForVary(const ResourceRequest& request, StringView headerName, Function<String()>&& cookieRequestHeaderFieldValueFunction)
{
// Explicit handling for cookies is needed because they are added magically by the networking layer.
// FIXME: The value might have changed between making the request and retrieving the cookie here.
@@ -361,7 +361,7 @@
return request.httpHeaderField(headerName);
}
-static Vector<std::pair<String, String>> collectVaryingRequestHeadersInternal(const ResourceResponse& response, Function<String(const String& headerName)>&& headerValueForVaryFunction)
+static Vector<std::pair<String, String>> collectVaryingRequestHeadersInternal(const ResourceResponse& response, Function<String(StringView headerName)>&& headerValueForVaryFunction)
{
auto varyValue = response.httpHeaderField(HTTPHeaderName::Vary);
if (varyValue.isEmpty())
@@ -369,8 +369,8 @@
Vector<std::pair<String, String>> headers;
for (auto varyHeaderName : StringView(varyValue).split(',')) {
- auto headerName = varyHeaderName.stripWhiteSpace().toString();
- headers.append(std::pair { headerName, headerValueForVaryFunction(headerName) });
+ auto headerName = varyHeaderName.stripWhiteSpace();
+ headers.append(std::pair { headerName.toString(), headerValueForVaryFunction(headerName) });
}
return headers;
}
@@ -379,7 +379,7 @@
{
if (!storageSession)
return { };
- return collectVaryingRequestHeadersInternal(response, [&] (const String& headerName) {
+ return collectVaryingRequestHeadersInternal(response, [&] (StringView headerName) {
return headerValueForVary(request, headerName, [&] {
return cookieRequestHeaderFieldValue(*storageSession, request);
});
@@ -388,7 +388,7 @@
Vector<std::pair<String, String>> collectVaryingRequestHeaders(const CookieJar* cookieJar, const ResourceRequest& request, const ResourceResponse& response)
{
- return collectVaryingRequestHeadersInternal(response, [&] (const String& headerName) {
+ return collectVaryingRequestHeadersInternal(response, [&] (StringView headerName) {
return headerValueForVary(request, headerName, [&] {
return cookieRequestHeaderFieldValue(cookieJar, request);
});
Modified: trunk/Source/WebCore/platform/network/HTTPHeaderMap.cpp (292476 => 292477)
--- trunk/Source/WebCore/platform/network/HTTPHeaderMap.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/platform/network/HTTPHeaderMap.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -58,7 +58,7 @@
return map;
}
-String HTTPHeaderMap::get(const String& name) const
+String HTTPHeaderMap::get(StringView name) const
{
HTTPHeaderName headerName;
if (findHTTPHeaderName(name, headerName))
@@ -67,7 +67,7 @@
return getUncommonHeader(name);
}
-String HTTPHeaderMap::getUncommonHeader(const String& name) const
+String HTTPHeaderMap::getUncommonHeader(StringView name) const
{
auto index = m_uncommonHeaders.findIf([&](auto& header) {
return equalIgnoringASCIICase(header.key, name);
Modified: trunk/Source/WebCore/platform/network/HTTPHeaderMap.h (292476 => 292477)
--- trunk/Source/WebCore/platform/network/HTTPHeaderMap.h 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/platform/network/HTTPHeaderMap.h 2022-04-06 17:48:44 UTC (rev 292477)
@@ -154,7 +154,7 @@
m_uncommonHeaders.shrinkToFit();
}
- WEBCORE_EXPORT String get(const String& name) const;
+ WEBCORE_EXPORT String get(StringView name) const;
WEBCORE_EXPORT void set(const String& name, const String& value);
WEBCORE_EXPORT void add(const String& name, const String& value);
WEBCORE_EXPORT void append(const String& name, const String& value);
@@ -214,7 +214,7 @@
private:
void setUncommonHeader(const String& name, const String& value);
- WEBCORE_EXPORT String getUncommonHeader(const String& name) const;
+ WEBCORE_EXPORT String getUncommonHeader(StringView name) const;
CommonHeadersVector m_commonHeaders;
UncommonHeadersVector m_uncommonHeaders;
Modified: trunk/Source/WebCore/platform/network/HTTPParsers.cpp (292476 => 292477)
--- trunk/Source/WebCore/platform/network/HTTPParsers.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/platform/network/HTTPParsers.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -939,7 +939,7 @@
default:
break;
}
- return accessControlExposeHeaderSet.contains(httpHeaderNameString(name).toStringWithoutCopying());
+ return accessControlExposeHeaderSet.contains<ASCIICaseInsensitiveStringViewHashTranslator>(httpHeaderNameString(name));
}
bool isCrossOriginSafeHeader(const String& name, const HTTPHeaderSet& accessControlExposeHeaderSet)
Modified: trunk/Source/WebCore/platform/network/ResourceRequestBase.cpp (292476 => 292477)
--- trunk/Source/WebCore/platform/network/ResourceRequestBase.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/platform/network/ResourceRequestBase.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -308,10 +308,10 @@
return m_httpHeaderFields;
}
-String ResourceRequestBase::httpHeaderField(const String& name) const
+String ResourceRequestBase::httpHeaderField(StringView name) const
{
- updateResourceRequest();
-
+ updateResourceRequest();
+
return m_httpHeaderFields.get(name);
}
Modified: trunk/Source/WebCore/platform/network/ResourceRequestBase.h (292476 => 292477)
--- trunk/Source/WebCore/platform/network/ResourceRequestBase.h 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/platform/network/ResourceRequestBase.h 2022-04-06 17:48:44 UTC (rev 292477)
@@ -98,7 +98,7 @@
WEBCORE_EXPORT const HTTPHeaderMap& httpHeaderFields() const;
WEBCORE_EXPORT void setHTTPHeaderFields(HTTPHeaderMap);
- WEBCORE_EXPORT String httpHeaderField(const String& name) const;
+ WEBCORE_EXPORT String httpHeaderField(StringView name) const;
WEBCORE_EXPORT String httpHeaderField(HTTPHeaderName) const;
WEBCORE_EXPORT void setHTTPHeaderField(const String& name, const String& value);
WEBCORE_EXPORT void setHTTPHeaderField(HTTPHeaderName, const String& value);
Modified: trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp (292476 => 292477)
--- trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -463,7 +463,7 @@
return;
m_httpHeaderFields.commonHeaders().removeAllMatching([&corsSafeHeaderSet](auto& header) {
- return !isSafeCrossOriginResponseHeader(header.key) && !corsSafeHeaderSet.contains(httpHeaderNameString(header.key).toStringWithoutCopying());
+ return !isSafeCrossOriginResponseHeader(header.key) && !corsSafeHeaderSet.contains<ASCIICaseInsensitiveStringViewHashTranslator>(httpHeaderNameString(header.key));
});
m_httpHeaderFields.uncommonHeaders().removeAllMatching([&corsSafeHeaderSet](auto& header) { return !corsSafeHeaderSet.contains(header.key); });
break;
@@ -503,7 +503,7 @@
return m_httpVersion.startsWith("HTTP/0.9");
}
-String ResourceResponseBase::httpHeaderField(const String& name) const
+String ResourceResponseBase::httpHeaderField(StringView name) const
{
lazyInit(CommonFieldsOnly);
Modified: trunk/Source/WebCore/platform/network/ResourceResponseBase.h (292476 => 292477)
--- trunk/Source/WebCore/platform/network/ResourceResponseBase.h 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/platform/network/ResourceResponseBase.h 2022-04-06 17:48:44 UTC (rev 292477)
@@ -119,7 +119,7 @@
enum class SanitizationType { Redirection, RemoveCookies, CrossOriginSafe };
WEBCORE_EXPORT void sanitizeHTTPHeaderFields(SanitizationType);
- String httpHeaderField(const String& name) const;
+ String httpHeaderField(StringView name) const;
WEBCORE_EXPORT String httpHeaderField(HTTPHeaderName) const;
WEBCORE_EXPORT void setHTTPHeaderField(const String& name, const String& value);
WEBCORE_EXPORT void setHTTPHeaderField(HTTPHeaderName, const String& value);
Modified: trunk/Source/WebCore/platform/network/curl/AuthenticationChallengeCurl.cpp (292476 => 292477)
--- trunk/Source/WebCore/platform/network/curl/AuthenticationChallengeCurl.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/platform/network/curl/AuthenticationChallengeCurl.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -111,12 +111,12 @@
String AuthenticationChallenge::parseRealm(const ResourceResponse& response)
{
- static NeverDestroyed<String> wwwAuthenticate(MAKE_STATIC_STRING_IMPL("www-authenticate"));
- static NeverDestroyed<String> proxyAuthenticate(MAKE_STATIC_STRING_IMPL("proxy-authenticate"));
+ static constexpr auto wwwAuthenticate = "www-authenticate"_s;
+ static constexpr auto proxyAuthenticate = "proxy-authenticate"_s;
static NeverDestroyed<String> realmString(MAKE_STATIC_STRING_IMPL("realm="));
String realm;
- auto authHeader = response.httpHeaderField(response.isUnauthorized() ? wwwAuthenticate : proxyAuthenticate);
+ auto authHeader = response.httpHeaderField(StringView { response.isUnauthorized() ? wwwAuthenticate : proxyAuthenticate });
auto realmPos = authHeader.findIgnoringASCIICase(realmString.get());
if (realmPos != notFound) {
realm = authHeader.substring(realmPos + realmString.get().length());
Modified: trunk/Source/WebCore/platform/network/curl/PublicSuffixCurl.cpp (292476 => 292477)
--- trunk/Source/WebCore/platform/network/curl/PublicSuffixCurl.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/platform/network/curl/PublicSuffixCurl.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -33,7 +33,7 @@
namespace WebCore {
-bool isPublicSuffix(const String& domain)
+bool isPublicSuffix(StringView domain)
{
if (domain.isEmpty())
return false;
@@ -40,7 +40,7 @@
const psl_ctx_t* psl = psl_builtin();
ASSERT(psl);
- bool ret = psl_is_public_suffix2(psl, domain.convertToLowercaseWithoutLocale().utf8().data(), PSL_TYPE_ANY | PSL_TYPE_NO_STAR_RULE);
+ bool ret = psl_is_public_suffix2(psl, domain.toStringWithoutCopying().convertToLowercaseWithoutLocale().utf8().data(), PSL_TYPE_ANY | PSL_TYPE_NO_STAR_RULE);
return ret;
}
Modified: trunk/Source/WebCore/platform/network/soup/SoupNetworkSession.cpp (292476 => 292477)
--- trunk/Source/WebCore/platform/network/soup/SoupNetworkSession.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/platform/network/soup/SoupNetworkSession.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -340,7 +340,7 @@
if (m_ignoreTLSErrors || !tlsErrors)
return std::nullopt;
- auto it = allowedCertificates().find(requestURL.host().toStringWithoutCopying());
+ auto it = allowedCertificates().find<ASCIICaseInsensitiveStringViewHashTranslator>(requestURL.host());
if (it != allowedCertificates().end() && it->value.contains(certificate))
return std::nullopt;
Modified: trunk/Source/WebCore/platform/soup/PublicSuffixSoup.cpp (292476 => 292477)
--- trunk/Source/WebCore/platform/soup/PublicSuffixSoup.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebCore/platform/soup/PublicSuffixSoup.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -33,7 +33,7 @@
namespace WebCore {
-bool isPublicSuffix(const String& domain)
+bool isPublicSuffix(StringView domain)
{
if (domain.isEmpty())
return false;
Modified: trunk/Source/WebKit/ChangeLog (292476 => 292477)
--- trunk/Source/WebKit/ChangeLog 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebKit/ChangeLog 2022-04-06 17:48:44 UTC (rev 292477)
@@ -1,3 +1,35 @@
+2022-04-06 Chris Dumez <cdu...@apple.com>
+
+ Reduce number of conversions from StringView to String
+ https://bugs.webkit.org/show_bug.cgi?id=238841
+
+ Reviewed by Geoffrey Garen.
+
+ * NetworkProcess/NetworkSchemeRegistry.cpp:
+ (WebKit::NetworkSchemeRegistry::shouldTreatURLSchemeAsCORSEnabled):
+ * NetworkProcess/cache/CacheStorageEngineCache.cpp:
+ (WebKit::CacheStorage::updateVaryInformation):
+ * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+ (WebKit::proxyDictionary):
+ * NetworkProcess/soup/NetworkDataTaskSoup.cpp:
+ (WebKit::NetworkDataTaskSoup::shouldAllowHSTSPolicySetting const):
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::decidePolicyForNavigationAction):
+ * WebProcess/Network/WebLoaderStrategy.cpp:
+ (WebKit::WebLoaderStrategy::tryLoadingUsingURLSchemeHandler):
+ (WebKit::WebLoaderStrategy::tryLoadingSynchronouslyUsingURLSchemeHandler):
+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+ (WebKit::WebFrameLoaderClient::representationExistsForURLScheme const):
+ (WebKit::WebFrameLoaderClient::generatedMIMETypeForURLScheme const):
+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
+ * WebProcess/WebPage/WebCookieCache.cpp:
+ (WebKit::WebCookieCache::cookiesForDOM):
+ (WebKit::WebCookieCache::setCookiesFromDOM):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::canHandleRequest):
+ (WebKit::WebPage::urlSchemeHandlerForScheme):
+ * WebProcess/WebPage/WebPage.h:
+
2022-04-06 Kimmo Kinnunen <kkinnu...@apple.com>
ServiceWorkerDownloadTask starts listening for IPC in constructor
Modified: trunk/Source/WebKit/NetworkProcess/NetworkSchemeRegistry.cpp (292476 => 292477)
--- trunk/Source/WebKit/NetworkProcess/NetworkSchemeRegistry.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSchemeRegistry.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -37,7 +37,7 @@
{
if (scheme.startsWith("http"))
return scheme.length() == 4 || (scheme.length() == 5 && scheme[4] == 's');
- return m_corsEnabledSchemes.contains(scheme.toStringWithoutCopying());
+ return m_corsEnabledSchemes.contains<StringViewHashTranslator>(scheme);
}
} // namespace WebKit
Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCache.cpp (292476 => 292477)
--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCache.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCache.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -90,8 +90,7 @@
varyValue.split(',', [&](StringView view) {
if (!recordInformation.hasVaryStar && stripLeadingAndTrailingHTTPSpaces(view) == "*")
recordInformation.hasVaryStar = true;
- String headerName = view.toString();
- recordInformation.varyHeaders.add(headerName, request.httpHeaderField(headerName));
+ recordInformation.varyHeaders.add(view.toString(), request.httpHeaderField(view));
});
if (recordInformation.hasVaryStar)
Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm (292476 => 292477)
--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm 2022-04-06 17:48:44 UTC (rev 292477)
@@ -1168,12 +1168,12 @@
auto dictionary = adoptNS([[NSMutableDictionary alloc] init]);
if (httpProxy.isValid()) {
- [dictionary setObject:httpProxy.host().toString() forKey:(NSString *)kCFStreamPropertyHTTPProxyHost];
+ [dictionary setObject:httpProxy.host().createNSString().get() forKey:(NSString *)kCFStreamPropertyHTTPProxyHost];
if (auto port = httpProxy.port())
[dictionary setObject:@(*port) forKey:(NSString *)kCFStreamPropertyHTTPProxyPort];
}
if (httpsProxy.isValid()) {
- [dictionary setObject:httpsProxy.host().toString() forKey:(NSString *)kCFStreamPropertyHTTPSProxyHost];
+ [dictionary setObject:httpsProxy.host().createNSString().get() forKey:(NSString *)kCFStreamPropertyHTTPSProxyHost];
if (auto port = httpsProxy.port())
[dictionary setObject:@(*port) forKey:(NSString *)kCFStreamPropertyHTTPSProxyPort];
}
Modified: trunk/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp (292476 => 292477)
--- trunk/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -1571,7 +1571,7 @@
#if ENABLE(PUBLIC_SUFFIX_LIST)
return isTopLevelNavigation()
|| m_currentRequest.url().host() == m_currentRequest.firstPartyForCookies().host()
- || isPublicSuffix(m_currentRequest.url().host().toStringWithoutCopying());
+ || isPublicSuffix(m_currentRequest.url().host());
#else
return isTopLevelNavigation()
|| m_currentRequest.url().host() == m_currentRequest.firstPartyForCookies().host();
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (292476 => 292477)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -5539,7 +5539,7 @@
// Other ports do not implement WebPage::platformCanHandleRequest().
#if PLATFORM(COCOA)
// Sandboxed iframes should be allowed to open external apps via custom protocols unless explicitely allowed (https://html.spec.whatwg.org/#hand-off-to-external-software).
- bool canHandleRequest = navigationActionData.canHandleRequest || m_urlSchemeHandlersByScheme.contains(request.url().protocol().toStringWithoutCopying());
+ bool canHandleRequest = navigationActionData.canHandleRequest || m_urlSchemeHandlersByScheme.contains<StringViewHashTranslator>(request.url().protocol());
if (!canHandleRequest && !destinationFrameInfo->isMainFrame() && !frameSandboxAllowsOpeningExternalCustomProtocols(navigationActionData.effectiveSandboxFlags, !!navigationActionData.userGestureTokenIdentifier)) {
if (!sourceFrameInfo || !m_preferences->needsSiteSpecificQuirks() || !Quirks::shouldAllowNavigationToCustomProtocolWithoutUserGesture(request.url().protocol(), sourceFrameInfo->securityOrigin())) {
WEBPAGEPROXY_RELEASE_LOG_ERROR(Process, "Ignoring request to load this main resource because it has a custom protocol and comes from a sandboxed iframe");
Modified: trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp (292476 => 292477)
--- trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -263,7 +263,7 @@
if (!webPage)
return false;
- auto* handler = webPage->urlSchemeHandlerForScheme(resourceLoader.request().url().protocol().toStringWithoutCopying());
+ auto* handler = webPage->urlSchemeHandlerForScheme(resourceLoader.request().url().protocol());
if (!handler)
return false;
@@ -633,7 +633,7 @@
if (!webPage)
return std::nullopt;
- auto* handler = webPage->urlSchemeHandlerForScheme(request.url().protocol().toStringWithoutCopying());
+ auto* handler = webPage->urlSchemeHandlerForScheme(request.url().protocol());
if (!handler)
return std::nullopt;
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (292476 => 292477)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -1385,13 +1385,13 @@
return true;
}
-bool WebFrameLoaderClient::representationExistsForURLScheme(const String& /*URLScheme*/) const
+bool WebFrameLoaderClient::representationExistsForURLScheme(StringView /*URLScheme*/) const
{
notImplemented();
return false;
}
-String WebFrameLoaderClient::generatedMIMETypeForURLScheme(const String& /*URLScheme*/) const
+String WebFrameLoaderClient::generatedMIMETypeForURLScheme(StringView /*URLScheme*/) const
{
notImplemented();
return String();
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h (292476 => 292477)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h 2022-04-06 17:48:44 UTC (rev 292477)
@@ -186,8 +186,8 @@
bool canHandleRequest(const WebCore::ResourceRequest&) const final;
bool canShowMIMEType(const String& MIMEType) const final;
bool canShowMIMETypeAsHTML(const String& MIMEType) const final;
- bool representationExistsForURLScheme(const String& URLScheme) const final;
- String generatedMIMETypeForURLScheme(const String& URLScheme) const final;
+ bool representationExistsForURLScheme(StringView URLScheme) const final;
+ String generatedMIMETypeForURLScheme(StringView URLScheme) const final;
void frameLoadCompleted() final;
void saveViewStateToItem(WebCore::HistoryItem&) final;
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebCookieCache.cpp (292476 => 292477)
--- trunk/Source/WebKit/WebProcess/WebPage/WebCookieCache.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebCookieCache.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -46,14 +46,14 @@
String WebCookieCache::cookiesForDOM(const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, FrameIdentifier frameID, PageIdentifier pageID, IncludeSecureCookies includeSecureCookies)
{
- String host = url.host().toString();
- if (!m_hostsWithInMemoryStorage.contains(host)) {
+ if (!m_hostsWithInMemoryStorage.contains<StringViewHashTranslator>(url.host())) {
+ auto host = url.host().toString();
Vector<Cookie> cookies;
bool subscribeToCookieChangeNotifications = true;
- if (!WebProcess::singleton().ensureNetworkProcessConnection().connection().sendSync(Messages::NetworkConnectionToWebProcess::DomCookiesForHost(url.host().toString(), subscribeToCookieChangeNotifications), Messages::NetworkConnectionToWebProcess::DomCookiesForHost::Reply(cookies), 0))
+ if (!WebProcess::singleton().ensureNetworkProcessConnection().connection().sendSync(Messages::NetworkConnectionToWebProcess::DomCookiesForHost(host, subscribeToCookieChangeNotifications), Messages::NetworkConnectionToWebProcess::DomCookiesForHost::Reply(cookies), 0))
return { };
pruneCacheIfNecessary();
- m_hostsWithInMemoryStorage.add(host);
+ m_hostsWithInMemoryStorage.add(WTFMove(host));
for (auto& cookie : cookies)
inMemoryStorageSession().setCookie(cookie);
}
@@ -62,8 +62,7 @@
void WebCookieCache::setCookiesFromDOM(const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, FrameIdentifier frameID, PageIdentifier pageID, const String& cookieString, ShouldRelaxThirdPartyCookieBlocking shouldRelaxThirdPartyCookieBlocking)
{
- String host = url.host().toString();
- if (m_hostsWithInMemoryStorage.contains(host))
+ if (m_hostsWithInMemoryStorage.contains<StringViewHashTranslator>(url.host()))
inMemoryStorageSession().setCookiesFromDOM(firstParty, sameSiteInfo, url, frameID, pageID, ShouldAskITP::No, cookieString, shouldRelaxThirdPartyCookieBlocking);
}
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (292476 => 292477)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -5871,7 +5871,7 @@
bool WebPage::canHandleRequest(const WebCore::ResourceRequest& request)
{
- if (LegacySchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(request.url().protocol().toStringWithoutCopying()))
+ if (LegacySchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(request.url().protocol()))
return true;
if (request.url().protocolIsBlob())
@@ -7220,9 +7220,9 @@
static_cast<WebFrameLoaderClient&>(corePage()->mainFrame().loader().client()).setUseIconLoadingClient(useIconLoadingClient);
}
-WebURLSchemeHandlerProxy* WebPage::urlSchemeHandlerForScheme(const String& scheme)
+WebURLSchemeHandlerProxy* WebPage::urlSchemeHandlerForScheme(StringView scheme)
{
- return m_schemeToURLSchemeHandlerProxyMap.get(scheme);
+ return m_schemeToURLSchemeHandlerProxyMap.get<StringViewHashTranslator>(scheme);
}
void WebPage::stopAllURLSchemeTasks()
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (292476 => 292477)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2022-04-06 17:48:44 UTC (rev 292477)
@@ -1289,7 +1289,7 @@
void didFinishLoadingImageForElement(WebCore::HTMLImageElement&);
- WebURLSchemeHandlerProxy* urlSchemeHandlerForScheme(const String&);
+ WebURLSchemeHandlerProxy* urlSchemeHandlerForScheme(StringView);
void stopAllURLSchemeTasks();
std::optional<double> cpuLimit() const { return m_cpuLimit; }
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (292476 => 292477)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2022-04-06 17:48:44 UTC (rev 292477)
@@ -1,3 +1,15 @@
+2022-04-06 Chris Dumez <cdu...@apple.com>
+
+ Reduce number of conversions from StringView to String
+ https://bugs.webkit.org/show_bug.cgi?id=238841
+
+ Reviewed by Geoffrey Garen.
+
+ * WebCoreSupport/WebFrameLoaderClient.h:
+ * WebCoreSupport/WebFrameLoaderClient.mm:
+ (WebFrameLoaderClient::representationExistsForURLScheme const):
+ (WebFrameLoaderClient::generatedMIMETypeForURLScheme const):
+
2022-04-06 Simon Fraser <simon.fra...@apple.com>
Unify the two ImageBuffer::create() functions, passing RenderingPurpose everywhere
Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h (292476 => 292477)
--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h 2022-04-06 17:48:44 UTC (rev 292477)
@@ -193,8 +193,8 @@
bool canHandleRequest(const WebCore::ResourceRequest&) const final;
bool canShowMIMEType(const WTF::String& MIMEType) const final;
bool canShowMIMETypeAsHTML(const WTF::String& MIMEType) const final;
- bool representationExistsForURLScheme(const WTF::String& URLScheme) const final;
- WTF::String generatedMIMETypeForURLScheme(const WTF::String& URLScheme) const final;
+ bool representationExistsForURLScheme(WTF::StringView URLScheme) const final;
+ WTF::String generatedMIMETypeForURLScheme(WTF::StringView URLScheme) const final;
void frameLoadCompleted() final;
void saveViewStateToItem(WebCore::HistoryItem&) final;
Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm (292476 => 292477)
--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm 2022-04-06 17:48:44 UTC (rev 292477)
@@ -1186,14 +1186,14 @@
return [WebView canShowMIMETypeAsHTML:MIMEType];
}
-bool WebFrameLoaderClient::representationExistsForURLScheme(const String& URLScheme) const
+bool WebFrameLoaderClient::representationExistsForURLScheme(StringView URLScheme) const
{
- return [WebView _representationExistsForURLScheme:URLScheme];
+ return [WebView _representationExistsForURLScheme:URLScheme.createNSString().get()];
}
-String WebFrameLoaderClient::generatedMIMETypeForURLScheme(const String& URLScheme) const
+String WebFrameLoaderClient::generatedMIMETypeForURLScheme(StringView URLScheme) const
{
- return [WebView _generatedMIMETypeForURLScheme:URLScheme];
+ return [WebView _generatedMIMETypeForURLScheme:URLScheme.createNSString().get()];
}
void WebFrameLoaderClient::frameLoadCompleted()
Modified: trunk/Source/WebKitLegacy/win/ChangeLog (292476 => 292477)
--- trunk/Source/WebKitLegacy/win/ChangeLog 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebKitLegacy/win/ChangeLog 2022-04-06 17:48:44 UTC (rev 292477)
@@ -1,3 +1,15 @@
+2022-04-06 Chris Dumez <cdu...@apple.com>
+
+ Reduce number of conversions from StringView to String
+ https://bugs.webkit.org/show_bug.cgi?id=238841
+
+ Reviewed by Geoffrey Garen.
+
+ * WebCoreSupport/WebFrameLoaderClient.cpp:
+ (WebFrameLoaderClient::representationExistsForURLScheme const):
+ (WebFrameLoaderClient::generatedMIMETypeForURLScheme const):
+ * WebCoreSupport/WebFrameLoaderClient.h:
+
2022-04-05 Chris Dumez <cdu...@apple.com>
Unreviewed WinCairo build fix after r292408.
Modified: trunk/Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.cpp (292476 => 292477)
--- trunk/Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.cpp 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.cpp 2022-04-06 17:48:44 UTC (rev 292477)
@@ -814,13 +814,13 @@
return m_webFrame->webView()->canShowMIMETypeAsHTML(mimeType);
}
-bool WebFrameLoaderClient::representationExistsForURLScheme(const String& /*URLScheme*/) const
+bool WebFrameLoaderClient::representationExistsForURLScheme(StringView /*URLScheme*/) const
{
notImplemented();
return false;
}
-String WebFrameLoaderClient::generatedMIMETypeForURLScheme(const String& /*URLScheme*/) const
+String WebFrameLoaderClient::generatedMIMETypeForURLScheme(StringView /*URLScheme*/) const
{
notImplemented();
ASSERT_NOT_REACHED();
Modified: trunk/Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.h (292476 => 292477)
--- trunk/Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.h 2022-04-06 17:46:23 UTC (rev 292476)
+++ trunk/Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.h 2022-04-06 17:48:44 UTC (rev 292477)
@@ -154,8 +154,8 @@
bool canHandleRequest(const WebCore::ResourceRequest&) const override;
bool canShowMIMEType(const WTF::String& MIMEType) const override;
bool canShowMIMETypeAsHTML(const WTF::String& MIMEType) const override;
- bool representationExistsForURLScheme(const WTF::String& URLScheme) const override;
- WTF::String generatedMIMETypeForURLScheme(const WTF::String& URLScheme) const override;
+ bool representationExistsForURLScheme(WTF::StringView URLScheme) const override;
+ WTF::String generatedMIMETypeForURLScheme(WTF::StringView URLScheme) const override;
void frameLoadCompleted() override;
void saveViewStateToItem(WebCore::HistoryItem&) override;