Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1662)

Unified Diff: Source/core/rendering/RenderText.cpp

Issue 16501003: text-transform: capitalize shouldn't upconvert (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderText.cpp
diff --git a/Source/core/rendering/RenderText.cpp b/Source/core/rendering/RenderText.cpp
index ccd71651ab57699eacf801c81cc502c5cc814e9b..dab93595c4b5b1304102845b2fa66e9d4cd7c73f 100644
--- a/Source/core/rendering/RenderText.cpp
+++ b/Source/core/rendering/RenderText.cpp
@@ -98,7 +98,7 @@ static void makeCapitalized(String* string, UChar previous)
return;
unsigned length = string->length();
- const UChar* characters = string->characters();
+ const StringImpl& input = *string->impl();
if (length >= numeric_limits<unsigned>::max())
CRASH();
@@ -107,28 +107,29 @@ static void makeCapitalized(String* string, UChar previous)
stringWithPrevious[0] = previous == noBreakSpace ? ' ' : previous;
for (unsigned i = 1; i < length + 1; i++) {
// Replace &nbsp with a real space since ICU no longer treats &nbsp as a word separator.
- if (characters[i - 1] == noBreakSpace)
+ if (input[i - 1] == noBreakSpace)
stringWithPrevious[i] = ' ';
else
- stringWithPrevious[i] = characters[i - 1];
+ stringWithPrevious[i] = input[i - 1];
}
TextBreakIterator* boundary = wordBreakIterator(stringWithPrevious.characters(), length + 1);
if (!boundary)
return;
- StringBuffer<UChar> 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(input[startOfWord - 1] == noBreakSpace ? noBreakSpace : toTitleCase(stringWithPrevious[startOfWord]));
for (int i = startOfWord + 1; i < endOfWord; i++)
- data[i - 1] = characters[i - 1];
+ result.append(input[i - 1]);
}
- *string = String::adopt(data);
+ *string = result.toString();
}
RenderText::RenderText(Node* node, PassRefPtr<StringImpl> str)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698