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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutText.cpp

Issue 2555923002: Changed TextDirection to an enum class and renamed its members (Closed)
Patch Set: Small rebase fixes Created 4 years 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Dirk Mueller (mueller@kde.org) 3 * (C) 2000 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 1077
1078 Hyphenation* hyphenation = styleToUse.getHyphenation(); 1078 Hyphenation* hyphenation = styleToUse.getHyphenation();
1079 bool disableSoftHyphen = styleToUse.getHyphens() == HyphensNone; 1079 bool disableSoftHyphen = styleToUse.getHyphens() == HyphensNone;
1080 float maxWordWidth = 0; 1080 float maxWordWidth = 0;
1081 if (!hyphenation) 1081 if (!hyphenation)
1082 maxWordWidth = std::numeric_limits<float>::infinity(); 1082 maxWordWidth = std::numeric_limits<float>::infinity();
1083 1083
1084 BidiResolver<TextRunIterator, BidiCharacterRun> bidiResolver; 1084 BidiResolver<TextRunIterator, BidiCharacterRun> bidiResolver;
1085 BidiCharacterRun* run; 1085 BidiCharacterRun* run;
1086 TextDirection textDirection = styleToUse.direction(); 1086 TextDirection textDirection = styleToUse.direction();
1087 if ((is8Bit() && textDirection == LTR) || 1087 if ((is8Bit() && textDirection == TextDirection::Ltr) ||
1088 isOverride(styleToUse.unicodeBidi())) { 1088 isOverride(styleToUse.unicodeBidi())) {
1089 run = 0; 1089 run = 0;
1090 } else { 1090 } else {
1091 TextRun textRun(text()); 1091 TextRun textRun(text());
1092 BidiStatus status(textDirection, false); 1092 BidiStatus status(textDirection, false);
1093 bidiResolver.setStatus(status); 1093 bidiResolver.setStatus(status);
1094 bidiResolver.setPositionIgnoringNestedIsolates( 1094 bidiResolver.setPositionIgnoringNestedIsolates(
1095 TextRunIterator(&textRun, 0)); 1095 TextRunIterator(&textRun, 0));
1096 bool hardLineBreak = false; 1096 bool hardLineBreak = false;
1097 bool reorderRuns = false; 1097 bool reorderRuns = false;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 j = std::min(j, run->stop() + 1); 1190 j = std::min(j, run->stop() + 1);
1191 int wordLen = j - i; 1191 int wordLen = j - i;
1192 if (wordLen) { 1192 if (wordLen) {
1193 bool isSpace = (j < len) && c == spaceCharacter; 1193 bool isSpace = (j < len) && c == spaceCharacter;
1194 1194
1195 // Non-zero only when kerning is enabled, in which case we measure words 1195 // Non-zero only when kerning is enabled, in which case we measure words
1196 // with their trailing space, then subtract its width. 1196 // with their trailing space, then subtract its width.
1197 float wordTrailingSpaceWidth = 0; 1197 float wordTrailingSpaceWidth = 0;
1198 if (isSpace && 1198 if (isSpace &&
1199 (f.getFontDescription().getTypesettingFeatures() & Kerning)) { 1199 (f.getFontDescription().getTypesettingFeatures() & Kerning)) {
1200 ASSERT(textDirection >= 0 && textDirection <= 1); 1200 unsigned textDirectionIndex = static_cast<unsigned>(textDirection);
napper 2016/12/07 05:27:13 const unsigned textDirectionIndex = static_cast<un
sashab 2016/12/07 05:40:26 Done
1201 if (!cachedWordTrailingSpaceWidth[textDirection]) 1201 DCHECK_GE(textDirectionIndex, 0U);
1202 cachedWordTrailingSpaceWidth[textDirection] = 1202 DCHECK_LE(textDirectionIndex, 1U);
1203 if (!cachedWordTrailingSpaceWidth[textDirectionIndex])
1204 cachedWordTrailingSpaceWidth[textDirectionIndex] =
1203 f.width(constructTextRun(f, &spaceCharacter, 1, styleToUse, 1205 f.width(constructTextRun(f, &spaceCharacter, 1, styleToUse,
1204 textDirection)) + 1206 textDirection)) +
1205 wordSpacing; 1207 wordSpacing;
1206 wordTrailingSpaceWidth = cachedWordTrailingSpaceWidth[textDirection]; 1208 wordTrailingSpaceWidth =
1209 cachedWordTrailingSpaceWidth[textDirectionIndex];
1207 } 1210 }
1208 1211
1209 float w; 1212 float w;
1210 if (wordTrailingSpaceWidth && isSpace) { 1213 if (wordTrailingSpaceWidth && isSpace) {
1211 w = widthFromFont(f, i, wordLen + 1, leadWidth, currMaxWidth, 1214 w = widthFromFont(f, i, wordLen + 1, leadWidth, currMaxWidth,
1212 textDirection, &fallbackFonts, &glyphBounds) - 1215 textDirection, &fallbackFonts, &glyphBounds) -
1213 wordTrailingSpaceWidth; 1216 wordTrailingSpaceWidth;
1214 } else { 1217 } else {
1215 w = widthFromFont(f, i, wordLen, leadWidth, currMaxWidth, textDirection, 1218 w = widthFromFont(f, i, wordLen, leadWidth, currMaxWidth, textDirection,
1216 &fallbackFonts, &glyphBounds); 1219 &fallbackFonts, &glyphBounds);
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
1975 LayoutRect rect = LayoutRect( 1978 LayoutRect rect = LayoutRect(
1976 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height())); 1979 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height()));
1977 LayoutBlock* block = containingBlock(); 1980 LayoutBlock* block = containingBlock();
1978 if (block && hasTextBoxes()) 1981 if (block && hasTextBoxes())
1979 block->adjustChildDebugRect(rect); 1982 block->adjustChildDebugRect(rect);
1980 1983
1981 return rect; 1984 return rect;
1982 } 1985 }
1983 1986
1984 } // namespace blink 1987 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698