Replace multiparameter overloads of append() in StringBuilder as a first step toward...
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Aug 2019 23:09:06 +0000 (23:09 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Aug 2019 23:09:06 +0000 (23:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=200614

Reviewed by Darin Adler.

Renames StringBuilder::append(const LChar*, unsigned), StringBuilder::append(const UChar*, unsigned) and
StringBuilder::append(const char*, unsigned) to StringBuilder::appendCharacters(...).

Renames StringBuilder::append(const String& string, unsigned offset, unsigned length) to
StringBuilder::appendSubstring(...).

Source/JavaScriptCore:

* dfg/DFGStrengthReductionPhase.cpp:
(JSC::DFG::StrengthReductionPhase::handleNode):
* runtime/ConfigFile.cpp:
(JSC::ConfigFile::parse):
* runtime/LiteralParser.cpp:
(JSC::LiteralParser<CharType>::Lexer::lexStringSlow):
* tools/FunctionOverrides.cpp:
(JSC::parseClause):
Update for renames.

Source/WebCore:

* dom/Range.cpp:
(WebCore::Range::toString const):
* editing/Editing.cpp:
(WebCore::stringWithRebalancedWhitespace):
* editing/MarkupAccumulator.cpp:
(WebCore::appendCharactersReplacingEntitiesInternal):
* editing/TextIterator.cpp:
(WebCore::TextIteratorCopyableText::appendToStringBuilder const):
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::valueWithHardLineBreaks const):
* html/parser/HTMLTokenizer.cpp:
(WebCore::HTMLTokenizer::bufferedCharacters const):
* platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
(WebCore::InbandTextTrackPrivateAVF::processNativeSamples):
* platform/text/SegmentedString.cpp:
(WebCore::SegmentedString::Substring::appendTo const):
* platform/text/TextCodecICU.cpp:
(WebCore::TextCodecICU::decode):
* xml/XSLTProcessorLibxslt.cpp:
(WebCore::writeToStringBuilder):
Update for renames.

Source/WebKit:

* Shared/mac/AuxiliaryProcessMac.mm:
(WebKit::setAndSerializeSandboxParameters):
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::didReceiveInvalidMessage):
Update for renames.

Source/WTF:

* wtf/HexNumber.h:
(WTF::appendUnsignedAsHexFixedSize):
Add overload that explicitly takes a StringBuilder to work around rename from append to appendCharacters.

* wtf/text/StringBuilder.cpp:
(WTF::StringBuilder::appendCharacters):
(WTF::StringBuilder::append):
* wtf/text/StringBuilder.h:
(WTF::StringBuilder::appendCharacters):
(WTF::StringBuilder::append):
(WTF::StringBuilder::appendSubstring):
(WTF::StringBuilder::appendLiteral):
(WTF::IntegerToStringConversionTrait<StringBuilder>::flush):
Update for renames.

Tools:

* TestWebKitAPI/Tests/WTF/StringBuilder.cpp:
(TestWebKitAPI::TEST):
Update for renames.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248552 268f45cc-cd09-0410-ab3c-d52691b4dbfc

28 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/dfg/DFGStrengthReductionPhase.cpp
Source/JavaScriptCore/runtime/ConfigFile.cpp
Source/JavaScriptCore/runtime/LiteralParser.cpp
Source/JavaScriptCore/tools/FunctionOverrides.cpp
Source/WTF/ChangeLog
Source/WTF/wtf/HexNumber.h
Source/WTF/wtf/text/StringBuilder.cpp
Source/WTF/wtf/text/StringBuilder.h
Source/WebCore/ChangeLog
Source/WebCore/dom/Range.cpp
Source/WebCore/editing/Editing.cpp
Source/WebCore/editing/MarkupAccumulator.cpp
Source/WebCore/editing/TextIterator.cpp
Source/WebCore/html/HTMLTextFormControlElement.cpp
Source/WebCore/html/parser/HTMLTokenizer.cpp
Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp
Source/WebCore/platform/text/SegmentedString.cpp
Source/WebCore/platform/text/TextCodecICU.cpp
Source/WebCore/platform/wpe/RenderThemeWPE.cpp
Source/WebCore/rendering/RenderThemeGtk.cpp
Source/WebCore/xml/XSLTProcessorLibxslt.cpp
Source/WebKit/ChangeLog
Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm
Source/WebKit/UIProcess/WebProcessPool.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WTF/StringBuilder.cpp
Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebContext.cpp

index 576b0d8..d09201f 100644 (file)
@@ -1,3 +1,26 @@
+2019-08-12  Sam Weinig  <weinig@apple.com>
+
+        Replace multiparameter overloads of append() in StringBuilder as a first step toward standardizinging on the flexibleAppend() implementation
+        https://bugs.webkit.org/show_bug.cgi?id=200614
+
+        Reviewed by Darin Adler.
+
+        Renames StringBuilder::append(const LChar*, unsigned), StringBuilder::append(const UChar*, unsigned) and 
+        StringBuilder::append(const char*, unsigned) to StringBuilder::appendCharacters(...).
+        
+        Renames StringBuilder::append(const String& string, unsigned offset, unsigned length) to 
+        StringBuilder::appendSubstring(...).
+
+        * dfg/DFGStrengthReductionPhase.cpp:
+        (JSC::DFG::StrengthReductionPhase::handleNode):
+        * runtime/ConfigFile.cpp:
+        (JSC::ConfigFile::parse):
+        * runtime/LiteralParser.cpp:
+        (JSC::LiteralParser<CharType>::Lexer::lexStringSlow):
+        * tools/FunctionOverrides.cpp:
+        (JSC::parseClause):
+        Update for renames.
+
 2019-08-12  Adrian Perez de Castro  <aperez@igalia.com>
 
         [WPE][GTK] Fix building without unified sources
index 6c74486..3d9e805 100644 (file)
@@ -854,7 +854,7 @@ private:
 
                 unsigned replLen = replace.length();
                 if (lastIndex < result.start || replLen) {
-                    builder.append(string, lastIndex, result.start - lastIndex);
+                    builder.appendSubstring(string, lastIndex, result.start - lastIndex);
                     if (replLen) {
                         StringBuilder replacement;
                         substituteBackreferences(replacement, replace, string, ovector.data(), regExp);
@@ -899,7 +899,7 @@ private:
                 m_node->convertToIdentityOn(stringNode);
             else {
                 if (lastIndex < string.length())
-                    builder.append(string, lastIndex, string.length() - lastIndex);
+                    builder.appendSubstring(string, lastIndex, string.length() - lastIndex);
                 
                 m_node->convertToLazyJSConstant(m_graph, LazyJSValue::newString(m_graph, builder.toString()));
             }
index 636c801..1c05e4b 100644 (file)
@@ -314,7 +314,7 @@ void ConfigFile::parse()
                     while (*p && !isASCIISpace(*p) && *p != '=')
                         p++;
 
-                    builder.append(optionNameStart, p - optionNameStart);
+                    builder.appendCharacters(optionNameStart, p - optionNameStart);
 
                     while (*p && isASCIISpace(*p) && *p != '=')
                         p++;
@@ -336,7 +336,7 @@ void ConfigFile::parse()
                     while (*p && !isASCIISpace(*p))
                         p++;
 
-                    builder.append(optionValueStart, p - optionValueStart);
+                    builder.appendCharacters(optionValueStart, p - optionValueStart);
                     builder.append('\n');
 
                     while (*p && isASCIISpace(*p))
index 84939b5..b39ddad 100644 (file)
@@ -622,12 +622,12 @@ TokenType LiteralParser<CharType>::Lexer::lexStringSlow(LiteralParserToken<CharT
         }
 
         if (!m_builder.isEmpty())
-            m_builder.append(runStart, m_ptr - runStart);
+            m_builder.appendCharacters(runStart, m_ptr - runStart);
 
 slowPathBegin:
         if ((m_mode != NonStrictJSON) && m_ptr < m_end && *m_ptr == '\\') {
             if (m_builder.isEmpty() && runStart < m_ptr)
-                m_builder.append(runStart, m_ptr - runStart);
+                m_builder.appendCharacters(runStart, m_ptr - runStart);
             ++m_ptr;
             if (m_ptr >= m_end) {
                 m_lexErrorMessage = "Unterminated string"_s;
index 75e0999..c1154f5 100644 (file)
@@ -217,7 +217,7 @@ static String parseClause(const char* keyword, size_t keywordLength, FILE* file,
             if (p[strlen(terminator)] != '\n')
                 FAIL_WITH_ERROR(SYNTAX_ERROR, ("Unexpected characters after '", keyword, "' clause end delimiter '", delimiter, "':\n", line, "\n"));
 
-            builder.append(line, p - line + 1);
+            builder.appendCharacters(line, p - line + 1);
             return builder.toString();
         }
         builder.append(line);
index a62af77..b9da92d 100644 (file)
@@ -1,3 +1,31 @@
+2019-08-12  Sam Weinig  <weinig@apple.com>
+
+        Replace multiparameter overloads of append() in StringBuilder as a first step toward standardizinging on the flexibleAppend() implementation
+        https://bugs.webkit.org/show_bug.cgi?id=200614
+
+        Reviewed by Darin Adler.
+
+        Renames StringBuilder::append(const LChar*, unsigned), StringBuilder::append(const UChar*, unsigned) and 
+        StringBuilder::append(const char*, unsigned) to StringBuilder::appendCharacters(...).
+        
+        Renames StringBuilder::append(const String& string, unsigned offset, unsigned length) to 
+        StringBuilder::appendSubstring(...).
+
+        * wtf/HexNumber.h:
+        (WTF::appendUnsignedAsHexFixedSize):
+        Add overload that explicitly takes a StringBuilder to work around rename from append to appendCharacters.
+
+        * wtf/text/StringBuilder.cpp:
+        (WTF::StringBuilder::appendCharacters):
+        (WTF::StringBuilder::append):
+        * wtf/text/StringBuilder.h:
+        (WTF::StringBuilder::appendCharacters):
+        (WTF::StringBuilder::append):
+        (WTF::StringBuilder::appendSubstring):
+        (WTF::StringBuilder::appendLiteral):
+        (WTF::IntegerToStringConversionTrait<StringBuilder>::flush):
+        Update for renames.
+
 2019-08-12  Yusuke Suzuki  <ysuzuki@apple.com>
 
         [WTF][JSC] Make JSC and WTF aggressively-fast-malloced
index 624c998..da0d381 100644 (file)
@@ -21,6 +21,7 @@
 #pragma once
 
 #include <array>
+#include <wtf/text/StringBuilder.h>
 #include <wtf/text/StringConcatenate.h>
 
 namespace WTF {
@@ -72,6 +73,17 @@ inline void appendUnsignedAsHexFixedSize(NumberType number, DestinationType& des
     destination.append(result.first, result.second);
 }
 
+// FIXME: Consider renaming to appendHex.
+// Same as appendUnsignedAsHex, but zero-padding to get at least the desired number of digits.
+template<typename NumberType>
+inline void appendUnsignedAsHexFixedSize(NumberType number, StringBuilder& destination, unsigned minimumDigits, HexConversionMode mode = Uppercase)
+{
+    // Each byte can generate up to two digits.
+    std::array<LChar, sizeof(NumberType) * 2> buffer;
+    auto result = Internal::appendHex(buffer, number, minimumDigits, mode);
+    destination.appendCharacters(result.first, result.second);
+}
+
 struct HexNumberBuffer {
     WTF_MAKE_STRUCT_FAST_ALLOCATED;
 
index 89e16ef..8b16df9 100644 (file)
@@ -303,7 +303,7 @@ CharacterType* StringBuilder::appendUninitializedSlow(unsigned requiredLength)
     return result;
 }
 
-void StringBuilder::append(const UChar* characters, unsigned length)
+void StringBuilder::appendCharacters(const UChar* characters, unsigned length)
 {
     if (!length || hasOverflowed())
         return;
@@ -314,7 +314,7 @@ void StringBuilder::append(const UChar* characters, unsigned length)
         if (length == 1 && !(*characters & ~0xff)) {
             // Append as 8 bit character
             LChar lChar = static_cast<LChar>(*characters);
-            return append(&lChar, 1);
+            return appendCharacters(&lChar, 1);
         }
 
         // Calculate the new size of the builder after appending.
@@ -345,7 +345,7 @@ void StringBuilder::append(const UChar* characters, unsigned length)
     ASSERT(m_buffer->length() >= m_length.unsafeGet<unsigned>());
 }
 
-void StringBuilder::append(const LChar* characters, unsigned length)
+void StringBuilder::appendCharacters(const LChar* characters, unsigned length)
 {
     if (!length || hasOverflowed())
         return;
@@ -383,7 +383,7 @@ void StringBuilder::append(CFStringRef string)
 {
     // Fast path: avoid constructing a temporary String when possible.
     if (auto* characters = CFStringGetCStringPtr(string, kCFStringEncodingISOLatin1)) {
-        append(reinterpret_cast<const LChar*>(characters), CFStringGetLength(string));
+        appendCharacters(reinterpret_cast<const LChar*>(characters), CFStringGetLength(string));
         return;
     }
     append(String(string));
index 9427058..d620440 100644 (file)
@@ -69,10 +69,10 @@ public:
     ALWAYS_INLINE bool hasOverflowed() const { return m_length.hasOverflowed(); }
     ALWAYS_INLINE bool crashesOnOverflow() const { return m_length.shouldCrashOnOverflow(); }
 
-    WTF_EXPORT_PRIVATE void append(const UChar*, unsigned);
-    WTF_EXPORT_PRIVATE void append(const LChar*, unsigned);
+    WTF_EXPORT_PRIVATE void appendCharacters(const UChar*, unsigned);
+    WTF_EXPORT_PRIVATE void appendCharacters(const LChar*, unsigned);
 
-    ALWAYS_INLINE void append(const char* characters, unsigned length) { append(reinterpret_cast<const LChar*>(characters), length); }
+    ALWAYS_INLINE void appendCharacters(const char* characters, unsigned length) { appendCharacters(reinterpret_cast<const LChar*>(characters), length); }
 
     void append(const AtomString& atomString)
     {
@@ -97,9 +97,9 @@ public:
         }
 
         if (string.is8Bit())
-            append(string.characters8(), string.length());
+            appendCharacters(string.characters8(), string.length());
         else
-            append(string.characters16(), string.length());
+            appendCharacters(string.characters16(), string.length());
     }
 
     void append(const StringBuilder& other)
@@ -122,17 +122,17 @@ public:
         }
 
         if (other.is8Bit())
-            append(other.characters8(), other.m_length.unsafeGet());
+            appendCharacters(other.characters8(), other.m_length.unsafeGet());
         else
-            append(other.characters16(), other.m_length.unsafeGet());
+            appendCharacters(other.characters16(), other.m_length.unsafeGet());
     }
 
     void append(StringView stringView)
     {
         if (stringView.is8Bit())
-            append(stringView.characters8(), stringView.length());
+            appendCharacters(stringView.characters8(), stringView.length());
         else
-            append(stringView.characters16(), stringView.length());
+            appendCharacters(stringView.characters16(), stringView.length());
     }
 
 #if USE(CF)
@@ -142,7 +142,7 @@ public:
     void append(NSString *string) { append((__bridge CFStringRef)string); }
 #endif
     
-    void append(const String& string, unsigned offset, unsigned length)
+    void appendSubstring(const String& string, unsigned offset, unsigned length)
     {
         if (!string.length())
             return;
@@ -151,15 +151,15 @@ public:
             return;
 
         if (string.is8Bit())
-            append(string.characters8() + offset, length);
+            appendCharacters(string.characters8() + offset, length);
         else
-            append(string.characters16() + offset, length);
+            appendCharacters(string.characters16() + offset, length);
     }
 
     void append(const char* characters)
     {
         if (characters)
-            append(characters, strlen(characters));
+            appendCharacters(characters, strlen(characters));
     }
 
     void append(UChar c)
@@ -180,7 +180,7 @@ public:
                 return;
             }
         }
-        append(&c, 1);
+        appendCharacters(&c, 1);
     }
 
     void append(LChar c)
@@ -195,7 +195,7 @@ public:
                 m_bufferCharacters16[length] = c;
             m_length++;
         } else
-            append(&c, 1);
+            appendCharacters(&c, 1);
     }
 
     void append(char c)
@@ -216,7 +216,7 @@ public:
     WTF_EXPORT_PRIVATE void appendQuotedJSONString(const String&);
 
     template<unsigned characterCount>
-    ALWAYS_INLINE void appendLiteral(const char (&characters)[characterCount]) { append(characters, characterCount - 1); }
+    ALWAYS_INLINE void appendLiteral(const char (&characters)[characterCount]) { appendCharacters(characters, characterCount - 1); }
 
     WTF_EXPORT_PRIVATE void appendNumber(int);
     WTF_EXPORT_PRIVATE void appendNumber(unsigned);
@@ -469,7 +469,7 @@ inline bool operator!=(const String& a, const StringBuilder& b) { return !equal(
 template<> struct IntegerToStringConversionTrait<StringBuilder> {
     using ReturnType = void;
     using AdditionalArgumentType = StringBuilder;
-    static void flush(LChar* characters, unsigned length, StringBuilder* stringBuilder) { stringBuilder->append(characters, length); }
+    static void flush(LChar* characters, unsigned length, StringBuilder* stringBuilder) { stringBuilder->appendCharacters(characters, length); }
 };
 
 } // namespace WTF
index 96ecadc..ce33d31 100644 (file)
@@ -1,3 +1,38 @@
+2019-08-12  Sam Weinig  <weinig@apple.com>
+
+        Replace multiparameter overloads of append() in StringBuilder as a first step toward standardizinging on the flexibleAppend() implementation
+        https://bugs.webkit.org/show_bug.cgi?id=200614
+
+        Reviewed by Darin Adler.
+
+        Renames StringBuilder::append(const LChar*, unsigned), StringBuilder::append(const UChar*, unsigned) and 
+        StringBuilder::append(const char*, unsigned) to StringBuilder::appendCharacters(...).
+        
+        Renames StringBuilder::append(const String& string, unsigned offset, unsigned length) to 
+        StringBuilder::appendSubstring(...).
+
+        * dom/Range.cpp:
+        (WebCore::Range::toString const):
+        * editing/Editing.cpp:
+        (WebCore::stringWithRebalancedWhitespace):
+        * editing/MarkupAccumulator.cpp:
+        (WebCore::appendCharactersReplacingEntitiesInternal):
+        * editing/TextIterator.cpp:
+        (WebCore::TextIteratorCopyableText::appendToStringBuilder const):
+        * html/HTMLTextFormControlElement.cpp:
+        (WebCore::HTMLTextFormControlElement::valueWithHardLineBreaks const):
+        * html/parser/HTMLTokenizer.cpp:
+        (WebCore::HTMLTokenizer::bufferedCharacters const):
+        * platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
+        (WebCore::InbandTextTrackPrivateAVF::processNativeSamples):
+        * platform/text/SegmentedString.cpp:
+        (WebCore::SegmentedString::Substring::appendTo const):
+        * platform/text/TextCodecICU.cpp:
+        (WebCore::TextCodecICU::decode):
+        * xml/XSLTProcessorLibxslt.cpp:
+        (WebCore::writeToStringBuilder):
+        Update for renames.
+
 2019-08-12  Adrian Perez de Castro  <aperez@igalia.com>
 
         [WPE][GTK] Fix building without unified sources
index c8b23ee..b574e67 100644 (file)
@@ -946,7 +946,7 @@ String Range::toString() const
             unsigned length = data.length();
             unsigned start = node == &startContainer() ? std::min(m_start.offset(), length) : 0U;
             unsigned end = node == &endContainer() ? std::min(std::max(start, m_end.offset()), length) : length;
-            builder.append(data, start, end - start);
+            builder.appendSubstring(data, start, end - start);
         }
     }
 
index f0d82d5..69999c9 100644 (file)
@@ -420,7 +420,7 @@ String stringWithRebalancedWhitespace(const String& string, bool startIsStartOfP
         if (character == selectedWhitespaceCharacter)
             continue;
         rebalancedString.reserveCapacity(length);
-        rebalancedString.append(string, rebalancedString.length(), i - rebalancedString.length());
+        rebalancedString.appendSubstring(string, rebalancedString.length(), i - rebalancedString.length());
         rebalancedString.append(selectedWhitespaceCharacter);
     }
 
@@ -428,7 +428,7 @@ String stringWithRebalancedWhitespace(const String& string, bool startIsStartOfP
         return string;
 
     rebalancedString.reserveCapacity(length);
-    rebalancedString.append(string, rebalancedString.length(), length - rebalancedString.length());
+    rebalancedString.appendSubstring(string, rebalancedString.length(), length - rebalancedString.length());
     return rebalancedString.toString();
 }
 
index a9bb04c..85c4fae 100644 (file)
@@ -150,12 +150,12 @@ static inline void appendCharactersReplacingEntitiesInternal(StringBuilder& resu
         CharacterType character = text[i];
         uint8_t substitution = character < WTF_ARRAY_LENGTH(entityMap) ? entityMap[character] : static_cast<uint8_t>(EntitySubstitutionNullIndex);
         if (UNLIKELY(substitution != EntitySubstitutionNullIndex) && entitySubstitutionList[substitution].mask & entityMask) {
-            result.append(text + positionAfterLastEntity, i - positionAfterLastEntity);
-            result.append(entitySubstitutionList[substitution].characters, entitySubstitutionList[substitution].length);
+            result.appendCharacters(text + positionAfterLastEntity, i - positionAfterLastEntity);
+            result.appendCharacters(entitySubstitutionList[substitution].characters, entitySubstitutionList[substitution].length);
             positionAfterLastEntity = i + 1;
         }
     }
-    result.append(text + positionAfterLastEntity, length - positionAfterLastEntity);
+    result.appendCharacters(text + positionAfterLastEntity, length - positionAfterLastEntity);
 }
 
 void MarkupAccumulator::appendCharactersReplacingEntities(StringBuilder& result, const String& source, unsigned offset, unsigned length, EntityMask entityMask)
index 23414a2..1896e1a 100644 (file)
@@ -335,7 +335,7 @@ void TextIteratorCopyableText::appendToStringBuilder(StringBuilder& builder) con
     if (m_singleCharacter)
         builder.append(m_singleCharacter);
     else
-        builder.append(m_string, m_offset, m_length);
+        builder.appendSubstring(m_string, m_offset, m_length);
 }
 
 // --------
index 145eb0f..a92aedb 100644 (file)
@@ -717,13 +717,13 @@ String HTMLTextFormControlElement::valueWithHardLineBreaks() const
             unsigned position = 0;
             while (breakNode == node && breakOffset <= length) {
                 if (breakOffset > position) {
-                    result.append(data, position, breakOffset - position);
+                    result.appendSubstring(data, position, breakOffset - position);
                     position = breakOffset;
                     result.append(newlineCharacter);
                 }
                 getNextSoftBreak(line, breakNode, breakOffset);
             }
-            result.append(data, position, length - position);
+            result.appendSubstring(data, position, length - position);
         }
         while (breakNode == node)
             getNextSoftBreak(line, breakNode, breakOffset);
index 663e0c1..aa75adc 100644 (file)
@@ -1401,7 +1401,7 @@ String HTMLTokenizer::bufferedCharacters() const
     characters.reserveCapacity(numberOfBufferedCharacters());
     characters.append('<');
     characters.append('/');
-    characters.append(m_temporaryBuffer.data(), m_temporaryBuffer.size());
+    characters.appendCharacters(m_temporaryBuffer.data(), m_temporaryBuffer.size());
     return characters.toString();
 }
 
index e6dfece..ba014b5 100644 (file)
@@ -529,7 +529,7 @@ void InbandTextTrackPrivateAVF::processNativeSamples(CFArrayRef nativeSamples, c
             // A WebVTT header is terminated by "One or more WebVTT line terminators" so append two line feeds to make sure the parser
             // reccognized this string as a full header.
             StringBuilder header;
-            header.append(reinterpret_cast<const unsigned char*>(CFDataGetBytePtr(webvttHeaderData)), length);
+            header.appendCharacters(reinterpret_cast<const unsigned char*>(CFDataGetBytePtr(webvttHeaderData)), length);
             header.append("\n\n");
 
             INFO_LOG(LOGIDENTIFIER, "VTT header ", &header);
index ff31b2a..c083ea7 100644 (file)
@@ -27,7 +27,7 @@ namespace WebCore {
 
 inline void SegmentedString::Substring::appendTo(StringBuilder& builder) const
 {
-    builder.append(string, string.length() - length, length);
+    builder.appendSubstring(string, string.length() - length, length);
 }
 
 SegmentedString& SegmentedString::operator=(SegmentedString&& other)
index d2e2ae7..f8e1670 100644 (file)
@@ -307,7 +307,7 @@ String TextCodecICU::decode(const char* bytes, size_t length, bool flush, bool s
 
     do {
         int ucharsDecoded = decodeToBuffer(buffer, bufferLimit, source, sourceLimit, offsets, flush, err);
-        result.append(buffer, ucharsDecoded);
+        result.appendCharacters(buffer, ucharsDecoded);
     } while (err == U_BUFFER_OVERFLOW_ERROR);
 
     if (U_FAILURE(err)) {
index 5613a4f..fbb8ed3 100644 (file)
@@ -58,8 +58,8 @@ String RenderThemeWPE::mediaControlsStyleSheet()
 String RenderThemeWPE::mediaControlsScript()
 {
     StringBuilder scriptBuilder;
-    scriptBuilder.append(mediaControlsLocalizedStringsJavaScript, sizeof(mediaControlsLocalizedStringsJavaScript));
-    scriptBuilder.append(mediaControlsBaseJavaScript, sizeof(mediaControlsBaseJavaScript));
+    scriptBuilder.appendCharacters(mediaControlsLocalizedStringsJavaScript, sizeof(mediaControlsLocalizedStringsJavaScript));
+    scriptBuilder.appendCharacters(mediaControlsBaseJavaScript, sizeof(mediaControlsBaseJavaScript));
     return scriptBuilder.toString();
 }
 #endif
index 4cc5513..0e1f5c9 100644 (file)
@@ -1212,9 +1212,9 @@ String RenderThemeGtk::fileListNameForWidth(const FileList* fileList, const Font
 String RenderThemeGtk::mediaControlsScript()
 {
     StringBuilder scriptBuilder;
-    scriptBuilder.append(mediaControlsLocalizedStringsJavaScript, sizeof(mediaControlsLocalizedStringsJavaScript));
-    scriptBuilder.append(mediaControlsBaseJavaScript, sizeof(mediaControlsBaseJavaScript));
-    scriptBuilder.append(mediaControlsGtkJavaScript, sizeof(mediaControlsGtkJavaScript));
+    scriptBuilder.appendCharacters(mediaControlsLocalizedStringsJavaScript, sizeof(mediaControlsLocalizedStringsJavaScript));
+    scriptBuilder.appendCharacters(mediaControlsBaseJavaScript, sizeof(mediaControlsBaseJavaScript));
+    scriptBuilder.appendCharacters(mediaControlsGtkJavaScript, sizeof(mediaControlsGtkJavaScript));
     return scriptBuilder.toString();
 }
 #endif // ENABLE(VIDEO)
index 1e30fd1..a0ce345 100644 (file)
@@ -190,7 +190,7 @@ static int writeToStringBuilder(void* context, const char* buffer, int length)
         }
     }
 
-    resultOutput.append(outputBuffer.data(), outputOffset);
+    resultOutput.appendCharacters(outputBuffer.data(), outputOffset);
     return inputOffset;
 }
 
index e9f7d9e..2861b9c 100644 (file)
@@ -1,3 +1,22 @@
+2019-08-12  Sam Weinig  <weinig@apple.com>
+
+        Replace multiparameter overloads of append() in StringBuilder as a first step toward standardizinging on the flexibleAppend() implementation
+        https://bugs.webkit.org/show_bug.cgi?id=200614
+
+        Reviewed by Darin Adler.
+
+        Renames StringBuilder::append(const LChar*, unsigned), StringBuilder::append(const UChar*, unsigned) and 
+        StringBuilder::append(const char*, unsigned) to StringBuilder::appendCharacters(...).
+        
+        Renames StringBuilder::append(const String& string, unsigned offset, unsigned length) to 
+        StringBuilder::appendSubstring(...).
+
+        * Shared/mac/AuxiliaryProcessMac.mm:
+        (WebKit::setAndSerializeSandboxParameters):
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::didReceiveInvalidMessage):
+        Update for renames.
+
 2019-08-12  Dean Jackson  <dino@apple.com>
 
         Contextual menu Hide and Show Link Previews should not have a symbol
index 24d5d7c..69b80d8 100644 (file)
@@ -234,16 +234,16 @@ static Optional<CString> setAndSerializeSandboxParameters(const SandboxInitializ
             WTFLogAlways("%s: Could not set sandbox parameter: %s\n", getprogname(), strerror(errno));
             CRASH();
         }
-        builder.append(name, strlen(name));
+        builder.append(name);
         builder.append(':');
-        builder.append(value, strlen(value));
+        builder.append(value);
         builder.append(':');
     }
     if (isProfilePath) {
         auto contents = fileContents(profileOrProfilePath);
         if (!contents)
             return WTF::nullopt;
-        builder.append(contents->data(), contents->size());
+        builder.appendCharacters(contents->data(), contents->size());
     } else
         builder.append(profileOrProfilePath);
     return builder.toString().ascii();
index 39d60d4..dbe2535 100644 (file)
@@ -792,9 +792,9 @@ void WebProcessPool::didReceiveInvalidMessage(const IPC::StringReference& messag
         return;
 
     StringBuilder messageNameStringBuilder;
-    messageNameStringBuilder.append(messageReceiverName.data(), messageReceiverName.size());
+    messageNameStringBuilder.appendCharacters(messageReceiverName.data(), messageReceiverName.size());
     messageNameStringBuilder.append('.');
-    messageNameStringBuilder.append(messageName.data(), messageName.size());
+    messageNameStringBuilder.appendCharacters(messageName.data(), messageName.size());
 
     s_invalidMessageCallback(toAPI(API::String::create(messageNameStringBuilder.toString()).ptr()));
 }
index 2da3faf..4fa7a94 100644 (file)
@@ -1,3 +1,20 @@
+2019-08-12  Sam Weinig  <weinig@apple.com>
+
+        Replace multiparameter overloads of append() in StringBuilder as a first step toward standardizinging on the flexibleAppend() implementation
+        https://bugs.webkit.org/show_bug.cgi?id=200614
+
+        Reviewed by Darin Adler.
+
+        Renames StringBuilder::append(const LChar*, unsigned), StringBuilder::append(const UChar*, unsigned) and 
+        StringBuilder::append(const char*, unsigned) to StringBuilder::appendCharacters(...).
+        
+        Renames StringBuilder::append(const String& string, unsigned offset, unsigned length) to 
+        StringBuilder::appendSubstring(...).
+
+        * TestWebKitAPI/Tests/WTF/StringBuilder.cpp:
+        (TestWebKitAPI::TEST):
+        Update for renames.
+
 2019-08-12  Megan Gardner  <megan_gardner@apple.com>
 
         Fix Crash in Mail Search
index e4b7c02..4a6ea38 100644 (file)
@@ -64,7 +64,7 @@ TEST(StringBuilderTest, Append)
     expectBuilderContent("0123456789", builder);
     builder.append("abcd");
     expectBuilderContent("0123456789abcd", builder);
-    builder.append("efgh", 3);
+    builder.appendCharacters("efgh", 3);
     expectBuilderContent("0123456789abcdefg", builder);
     builder.append("");
     expectBuilderContent("0123456789abcdefg", builder);
@@ -73,11 +73,11 @@ TEST(StringBuilderTest, Append)
 
     builder.toString(); // Test after reifyString().
     StringBuilder builder1;
-    builder.append("", 0);
+    builder.appendCharacters("", 0);
     expectBuilderContent("0123456789abcdefg#", builder);
-    builder1.append(builder.characters8(), builder.length());
+    builder1.appendCharacters(builder.characters8(), builder.length());
     builder1.append("XYZ");
-    builder.append(builder1.characters8(), builder1.length());
+    builder.appendCharacters(builder1.characters8(), builder1.length());
     expectBuilderContent("0123456789abcdefg#0123456789abcdefg#XYZ", builder);
 
     StringBuilder builder2;
@@ -104,12 +104,12 @@ TEST(StringBuilderTest, Append)
         StringBuilder builder2;
         UChar32 frakturAChar = 0x1D504;
         const UChar data[] = { U16_LEAD(frakturAChar), U16_TRAIL(frakturAChar) };
-        builder2.append(data, 2);
+        builder2.appendCharacters(data, 2);
         ASSERT_EQ(2U, builder2.length());
         String result2 = builder2.toString();
         ASSERT_EQ(2U, result2.length());
         builder.append(builder2);
-        builder.append(data, 2);
+        builder.appendCharacters(data, 2);
         ASSERT_EQ(4U, builder.length());
         const UChar resultArray[] = { U16_LEAD(frakturAChar), U16_TRAIL(frakturAChar), U16_LEAD(frakturAChar), U16_TRAIL(frakturAChar) };
         expectBuilderContent(String(resultArray, WTF_ARRAY_LENGTH(resultArray)), builder);
@@ -360,7 +360,7 @@ TEST(StringBuilderTest, ToAtomStringOnEmpty)
     }
     { // AtomString constructed from an empty char* string.
         StringBuilder builder;
-        builder.append("", 0);
+        builder.appendCharacters("", 0);
         AtomString atomString = builder.toAtomString();
         ASSERT_EQ(emptyAtom(), atomString);
     }
index 2b404e5..6160ae7 100644 (file)
@@ -271,14 +271,14 @@ String generateHTMLContent(unsigned contentLength)
     builder.append("<html><body>");
 
     if (contentLength <= baseLength)
-        builder.append(baseString, 0, contentLength);
+        builder.appendSubstring(baseString, 0, contentLength);
     else {
         unsigned currentLength = 0;
         while (currentLength < contentLength) {
             if ((currentLength + baseLength) <= contentLength)
                 builder.append(baseString);
             else
-                builder.append(baseString, 0, contentLength - currentLength);
+                builder.appendSubstring(baseString, 0, contentLength - currentLength);
 
             // Account for the 12 characters of the '<html><body>' prefix.
             currentLength = builder.length() - 12;