OLD | NEW |
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 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1082 | 1082 |
1083 Hyphenation* hyphenation = styleToUse.getHyphenation(); | 1083 Hyphenation* hyphenation = styleToUse.getHyphenation(); |
1084 bool disableSoftHyphen = styleToUse.getHyphens() == HyphensNone; | 1084 bool disableSoftHyphen = styleToUse.getHyphens() == HyphensNone; |
1085 float maxWordWidth = 0; | 1085 float maxWordWidth = 0; |
1086 if (!hyphenation) | 1086 if (!hyphenation) |
1087 maxWordWidth = std::numeric_limits<float>::infinity(); | 1087 maxWordWidth = std::numeric_limits<float>::infinity(); |
1088 | 1088 |
1089 BidiResolver<TextRunIterator, BidiCharacterRun> bidiResolver; | 1089 BidiResolver<TextRunIterator, BidiCharacterRun> bidiResolver; |
1090 BidiCharacterRun* run; | 1090 BidiCharacterRun* run; |
1091 TextDirection textDirection = styleToUse.direction(); | 1091 TextDirection textDirection = styleToUse.direction(); |
1092 if ((is8Bit() && textDirection == LTR) || | 1092 if ((is8Bit() && textDirection == TextDirection::Ltr) || |
1093 isOverride(styleToUse.unicodeBidi())) { | 1093 isOverride(styleToUse.unicodeBidi())) { |
1094 run = 0; | 1094 run = 0; |
1095 } else { | 1095 } else { |
1096 TextRun textRun(text()); | 1096 TextRun textRun(text()); |
1097 BidiStatus status(textDirection, false); | 1097 BidiStatus status(textDirection, false); |
1098 bidiResolver.setStatus(status); | 1098 bidiResolver.setStatus(status); |
1099 bidiResolver.setPositionIgnoringNestedIsolates( | 1099 bidiResolver.setPositionIgnoringNestedIsolates( |
1100 TextRunIterator(&textRun, 0)); | 1100 TextRunIterator(&textRun, 0)); |
1101 bool hardLineBreak = false; | 1101 bool hardLineBreak = false; |
1102 bool reorderRuns = false; | 1102 bool reorderRuns = false; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 j = std::min(j, run->stop() + 1); | 1195 j = std::min(j, run->stop() + 1); |
1196 int wordLen = j - i; | 1196 int wordLen = j - i; |
1197 if (wordLen) { | 1197 if (wordLen) { |
1198 bool isSpace = (j < len) && c == spaceCharacter; | 1198 bool isSpace = (j < len) && c == spaceCharacter; |
1199 | 1199 |
1200 // Non-zero only when kerning is enabled, in which case we measure words | 1200 // Non-zero only when kerning is enabled, in which case we measure words |
1201 // with their trailing space, then subtract its width. | 1201 // with their trailing space, then subtract its width. |
1202 float wordTrailingSpaceWidth = 0; | 1202 float wordTrailingSpaceWidth = 0; |
1203 if (isSpace && | 1203 if (isSpace && |
1204 (f.getFontDescription().getTypesettingFeatures() & Kerning)) { | 1204 (f.getFontDescription().getTypesettingFeatures() & Kerning)) { |
1205 ASSERT(textDirection >= 0 && textDirection <= 1); | 1205 const unsigned textDirectionIndex = |
1206 if (!cachedWordTrailingSpaceWidth[textDirection]) | 1206 static_cast<unsigned>(textDirection); |
1207 cachedWordTrailingSpaceWidth[textDirection] = | 1207 DCHECK_GE(textDirectionIndex, 0U); |
| 1208 DCHECK_LE(textDirectionIndex, 1U); |
| 1209 if (!cachedWordTrailingSpaceWidth[textDirectionIndex]) |
| 1210 cachedWordTrailingSpaceWidth[textDirectionIndex] = |
1208 f.width(constructTextRun(f, &spaceCharacter, 1, styleToUse, | 1211 f.width(constructTextRun(f, &spaceCharacter, 1, styleToUse, |
1209 textDirection)) + | 1212 textDirection)) + |
1210 wordSpacing; | 1213 wordSpacing; |
1211 wordTrailingSpaceWidth = cachedWordTrailingSpaceWidth[textDirection]; | 1214 wordTrailingSpaceWidth = |
| 1215 cachedWordTrailingSpaceWidth[textDirectionIndex]; |
1212 } | 1216 } |
1213 | 1217 |
1214 float w; | 1218 float w; |
1215 if (wordTrailingSpaceWidth && isSpace) { | 1219 if (wordTrailingSpaceWidth && isSpace) { |
1216 w = widthFromFont(f, i, wordLen + 1, leadWidth, currMaxWidth, | 1220 w = widthFromFont(f, i, wordLen + 1, leadWidth, currMaxWidth, |
1217 textDirection, &fallbackFonts, &glyphBounds) - | 1221 textDirection, &fallbackFonts, &glyphBounds) - |
1218 wordTrailingSpaceWidth; | 1222 wordTrailingSpaceWidth; |
1219 } else { | 1223 } else { |
1220 w = widthFromFont(f, i, wordLen, leadWidth, currMaxWidth, textDirection, | 1224 w = widthFromFont(f, i, wordLen, leadWidth, currMaxWidth, textDirection, |
1221 &fallbackFonts, &glyphBounds); | 1225 &fallbackFonts, &glyphBounds); |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1984 LayoutRect rect = LayoutRect( | 1988 LayoutRect rect = LayoutRect( |
1985 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height())); | 1989 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height())); |
1986 LayoutBlock* block = containingBlock(); | 1990 LayoutBlock* block = containingBlock(); |
1987 if (block && hasTextBoxes()) | 1991 if (block && hasTextBoxes()) |
1988 block->adjustChildDebugRect(rect); | 1992 block->adjustChildDebugRect(rect); |
1989 | 1993 |
1990 return rect; | 1994 return rect; |
1991 } | 1995 } |
1992 | 1996 |
1993 } // namespace blink | 1997 } // namespace blink |
OLD | NEW |