Title: [293326] trunk
Revision
293326
Author
cdu...@apple.com
Date
2022-04-25 08:25:06 -0700 (Mon, 25 Apr 2022)

Log Message

Replace String::replace() functions with makeStringByReplacingAll() free functions
https://bugs.webkit.org/show_bug.cgi?id=239685

Reviewed by Darin Adler.

Replace String::replace() functions with makeStringByReplacingAll() free functions.

"All" is added to the name since every instance is replaced, not just the first one.
Making it a free function that returns a new String is a step towards making String
immutable.

In the future, we may want to add a makeStringByReplacingAll() that takes in a
StringView instead of a `const String`. Some call sites would benefit from that.

* Tools/TestWebKitAPI/Tests/WTF/StringBuilder.cpp:
(TestWebKitAPI::TEST):
* Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp:
(TestWebKitAPI::TEST):
* Tools/TestWebKitAPI/Tests/WebKit/OverrideAppleLanguagesPreference.mm:
(AppleLanguagesTest::AppleLanguagesTest):
* Tools/WebKitTestRunner/InjectedBundle/atspi/AccessibilityUIElementAtspi.cpp:
(WTR::AccessibilityUIElement::stringValue):
(WTR::AccessibilityUIElement::attributedStringForRange):
* Source/_javascript_Core/inspector/agents/InspectorAuditAgent.cpp:
(Inspector::InspectorAuditAgent::run):
* Source/_javascript_Core/jit/ExecutableAllocator.cpp:
(JSC::dumpJITMemory):
* Source/_javascript_Core/runtime/TypeProfiler.cpp:
(JSC::TypeProfiler::logTypesForTypeLocation):
* Source/_javascript_Core/runtime/TypeSet.cpp:
(JSC::StructureShape::propertyHash):
* Source/_javascript_Core/yarr/RegularExpression.cpp:
(JSC::Yarr::replace):
* Source/WebCore/PAL/pal/text/TextCodecICU.cpp:
(PAL::TextCodecICU::encode const):
* Source/WebKit/NetworkProcess/DatabaseUtilities.cpp:
(WebKit::DatabaseUtilities::stripIndexQueryToMatchStoredValue):
* Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::escapeForJSON):
* Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp:
(webkit_web_context_set_preferred_languages):
* Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::insertText):
* Source/WebKit/WebProcess/WebCoreSupport/WebContextMenuClient.cpp:
(WebKit::WebContextMenuClient::searchWithGoogle):
* Source/WebKit/WebProcess/WebCoreSupport/WebResourceLoadObserver.cpp:
(WebKit::WebResourceLoadObserver::logUserInteractionWithReducedTimeResolution):
* Source/WebKitLegacy/mac/WebView/WebHTMLRepresentation.mm:
(matchLabelsAgainstString):
* Source/WebKitLegacy/mac/WebView/WebHTMLView.mm:
(-[WebHTMLView insertText:]):
* Source/WebKitLegacy/win/DOMHTMLClasses.cpp:
(DOMHTMLInputElement::replaceCharactersInRange):
* Source/WebKitLegacy/win/WebCoreSupport/WebContextMenuClient.cpp:
(WebContextMenuClient::searchWithGoogle):
* Source/WebKitLegacy/win/WebLocalizableStrings.cpp:
(LocalizedString::operator LPCTSTR const):
* Source/WTF/wtf/Language.cpp:
(WTF::canonicalLanguageIdentifier):
* Source/WTF/wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostNames):
* Source/WTF/wtf/URLParser.cpp:
(WTF::URLParser::parseURLEncodedForm):
* Source/WTF/wtf/text/StringView.h:
(WTF::makeStringByReplacingAll):
(WTF::makeStringByReplacing):
(WTF::String::replace): Deleted.
* Source/WTF/wtf/text/WTFString.h:
(WTF::makeStringByReplacingAll):
(WTF::String::replace): Deleted.
* Source/WTF/wtf/unix/LanguageUnix.cpp:
(WTF::platformLanguage):
* Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::encodeDatabaseName):
(WebCore::IDBServer::SQLiteIDBBackingStore::decodeDatabaseName):
* Source/WebCore/Modules/mediastream/gstreamer/GStreamerMediaEndpoint.cpp:
(WebCore::GStreamerMediaEndpoint::setConfiguration):
* Source/WebCore/Modules/plugins/YouTubePluginReplacement.cpp:
(WebCore::queryKeysAndValues):
* Source/WebCore/accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::determineDropEffects const):
* Source/WebCore/accessibility/atspi/AccessibilityAtspi.cpp:
(WebCore::AccessibilityAtspi::registerRoot):
(WebCore::AccessibilityAtspi::registerObject):
(WebCore::AccessibilityAtspi::registerHyperlink):
* Source/WebCore/contentextensions/ContentExtensionActions.cpp:
(WebCore::ContentExtensions::RedirectAction::RegexSubstitutionAction::applyToURL const):
* Source/WebCore/contentextensions/ContentExtensionParser.cpp:
(WebCore::ContentExtensions::getDomainList):
* Source/WebCore/css/parser/CSSTokenizer.cpp:
(WebCore::CSSTokenizer::preprocessString):
* Source/WebCore/display/css/DisplayTextBox.cpp:
(WebCore::Display::TextBox::debugDescription const):
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::displayStringModifiedByEncoding const):
* Source/WebCore/dom/Node.cpp:
(WebCore::Node::showNode const):
* Source/WebCore/dom/Text.cpp:
(WebCore::appendTextRepresentation):
* Source/WebCore/dom/ViewportArguments.cpp:
(WebCore::viewportErrorMessage):
* Source/WebCore/editing/EditingStyle.cpp:
(WebCore::StyleChange::extractTextStyles):
* Source/WebCore/editing/Editor.cpp:
(WebCore::Editor::selectedText const):
* Source/WebCore/editing/FrameSelection.cpp:
(WebCore::FrameSelection::debugRenderer const):
* Source/WebCore/editing/MarkupAccumulator.cpp:
(WebCore::MarkupAccumulator::appendQuotedURLAttributeValue):
* Source/WebCore/editing/TextIterator.cpp:
(WebCore::foldQuoteMarks):
* Source/WebCore/editing/VisibleUnits.cpp:
(WebCore::charactersAroundPosition):
* Source/WebCore/editing/cocoa/EditorCocoa.mm:
(WebCore::Editor::stringSelectionForPasteboard):
(WebCore::Editor::stringSelectionForPasteboardWithImageAltText):
* Source/WebCore/editing/cocoa/HTMLConverter.mm:
(WebCore::editingAttributedString):
* Source/WebCore/editing/markup.cpp:
(WebCore::StyledMarkupAccumulator::takeResults):
(WebCore::createFragmentFromText):
* Source/WebCore/html/HTMLElement.cpp:
(WebCore::HTMLElement::setInnerText):
* Source/WebCore/html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::setValueCommon):
* Source/WebCore/html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::setRangeText):
* Source/WebCore/html/LinkRelAttribute.cpp:
(WebCore::LinkRelAttribute::LinkRelAttribute):
* Source/WebCore/html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::handleBeforeTextInsertedEvent):
* Source/WebCore/html/URLDecomposition.cpp:
(WebCore::URLDecomposition::setSearch):
* Source/WebCore/inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyleSheet::setRuleSelector):
(WebCore::InspectorStyleSheet::styleSheetTextWithChangedStyle):
* Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp:
(WebCore::Layout::outputLayoutBox):
* Source/WebCore/loader/FormSubmission.cpp:
(WebCore::appendMailtoPostFormDataToURL):
(WebCore::encodingFromAcceptCharset):
* Source/WebCore/page/Frame.cpp:
(WebCore::matchLabelsAgainstString):
* Source/WebCore/platform/LocalizedStrings.cpp:
(WebCore::contextMenuItemTagLookUpInDictionary):
(WebCore::imageTitle):
(WebCore::webCryptoMasterKeyKeychainLabel):
* Source/WebCore/platform/graphics/avfoundation/objc/AVStreamDataParserMIMETypeCache.mm:
(WebCore::AVStreamDataParserMIMETypeCache::canDecodeExtendedType):
* Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::configureDownloadBuffer):
* Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp:
(WebCore::AppendPipeline::AppendPipeline):
(WebCore::AppendPipeline::handleStateChangeMessage):
* Source/WebCore/platform/gtk/SelectionData.cpp:
(WebCore::replaceNonBreakingSpaceWithSpace):
* Source/WebCore/platform/mediastream/gstreamer/GStreamerDisplayCaptureDeviceManager.cpp:
(WebCore::GStreamerDisplayCaptureDeviceManager::createDisplayCaptureSource):
* Source/WebCore/platform/network/ResourceResponseBase.cpp:
(WebCore::ResourceResponseBase::sanitizeSuggestedFilename):
* Source/WebCore/platform/network/soup/ResourceRequestSoup.cpp:
(WebCore::ResourceRequest::createSoupURI const):
* Source/WebCore/platform/network/soup/ResourceResponseSoup.cpp:
(WebCore::sanitizeFilename):
* Source/WebCore/platform/text/DateTimeFormat.cpp:
(WebCore::DateTimeFormat::quoteAndAppendLiteral):
* Source/WebCore/platform/text/LocaleToScriptMapping.cpp:
(WebCore::localeToScriptCodeForFontSelection):
* Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp:
(WebCore::scanDirectoryForDictionaries):
* Source/WebCore/platform/text/win/LocaleWin.cpp:
(WebCore::LocaleWin::shortMonthFormat):
* Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp:
(WebCore::replaceNBSPWithSpace):
* Source/WebCore/rendering/LegacyInlineTextBox.cpp:
(WebCore::LegacyInlineTextBox::outputLineBox const):
* Source/WebCore/rendering/RenderBlock.cpp:
(WebCore::RenderBlock::updateSecurityDiscCharacters):
* Source/WebCore/rendering/RenderObject.cpp:
(WebCore::RenderObject::outputRenderObject const):
* Source/WebCore/rendering/RenderText.cpp:
(WebCore::RenderText::setRenderedText):
* Source/WebCore/rendering/svg/RenderSVGInlineText.cpp:
(WebCore::applySVGWhitespaceRules):
* Source/WebCore/xml/XSLTProcessor.cpp:
(WebCore::transformTextStringToXHTMLDocumentString):

Canonical link: https://commits.webkit.org/249949@main

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorAuditAgent.cpp (293325 => 293326)


--- trunk/Source/_javascript_Core/inspector/agents/InspectorAuditAgent.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorAuditAgent.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -92,7 +92,7 @@
     if (injectedScript.hasNoValue())
         return makeUnexpected(errorString);
 
-    auto functionString = makeString("(function(WebInspectorAudit) { \"use strict\"; return eval(`(", String { test }.replace('`', "\\`"_s), ")`)(WebInspectorAudit); })");
+    auto functionString = makeString("(function(WebInspectorAudit) { \"use strict\"; return eval(`(", makeStringByReplacingAll(test, '`', "\\`"_s), ")`)(WebInspectorAudit); })");
 
     InjectedScript::ExecuteOptions options;
     options.objectGroup = "audit"_s;

Modified: trunk/Source/_javascript_Core/jit/ExecutableAllocator.cpp (293325 => 293326)


--- trunk/Source/_javascript_Core/jit/ExecutableAllocator.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/_javascript_Core/jit/ExecutableAllocator.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -1173,7 +1173,7 @@
         {
             if (fd == -1) {
                 auto path = String::fromLatin1(Options::dumpJITMemoryPath());
-                path = path.replace("%pid", String::number(getCurrentProcessID()));
+                path = makeStringByReplacingAll(path, "%pid", 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);
             }

Modified: trunk/Source/_javascript_Core/runtime/TypeProfiler.cpp (293325 => 293326)


--- trunk/Source/_javascript_Core/runtime/TypeProfiler.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/_javascript_Core/runtime/TypeProfiler.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -53,9 +53,9 @@
 
     dataLog("\t\t", location->m_globalVariableID == TypeProfilerReturnStatement ? "[Return Statement]" : "[Normal Statement]", "\n");
 
-    dataLog("\t\t#Local#\n\t\t", location->m_instructionTypeSet->dumpTypes().replace("\n", "\n\t\t"), "\n");
+    dataLog("\t\t#Local#\n\t\t", makeStringByReplacingAll(location->m_instructionTypeSet->dumpTypes(), "\n", "\n\t\t"), "\n");
     if (location->m_globalTypeSet)
-        dataLog("\t\t#Global#\n\t\t", location->m_globalTypeSet->dumpTypes().replace("\n", "\n\t\t"), "\n");
+        dataLog("\t\t#Global#\n\t\t", makeStringByReplacingAll(location->m_globalTypeSet->dumpTypes(), '\n', "\n\t\t"_s), "\n");
 }
 
 void TypeProfiler::insertNewLocation(TypeLocation* location)

Modified: trunk/Source/_javascript_Core/runtime/TypeSet.cpp (293325 => 293326)


--- trunk/Source/_javascript_Core/runtime/TypeSet.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/_javascript_Core/runtime/TypeSet.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -347,8 +347,8 @@
     builder.append(m_constructorName);
     builder.append(':');
     for (auto& key : m_fields) {
-        String property = key.get();
-        property.replace(":", "\\:"); // Ensure that hash({"foo:", "bar"}) != hash({"foo", ":bar"}) because we're using colons as a separator and colons are legal characters in field names in JS.
+        // Ensure that hash({"foo:", "bar"}) != hash({"foo", ":bar"}) because we're using colons as a separator and colons are legal characters in field names in JS.
+        String property = makeStringByReplacingAll(key.get(), ':', "\\:"_s);
         builder.append(property);
     }
 

Modified: trunk/Source/_javascript_Core/yarr/RegularExpression.cpp (293325 => 293326)


--- trunk/Source/_javascript_Core/yarr/RegularExpression.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/_javascript_Core/yarr/RegularExpression.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -180,7 +180,7 @@
         index = target.match(string, index, &matchLength);
         if (index < 0)
             break;
-        string.replace(index, matchLength, replacement);
+        string = makeStringByReplacing(string, index, matchLength, replacement);
         index += replacement.length();
         if (!matchLength)
             break; // Avoid infinite loop on 0-length matches, e.g. [a-z]*

Modified: trunk/Source/WTF/wtf/Language.cpp (293325 => 293326)


--- trunk/Source/WTF/wtf/Language.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WTF/wtf/Language.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -151,7 +151,7 @@
     String lowercaseLanguageCode = languageCode.convertToASCIILowercase();
     
     if (lowercaseLanguageCode.length() >= 3 && lowercaseLanguageCode[2] == '_')
-        lowercaseLanguageCode.replace(2, 1, "-");
+        lowercaseLanguageCode = makeStringByReplacing(lowercaseLanguageCode, 2, 1, "-"_s);
 
     return lowercaseLanguageCode;
 }

Modified: trunk/Source/WTF/wtf/URLHelpers.cpp (293325 => 293326)


--- trunk/Source/WTF/wtf/URLHelpers.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WTF/wtf/URLHelpers.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -773,7 +773,7 @@
     String result = string;
     while (!hostNameRanges->isEmpty()) {
         auto [location, length, mappedHostName] = hostNameRanges->takeLast();
-        result = result.replace(location, length, mappedHostName);
+        result = makeStringByReplacing(result, location, length, mappedHostName);
     }
     return result;
 }

Modified: trunk/Source/WTF/wtf/URLParser.cpp (293325 => 293326)


--- trunk/Source/WTF/wtf/URLParser.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WTF/wtf/URLParser.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -2887,12 +2887,12 @@
     for (StringView bytes : input.split('&')) {
         auto equalIndex = bytes.find('=');
         if (equalIndex == notFound) {
-            auto name = formURLDecode(bytes.toString().replace('+', 0x20));
+            auto name = formURLDecode(makeStringByReplacingAll(bytes.toString(), '+', 0x20));
             if (name)
                 output.append({ name.value(), emptyString() });
         } else {
-            auto name = formURLDecode(bytes.left(equalIndex).toString().replace('+', 0x20));
-            auto value = formURLDecode(bytes.substring(equalIndex + 1).toString().replace('+', 0x20));
+            auto name = formURLDecode(makeStringByReplacingAll(bytes.left(equalIndex).toString(), '+', 0x20));
+            auto value = formURLDecode(makeStringByReplacingAll(bytes.substring(equalIndex + 1).toString(), '+', 0x20));
             if (name && value)
                 output.append({ name.value(), value.value() });
         }

Modified: trunk/Source/WTF/wtf/text/StringConcatenate.h (293325 => 293326)


--- trunk/Source/WTF/wtf/text/StringConcatenate.h	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WTF/wtf/text/StringConcatenate.h	2022-04-25 15:25:06 UTC (rev 293326)
@@ -531,7 +531,7 @@
     return result;
 }
 
-inline String makeStringByInserting(StringView originalString, StringView stringToInsert, unsigned position)
+inline String WARN_UNUSED_RETURN makeStringByInserting(StringView originalString, StringView stringToInsert, unsigned position)
 {
     return makeString(originalString.left(position), stringToInsert, originalString.substring(position));
 }

Modified: trunk/Source/WTF/wtf/text/StringView.h (293325 => 293326)


--- trunk/Source/WTF/wtf/text/StringView.h	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WTF/wtf/text/StringView.h	2022-04-25 15:25:06 UTC (rev 293326)
@@ -1308,27 +1308,32 @@
     return findIgnoringASCIICase(string, start) != notFound;
 }
 
-inline String& String::replace(StringView target, StringView replacement)
+inline String WARN_UNUSED_RETURN makeStringByReplacingAll(const String& string, StringView target, StringView replacement)
 {
-    if (m_impl)
-        m_impl = m_impl->replace(target, replacement);
-    return *this;
+    if (auto* impl = string.impl())
+        return String { impl->replace(target, replacement) };
+    return string;
 }
 
-inline String& String::replace(unsigned start, unsigned length, StringView replacement)
+inline String WARN_UNUSED_RETURN makeStringByReplacing(const String& string, unsigned start, unsigned length, StringView replacement)
 {
-    if (m_impl)
-        m_impl = m_impl->replace(start, length, replacement);
-    return *this;
+    if (auto* impl = string.impl())
+        return String { impl->replace(start, length, replacement) };
+    return string;
 }
 
-inline String& String::replace(UChar target, StringView replacement)
+inline String WARN_UNUSED_RETURN makeStringByReplacingAll(const String& string, UChar target, StringView replacement)
 {
-    if (m_impl)
-        m_impl = m_impl->replace(target, replacement);
-    return *this;
+    if (auto* impl = string.impl())
+        return String { impl->replace(target, replacement) };
+    return string;
 }
 
+inline String WARN_UNUSED_RETURN makeStringBySimplifyingNewLines(const String& string)
+{
+    return makeStringByReplacingAll(makeStringByReplacingAll(string, "\r\n"_s, "\n"_s), '\r', '\n');
+}
+
 inline bool String::startsWith(StringView string) const
 {
     return m_impl ? m_impl->startsWith(string) : string.isEmpty();
@@ -1408,6 +1413,8 @@
 
 using WTF::append;
 using WTF::equal;
+using WTF::makeStringByReplacing;
+using WTF::makeStringBySimplifyingNewLines;
 using WTF::StringView;
 using WTF::StringViewWithUnderlyingString;
 using WTF::hasUnpairedSurrogate;

Modified: trunk/Source/WTF/wtf/text/WTFString.h (293325 => 293326)


--- trunk/Source/WTF/wtf/text/WTFString.h	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WTF/wtf/text/WTFString.h	2022-04-25 15:25:06 UTC (rev 293326)
@@ -191,13 +191,6 @@
     bool endsWith(char character) const { return endsWith(static_cast<UChar>(character)); }
     bool hasInfixEndingAt(StringView suffix, unsigned end) const;
 
-    String& replace(UChar target, UChar replacement);
-    String& replace(UChar target, StringView replacement);
-    String& replace(UChar target, ASCIILiteral);
-    String& replace(UChar target, const char*) = delete;
-    String& replace(StringView target, StringView replacement);
-    String& replace(unsigned start, unsigned length, StringView replacement);
-
     WTF_EXPORT_PRIVATE void remove(unsigned position, unsigned length = 1);
 
     WTF_EXPORT_PRIVATE String substring(unsigned position, unsigned length = MaxLength) const;
@@ -482,20 +475,22 @@
     return (*m_impl)[index];
 }
 
-inline String& String::replace(UChar target, UChar replacement)
+inline String WARN_UNUSED_RETURN makeStringByReplacingAll(const String& string, UChar target, UChar replacement)
 {
-    if (m_impl)
-        m_impl = m_impl->replace(target, replacement);
-    return *this;
+    if (auto impl = string.impl())
+        return String { impl->replace(target, replacement) };
+    return string;
 }
 
-ALWAYS_INLINE String& String::replace(UChar target, ASCIILiteral literal)
+ALWAYS_INLINE String WARN_UNUSED_RETURN makeStringByReplacingAll(const String& string, UChar target, ASCIILiteral literal)
 {
-    if (m_impl)
-        m_impl = m_impl->replace(target, literal.characters(), literal.length());
-    return *this;
+    if (auto impl = string.impl())
+        return String { impl->replace(target, literal.characters(), literal.length()) };
+    return string;
 }
 
+String makeStringByReplacingAll(const String&, UChar target, const char*) = delete;
+
 template<size_t inlineCapacity> inline String String::make8BitFrom16BitSource(const Vector<UChar, inlineCapacity>& buffer)
 {
     return make8BitFrom16BitSource(buffer.data(), buffer.size());
@@ -636,6 +631,7 @@
 using WTF::charactersToDouble;
 using WTF::charactersToFloat;
 using WTF::emptyString;
+using WTF::makeStringByReplacingAll;
 using WTF::nullString;
 using WTF::equal;
 using WTF::find;

Modified: trunk/Source/WTF/wtf/unix/LanguageUnix.cpp (293325 => 293326)


--- trunk/Source/WTF/wtf/unix/LanguageUnix.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WTF/wtf/unix/LanguageUnix.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -36,8 +36,7 @@
     if (localeDefault.isEmpty() || equalIgnoringASCIICase(localeDefault, "C") || equalIgnoringASCIICase(localeDefault, "POSIX"))
         return "en-US"_s;
 
-    String normalizedDefault = localeDefault;
-    normalizedDefault.replace('_', '-');
+    auto normalizedDefault = makeStringByReplacingAll(localeDefault, '_', '-');
     return normalizedDefault.left(normalizedDefault.find('.'));
 }
 

Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp (293325 => 293326)


--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -916,10 +916,7 @@
     if (databaseName.isEmpty())
         return "%00"_s;
 
-    String filename = FileSystem::encodeForFileName(databaseName);
-    filename.replace('.', "%2E"_s);
-
-    return filename;
+    return makeStringByReplacingAll(FileSystem::encodeForFileName(databaseName), '.', "%2E"_s);
 }
 
 String SQLiteIDBBackingStore::decodeDatabaseName(const String& encodedName)
@@ -927,10 +924,7 @@
     if (encodedName == "%00"_s)
         return emptyString();
 
-    String name = encodedName;
-    name.replace("%2E", ".");
-
-    return FileSystem::decodeFromFilename(name);
+    return FileSystem::decodeFromFilename(makeStringByReplacingAll(encodedName, "%2E"_s, "."_s));
 }
 
 String SQLiteIDBBackingStore::fullDatabasePathForDirectory(const String& fullDatabaseDirectory)

Modified: trunk/Source/WebCore/Modules/mediastream/gstreamer/GStreamerMediaEndpoint.cpp (293325 => 293326)


--- trunk/Source/WebCore/Modules/mediastream/gstreamer/GStreamerMediaEndpoint.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/Modules/mediastream/gstreamer/GStreamerMediaEndpoint.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -216,7 +216,8 @@
         bool stunSet = false;
         for (auto& url : server.urls) {
             if (url.protocol().startsWith("turn")) {
-                auto valid = url.string().isolatedCopy().replace("turn:", "turn://").replace("turns:", "turns://");
+                auto valid = makeStringByReplacingAll(url.string().isolatedCopy(), "turn:"_s, "turn://"_s);
+                valid = makeStringByReplacingAll(valid, "turns:"_s, "turns://"_s);
                 URL validURL(URL(), valid);
                 // FIXME: libnice currently doesn't seem to handle IPv6 addresses very well.
                 if (validURL.host().startsWith('['))
@@ -229,7 +230,7 @@
                     GST_WARNING("Unable to use TURN server: %s", validURL.string().utf8().data());
             }
             if (!stunSet && url.protocol().startsWith("stun")) {
-                auto valid = url.string().isolatedCopy().replace("stun:", "stun://");
+                auto valid = makeStringByReplacingAll(url.string().isolatedCopy(), "stun:"_s, "stun://"_s);
                 URL validURL(URL(), valid);
                 // FIXME: libnice currently doesn't seem to handle IPv6 addresses very well.
                 if (validURL.host().startsWith('['))

Modified: trunk/Source/WebCore/Modules/plugins/YouTubePluginReplacement.cpp (293325 => 293326)


--- trunk/Source/WebCore/Modules/plugins/YouTubePluginReplacement.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/Modules/plugins/YouTubePluginReplacement.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -149,7 +149,7 @@
         if (keyLength && valueLength) {
             String key = queryString.substring(keyLocation, keyLength).convertToASCIILowercase();
             String value = queryString.substring(valueLocation, valueLength).toString();
-            value.replace('+', ' ');
+            value = makeStringByReplacingAll(value, '+', ' ');
 
             if (!key.isEmpty() && !value.isEmpty())
                 queryDictionary.add(key, value);

Modified: trunk/Source/WebCore/PAL/pal/text/TextCodecICU.cpp (293325 => 293326)


--- trunk/Source/WebCore/PAL/pal/text/TextCodecICU.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/PAL/pal/text/TextCodecICU.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -302,8 +302,7 @@
     // Encoding will change the yen sign back into a backslash.
     String copy;
     if (shouldShowBackslashAsCurrencySymbolIn(m_encodingName)) {
-        copy = string.toStringWithoutCopying();
-        copy.replace('\\', yenSign);
+        copy = makeStringByReplacingAll(string.toStringWithoutCopying(), '\\', yenSign);
         string = copy;
     }
 

Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (293325 => 293326)


--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -1127,11 +1127,8 @@
 {
     // Order is aria-dropeffect, dropzone, webkitdropzone
     const AtomString& dropEffects = getAttribute(aria_dropeffectAttr);
-    if (!dropEffects.isEmpty()) {
-        String dropEffectsString = dropEffects.string();
-        dropEffectsString.replace('\n', ' ');
-        return dropEffectsString.split(' ');
-    }
+    if (!dropEffects.isEmpty())
+        return makeStringByReplacingAll(dropEffects.string(), '\n', ' ').split(' ');
     
     auto dropzone = getAttribute(dropzoneAttr);
     if (!dropzone.isEmpty())

Modified: trunk/Source/WebCore/accessibility/atspi/AccessibilityAtspi.cpp (293325 => 293326)


--- trunk/Source/WebCore/accessibility/atspi/AccessibilityAtspi.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/accessibility/atspi/AccessibilityAtspi.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -288,7 +288,7 @@
     }
 
     ensureCache();
-    String path = makeString("/org/a11y/webkit/accessible/", createVersion4UUIDString().replace('-', '_'));
+    String path = makeString("/org/a11y/webkit/accessible/", makeStringByReplacingAll(createVersion4UUIDString(), '-', '_'));
     Vector<unsigned, 3> registeredObjects;
     registeredObjects.reserveInitialCapacity(interfaces.size());
     for (const auto& interface : interfaces) {
@@ -332,7 +332,7 @@
         return { };
 
     ensureCache();
-    String path = makeString("/org/a11y/atspi/accessible/", createVersion4UUIDString().replace('-', '_'));
+    String path = makeString("/org/a11y/atspi/accessible/", makeStringByReplacingAll(createVersion4UUIDString(), '-', '_'));
     Vector<unsigned, 7> registeredObjects;
     registeredObjects.reserveInitialCapacity(interfaces.size());
     for (const auto& interface : interfaces) {
@@ -382,7 +382,7 @@
     if (!m_connection)
         return { };
 
-    String path = makeString("/org/a11y/atspi/accessible/", createVersion4UUIDString().replace('-', '_'));
+    String path = makeString("/org/a11y/atspi/accessible/", makeStringByReplacingAll(createVersion4UUIDString(), '-', '_'));
     Vector<unsigned, 1> registeredObjects;
     registeredObjects.reserveInitialCapacity(interfaces.size());
     for (const auto& interface : interfaces) {

Modified: trunk/Source/WebCore/contentextensions/ContentExtensionActions.cpp (293325 => 293326)


--- trunk/Source/WebCore/contentextensions/ContentExtensionActions.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionActions.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -473,7 +473,7 @@
     String substitution = regexSubstitution;
     size_t resultLength = JSValueToNumber(context, getProperty(result, "length"), nullptr);
     for (size_t i = 0; i < std::min<size_t>(10, resultLength); i++)
-        substitution.replace(makeString('\\', i), valueToWTFString(getArrayValue(result, i)));
+        substitution = makeStringByReplacingAll(substitution, makeString('\\', i), valueToWTFString(getArrayValue(result, i)));
 
     URL replacementURL(substitution);
     if (replacementURL.isValid())

Modified: trunk/Source/WebCore/contentextensions/ContentExtensionParser.cpp (293325 => 293326)


--- trunk/Source/WebCore/contentextensions/ContentExtensionParser.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionParser.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -94,7 +94,7 @@
             { '$', "\\$"_s }
         } };
         for (auto& pair : escapeTable)
-            domain = domain.replace(pair.first, pair.second);
+            domain = makeStringByReplacingAll(domain, pair.first, pair.second);
 
         const char* protocolRegex = "[a-z][a-z+.-]*:\\/\\/";
         const char* allowSubdomainsRegex = "(.*\\.)*";

Modified: trunk/Source/WebCore/css/parser/CSSTokenizer.cpp (293325 => 293326)


--- trunk/Source/WebCore/css/parser/CSSTokenizer.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/css/parser/CSSTokenizer.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -43,13 +43,13 @@
 namespace WebCore {
 
 // https://drafts.csswg.org/css-syntax/#input-preprocessing
-String CSSTokenizer::preprocessString(String string)
+String CSSTokenizer::preprocessString(const String& string)
 {
     // We don't replace '\r' and '\f' with '\n' as the specification suggests, instead
     // we treat them all the same in the isNewLine function below.
     StringImpl* oldImpl = string.impl();
-    string.replace('\0', replacementCharacter);
-    String replaced = replaceUnpairedSurrogatesWithReplacementCharacter(WTFMove(string));
+    String replaced = makeStringByReplacingAll(string, '\0', replacementCharacter);
+    replaced = replaceUnpairedSurrogatesWithReplacementCharacter(WTFMove(replaced));
     if (replaced.impl() != oldImpl)
         registerString(replaced);
     return replaced;

Modified: trunk/Source/WebCore/css/parser/CSSTokenizer.h (293325 => 293326)


--- trunk/Source/WebCore/css/parser/CSSTokenizer.h	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/css/parser/CSSTokenizer.h	2022-04-25 15:25:06 UTC (rev 293326)
@@ -64,7 +64,7 @@
     UChar consume();
     void reconsume(UChar);
 
-    String preprocessString(String);
+    String preprocessString(const String&);
 
     CSSParserToken consumeNumericToken();
     CSSParserToken consumeIdentLikeToken();

Modified: trunk/Source/WebCore/display/css/DisplayTextBox.cpp (293325 => 293326)


--- trunk/Source/WebCore/display/css/DisplayTextBox.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/display/css/DisplayTextBox.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -54,8 +54,8 @@
 
     stream << boxName() << " " << absoluteBoxRect() << " (" << this << ")";
     auto textContent = text().originalContent().substring(text().start(), text().length()).toString();
-    textContent.replace('\\', "\\\\"_s);
-    textContent.replace('\n', "\\n"_s);
+    textContent = makeStringByReplacingAll(textContent, '\\', "\\\\"_s);
+    textContent = makeStringByReplacingAll(textContent, '\n', "\\n"_s);
     const size_t maxPrintedLength = 80;
     if (textContent.length() > maxPrintedLength) {
         auto substring = StringView(textContent).left(maxPrintedLength);

Modified: trunk/Source/WebCore/dom/Document.cpp (293325 => 293326)


--- trunk/Source/WebCore/dom/Document.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/dom/Document.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -6814,7 +6814,7 @@
 {
     if (!m_decoder)
         return string;
-    return String { string }.replace('\\', m_decoder->encoding().backslashAsCurrencySymbol());
+    return makeStringByReplacingAll(string, '\\', m_decoder->encoding().backslashAsCurrencySymbol());
 }
 
 void Document::dispatchPageshowEvent(PageshowEventPersistence persisted)

Modified: trunk/Source/WebCore/dom/Node.cpp (293325 => 293326)


--- trunk/Source/WebCore/dom/Node.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/dom/Node.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -1798,9 +1798,8 @@
     if (!prefix)
         prefix = "";
     if (isTextNode()) {
-        String value = nodeValue();
-        value.replace('\\', "\\\\"_s);
-        value.replace('\n', "\\n"_s);
+        String value = makeStringByReplacingAll(nodeValue(), '\\', "\\\\"_s);
+        value = makeStringByReplacingAll(value, '\n', "\\n"_s);
         fprintf(stderr, "%s%s\t%p \"%s\"\n", prefix, nodeName().utf8().data(), this, value.utf8().data());
     } else {
         StringBuilder attrs;

Modified: trunk/Source/WebCore/dom/Text.cpp (293325 => 293326)


--- trunk/Source/WebCore/dom/Text.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/dom/Text.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -224,8 +224,8 @@
     String value = text.data();
     builder.append(" length="_s, value.length());
 
-    value.replace('\\', "\\\\"_s);
-    value.replace('\n', "\\n"_s);
+    value = makeStringByReplacingAll(value, '\\', "\\\\"_s);
+    value = makeStringByReplacingAll(value, '\n', "\\n"_s);
     
     constexpr size_t maxDumpLength = 30;
     if (value.length() > maxDumpLength)

Modified: trunk/Source/WebCore/dom/ViewportArguments.cpp (293325 => 293326)


--- trunk/Source/WebCore/dom/ViewportArguments.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/dom/ViewportArguments.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -427,10 +427,10 @@
 {
     String message = viewportErrorMessageTemplate(errorCode);
     if (!replacement1.isNull())
-        message.replace("%replacement1", replacement1);
+        message = makeStringByReplacingAll(message, "%replacement1", replacement1);
     // FIXME: This will do the wrong thing if replacement1 contains the substring "%replacement2".
     if (!replacement2.isNull())
-        message.replace("%replacement2", replacement2);
+        message = makeStringByReplacingAll(message, "%replacement2", replacement2);
 
     if ((errorCode == UnrecognizedViewportArgumentValueError || errorCode == TruncatedViewportArgumentValueError) && replacement1.contains(';'))
         message = makeString(message, " Note that ';' is not a separator in viewport values. The list should be comma-separated."_s);

Modified: trunk/Source/WebCore/editing/EditingStyle.cpp (293325 => 293326)


--- trunk/Source/WebCore/editing/EditingStyle.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/editing/EditingStyle.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -1851,9 +1851,8 @@
         }
     }
 
-    m_applyFontFace = style.getPropertyValue(CSSPropertyFontFamily);
     // Remove quotes for Outlook 2007 compatibility. See https://bugs.webkit.org/show_bug.cgi?id=79448
-    m_applyFontFace.replace('\"', ""_s);
+    m_applyFontFace = makeStringByReplacingAll(style.getPropertyValue(CSSPropertyFontFamily), '\"', ""_s);
     style.removeProperty(CSSPropertyFontFamily);
 
     if (RefPtr<CSSValue> fontSize = style.getPropertyCSSValue(CSSPropertyFontSize)) {

Modified: trunk/Source/WebCore/editing/Editor.cpp (293325 => 293326)


--- trunk/Source/WebCore/editing/Editor.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/editing/Editor.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -3334,7 +3334,7 @@
 {
     // We remove '\0' characters because they are not visibly rendered to the user.
     auto range = m_document.selection().selection().firstRange();
-    return range ? plainText(*range, behaviors).replace('\0', ""_s) : emptyString();
+    return range ? makeStringByReplacingAll(plainText(*range, behaviors), '\0', ""_s) : emptyString();
 }
 
 RefPtr<TextPlaceholderElement> Editor::insertTextPlaceholder(const IntSize& size)

Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (293325 => 293326)


--- trunk/Source/WebCore/editing/FrameSelection.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -1915,8 +1915,8 @@
                 caret = pos - (textLength - show.length());
             }
             
-            show.replace('\n', ' ');
-            show.replace('\r', ' ');
+            show = makeStringByReplacingAll(show, '\n', ' ');
+            show = makeStringByReplacingAll(show, '\r', ' ');
             fprintf(stderr, "==> #text : \"%s\" at offset %d\n", show.utf8().data(), pos);
             fprintf(stderr, "           ");
             for (int i = 0; i < caret; i++)

Modified: trunk/Source/WebCore/editing/MarkupAccumulator.cpp (293325 => 293326)


--- trunk/Source/WebCore/editing/MarkupAccumulator.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/editing/MarkupAccumulator.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -289,7 +289,7 @@
         // minimal escaping for _javascript_ urls
         if (resolvedURLString.contains('"')) {
             if (resolvedURLString.contains('\''))
-                resolvedURLString.replace('"', "&quot;"_s);
+                resolvedURLString = makeStringByReplacingAll(resolvedURLString, '"', "&quot;"_s);
             else
                 quoteChar = '\'';
         }

Modified: trunk/Source/WebCore/editing/TextIterator.cpp (293325 => 293326)


--- trunk/Source/WebCore/editing/TextIterator.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/editing/TextIterator.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -1632,17 +1632,14 @@
 // to add tailoring on top of the locale-specific tailoring as of this writing.
 String foldQuoteMarks(const String& stringToFold)
 {
-    String result(stringToFold);
-    result.replace(hebrewPunctuationGeresh, '\'');
-    result.replace(hebrewPunctuationGershayim, '"');
-    result.replace(leftDoubleQuotationMark, '"');
-    result.replace(leftLowDoubleQuotationMark, '"');
-    result.replace(leftSingleQuotationMark, '\'');
-    result.replace(leftLowSingleQuotationMark, '\'');
-    result.replace(rightDoubleQuotationMark, '"');
-    result.replace(rightSingleQuotationMark, '\'');
-
-    return result;
+    String result = makeStringByReplacingAll(stringToFold, hebrewPunctuationGeresh, '\'');
+    result = makeStringByReplacingAll(result, hebrewPunctuationGershayim, '"');
+    result = makeStringByReplacingAll(result, leftDoubleQuotationMark, '"');
+    result = makeStringByReplacingAll(result, leftLowDoubleQuotationMark, '"');
+    result = makeStringByReplacingAll(result, leftSingleQuotationMark, '\'');
+    result = makeStringByReplacingAll(result, leftLowSingleQuotationMark, '\'');
+    result = makeStringByReplacingAll(result, rightDoubleQuotationMark, '"');
+    return makeStringByReplacingAll(result, rightSingleQuotationMark, '\'');
 }
 
 #if !UCONFIG_NO_COLLATION
@@ -2479,7 +2476,7 @@
 
 String plainTextReplacingNoBreakSpace(const SimpleRange& range, TextIteratorBehaviors defaultBehaviors, bool isDisplayString)
 {
-    return plainText(range, defaultBehaviors, isDisplayString).replace(noBreakSpace, ' ');
+    return makeStringByReplacingAll(plainText(range, defaultBehaviors, isDisplayString), noBreakSpace, ' ');
 }
 
 static void forEachMatch(const SimpleRange& range, const String& target, FindOptions options, const Function<bool(CharacterRange)>& match)

Modified: trunk/Source/WebCore/editing/VisibleUnits.cpp (293325 => 293326)


--- trunk/Source/WebCore/editing/VisibleUnits.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/editing/VisibleUnits.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -1860,7 +1860,7 @@
     }
 
     if (startPosition != endPosition) {
-        String characterString = plainText(*makeSimpleRange(startPosition, endPosition)).replace(noBreakSpace, ' ');
+        String characterString = makeStringByReplacingAll(plainText(*makeSimpleRange(startPosition, endPosition)), noBreakSpace, ' ');
         for (int i = characterString.length() - 1, index = 0; i >= 0 && index < maxCharacters; --i) {
             if (!index && nextPosition.isNull())
                 index++;

Modified: trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm (293325 => 293326)


--- trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm	2022-04-25 15:25:06 UTC (rev 293326)
@@ -208,9 +208,7 @@
 {
     if (!canCopy())
         return emptyString();
-    String text = selectedText();
-    text.replace(noBreakSpace, ' ');
-    return text;
+    return makeStringByReplacingAll(selectedText(), noBreakSpace, ' ');
 }
 
 String Editor::stringSelectionForPasteboardWithImageAltText()
@@ -217,9 +215,7 @@
 {
     if (!canCopy())
         return emptyString();
-    String text = selectedTextForDataTransfer();
-    text.replace(noBreakSpace, ' ');
-    return text;
+    return makeStringByReplacingAll(selectedTextForDataTransfer(), noBreakSpace, ' ');
 }
 
 void Editor::replaceSelectionWithAttributedString(NSAttributedString *attributedString, MailBlockquoteHandling mailBlockquoteHandling)

Modified: trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm (293325 => 293326)


--- trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm	2022-04-25 15:25:06 UTC (rev 293326)
@@ -2442,7 +2442,7 @@
         if (style.nbspMode() == NBSPMode::Normal)
             text = it.text().createNSStringWithoutCopying();
         else
-            text = it.text().toString().replace(noBreakSpace, ' ');
+            text = makeStringByReplacingAll(it.text().toString(), noBreakSpace, ' ');
 
         [string replaceCharactersInRange:NSMakeRange(stringLength, 0) withString:text.get()];
         [string setAttributes:attrs.get() range:NSMakeRange(stringLength, currentTextLength)];

Modified: trunk/Source/WebCore/editing/markup.cpp (293325 => 293326)


--- trunk/Source/WebCore/editing/markup.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/editing/markup.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -422,7 +422,7 @@
         result.append(string);
     result.append(takeMarkup());
     // Remove '\0' characters because they are not visibly rendered to the user.
-    return result.toString().replace('\0', ""_s);
+    return makeStringByReplacingAll(result.toString(), '\0', ""_s);
 }
 
 void StyledMarkupAccumulator::appendText(StringBuilder& out, const Text& text)
@@ -1170,9 +1170,7 @@
     if (text.isEmpty())
         return fragment;
 
-    String string = text;
-    string.replace("\r\n", "\n");
-    string.replace('\r', '\n');
+    String string = makeStringBySimplifyingNewLines(text);
 
     auto createHTMLBRElement = [&document]() {
         auto element = HTMLBRElement::create(document);

Modified: trunk/Source/WebCore/html/HTMLElement.cpp (293325 => 293326)


--- trunk/Source/WebCore/html/HTMLElement.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/html/HTMLElement.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -449,9 +449,7 @@
             stringReplaceAll(WTFMove(text));
             return { };
         }
-        String textWithConsistentLineBreaks = WTFMove(text);
-        textWithConsistentLineBreaks.replace("\r\n", "\n");
-        textWithConsistentLineBreaks.replace('\r', '\n');
+        String textWithConsistentLineBreaks = makeStringBySimplifyingNewLines(text);
         stringReplaceAll(WTFMove(textWithConsistentLineBreaks));
         return { };
     }

Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.cpp (293325 => 293326)


--- trunk/Source/WebCore/html/HTMLTextAreaElement.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -394,9 +394,7 @@
     m_wasModifiedByUser = false;
     // Code elsewhere normalizes line endings added by the user via the keyboard or pasting.
     // We normalize line endings coming from _javascript_ here.
-    String normalizedValue = newValue.isNull() ? emptyString() : newValue;
-    normalizedValue.replace("\r\n", "\n");
-    normalizedValue.replace('\r', '\n');
+    auto normalizedValue = newValue.isNull() ? emptyString() : makeStringBySimplifyingNewLines(newValue);
 
     // Return early because we don't want to move the caret or trigger other side effects
     // when the value isn't changing. This matches Firefox behavior, at least.

Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp (293325 => 293326)


--- trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -258,7 +258,7 @@
     end = std::min(end, textLength);
 
     if (start < end)
-        text.replace(start, end - start, replacement);
+        text = makeStringByReplacing(text, start, end - start, replacement);
     else
         text = makeStringByInserting(text, replacement, start);
 

Modified: trunk/Source/WebCore/html/LinkRelAttribute.cpp (293325 => 293326)


--- trunk/Source/WebCore/html/LinkRelAttribute.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/html/LinkRelAttribute.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -84,8 +84,7 @@
 #endif
     } else {
         // Tokenize the rel attribute and set bits based on specific keywords that we find.
-        String relCopy = rel;
-        relCopy.replace('\n', ' ');
+        String relCopy = makeStringByReplacingAll(rel, '\n', ' ');
         for (auto word : StringView(relCopy).split(' ')) {
             if (equalLettersIgnoringASCIICase(word, "stylesheet"))
                 isStyleSheet = true;

Modified: trunk/Source/WebCore/html/TextFieldInputType.cpp (293325 => 293326)


--- trunk/Source/WebCore/html/TextFieldInputType.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/html/TextFieldInputType.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -626,7 +626,9 @@
     unsigned textLength = eventText.length();
     while (textLength > 0 && isHTMLLineBreak(eventText[textLength - 1]))
         textLength--;
-    eventText = eventText.left(textLength).replace("\r\n", " ").replace('\r', ' ').replace('\n', ' ');
+    eventText = makeStringByReplacingAll(eventText.left(textLength), "\r\n", " ");
+    eventText = makeStringByReplacingAll(eventText, '\r', ' ');
+    eventText = makeStringByReplacingAll(eventText, '\n', ' ');
     event.setText(limitLength(eventText, appendableLength));
 }
 

Modified: trunk/Source/WebCore/html/URLDecomposition.cpp (293325 => 293326)


--- trunk/Source/WebCore/html/URLDecomposition.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/html/URLDecomposition.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -233,9 +233,8 @@
         // If the given value is the empty string, set url's query to null.
         fullURL.setQuery({ });
     } else {
-        String newSearch = value;
         // Make sure that '#' in the query does not leak to the hash.
-        fullURL.setQuery(newSearch.replace('#', "%23"_s));
+        fullURL.setQuery(makeStringByReplacingAll(value, '#', "%23"_s));
     }
     setFullURL(fullURL);
 }

Modified: trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp (293325 => 293326)


--- trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -984,7 +984,7 @@
         return Exception { NotFoundError };
 
     String sheetText = m_parsedStyleSheet->text();
-    sheetText.replace(sourceData->ruleHeaderRange.start, sourceData->ruleHeaderRange.length(), selector);
+    sheetText = makeStringByReplacing(sheetText, sourceData->ruleHeaderRange.start, sourceData->ruleHeaderRange.length(), selector);
     m_parsedStyleSheet->setText(sheetText);
     m_pageStyleSheet->clearHadRulesMutation();
     fireStyleSheetChanged();
@@ -1489,8 +1489,7 @@
     String text = m_parsedStyleSheet->text();
     ASSERT_WITH_SECURITY_IMPLICATION(bodyEnd <= text.length()); // bodyEnd is exclusive
 
-    text.replace(bodyStart, bodyEnd - bodyStart, newStyleText);
-    *result = text;
+    *result = makeStringByReplacing(text, bodyStart, bodyEnd - bodyStart, newStyleText);
     return true;
 }
 

Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (293325 => 293326)


--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -498,8 +498,8 @@
         auto textContent = downcast<InlineTextBox>(layoutBox).content();
         stream << " length->(" << textContent.length() << ")";
 
-        textContent.replace('\\', "\\\\"_s);
-        textContent.replace('\n', "\\n"_s);
+        textContent = makeStringByReplacingAll(textContent, '\\', "\\\\"_s);
+        textContent = makeStringByReplacingAll(textContent, '\n', "\\n"_s);
 
         const size_t maxPrintedLength = 80;
         if (textContent.length() > maxPrintedLength) {

Modified: trunk/Source/WebCore/loader/FormSubmission.cpp (293325 => 293326)


--- trunk/Source/WebCore/loader/FormSubmission.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/loader/FormSubmission.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -65,6 +65,7 @@
     return ++nextIdentifier;
 }
 
+// FIXME: This function copies the body a lot and is really inefficient.
 static void appendMailtoPostFormDataToURL(URL& url, const FormData& data, const String& encodingType)
 {
     String body = data.flattenToString();
@@ -71,13 +72,13 @@
 
     if (equalLettersIgnoringASCIICase(encodingType, "text/plain")) {
         // Convention seems to be to decode, and s/&/\r\n/. Also, spaces are encoded as %20.
-        body = PAL::decodeURLEscapeSequences(body.replace('&', "\r\n"_s).replace('+', ' '));
+        body = PAL::decodeURLEscapeSequences(makeStringByReplacingAll(makeStringByReplacingAll(body, '&', "\r\n"_s), '+', ' '));
     }
 
     Vector<char> bodyData;
     bodyData.append("body=", 5);
     FormDataBuilder::encodeStringAsFormData(bodyData, body.utf8());
-    body = String(bodyData.data(), bodyData.size()).replace('+', "%20"_s);
+    body = makeStringByReplacingAll(String(bodyData.data(), bodyData.size()), '+', "%20"_s);
 
     auto query = url.query();
     if (query.isEmpty())
@@ -156,8 +157,7 @@
 
 static PAL::TextEncoding encodingFromAcceptCharset(const String& acceptCharset, Document& document)
 {
-    String normalizedAcceptCharset = acceptCharset;
-    normalizedAcceptCharset.replace(',', ' ');
+    String normalizedAcceptCharset = makeStringByReplacingAll(acceptCharset, ',', ' ');
 
     for (auto charset : StringView { normalizedAcceptCharset }.split(' ')) {
         PAL::TextEncoding encoding(charset);

Modified: trunk/Source/WebCore/page/Frame.cpp (293325 => 293326)


--- trunk/Source/WebCore/page/Frame.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/page/Frame.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -504,7 +504,7 @@
 
     // Make numbers and _'s in field names behave like word boundaries, e.g., "address2"
     replace(mutableStringToMatch, JSC::Yarr::RegularExpression("\\d"), " ");
-    mutableStringToMatch.replace('_', ' ');
+    mutableStringToMatch = makeStringByReplacingAll(mutableStringToMatch, '_', ' ');
     
     JSC::Yarr::RegularExpression regExp = createRegExpForLabels(labels);
     // Use the largest match we can find in the whole string

Modified: trunk/Source/WebCore/platform/LocalizedStrings.cpp (293325 => 293326)


--- trunk/Source/WebCore/platform/LocalizedStrings.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/platform/LocalizedStrings.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -302,7 +302,7 @@
 #elif USE(GLIB)
     return WEB_UI_FORMAT_STRING("Look Up “%s”", "Look Up context menu item with selected word", truncatedStringForMenuItem(selectedString).utf8().data());
 #else
-    return WEB_UI_STRING("Look Up “<selection>”", "Look Up context menu item with selected word").replace("<selection>", truncatedStringForMenuItem(selectedString));
+    return makeStringByReplacingAll(WEB_UI_STRING("Look Up “<selection>”", "Look Up context menu item with selected word"), "<selection>"_s, truncatedStringForMenuItem(selectedString));
 #endif
 }
 
@@ -915,7 +915,7 @@
 #elif USE(GLIB)
     return WEB_UI_FORMAT_STRING("%s %d×%d pixels", "window title for a standalone image (uses multiplication symbol, not x)", filename.utf8().data(), size.width(), size.height());
 #else
-    return WEB_UI_FORMAT_STRING("<filename> %d×%d pixels", "window title for a standalone image (uses multiplication symbol, not x)", size.width(), size.height()).replace("<filename>", filename);
+    return makeStringByReplacingAll(WEB_UI_FORMAT_STRING("<filename> %d×%d pixels", "window title for a standalone image (uses multiplication symbol, not x)", size.width(), size.height()), "<filename>"_s, filename);
 #endif
 }
 
@@ -1325,7 +1325,7 @@
 #elif USE(GLIB)
     return WEB_UI_FORMAT_STRING("%s WebCrypto Master Key", "Name of application's single WebCrypto master key in Keychain", localizedApplicationName.utf8().data());
 #else
-    return WEB_UI_STRING("<application> WebCrypto Master Key", "Name of application's single WebCrypto master key in Keychain").replace("<application>", localizedApplicationName);
+    return makeStringByReplacingAll(WEB_UI_STRING("<application> WebCrypto Master Key", "Name of application's single WebCrypto master key in Keychain"), "<application>"_s, localizedApplicationName);
 #endif
 }
 

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVStreamDataParserMIMETypeCache.mm (293325 => 293326)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVStreamDataParserMIMETypeCache.mm	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVStreamDataParserMIMETypeCache.mm	2022-04-25 15:25:06 UTC (rev 293326)
@@ -101,8 +101,7 @@
     if (!assetCache.isAvailable() || assetCache.supportedTypes().isEmpty())
         return false;
 
-    String replacementType { type.raw() };
-    replacementType.replace(type.containerType(), *assetCache.supportedTypes().begin());
+    String replacementType = makeStringByReplacingAll(type.raw(), type.containerType(), *assetCache.supportedTypes().begin());
     return assetCache.canDecodeType(replacementType) == MediaPlayerEnums::SupportsType::IsSupported;
 #endif
 

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (293325 => 293326)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -2177,8 +2177,8 @@
     g_object_set(element, "temp-template", newDownloadTemplate.get(), nullptr);
     GST_DEBUG_OBJECT(pipeline(), "Reconfigured file download template from '%s' to '%s'", oldDownloadTemplate.get(), newDownloadTemplate.get());
 
-    auto newDownloadPrefixPath = String::fromLatin1(newDownloadTemplate.get());
-    purgeOldDownloadFiles(newDownloadPrefixPath.replace("XXXXXX", ""));
+    auto newDownloadPrefixPath = makeStringByReplacingAll(String::fromLatin1(newDownloadTemplate.get()), "XXXXXX", "");
+    purgeOldDownloadFiles(newDownloadPrefixPath);
 }
 
 void MediaPlayerPrivateGStreamer::downloadBufferFileCreatedCallback(MediaPlayerPrivateGStreamer* player)

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp (293325 => 293326)


--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -113,7 +113,7 @@
     // The track name is still unknown at this time, though.
     static size_t appendPipelineCount = 0;
     String pipelineName = makeString("append-pipeline-",
-        m_sourceBufferPrivate.type().containerType().replace("/", "-"), '-', appendPipelineCount++);
+        makeStringByReplacingAll(m_sourceBufferPrivate.type().containerType(), '/', '-'), '-', appendPipelineCount++);
     m_pipeline = gst_pipeline_new(pipelineName.utf8().data());
 
     m_bus = adoptGRef(gst_pipeline_get_bus(GST_PIPELINE(m_pipeline.get())));
@@ -299,9 +299,11 @@
     if (GST_MESSAGE_SRC(message) == reinterpret_cast<GstObject*>(m_pipeline.get())) {
         GstState currentState, newState;
         gst_message_parse_state_changed(message, &currentState, &newState, nullptr);
-        CString sourceBufferType = String(m_sourceBufferPrivate.type().raw())
-            .replace("/", "_").replace(" ", "_")
-            .replace("\"", "").replace("\'", "").utf8();
+        String sourceBufferTypeString = makeStringByReplacingAll(m_sourceBufferPrivate.type().raw(), '/', '_');
+        sourceBufferTypeString = makeStringByReplacingAll(sourceBufferTypeString, ' ', '_');
+        sourceBufferTypeString = makeStringByReplacingAll(sourceBufferTypeString, '"', ""_s);
+        sourceBufferTypeString = makeStringByReplacingAll(sourceBufferTypeString, '\'', ""_s);
+        CString sourceBufferType = sourceBufferTypeString.utf8();
         CString dotFileName = makeString("webkit-append-",
             sourceBufferType.data(), '-',
             gst_element_state_get_name(currentState), '_',

Modified: trunk/Source/WebCore/platform/gtk/SelectionData.cpp (293325 => 293326)


--- trunk/Source/WebCore/platform/gtk/SelectionData.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/platform/gtk/SelectionData.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -22,14 +22,13 @@
 #include <wtf/glib/GUniquePtr.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/StringBuilder.h>
+#include <wtf/unicode/CharacterNames.h>
 
 namespace WebCore {
 
-static void replaceNonBreakingSpaceWithSpace(String& str)
+static void replaceNonBreakingSpaceWithSpace(String& string)
 {
-    static const UChar NonBreakingSpaceCharacter = 0xA0;
-    static const UChar SpaceCharacter = ' ';
-    str.replace(NonBreakingSpaceCharacter, SpaceCharacter);
+    string = makeStringByReplacingAll(string, noBreakSpace, space);
 }
 
 void SelectionData::setText(const String& newText)

Modified: trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerDisplayCaptureDeviceManager.cpp (293325 => 293326)


--- trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerDisplayCaptureDeviceManager.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerDisplayCaptureDeviceManager.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -95,7 +95,8 @@
     waitResponseSignal(objectPath.get());
 
     auto requestPath = String::fromLatin1(objectPath.get());
-    auto sessionPath = requestPath.replace("/request/", "/session/").replace(token, sessionToken);
+    auto sessionPath = makeStringByReplacingAll(requestPath, "/request/"_s, "/session/"_s);
+    sessionPath = makeStringByReplacingAll(sessionPath, token, sessionToken);
 
     // FIXME: Maybe check this depending on device.type().
     auto outputType = GStreamerDisplayCaptureDeviceManager::PipeWireOutputType::Monitor | GStreamerDisplayCaptureDeviceManager::PipeWireOutputType::Window;

Modified: trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp (293325 => 293326)


--- trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -309,7 +309,8 @@
 
     ResourceResponse response { { { }, "http://example.com/"_s }, { }, -1, { } };
     response.setHTTPStatusCode(200);
-    String escapedSuggestedFilename = String(suggestedFilename).replace('\\', "\\\\"_s).replace('"', "\\\""_s);
+    String escapedSuggestedFilename = makeStringByReplacingAll(suggestedFilename, '\\', "\\\\"_s);
+    escapedSuggestedFilename = makeStringByReplacingAll(escapedSuggestedFilename, '"', "\\\""_s);
     response.setHTTPHeaderField(HTTPHeaderName::ContentDisposition, makeString("attachment; filename=\"", escapedSuggestedFilename, '"'));
     return response.suggestedFilename();
 }

Modified: trunk/Source/WebCore/platform/network/soup/ResourceRequestSoup.cpp (293325 => 293326)


--- trunk/Source/WebCore/platform/network/soup/ResourceRequestSoup.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/platform/network/soup/ResourceRequestSoup.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -177,8 +177,7 @@
     // characters, so that soup does not interpret them as fragment identifiers.
     // See http://wkbug.com/68089
     if (m_url.protocolIsData()) {
-        String urlString = m_url.string();
-        urlString.replace("#", "%23");
+        String urlString = makeStringByReplacingAll(m_url.string(), '#', "%23"_s);
         return GUniquePtr<SoupURI>(soup_uri_new(urlString.utf8().data()));
     }
 

Modified: trunk/Source/WebCore/platform/network/soup/ResourceResponseSoup.cpp (293325 => 293326)


--- trunk/Source/WebCore/platform/network/soup/ResourceResponseSoup.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/platform/network/soup/ResourceResponseSoup.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -127,7 +127,7 @@
             illegalCharactersInFilename.add(character);
     }
     for (auto character : illegalCharactersInFilename)
-        result = result.replace(character, '_');
+        result = makeStringByReplacingAll(result, character, '_');
 
     return result;
 }

Modified: trunk/Source/WebCore/platform/text/DateTimeFormat.cpp (293325 => 293326)


--- trunk/Source/WebCore/platform/text/DateTimeFormat.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/platform/text/DateTimeFormat.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -265,7 +265,7 @@
         if (literal[i] == '\'')
             buffer.append("''");
         else {
-            buffer.append('\'', String { literal.substring(i) }.replace('\'', "''"_s), '\'');
+            buffer.append('\'', makeStringByReplacingAll(literal.substring(i), '\'', "''"_s), '\'');
             return;
         }
     }

Modified: trunk/Source/WebCore/platform/text/LocaleToScriptMapping.cpp (293325 => 293326)


--- trunk/Source/WebCore/platform/text/LocaleToScriptMapping.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/platform/text/LocaleToScriptMapping.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -364,8 +364,7 @@
     static_assert(LocaleName("aa").value() == 0x6161000000000000ULL);
     static_assert(LocaleName("zh_tw").value() == 0x7a685f7477000000ULL);
     static constexpr SortedArrayMap map { localeScriptList };
-    String canonicalLocaleString = locale;
-    canonicalLocaleString.replace('-', '_');
+    String canonicalLocaleString = makeStringByReplacingAll(locale, '-', '_');
     for (StringView canonicalLocale = canonicalLocaleString; !canonicalLocale.isEmpty(); ) {
         if (auto scriptCode = map.tryGet(canonicalLocale))
             return *scriptCode;

Modified: trunk/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp (293325 => 293326)


--- trunk/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -79,8 +79,7 @@
         filePath = FileSystem::stringFromFileSystemRepresentation(normalizedPath);
         availableLocales.add(locale, Vector<String>()).iterator->value.append(filePath);
 
-        String localeReplacingUnderscores = locale;
-        localeReplacingUnderscores.replace('_', '-');
+        String localeReplacingUnderscores = makeStringByReplacingAll(locale, '_', '-');
         if (locale != localeReplacingUnderscores)
             availableLocales.add(localeReplacingUnderscores, Vector<String>()).iterator->value.append(filePath);
 

Modified: trunk/Source/WebCore/platform/text/win/LocaleWin.cpp (293325 => 293326)


--- trunk/Source/WebCore/platform/text/win/LocaleWin.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/platform/text/win/LocaleWin.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -302,7 +302,7 @@
 String LocaleWin::shortMonthFormat()
 {
     if (m_shortMonthFormat.isNull())
-        m_shortMonthFormat = convertWindowsDateTimeFormat(getLocaleInfoString(LOCALE_SYEARMONTH)).replace("MMMM", "MMM");
+        m_shortMonthFormat = makeStringByReplacingAll(convertWindowsDateTimeFormat(getLocaleInfoString(LOCALE_SYEARMONTH)), "MMMM"_s, "MMM"_s);
     return m_shortMonthFormat;
 }
 

Modified: trunk/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp (293325 => 293326)


--- trunk/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -38,6 +38,7 @@
 #include <wtf/text/CString.h>
 #include <wtf/text/StringBuilder.h>
 #include <wtf/text/win/WCharStringExtras.h>
+#include <wtf/unicode/CharacterNames.h>
 
 namespace WebCore {
 
@@ -298,11 +299,9 @@
     str = result.toString();
 }
 
-void replaceNBSPWithSpace(String& str)
+void replaceNBSPWithSpace(String& string)
 {
-    static const UChar NonBreakingSpaceCharacter = 0xA0;
-    static const UChar SpaceCharacter = ' ';
-    str.replace(NonBreakingSpaceCharacter, SpaceCharacter);
+    string = makeStringByReplacingAll(string, noBreakSpace, space);
 }
 
 FORMATETC* urlWFormat()

Modified: trunk/Source/WebCore/rendering/LegacyInlineTextBox.cpp (293325 => 293326)


--- trunk/Source/WebCore/rendering/LegacyInlineTextBox.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/rendering/LegacyInlineTextBox.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -528,8 +528,8 @@
 
     String value = renderer().text();
     value = value.substring(start(), len());
-    value.replace('\\', "\\\\"_s);
-    value.replace('\n', "\\n"_s);
+    value = makeStringByReplacingAll(value, '\\', "\\\\"_s);
+    value = makeStringByReplacingAll(value, '\n', "\\n"_s);
     stream << boxName() << " " << FloatRect(x(), y(), width(), height()) << " (" << this << ") renderer->(" << &renderer() << ") run(" << start() << ", " << start() + len() << ") \"" << value.utf8().data() << "\"";
     stream.nextLine();
 }

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (293325 => 293326)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -3509,7 +3509,7 @@
     constexpr UChar discCharacterToReplace = bullet;
 #endif
 
-    return string.replace(discCharacterToReplace, textSecurityDiscPUACodePoint);
+    return makeStringByReplacingAll(string, discCharacterToReplace, textSecurityDiscPUACodePoint);
 #endif
 }
     

Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (293325 => 293326)


--- trunk/Source/WebCore/rendering/RenderObject.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -1265,8 +1265,8 @@
             String value = node()->nodeValue();
             stream << " length->(" << value.length() << ")";
 
-            value.replace('\\', "\\\\"_s);
-            value.replace('\n', "\\n"_s);
+            value = makeStringByReplacingAll(value, '\\', "\\\\"_s);
+            value = makeStringByReplacingAll(value, '\n', "\\n"_s);
             
             const int maxPrintedLength = 80;
             if (value.length() > maxPrintedLength) {

Modified: trunk/Source/WebCore/rendering/RenderText.cpp (293325 => 293326)


--- trunk/Source/WebCore/rendering/RenderText.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/rendering/RenderText.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -1351,7 +1351,7 @@
     m_text = newText;
 
     if (m_useBackslashAsYenSymbol)
-        m_text.replace('\\', yenSign);
+        m_text = makeStringByReplacingAll(m_text, '\\', yenSign);
     
     const auto& style = this->style();
     if (style.textTransform() != TextTransform::None)

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp (293325 => 293326)


--- trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -52,9 +52,9 @@
         // copy of the original character data content. It will convert all newline and tab
         // characters into space characters. Then, it will draw all space characters, including
         // leading, trailing and multiple contiguous space characters.
-        newString.replace('\t', ' ');
-        newString.replace('\n', ' ');
-        newString.replace('\r', ' ');
+        newString = makeStringByReplacingAll(newString, '\t', ' ');
+        newString = makeStringByReplacingAll(newString, '\n', ' ');
+        newString = makeStringByReplacingAll(newString, '\r', ' ');
         return newString;
     }
 
@@ -63,9 +63,9 @@
     // characters. Then it will convert all tab characters into space characters.
     // Then, it will strip off all leading and trailing space characters.
     // Then, all contiguous space characters will be consolidated.
-    newString.replace('\n', emptyString());
-    newString.replace('\r', emptyString());
-    newString.replace('\t', ' ');
+    newString = makeStringByReplacingAll(newString, '\n', ""_s);
+    newString = makeStringByReplacingAll(newString, '\r', ""_s);
+    newString = makeStringByReplacingAll(newString, '\t', ' ');
     return newString;
 }
 

Modified: trunk/Source/WebCore/xml/XSLTProcessor.cpp (293325 => 293326)


--- trunk/Source/WebCore/xml/XSLTProcessor.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebCore/xml/XSLTProcessor.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -45,8 +45,8 @@
 static inline void transformTextStringToXHTMLDocumentString(String& text)
 {
     // Modify the output so that it is a well-formed XHTML document with a <pre> tag enclosing the text.
-    text.replace('&', "&amp;"_s);
-    text.replace('<', "&lt;"_s);
+    text = makeStringByReplacingAll(text, '&', "&amp;"_s);
+    text = makeStringByReplacingAll(text, '<', "&lt;"_s);
     text = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
         "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
         "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"

Modified: trunk/Source/WebKit/NetworkProcess/DatabaseUtilities.cpp (293325 => 293326)


--- trunk/Source/WebKit/NetworkProcess/DatabaseUtilities.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebKit/NetworkProcess/DatabaseUtilities.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -205,7 +205,7 @@
 
 String DatabaseUtilities::stripIndexQueryToMatchStoredValue(const char* originalQuery)
 {
-    return String::fromLatin1(originalQuery).replace("CREATE UNIQUE INDEX IF NOT EXISTS", "CREATE UNIQUE INDEX");
+    return makeStringByReplacingAll(String::fromLatin1(originalQuery), "CREATE UNIQUE INDEX IF NOT EXISTS"_s, "CREATE UNIQUE INDEX"_s);
 }
 
 TableAndIndexPair DatabaseUtilities::currentTableAndIndexQueries(const String& tableName)

Modified: trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp (293325 => 293326)


--- trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -1590,9 +1590,9 @@
     return false;
 }
 
-static String escapeForJSON(String s)
+static String escapeForJSON(const String& s)
 {
-    return s.replace('\\', "\\\\"_s).replace('"', "\\\""_s);
+    return makeStringByReplacingAll(makeStringByReplacingAll(s, '\\', "\\\\"_s), '"', "\\\""_s);
 }
 
 template<typename IdentifierType>

Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp (293325 => 293326)


--- trunk/Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -1484,7 +1484,7 @@
         if (!g_ascii_strcasecmp(languageList[i], "C") || !g_ascii_strcasecmp(languageList[i], "POSIX"))
             languages.append("en-US"_s);
         else
-            languages.append(String::fromUTF8(languageList[i]).replace("_", "-"));
+            languages.append(makeStringByReplacingAll(String::fromUTF8(languageList[i]), '_', '-'));
     }
     context->priv->processPool->setOverrideLanguages(WTFMove(languages));
 }

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (293325 => 293326)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2022-04-25 15:25:06 UTC (rev 293326)
@@ -5232,8 +5232,7 @@
         return;
     }
 
-    String eventText = text;
-    eventText.replace(NSBackTabCharacter, NSTabCharacter); // same thing is done in KeyEventMac.mm in WebCore
+    String eventText = makeStringByReplacingAll(text, NSBackTabCharacter, NSTabCharacter); // same thing is done in KeyEventMac.mm in WebCore
     if (!dictationAlternatives.isEmpty()) {
         InsertTextOptions options;
         options.registerUndoGroup = registerUndoGroup;

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebContextMenuClient.cpp (293325 => 293326)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebContextMenuClient.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebContextMenuClient.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -60,8 +60,7 @@
 
     auto searchString = frame->editor().selectedText();
     searchString.stripWhiteSpace();
-    searchString = encodeWithURLEscapeSequences(searchString);
-    searchString.replace("%20", "+");
+    searchString = makeStringByReplacingAll(encodeWithURLEscapeSequences(searchString), "%20"_s, "+"_s);
     auto searchURL = URL { "https://www.google.com/search?q=" + searchString + "&ie=UTF-8&oe=UTF-8" };
 
     WebCore::UserGestureIndicator indicator { WebCore::ProcessingUserGesture };

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebResourceLoadObserver.cpp (293325 => 293326)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebResourceLoadObserver.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebResourceLoadObserver.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -383,9 +383,10 @@
 #define LOCAL_LOG(str, ...) \
         RELEASE_LOG(ResourceLoadStatistics, "ResourceLoadObserver::logUserInteraction: counter=%" PRIu64 ": " str, counter, ##__VA_ARGS__)
 
-        auto escapeForJSON = [](String s) {
-            s.replace('\\', "\\\\"_s).replace('"', "\\\""_s);
-            return s;
+        auto escapeForJSON = [](const String& s) {
+            auto result = makeStringByReplacingAll(s, '\\', "\\\\"_s);
+            result = makeStringByReplacingAll(result, '"', "\\\""_s);
+            return result;
         };
         auto escapedURL = escapeForJSON(url.string());
         auto escapedDomain = escapeForJSON(topFrameDomain.string());

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebHTMLRepresentation.mm (293325 => 293326)


--- trunk/Source/WebKitLegacy/mac/WebView/WebHTMLRepresentation.mm	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebHTMLRepresentation.mm	2022-04-25 15:25:06 UTC (rev 293326)
@@ -485,7 +485,7 @@
     
     // Make numbers and _'s in field names behave like word boundaries, e.g., "address2"
     replace(mutableStringToMatch, RegularExpression("\\d"), " ");
-    mutableStringToMatch.replace('_', ' ');
+    mutableStringToMatch = makeStringByReplacingAll(mutableStringToMatch, '_', ' ');
     
     RegularExpression* regExp = regExpForLabels(labels);
     // Use the largest match we can find in the whole string

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm (293325 => 293326)


--- trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm	2022-04-25 15:25:06 UTC (rev 293326)
@@ -6699,8 +6699,7 @@
     }
 
     bool eventHandled = false;
-    String eventText = text;
-    eventText.replace(NSBackTabCharacter, NSTabCharacter); // same thing is done in KeyEventMac.mm in WebCore
+    String eventText = makeStringByReplacingAll(text, NSBackTabCharacter, NSTabCharacter); // same thing is done in KeyEventMac.mm in WebCore
     if (!coreFrame->editor().hasComposition()) {
         // An insertText: might be handled by other responders in the chain if we don't handle it.
         // One example is space bar that results in scrolling down the page.

Modified: trunk/Source/WebKitLegacy/win/DOMHTMLClasses.cpp (293325 => 293326)


--- trunk/Source/WebKitLegacy/win/DOMHTMLClasses.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebKitLegacy/win/DOMHTMLClasses.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -1326,7 +1326,7 @@
 
     String newValue = inputElement.value();
     String webCoreReplacementString(replacementString, SysStringLen(replacementString));
-    newValue.replace(startTarget, endTarget - startTarget, webCoreReplacementString);
+    newValue = makeStringByReplacing(newValue, startTarget, endTarget - startTarget, webCoreReplacementString);
     inputElement.setValue(newValue);
     inputElement.setSelectionRange(index, newValue.length());
 

Modified: trunk/Source/WebKitLegacy/win/WebCoreSupport/WebContextMenuClient.cpp (293325 => 293326)


--- trunk/Source/WebKitLegacy/win/WebCoreSupport/WebContextMenuClient.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebKitLegacy/win/WebCoreSupport/WebContextMenuClient.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -57,8 +57,7 @@
 
     auto searchString = frame->editor().selectedText();
     searchString.stripWhiteSpace();
-    searchString = encodeWithURLEscapeSequences(searchString);
-    searchString.replace("%20", "+");
+    searchString = makeStringByReplacingAll(encodeWithURLEscapeSequences(searchString), "%20"_s, "+"_s);
     auto searchURL = URL { "https://www.google.com/search?q=" + searchString + "&ie=UTF-8&oe=UTF-8" };
 
     WebCore::UserGestureIndicator indicator { WebCore::ProcessingUserGesture };

Modified: trunk/Source/WebKitLegacy/win/WebLocalizableStrings.cpp (293325 => 293326)


--- trunk/Source/WebKitLegacy/win/WebLocalizableStrings.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Source/WebKitLegacy/win/WebLocalizableStrings.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -90,7 +90,7 @@
 
     for (unsigned int i = 1; i < m_string.length(); i++)
         if (m_string[i] == '@' && (m_string[i - 1] == '%' || (i > 2 && m_string[i - 1] == '$' && m_string[i - 2] >= '1' && m_string[i - 2] <= '9' && m_string[i - 3] == '%')))
-            m_string.replace(i, 1, "s");
+            m_string = makeStringByReplacing(m_string, i, 1, "s"_s);
 
     return m_string.wideCharacters().data();
 }

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/StringBuilder.cpp (293325 => 293326)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/StringBuilder.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/StringBuilder.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -209,7 +209,7 @@
     // Changing the original result of toString() should not affect the content of the StringBuilder.
     String string1 = builder.toString();
     EXPECT_EQ(String("0123456789abcdefghijklmnopqrstuvwxyzABC"_s), string1);
-    string1.replace('0', 'a');
+    string1 = makeStringByReplacingAll(string1, '0', 'a');
     EXPECT_EQ(String("0123456789abcdefghijklmnopqrstuvwxyzABC"_s), builder.toString());
     EXPECT_EQ(String("a123456789abcdefghijklmnopqrstuvwxyzABC"_s), string1);
 
@@ -251,7 +251,7 @@
     EXPECT_EQ(capacity, builder.capacity());
     EXPECT_EQ(string1.characters8(), builder.characters8());
     EXPECT_EQ(String("0123456789abcdefghijklmnopqrstuvwxyzABC"_s), string1);
-    string1.replace('0', 'a');
+    string1 = makeStringByReplacingAll(string1, '0', 'a');
     EXPECT_EQ(String("0123456789abcdefghijklmnopqrstuvwxyzABC"_s), builder.toStringPreserveCapacity());
     EXPECT_EQ(String("a123456789abcdefghijklmnopqrstuvwxyzABC"_s), string1);
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp (293325 => 293326)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -239,38 +239,38 @@
     // Cases for 8Bit source.
     String testString = "1224"_s;
     EXPECT_TRUE(testString.is8Bit());
-    testString.replace('2', ""_s);
+    testString = makeStringByReplacingAll(testString, '2', ""_s);
     EXPECT_STREQ("14", testString.utf8().data());
 
     testString = "1224"_s;
     EXPECT_TRUE(testString.is8Bit());
-    testString.replace('2', "3"_s);
+    testString = makeStringByReplacingAll(testString, '2', "3"_s);
     EXPECT_STREQ("1334", testString.utf8().data());
 
     testString = "1224"_s;
     EXPECT_TRUE(testString.is8Bit());
-    testString.replace('2', "555"_s);
+    testString = makeStringByReplacingAll(testString, '2', "555"_s);
     EXPECT_STREQ("15555554", testString.utf8().data());
 
     testString = "1224"_s;
     EXPECT_TRUE(testString.is8Bit());
-    testString.replace('3', "NotFound"_s);
+    testString = makeStringByReplacingAll(testString, '3', "NotFound"_s);
     EXPECT_STREQ("1224", testString.utf8().data());
 
     // Cases for 16Bit source.
     testString = String::fromUTF8("résumé");
     EXPECT_FALSE(testString.is8Bit());
-    testString.replace(UChar(0x00E9 /*U+00E9 is 'é'*/), "e"_s);
+    testString = makeStringByReplacingAll(testString, UChar(0x00E9 /*U+00E9 is 'é'*/), "e"_s);
     EXPECT_STREQ("resume", testString.utf8().data());
 
     testString = String::fromUTF8("résumé");
     EXPECT_FALSE(testString.is8Bit());
-    testString.replace(UChar(0x00E9 /*U+00E9 is 'é'*/), ""_s);
+    testString = makeStringByReplacingAll(testString, UChar(0x00E9 /*U+00E9 is 'é'*/), ""_s);
     EXPECT_STREQ("rsum", testString.utf8().data());
 
     testString = String::fromUTF8("résumé");
     EXPECT_FALSE(testString.is8Bit());
-    testString.replace('3', "NotFound"_s);
+    testString = makeStringByReplacingAll(testString, '3', "NotFound"_s);
     EXPECT_STREQ("résumé", testString.utf8().data());
 }
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit/OverrideAppleLanguagesPreference.mm (293325 => 293326)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit/OverrideAppleLanguagesPreference.mm	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/OverrideAppleLanguagesPreference.mm	2022-04-25 15:25:06 UTC (rev 293326)
@@ -73,8 +73,8 @@
         [task launch];
         NSData *data = "" readDataToEndOfFile];
         m_savedAppleLanguages = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
-        m_savedAppleLanguages.replace("\n", "");
-        m_savedAppleLanguages.replace(" ", "");
+        m_savedAppleLanguages = makeStringByReplacingAll(m_savedAppleLanguages, '\n', ""_s);
+        m_savedAppleLanguages = makeStringByReplacingAll(m_savedAppleLanguages, ' ', ""_s);
     }
 
     ~AppleLanguagesTest()

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/atspi/AccessibilityUIElementAtspi.cpp (293325 => 293326)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/atspi/AccessibilityUIElementAtspi.cpp	2022-04-25 14:12:15 UTC (rev 293325)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/atspi/AccessibilityUIElementAtspi.cpp	2022-04-25 15:25:06 UTC (rev 293326)
@@ -895,7 +895,7 @@
     if (!m_element->interfaces().contains(WebCore::AccessibilityObjectAtspi::Interface::Text))
         return JSStringCreateWithCharacters(nullptr, 0);
 
-    auto value = makeString("AXValue: ", m_element->text().replace('\n', "<\\n>"_s).replace(objectReplacementCharacter, "<obj>"_s));
+    auto value = makeString("AXValue: ", makeStringByReplacingAll(makeStringByReplacingAll(m_element->text(), '\n', "<\\n>"_s), objectReplacementCharacter, "<obj>"_s));
     return OpaqueJSString::tryCreate(value).leakRef();
 }
 
@@ -1203,7 +1203,7 @@
         auto attributes = m_element->textAttributes(i);
         auto rangeStart = std::max<int>(location, attributes.startOffset);
         auto rangeEnd = std::min<int>(limit, attributes.endOffset);
-        builder.append("\n\tRange attributes for '", text.substring(rangeStart, rangeEnd - rangeStart).replace('\n', "<\\n>"_s).replace(objectReplacementCharacter, "<obj>"_s), "':");
+        builder.append("\n\tRange attributes for '", makeStringByReplacingAll(makeStringByReplacingAll(text.substring(rangeStart, rangeEnd - rangeStart), '\n', "<\\n>"_s), objectReplacementCharacter, "<obj>"_s), "':");
         buildAttributes(attributes);
         endOffset = attributes.endOffset;
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to