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

Unified Diff: Source/core/layout/LayoutText.cpp

Issue 1119663002: Making Unicode character names consistent (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Code changes to correct Test Expectation Created 5 years, 7 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
Index: Source/core/layout/LayoutText.cpp
diff --git a/Source/core/layout/LayoutText.cpp b/Source/core/layout/LayoutText.cpp
index afa5523fcbb7d11cc194e8c7fcf92926ac71f7aa..817d1c2d5b62b09f751766f51e746807fcfec950 100644
--- a/Source/core/layout/LayoutText.cpp
+++ b/Source/core/layout/LayoutText.cpp
@@ -108,11 +108,11 @@ static void makeCapitalized(String* string, UChar previous)
CRASH();
StringBuffer<UChar> stringWithPrevious(length + 1);
- stringWithPrevious[0] = previous == noBreakSpace ? space : previous;
+ stringWithPrevious[0] = previous == characterNoBreakSpace ? characterSpace : 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 (input[i - 1] == noBreakSpace)
- stringWithPrevious[i] = space;
+ if (input[i - 1] == characterNoBreakSpace)
+ stringWithPrevious[i] = characterSpace;
else
stringWithPrevious[i] = input[i - 1];
}
@@ -128,7 +128,7 @@ static void makeCapitalized(String* string, UChar previous)
int32_t startOfWord = boundary->first();
for (endOfWord = boundary->next(); endOfWord != TextBreakDone; startOfWord = endOfWord, endOfWord = boundary->next()) {
if (startOfWord) // Ignore first char of previous string
- result.append(input[startOfWord - 1] == noBreakSpace ? noBreakSpace : toTitleCase(stringWithPrevious[startOfWord]));
+ result.append(input[startOfWord - 1] == characterNoBreakSpace ? characterNoBreakSpace : toTitleCase(stringWithPrevious[startOfWord]));
for (int i = startOfWord + 1; i < endOfWord; i++)
result.append(input[i - 1]);
}
@@ -314,7 +314,7 @@ String LayoutText::plainText() const
String text = m_text.substring(textBox->start(), textBox->len()).simplifyWhiteSpace(WTF::DoNotStripWhiteSpace);
plainTextBuilder.append(text);
if (textBox->nextTextBox() && textBox->nextTextBox()->start() > textBox->end() && text.length() && !text.right(1).containsOnlyWhitespace())
- plainTextBuilder.append(space);
+ plainTextBuilder.append(characterSpace);
}
return plainTextBuilder.toString();
}
@@ -768,14 +768,14 @@ void LayoutText::trimmedPrefWidths(FloatWillBeLayoutUnit leadWidth,
ASSERT(m_text);
StringImpl& text = *m_text.impl();
- if (text[0] == space || (text[0] == newlineCharacter && !style()->preserveNewline()) || text[0] == characterTabulation) {
+ if (text[0] == characterSpace || (text[0] == characterNewline && !style()->preserveNewline()) || text[0] == characterTabulation) {
const Font& font = style()->font(); // FIXME: This ignores first-line.
if (stripFrontSpaces) {
- const UChar spaceChar = space;
+ const UChar spaceChar = characterSpace;
TextRun run = constructTextRun(this, font, &spaceChar, 1, styleRef(), direction);
run.setCodePath(canUseSimpleFontCodePath() ? TextRun::ForceSimple : TextRun::ForceComplex);
- float spaceWidth = font.width(run);
- floatMaxWidth -= spaceWidth;
+ float characterSpaceWidth = font.width(run);
+ floatMaxWidth -= characterSpaceWidth;
} else {
floatMaxWidth += font.fontDescription().wordSpacing();
}
@@ -794,7 +794,7 @@ void LayoutText::trimmedPrefWidths(FloatWillBeLayoutUnit leadWidth,
lastLineMaxWidth = floatMaxWidth;
for (int i = 0; i < len; i++) {
int linelen = 0;
- while (i + linelen < len && text[i + linelen] != newlineCharacter)
+ while (i + linelen < len && text[i + linelen] != characterNewline)
linelen++;
if (linelen) {
@@ -930,7 +930,7 @@ void LayoutText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si
bool previousCharacterIsSpace = isSpace;
bool isNewline = false;
- if (c == newlineCharacter) {
+ if (c == characterNewline) {
if (styleToUse.preserveNewline()) {
m_hasBreak = true;
isNewline = true;
@@ -946,7 +946,7 @@ void LayoutText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si
isSpace = true;
}
} else {
- isSpace = c == space;
+ isSpace = c == characterSpace;
}
bool isBreakableLocation = isNewline || (isSpace && styleToUse.autoWrap());
@@ -969,7 +969,7 @@ void LayoutText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si
lastWordBoundary++;
continue;
}
- if (c == softHyphen) {
+ if (c == characterSoftHyphen) {
currMaxWidth += widthFromCache(f, lastWordBoundary, i - lastWordBoundary, leadWidth + currMaxWidth, textDirection, &fallbackFonts, &glyphOverflow);
if (firstGlyphLeftOverflow < 0)
firstGlyphLeftOverflow = glyphOverflow.left;
@@ -980,12 +980,12 @@ void LayoutText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si
bool hasBreak = breakIterator.isBreakable(i, nextBreakable, breakAll ? LineBreakType::BreakAll : keepAll ? LineBreakType::KeepAll : LineBreakType::Normal);
bool betweenWords = true;
int j = i;
- while (c != newlineCharacter && c != space && c != characterTabulation && (c != softHyphen)) {
+ while (c != characterNewline && c != characterSpace && c != characterTabulation && (c != characterSoftHyphen)) {
j++;
if (j == len)
break;
c = uncheckedCharacterAt(j);
- if (breakIterator.isBreakable(j, nextBreakable) && characterAt(j - 1) != softHyphen)
+ if (breakIterator.isBreakable(j, nextBreakable) && characterAt(j - 1) != characterSoftHyphen)
break;
if (breakAll) {
betweenWords = false;
@@ -998,7 +998,7 @@ void LayoutText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si
j = std::min(j, run->stop() + 1);
int wordLen = j - i;
if (wordLen) {
- bool isSpace = (j < len) && c == space;
+ bool isSpace = (j < len) && c == characterSpace;
// Non-zero only when kerning is enabled, in which case we measure words with their trailing
// space, then subtract its width.
@@ -1006,7 +1006,7 @@ void LayoutText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si
if (isSpace && (f.fontDescription().typesettingFeatures() & Kerning)) {
ASSERT(textDirection >=0 && textDirection <= 1);
if (!cachedWordTrailingSpaceWidth[textDirection])
- cachedWordTrailingSpaceWidth[textDirection] = f.width(constructTextRun(this, f, &space, 1, styleToUse, textDirection)) + wordSpacing;
+ cachedWordTrailingSpaceWidth[textDirection] = f.width(constructTextRun(this, f, &characterSpace, 1, styleToUse, textDirection)) + wordSpacing;
wordTrailingSpaceWidth = cachedWordTrailingSpaceWidth[textDirection];
}
@@ -1015,7 +1015,7 @@ void LayoutText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si
w = widthFromCache(f, i, wordLen + 1, leadWidth + currMaxWidth, textDirection, &fallbackFonts, &glyphOverflow) - wordTrailingSpaceWidth;
} else {
w = widthFromCache(f, i, wordLen, leadWidth + currMaxWidth, textDirection, &fallbackFonts, &glyphOverflow);
- if (c == softHyphen)
+ if (c == characterSoftHyphen)
currMinWidth += hyphenWidth(this, f, textDirection);
}
@@ -1139,7 +1139,7 @@ bool LayoutText::containsOnlyWhitespace(unsigned from, unsigned len) const
StringImpl& text = *m_text.impl();
unsigned currPos;
for (currPos = from;
- currPos < from + len && (text[currPos] == newlineCharacter || text[currPos] == space || text[currPos] == characterTabulation);
+ currPos < from + len && (text[currPos] == characterNewline || text[currPos] == characterSpace || text[currPos] == characterTabulation);
currPos++) { }
return currPos >= (from + len);
}
@@ -1296,7 +1296,7 @@ UChar LayoutText::previousCharacter() const
if (!isInlineFlowOrEmptyText(previousText))
break;
}
- UChar prev = space;
+ UChar prev = characterSpace;
if (previousText && previousText->isText()) {
if (StringImpl* previousString = toLayoutText(previousText)->text().impl())
prev = (*previousString)[previousString->length() - 1];
@@ -1343,18 +1343,18 @@ void LayoutText::setTextInternal(PassRefPtr<StringImpl> text)
case TSNONE:
break;
case TSCIRCLE:
- secureText(whiteBullet);
+ secureText(characterWhiteBullet);
break;
case TSDISC:
- secureText(bullet);
+ secureText(characterBullet);
break;
case TSSQUARE:
- secureText(blackSquare);
+ secureText(characterBlackSquare);
}
}
ASSERT(m_text);
- ASSERT(!isBR() || (textLength() == 1 && m_text[0] == newlineCharacter));
+ ASSERT(!isBR() || (textLength() == 1 && m_text[0] == characterNewline));
m_canUseSimpleFontCodePath = computeCanUseSimpleFontCodePath();
}

Powered by Google App Engine
This is Rietveld 408576698