Skip to content
Permalink
Browse files
Start preparing the code base for marking the StringView(const char*)…
… constructor explicit

https://bugs.webkit.org/show_bug.cgi?id=240687

Reviewed by Darin Adler.

Start preparing the code base for marking the StringView(const char*) constructor explicit.
This encourages people to ensure ASCIILiteral / ""_s whenever possible.

* Source/JavaScriptCore/API/JSAPIGlobalObject.mm:
(JSC::computeValidImportSpecifier):
* Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp:
(Inspector::isWebKitInjectedScript):
* Source/JavaScriptCore/jit/ExecutableAllocator.cpp:
(JSC::dumpJITMemory):
* Source/JavaScriptCore/jsc.cpp:
(GlobalObject::moduleLoaderImportModule):
(GlobalObject::moduleLoaderResolve):
* Source/JavaScriptCore/runtime/FileBasedFuzzerAgent.cpp:
(JSC::FileBasedFuzzerAgent::getPredictionInternal):
* Source/JavaScriptCore/runtime/IntlLocale.cpp:
(JSC::IntlLocale::initializeLocale):
* Source/JavaScriptCore/runtime/IntlObject.cpp:
(JSC::isValidTimeZoneNameFromICUTimeZone):
* Source/JavaScriptCore/runtime/TypeProfiler.cpp:
(JSC::TypeProfiler::logTypesForTypeLocation):
* Source/JavaScriptCore/testRegExp.cpp:
(parseRegExpLine):
* Source/JavaScriptCore/yarr/YarrUnicodeProperties.cpp:
(JSC::Yarr::HashTable::entry const):
* Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
(WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection):
* Source/WebKit/UIProcess/PageLoadState.cpp:
(WebKit::PageLoadState::hasOnlySecureContent):
* Source/WebKit/UIProcess/mac/WKImmediateActionController.mm:
(-[WKImmediateActionController _defaultAnimationController]):
* Source/WebKitLegacy/mac/WebView/WebImmediateActionController.mm:
(-[WebImmediateActionController _defaultAnimationController]):
* Source/WTF/wtf/DateMath.cpp:
(WTF::parseDateFromNullTerminatedCharacters):
* Source/WTF/wtf/SortedArrayMap.h:
(WTF::operator<):
* Source/WTF/wtf/URL.cpp:
(WTF::URL::hasSpecialScheme const):
(WTF::URL::setPath):
(WTF::protocolIsInternal):
(WTF::protocolIs):
(WTF::URL::isLocalFile const):
(WTF::protocolIsJavaScript):
(WTF::URL::protocolIsAbout const):
(WTF::portAllowed):
(WTF::mimeTypeFromDataURL):
(WTF::URL::isAboutBlank const):
(WTF::URL::isAboutSrcDoc const):
* Source/WTF/wtf/URL.h:
(WTF::URL::protocolIsBlob const):
(WTF::URL::protocolIsData const):
* Source/WTF/wtf/URLHelpers.cpp:
(WTF::URLHelpers::applyHostNameFunctionToURLString):
* Source/WTF/wtf/URLParser.cpp:
(WTF::URLParser::copyBaseWindowsDriveLetter):
(WTF::URLParser::URLParser):
(WTF::URLParser::parse):
* Source/WTF/wtf/text/ASCIILiteral.h:
* Source/WTF/wtf/text/StringView.h:
(WTF::operator==):
(WTF::operator!=):
(WTF::equal):
* Source/WebCore/Modules/applepay/PaymentSession.cpp:
(WebCore::isSecure):
* Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp:
(WebCore::resolveRelativeVirtualPath):
(WebCore::DOMFileSystem::getParent):
* Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp:
(WebCore::FetchBodyConsumer::packageFormData):
* Source/WebCore/Modules/indexeddb/server/IDBServer.cpp:
(WebCore::IDBServer::removeAllDatabasesForFullOriginPath):
* Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::databasesSizeForDirectory):
* Source/WebCore/Modules/mediasource/MediaSource.cpp:
(WebCore::addVP9FullRangeVideoFlagToContentType):
* Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp:
(WebCore::shouldIgnoreIceCandidate):
* Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::iceServersFromConfiguration):
* Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::isValidURLBasedPaymentMethodIdentifier):
* Source/WebCore/Modules/plugins/YouTubePluginReplacement.cpp:
(WebCore::YouTubePluginReplacement::youTubeURLFromAbsoluteURL):
* Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.cpp:
(WebCore::AuthenticatorCoordinatorInternal::needsAppIdQuirks):
* Source/WebCore/Modules/webdatabase/Database.cpp:
(WebCore::fullyQualifiedInfoTableName):
* Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp:
(WebCore::DatabaseTracker::usage):
* Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp:
(WebCore::ThreadableWebSocketChannel::validateURL):
* Source/WebCore/Modules/websockets/WebSocket.cpp:
(WebCore::WebSocket::connect):
(WebCore::WebSocket::didUpgradeURL):
* Source/WebCore/Modules/websockets/WebSocketHandshake.cpp:
(WebCore::hostName):
(WebCore::WebSocketHandshake::WebSocketHandshake):
(WebCore::WebSocketHandshake::httpURLForAuthenticationAndCookies const):
(WebCore::headerHasValidHTTPVersion):
* Source/WebCore/accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::handleAttributeChange):
* Source/WebCore/accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::isSearchField const):
* Source/WebCore/accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::ariaLandmarkRoleDescription const):
* Source/WebCore/accessibility/mac/AccessibilityObjectMac.mm:
(WebCore::AccessibilityObject::rolePlatformDescription const):
* Source/WebCore/animation/KeyframeEffect.cpp:
(WebCore::KeyframeEffect::setPseudoElement):
* Source/WebCore/bindings/js/ScriptModuleLoader.cpp:
(WebCore::resolveModuleSpecifier):
* Source/WebCore/contentextensions/ContentExtensionsBackend.cpp:
(WebCore::ContentExtensions::ContentExtensionsBackend::processContentRuleListsForLoad):
(WebCore::ContentExtensions::ContentExtensionsBackend::processContentRuleListsForPingLoad):
(WebCore::ContentExtensions::applyResultsToRequest):
* Source/WebCore/css/CSSFontFaceSrcValue.cpp:
(WebCore::CSSFontFaceSrcValue::isSupportedFormat const):
* Source/WebCore/css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::formatInfiniteOrNanValue const):
(WebCore::CSSPrimitiveValue::formatNumberValue const):
(WebCore::CSSPrimitiveValue::formatIntegerValue const):
(WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText const):
* Source/WebCore/css/CSSPrimitiveValue.h:
* Source/WebCore/css/CSSSelector.cpp:
(WebCore::CSSSelector::parsePseudoElementType):
* Source/WebCore/css/ContainerQueryParser.cpp:
(WebCore::ContainerQueryParser::consumePlainSizeFeature):
* Source/WebCore/css/DOMCSSNamespace.cpp:
(WebCore::valueWithoutImportant):
* Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:
(WebCore::CSSPropertyParserHelpers::consumeDashedIdent):
* Source/WebCore/css/parser/CSSSelectorParser.cpp:
(WebCore::consumeLangArgumentList):
* Source/WebCore/css/typedom/CSSOMVariableReferenceValue.cpp:
(WebCore::CSSOMVariableReferenceValue::create):
(WebCore::CSSOMVariableReferenceValue::setVariable):
* Source/WebCore/dom/ConstantPropertyMap.cpp:
(WebCore::variableDataForPositivePixelLength):
(WebCore::variableDataForPositiveDuration):
* Source/WebCore/dom/DataTransfer.cpp:
(WebCore::normalizeType):
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::isCookieAverse const):
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::isEventHandlerAttribute const):
* Source/WebCore/dom/TextDecoder.cpp:
(WebCore::TextDecoder::encoding const):
* Source/WebCore/editing/cocoa/HTMLConverter.mm:
(HTMLConverterCaches::isBlockElement):
(HTMLConverter::computedAttributesForElement):
(HTMLConverter::_processText):
* Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm:
(WebCore::stripMicrosoftPrefix):
* Source/WebCore/editing/markup.cpp:
(WebCore::shouldPreserveMSOLists):
* Source/WebCore/fileapi/BlobURL.cpp:
* Source/WebCore/html/FeaturePolicy.cpp:
(WebCore::FeaturePolicy::parse):
* Source/WebCore/html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::parseAttribute):
* Source/WebCore/html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::formWouldHaveSecureSubmission):
* Source/WebCore/html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::process):
* Source/WebCore/html/HTMLMediaElement.cpp:
* Source/WebCore/html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::hasValidClassId):
* Source/WebCore/html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::isImageType):
* Source/WebCore/html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::handleBeforeTextInsertedEvent):
* Source/WebCore/html/URLDecomposition.cpp:
(WebCore::URLDecomposition::setUsername):
(WebCore::URLDecomposition::setPassword):
(WebCore::URLDecomposition::setHost):
(WebCore::URLDecomposition::setHostname):
* Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::State::fontString const):
* Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::getActiveUniform):
(WebCore::WebGLRenderingContextBase::getUniformLocation):
* Source/WebCore/html/parser/CSSPreloadScanner.cpp:
(WebCore::hasValidImportConditions):
* Source/WebCore/html/parser/HTMLMetaCharsetParser.cpp:
(WebCore::extractCharset):
* Source/WebCore/html/parser/HTMLPreloadScanner.cpp:
(WebCore::TokenPreloadScanner::StartTagScanner::shouldPreload):
* Source/WebCore/html/track/WebVTTParser.cpp:
* Source/WebCore/inspector/DOMPatchSupport.cpp:
* Source/WebCore/inspector/InspectorFrontendHost.cpp:
(WebCore::InspectorFrontendHost::revealFileExternally):
* Source/WebCore/inspector/InspectorStyleSheet.cpp:
(WebCore::StyleSheetHandler::observeComment):
(WebCore::lowercasePropertyName):
(WebCore::selectorsFromSource):
* Source/WebCore/loader/CookieJar.cpp:
(WebCore::CookieJar::shouldIncludeSecureCookies):
* Source/WebCore/loader/CustomHeaderFields.cpp:
(WebCore::CustomHeaderFields::thirdPartyDomainsMatch const):
* Source/WebCore/loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* Source/WebCore/loader/FrameLoader.cpp:
(WebCore::FrameLoader::open):
* Source/WebCore/loader/PolicyChecker.cpp:
(WebCore::FrameLoader::PolicyChecker::checkNavigationPolicy):
* Source/WebCore/loader/PrivateClickMeasurement.cpp:
(WebCore::PrivateClickMeasurement::parseAttributionRequest):
* Source/WebCore/loader/ResourceLoader.cpp:
(WebCore::ResourceLoader::isPDFJSResourceLoad const):
* Source/WebCore/loader/appcache/ApplicationCacheManifestParser.cpp:
(WebCore::parseApplicationCacheManifest):
* Source/WebCore/loader/archive/ArchiveResourceCollection.cpp:
(WebCore::ArchiveResourceCollection::archiveResourceForURL):
* Source/WebCore/loader/cache/CachedResource.cpp:
(WebCore::CachedResource::makeRevalidationDecision const):
* Source/WebCore/loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::requestResource):
* Source/WebCore/page/ContextMenuController.cpp:
(WebCore::ContextMenuController::checkOrEnableIfNeeded const):
* Source/WebCore/page/EventHandler.cpp:
(WebCore::hasDropZoneType):
* Source/WebCore/page/Frame.cpp:
(WebCore::createRegExpForLabels):
(WebCore::matchLabelsAgainstString):
* Source/WebCore/page/Page.cpp:
(WebCore::Page::userStyleSheetLocationChanged):
(WebCore::Page::allowsLoadFromURL const):
* Source/WebCore/page/Quirks.cpp:
(WebCore::isYahooMail):
(WebCore::Quirks::shouldDisableContentChangeObserverTouchEventAdjustment const):
(WebCore::Quirks::shouldHideSearchFieldResultsButton const):
(WebCore::Quirks::isAmazon const):
(WebCore::Quirks::isGoogleMaps const):
(WebCore::Quirks::shouldDispatchSimulatedMouseEvents const):
(WebCore::Quirks::shouldDispatchedSimulatedMouseEventsAssumeDefaultPrevented const):
(WebCore::Quirks::simulatedMouseEventTypeForTarget const):
(WebCore::Quirks::shouldPreventPointerMediaQueryFromEvaluatingToCoarse const):
(WebCore::Quirks::shouldAvoidResizingWhenInputViewBoundsChange const):
(WebCore::Quirks::shouldDisablePointerEventsQuirk const):
(WebCore::Quirks::needsInputModeNoneImplicitly const):
(WebCore::Quirks::needsFullscreenDisplayNoneQuirk const):
(WebCore::Quirks::shouldSilenceWindowResizeEvents const):
(WebCore::Quirks::shouldSilenceMediaQueryListChangeEvents const):
(WebCore::Quirks::shouldUseLegacySelectPopoverDismissalBehaviorInDataActivation const):
(WebCore::Quirks::shouldOpenAsAboutBlank const):
(WebCore::Quirks::shouldBypassBackForwardCache const):
(WebCore::Quirks::shouldBypassAsyncScriptDeferring const):
(WebCore::Quirks::shouldMakeEventListenerPassive):
(WebCore::Quirks::shouldDisableElementFullscreenQuirk const):
(WebCore::Quirks::needsCanPlayAfterSeekedQuirk const):
(WebCore::Quirks::shouldLayOutAtMinimumWindowWidthWhenIgnoringScalingConstraints const):
(WebCore::Quirks::shouldIgnoreContentObservationForSyntheticClick const):
(WebCore::isKinjaLoginAvatarElement):
(WebCore::Quirks::isMicrosoftTeamsRedirectURL):
(WebCore::Quirks::needsBlackFullscreenBackgroundQuirk const):
(WebCore::Quirks::needsToForceUserSelectAndUserDragWhenInstallingImageOverlay const):
* Source/WebCore/page/SecurityOrigin.cpp:
(WebCore::schemeRequiresHost):
(WebCore::SecurityOrigin::shouldIgnoreHost):
(WebCore::shouldTreatAsUniqueOrigin):
(WebCore::isLoopbackIPAddress):
(WebCore::SecurityOrigin::isLocalHostOrLoopbackIPAddress):
* Source/WebCore/page/SecurityPolicy.cpp:
(WebCore::SecurityPolicy::shouldHideReferrer):
(WebCore::SecurityPolicy::generateOriginHeader):
* Source/WebCore/page/UserContentURLPattern.cpp:
(WebCore::UserContentURLPattern::parse):
* Source/WebCore/page/cocoa/ResourceUsageThreadCocoa.mm:
(WebCore::ResourceUsageThread::platformCollectCPUData):
* Source/WebCore/page/csp/ContentSecurityPolicy.cpp:
(WebCore::shouldReportProtocolOnly):
(WebCore::ContentSecurityPolicy::upgradeInsecureRequestIfNeeded const):
(WebCore::ContentSecurityPolicy::setUpgradeInsecureRequests):
* Source/WebCore/page/csp/ContentSecurityPolicySource.cpp:
(WebCore::ContentSecurityPolicySource::portMatches const):
* Source/WebCore/page/csp/ContentSecurityPolicySourceList.cpp:
(WebCore::ContentSecurityPolicySourceList::isProtocolAllowedByStar const):
* Source/WebCore/platform/MIMETypeRegistry.cpp:
(WebCore::MIMETypeRegistry::isSupportedJSONMIMEType):
(WebCore::MIMETypeRegistry::isXMLMIMEType):
* Source/WebCore/platform/cocoa/RuntimeApplicationChecksCocoa.mm:
(WebCore::MacApplication::isSafari):
* Source/WebCore/platform/graphics/Image.cpp:
(WebCore::Image::isPDFResource):
(WebCore::Image::isPostScriptResource):
* Source/WebCore/platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::CDMFactoryFairPlayStreaming::supportsKeySystem):
* Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
(WebCore::MediaPlayerPrivateAVFoundation::isUnsupportedMIMEType):
* Source/WebCore/platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.mm:
(WebCore::AVAssetMIMETypeCache::isUnsupportedContainerType):
* Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::fontWithFamilySpecialCase):
* Source/WebCore/platform/graphics/cocoa/MediaEngineConfigurationFactoryCocoa.cpp:
(WebCore::videoCodecTypeFromRFC4281Type):
(WebCore::computeMediaCapabilitiesInfo):
* Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp:
(WebCore::SourceBufferParserWebM::isContentTypeSupported):
* Source/WebCore/platform/mac/UserAgentMac.mm:
(WebCore::standardUserAgentWithApplicationName):
* Source/WebCore/platform/mediastream/mac/CoreAudioCaptureDeviceManager.cpp:
(WebCore::isValidCaptureDevice):
* Source/WebCore/platform/network/CacheValidation.cpp:
(WebCore::parseCacheControlDirectives):
(WebCore::cookieRequestHeaderFieldValue):
* Source/WebCore/platform/network/DataURLDecoder.cpp:
(WebCore::DataURLDecoder::DecodeTask::process):
* Source/WebCore/platform/network/HTTPParsers.cpp:
(WebCore::extractCharsetFromMediaType):
* Source/WebCore/platform/network/ParsedContentRange.cpp:
(WebCore::parseContentRange):
* Source/WebCore/platform/network/ParsedRequestRange.cpp:
(WebCore::ParsedRequestRange::parse):
* Source/WebCore/platform/network/ResourceHandle.cpp:
(WebCore::ResourceHandle::shouldContentSniffURL):
* Source/WebCore/platform/network/ResourceRequestBase.cpp:
(WebCore::ResourceRequestBase::redirectedRequest const):
* Source/WebCore/platform/network/ResourceResponseBase.cpp:
(WebCore::ResourceResponseBase::isHTTP09 const):
* Source/WebCore/platform/network/cf/SocketStreamHandleImpl.h:
(WebCore::SocketStreamHandleImpl::shouldUseSSL const):
* Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp:
(WebCore::SocketStreamHandleImpl::SocketStreamHandleImpl):
* Source/WebCore/platform/network/mac/ResourceHandleMac.mm:
(WebCore::ResourceHandle::willSendRequest):
* Source/WebCore/plugins/PluginData.cpp:
(WebCore::shouldBePubliclyVisible):
* Source/WebCore/rendering/HitTestResult.cpp:
(WebCore::HitTestResult::absolutePDFURL const):
* Source/WebCore/rendering/RenderListMarker.cpp:
(WebCore::listMarkerSuffix):
* Source/WebCore/svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::scrollToFragment):
* Source/WebCore/svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::parseOffsetValue):
(WebCore::SVGSMILElement::parseCondition):
* Source/WebCore/workers/Worker.cpp:
(WebCore::Worker::didReceiveResponse):
* Source/WebCore/workers/service/ServiceWorkerContainer.cpp:
(WebCore::ServiceWorkerContainer::addRegistration):
* Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::shouldAllowExternalLoad):

Canonical link: https://commits.webkit.org/250837@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294611 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
cdumez committed May 21, 2022
1 parent c989ce3 commit c68178ddc01939b4bce3cdb9718c62087649dad4
Showing 139 changed files with 464 additions and 456 deletions.
@@ -86,7 +86,7 @@
if (absoluteURL.isValid())
return absoluteURL;

if (!specifier.startsWith('/') && !specifier.startsWith("./") && !specifier.startsWith("../"))
if (!specifier.startsWith('/') && !specifier.startsWith("./"_s) && !specifier.startsWith("../"_s))
return makeUnexpected(makeString("Module specifier: "_s, specifier, " does not start with \"/\", \"./\", or \"../\". Referenced from: "_s, base.string()));

if (specifier.startsWith('/')) {
@@ -62,7 +62,7 @@ static String objectGroupForBreakpointAction(JSC::BreakpointActionID id)

static bool isWebKitInjectedScript(const String& sourceURL)
{
return sourceURL.startsWith("__InjectedScript_") && sourceURL.endsWith(".js");
return sourceURL.startsWith("__InjectedScript_"_s) && sourceURL.endsWith(".js"_s);
}

static std::optional<JSC::Breakpoint::Action::Type> breakpointActionTypeForString(Protocol::ErrorString& errorString, const String& typeString)
@@ -1173,7 +1173,7 @@ void dumpJITMemory(const void* dst, const void* src, size_t size)
{
if (fd == -1) {
auto path = String::fromLatin1(Options::dumpJITMemoryPath());
path = makeStringByReplacingAll(path, "%pid", String::number(getCurrentProcessID()));
path = makeStringByReplacingAll(path, "%pid"_s, String::number(getCurrentProcessID()));
fd = open(FileSystem::fileSystemRepresentation(path).data(), O_CREAT | O_TRUNC | O_APPEND | O_WRONLY | O_EXLOCK | O_NONBLOCK, 0666);
RELEASE_ASSERT(fd != -1);
}
@@ -870,7 +870,7 @@ JSInternalPromise* GlobalObject::moduleLoaderImportModule(JSGlobalObject* global
if (!referrer.isLocalFile())
RELEASE_AND_RETURN(scope, rejectWithError(createError(globalObject, makeString("Could not resolve the referrer's path '", referrer.string(), "', while trying to resolve module '", specifier, "'."))));

if (!specifier.startsWith('/') && !specifier.startsWith("./") && !specifier.startsWith("../"))
if (!specifier.startsWith('/') && !specifier.startsWith("./"_s) && !specifier.startsWith("../"_s))
RELEASE_AND_RETURN(scope, rejectWithError(createTypeError(globalObject, makeString("Module specifier, '"_s, specifier, "' does not start with \"/\", \"./\", or \"../\". Referenced from: "_s, referrer.fileSystemPath()))));

URL moduleURL(referrer, specifier);
@@ -897,7 +897,7 @@ Identifier GlobalObject::moduleLoaderResolve(JSGlobalObject* globalObject, JSMod

auto resolvePath = [&] (const URL& directoryURL) -> Identifier {
String specifier = key.impl();
if (!specifier.startsWith('/') && !specifier.startsWith("./") && !specifier.startsWith("../")) {
if (!specifier.startsWith('/') && !specifier.startsWith("./"_s) && !specifier.startsWith("../"_s)) {
throwTypeError(globalObject, scope, makeString("Module specifier, '"_s, specifier, "' does not start with \"/\", \"./\", or \"../\". Referenced from: "_s, directoryURL.fileSystemPath()));
return { };
}
@@ -1098,7 +1098,7 @@ class ShellSourceProvider final : public StringSourceProvider {
return { };
const char* cachePath = Options::diskCachePath();
String filename = FileSystem::encodeForFileName(FileSystem::lastComponentOfPathIgnoringTrailingSlash(sourceOrigin().url().fileSystemPath()));
return FileSystem::pathByAppendingComponent(cachePath, makeString(source().hash(), '-', filename, ".bytecode-cache"));
return FileSystem::pathByAppendingComponent(StringView::fromLatin1(cachePath), makeString(source().hash(), '-', filename, ".bytecode-cache"_s));
}

void loadBytecode() const
@@ -72,17 +72,17 @@ SpeculatedType FileBasedFuzzerAgent::getPredictionInternal(CodeBlock* codeBlock,

case op_call: // op_call appears implicitly in for-of loops, generators, spread/rest elements, destructuring assignment
if (!generated) {
if (sourceAfterDivot.containsIgnoringASCIICase("of "))
if (sourceAfterDivot.containsIgnoringASCIICase("of "_s))
return original;
if (sourceAfterDivot.containsIgnoringASCIICase("..."))
if (sourceAfterDivot.containsIgnoringASCIICase("..."_s))
return original;
if (sourceAfterDivot.containsIgnoringASCIICase("yield"))
if (sourceAfterDivot.containsIgnoringASCIICase("yield"_s))
return original;
if (sourceAfterDivot.startsWith('[') && sourceAfterDivot.endsWith(']'))
return original;
if (sourceUpToDivot.containsIgnoringASCIICase("yield"))
if (sourceUpToDivot.containsIgnoringASCIICase("yield"_s))
return original;
if (sourceUpToDivot == "...")
if (sourceUpToDivot == "..."_s)
return original;
if (!target.startOffset && !target.endOffset)
return original;
@@ -308,7 +308,7 @@ void IntlLocale::initializeLocale(JSGlobalObject* globalObject, const String& ta
TriState numeric = intlBooleanOption(globalObject, options, vm.propertyNames->numeric);
RETURN_IF_EXCEPTION(scope, void());
if (numeric != TriState::Indeterminate)
localeID.setKeywordValue("colnumeric"_s, numeric == TriState::True ? "yes" : "no");
localeID.setKeywordValue("colnumeric"_s, numeric == TriState::True ? "yes"_s : "no"_s);

String numberingSystem = intlStringOption(globalObject, options, vm.propertyNames->numberingSystem, { }, { }, { });
RETURN_IF_EXCEPTION(scope, void());
@@ -1795,9 +1795,9 @@ static bool isValidTimeZoneNameFromICUTimeZone(StringView timeZoneName)
{
// Some time zone names are included in ICU, but they are not included in the IANA Time Zone Database.
// We need to filter them out.
if (timeZoneName.startsWith("SystemV/"))
if (timeZoneName.startsWith("SystemV/"_s))
return false;
if (timeZoneName.startsWith("Etc/"))
if (timeZoneName.startsWith("Etc/"_s))
return isUTCEquivalent(timeZoneName);
// IANA time zone names include '/'. Some of them are not including, but it is in backward links.
// And ICU already resolved these backward links.
@@ -53,7 +53,7 @@ void TypeProfiler::logTypesForTypeLocation(TypeLocation* location, VM& vm)

dataLog("\t\t", location->m_globalVariableID == TypeProfilerReturnStatement ? "[Return Statement]" : "[Normal Statement]", "\n");

dataLog("\t\t#Local#\n\t\t", makeStringByReplacingAll(location->m_instructionTypeSet->dumpTypes(), "\n", "\n\t\t"), "\n");
dataLog("\t\t#Local#\n\t\t", makeStringByReplacingAll(location->m_instructionTypeSet->dumpTypes(), '\n', "\n\t\t"_s), "\n");
if (location->m_globalTypeSet)
dataLog("\t\t#Global#\n\t\t", makeStringByReplacingAll(location->m_globalTypeSet->dumpTypes(), '\n', "\n\t\t"_s), "\n");
}
@@ -318,7 +318,7 @@ static RegExp* parseRegExpLine(VM& vm, char* line, int lineLength, const char**

++i;

auto flags = Yarr::parseFlags(line + i);
auto flags = Yarr::parseFlags(StringView::fromLatin1(line + i));
if (!flags) {
*regexpError = Yarr::errorMessage(Yarr::ErrorCode::InvalidRegularExpressionFlags);
return nullptr;
@@ -57,7 +57,7 @@ struct HashTable {
return -1;

while (true) {
if (WTF::equal(key, values[valueIndex].key))
if (WTF::equal(key, StringView::fromLatin1(values[valueIndex].key)))
return values[valueIndex].index;

indexEntry = index[indexEntry].next;
@@ -884,14 +884,14 @@ double parseDateFromNullTerminatedCharacters(const char* dateString, bool& isLoc

skipSpacesAndComments(dateString);

if (startsWithLettersIgnoringASCIICase(dateString, "am"_s)) {
if (startsWithLettersIgnoringASCIICase(StringView::fromLatin1(dateString), "am"_s)) {
if (hour > 12)
return std::numeric_limits<double>::quiet_NaN();
if (hour == 12)
hour = 0;
dateString += 2;
skipSpacesAndComments(dateString);
} else if (startsWithLettersIgnoringASCIICase(dateString, "pm"_s)) {
} else if (startsWithLettersIgnoringASCIICase(StringView::fromLatin1(dateString), "pm"_s)) {
if (hour > 12)
return std::numeric_limits<double>::quiet_NaN();
if (hour != 12)
@@ -915,7 +915,7 @@ double parseDateFromNullTerminatedCharacters(const char* dateString, bool& isLoc
// Don't fail if the time zone is missing.
// Some websites omit the time zone (4275206).
if (*dateString) {
if (startsWithLettersIgnoringASCIICase(dateString, "gmt"_s) || startsWithLettersIgnoringASCIICase(dateString, "utc"_s)) {
if (startsWithLettersIgnoringASCIICase(StringView ::fromLatin1(dateString), "gmt"_s) || startsWithLettersIgnoringASCIICase(StringView::fromLatin1(dateString), "utc"_s)) {
dateString += 3;
isLocalTime = false;
}
@@ -280,12 +280,12 @@ inline bool operator==(ComparableStringView a, ComparableASCIILiteral b)

inline bool operator<(ComparableStringView a, ComparableASCIILiteral b)
{
return codePointCompare(a.string, b.literal.characters()) < 0;
return codePointCompare(a.string, b.literal) < 0;
}

inline bool operator<(ComparableASCIILiteral a, ComparableStringView b)
{
return codePointCompare(a.literal.characters(), b.string) < 0;
return codePointCompare(a.literal, b.string) < 0;
}

inline bool operator==(ComparableStringView a, ComparableLettersLiteral b)
@@ -112,12 +112,12 @@ StringView URL::lastPathComponent() const
bool URL::hasSpecialScheme() const
{
// https://url.spec.whatwg.org/#special-scheme
return protocolIs("ftp")
|| protocolIs("file")
|| protocolIs("http")
|| protocolIs("https")
|| protocolIs("ws")
|| protocolIs("wss");
return protocolIs("ftp"_s)
|| protocolIs("file"_s)
|| protocolIs("http"_s)
|| protocolIs("https"_s)
|| protocolIs("ws"_s)
|| protocolIs("wss"_s);
}

unsigned URL::pathStart() const
@@ -681,8 +681,8 @@ void URL::setPath(StringView path)

parse(makeString(
StringView(m_string).left(pathStart()),
path.startsWith('/') || (path.startsWith('\\') && (hasSpecialScheme() || protocolIs("file"))) || (!hasSpecialScheme() && path.isEmpty() && m_schemeEnd + 1U < pathStart()) ? "" : "/",
!hasSpecialScheme() && host().isEmpty() && path.startsWith("//") && path.length() > 2 ? "/." : "",
path.startsWith('/') || (path.startsWith('\\') && (hasSpecialScheme() || protocolIs("file"_s))) || (!hasSpecialScheme() && path.isEmpty() && m_schemeEnd + 1U < pathStart()) ? ""_s : "/"_s,
!hasSpecialScheme() && host().isEmpty() && path.startsWith("//"_s) && path.length() > 2 ? "/."_s : ""_s,
escapePathWithoutCopying(path),
StringView(m_string).substring(m_pathEnd)
));
@@ -781,9 +781,10 @@ bool URL::isHierarchical() const
return m_string[m_schemeEnd + 1] == '/';
}

static bool protocolIsInternal(StringView string, const char* protocol)
static bool protocolIsInternal(StringView string, ASCIILiteral protocolLiteral)
{
assertProtocolIsGood(protocol);
assertProtocolIsGood(protocolLiteral);
auto* protocol = protocolLiteral.characters();
bool isLeading = true;
for (auto codeUnit : string.codeUnits()) {
if (isLeading) {
@@ -806,7 +807,7 @@ static bool protocolIsInternal(StringView string, const char* protocol)
return false;
}

bool protocolIs(StringView string, const char* protocol)
bool protocolIs(StringView string, ASCIILiteral protocol)
{
return protocolIsInternal(string, protocol);
}
@@ -847,12 +848,12 @@ bool URL::isLocalFile() const
// and including feed would allow feeds to potentially let someone's blog
// read the contents of the clipboard on a drag, even without a drop.
// Likewise with using the FrameLoader::shouldTreatURLAsLocal() function.
return protocolIs("file");
return protocolIs("file"_s);
}

bool protocolIsJavaScript(StringView string)
{
return protocolIsInternal(string, "javascript");
return protocolIsInternal(string, "javascript"_s);
}

bool protocolIsInFTPFamily(StringView url)
@@ -903,7 +904,7 @@ const URL& aboutSrcDocURL()

bool URL::protocolIsAbout() const
{
return protocolIs("about");
return protocolIs("about"_s);
}

bool portAllowed(const URL& url)
@@ -1007,19 +1008,19 @@ bool portAllowed(const URL& url)
return true;

// Allow ports 21 and 22 for FTP URLs, as Mozilla does.
if ((port.value() == 21 || port.value() == 22) && url.protocolIs("ftp"))
if ((port.value() == 21 || port.value() == 22) && url.protocolIs("ftp"_s))
return true;

// Allow any port number in a file URL, since the port number is ignored.
if (url.protocolIs("file"))
if (url.protocolIs("file"_s))
return true;

return false;
}

String mimeTypeFromDataURL(StringView dataURL)
{
ASSERT(protocolIsInternal(dataURL, "data"));
ASSERT(protocolIsInternal(dataURL, "data"_s));

// FIXME: What's the right behavior when the URL has a comma first, but a semicolon later?
// Currently this code will break at the semicolon in that case; should add a test.
@@ -1077,12 +1078,12 @@ StringView URL::fragmentIdentifierWithLeadingNumberSign() const

bool URL::isAboutBlank() const
{
return protocolIsAbout() && path() == "blank";
return protocolIsAbout() && path() == "blank"_s;
}

bool URL::isAboutSrcDoc() const
{
return protocolIsAbout() && path() == "srcdoc";
return protocolIsAbout() && path() == "srcdoc"_s;
}

TextStream& operator<<(TextStream& ts, const URL& url)
@@ -138,8 +138,8 @@ class URL {
// Returns true if the current URL's protocol is the same as the null-
// terminated ASCII argument. The argument must be lower-case.
WTF_EXPORT_PRIVATE bool protocolIs(StringView) const;
bool protocolIsBlob() const { return protocolIs("blob"); }
bool protocolIsData() const { return protocolIs("data"); }
bool protocolIsBlob() const { return protocolIs("blob"_s); }
bool protocolIsData() const { return protocolIs("data"_s); }
WTF_EXPORT_PRIVATE bool protocolIsAbout() const;
WTF_EXPORT_PRIVATE bool protocolIsJavaScript() const;
WTF_EXPORT_PRIVATE bool protocolIsInFTPFamily() const;
@@ -270,7 +270,7 @@ WTF_EXPORT_PRIVATE const URL& aboutSrcDocURL();
// These are also different from the WTF::URL functions in that they don't require the string to be a valid and parsable URL.
// This is especially important because valid javascript URLs are not necessarily considered valid by WTF::URL.

WTF_EXPORT_PRIVATE bool protocolIs(StringView url, const char* protocol);
WTF_EXPORT_PRIVATE bool protocolIs(StringView url, ASCIILiteral protocol);
WTF_EXPORT_PRIVATE bool protocolIsJavaScript(StringView url);
WTF_EXPORT_PRIVATE bool protocolIsInFTPFamily(StringView url);
WTF_EXPORT_PRIVATE bool protocolIsInHTTPFamily(StringView url);
@@ -718,7 +718,7 @@ static void applyHostNameFunctionToURLString(const String& string, URLDecodeFunc

// Maybe we should implement this using a character buffer instead?

if (protocolIs(string, "mailto")) {
if (protocolIs(string, "mailto"_s)) {
applyHostNameFunctionToMailToURLString(string, decodeFunction, array);
return;
}
@@ -727,12 +727,12 @@ static void applyHostNameFunctionToURLString(const String& string, URLDecodeFunc
// It comes after a "://" sequence, with scheme characters preceding.
// If ends with the end of the string or a ":", "/", or a "?".
// If there is a "@" character, the host part is just the part after the "@".
static const char* separator = "://";
static constexpr auto separator = "://"_s;
auto separatorIndex = string.find(separator);
if (separatorIndex == notFound)
return;

unsigned authorityStart = separatorIndex + strlen(separator);
unsigned authorityStart = separatorIndex + separator.length();

// Check that all characters before the :// are valid scheme characters.
if (StringView { string }.left(separatorIndex).contains([](UChar character) {

0 comments on commit c68178d

Please sign in to comment.