X-Git-Url: https://git.webkit.org/?p=WebKit-https.git;a=blobdiff_plain;f=Source%2FWebCore%2Frendering%2FRenderText.cpp;h=68f16d47c949eccb2f14676851db0be73ffe9b9a;hp=c84ec7f7f90bd1fd49cefef0b6fb54736fa6068f;hb=c978f7f39ca2695e2c6ac6fb75edf0f1f92a2e78;hpb=a1b7cf8f056464428c82d69aeb9e354e36aacd3d diff --git a/Source/WebCore/rendering/RenderText.cpp b/Source/WebCore/rendering/RenderText.cpp index c84ec7f7f90b..68f16d47c949 100644 --- a/Source/WebCore/rendering/RenderText.cpp +++ b/Source/WebCore/rendering/RenderText.cpp @@ -100,7 +100,7 @@ static void makeCapitalized(String* string, UChar previous) return; unsigned length = string->length(); - const UChar* characters = string->characters(); + const StringImpl& stringImpl = *string->impl(); if (length >= numeric_limits::max()) CRASH(); @@ -109,28 +109,29 @@ static void makeCapitalized(String* string, UChar previous) stringWithPrevious[0] = previous == noBreakSpace ? ' ' : previous; for (unsigned i = 1; i < length + 1; i++) { // Replace   with a real space since ICU no longer treats   as a word separator. - if (characters[i - 1] == noBreakSpace) + if (stringImpl[i - 1] == noBreakSpace) stringWithPrevious[i] = ' '; else - stringWithPrevious[i] = characters[i - 1]; + stringWithPrevious[i] = stringImpl[i - 1]; } TextBreakIterator* boundary = wordBreakIterator(stringWithPrevious.characters(), length + 1); if (!boundary) return; - StringBuffer data(length); + StringBuilder result; + result.reserveCapacity(length); int32_t endOfWord; int32_t startOfWord = textBreakFirst(boundary); for (endOfWord = textBreakNext(boundary); endOfWord != TextBreakDone; startOfWord = endOfWord, endOfWord = textBreakNext(boundary)) { if (startOfWord) // Ignore first char of previous string - data[startOfWord - 1] = characters[startOfWord - 1] == noBreakSpace ? noBreakSpace : toTitleCase(stringWithPrevious[startOfWord]); + result.append(stringImpl[startOfWord - 1] == noBreakSpace ? noBreakSpace : toTitleCase(stringWithPrevious[startOfWord])); for (int i = startOfWord + 1; i < endOfWord; i++) - data[i - 1] = characters[i - 1]; + result.append(stringImpl[i - 1]); } - *string = String::adopt(data); + *string = result.toString(); } RenderText::RenderText(Node* node, PassRefPtr str)