| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. | 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. |
| 4 * All right reserved. | 4 * All right reserved. |
| 5 * Copyright (C) 2010 Google Inc. All rights reserved. | 5 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 6 * Copyright (C) 2013 Adobe Systems Incorporated. | 6 * Copyright (C) 2013 Adobe Systems Incorporated. |
| 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 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1106 if (!m_appliedStartWidth) { | 1106 if (!m_appliedStartWidth) { |
| 1107 m_width.addUncommittedWidth( | 1107 m_width.addUncommittedWidth( |
| 1108 inlineLogicalWidthFromAncestorsIfNeeded(m_current.getLineLayoutItem(), | 1108 inlineLogicalWidthFromAncestorsIfNeeded(m_current.getLineLayoutItem(), |
| 1109 true, false) | 1109 true, false) |
| 1110 .toFloat()); | 1110 .toFloat()); |
| 1111 m_appliedStartWidth = true; | 1111 m_appliedStartWidth = true; |
| 1112 } | 1112 } |
| 1113 | 1113 |
| 1114 midWordBreak = false; | 1114 midWordBreak = false; |
| 1115 if (!m_width.fitsOnLine()) { | 1115 if (!m_width.fitsOnLine()) { |
| 1116 if (canBreakMidWord) { | 1116 if (hyphenation && (m_nextObject || isLineEmpty || |
| 1117 m_width.addUncommittedWidth(-wordMeasurement.width); | 1117 hasVisibleText(layoutText, m_current.offset()))) { |
| 1118 if (rewindToMidWordBreak(layoutText, style, font, breakAll, | |
| 1119 wordMeasurement)) { | |
| 1120 lastWidthMeasurement = wordMeasurement.width + lastSpaceWordSpacing; | |
| 1121 midWordBreak = true; | |
| 1122 } | |
| 1123 m_width.addUncommittedWidth(wordMeasurement.width); | |
| 1124 } else if (hyphenation && | |
| 1125 (m_nextObject || isLineEmpty || | |
| 1126 hasVisibleText(layoutText, m_current.offset()))) { | |
| 1127 m_width.addUncommittedWidth(-wordMeasurement.width); | 1118 m_width.addUncommittedWidth(-wordMeasurement.width); |
| 1128 DCHECK(lastSpace == static_cast<unsigned>(wordMeasurement.startOffset)); | 1119 DCHECK(lastSpace == static_cast<unsigned>(wordMeasurement.startOffset)); |
| 1129 DCHECK(m_current.offset() == | 1120 DCHECK(m_current.offset() == |
| 1130 static_cast<unsigned>(wordMeasurement.endOffset)); | 1121 static_cast<unsigned>(wordMeasurement.endOffset)); |
| 1131 if (hyphenate(layoutText, style, font, *hyphenation, | 1122 if (hyphenate(layoutText, style, font, *hyphenation, |
| 1132 lastSpaceWordSpacing, wordMeasurement)) { | 1123 lastSpaceWordSpacing, wordMeasurement)) { |
| 1133 m_width.addUncommittedWidth(wordMeasurement.width); | 1124 m_width.addUncommittedWidth(wordMeasurement.width); |
| 1134 hyphenated = true; | 1125 hyphenated = true; |
| 1135 m_atEnd = true; | 1126 m_atEnd = true; |
| 1136 return false; | 1127 return false; |
| 1137 } | 1128 } |
| 1138 m_width.addUncommittedWidth(wordMeasurement.width); | 1129 m_width.addUncommittedWidth(wordMeasurement.width); |
| 1139 } | 1130 } |
| 1131 if (canBreakMidWord) { |
| 1132 m_width.addUncommittedWidth(-wordMeasurement.width); |
| 1133 if (rewindToMidWordBreak(layoutText, style, font, breakAll, |
| 1134 wordMeasurement)) { |
| 1135 lastWidthMeasurement = wordMeasurement.width + lastSpaceWordSpacing; |
| 1136 midWordBreak = true; |
| 1137 } |
| 1138 m_width.addUncommittedWidth(wordMeasurement.width); |
| 1139 } |
| 1140 } | 1140 } |
| 1141 | 1141 |
| 1142 // If we haven't hit a breakable position yet and already don't fit on the | 1142 // If we haven't hit a breakable position yet and already don't fit on the |
| 1143 // line try to move below any floats. | 1143 // line try to move below any floats. |
| 1144 if (!m_width.committedWidth() && m_autoWrap && !m_width.fitsOnLine() && | 1144 if (!m_width.committedWidth() && m_autoWrap && !m_width.fitsOnLine() && |
| 1145 !widthMeasurementAtLastBreakOpportunity) { | 1145 !widthMeasurementAtLastBreakOpportunity) { |
| 1146 float availableWidthBefore = m_width.availableWidth(); | 1146 float availableWidthBefore = m_width.availableWidth(); |
| 1147 m_width.fitBelowFloats(m_lineInfo.isFirstLine()); | 1147 m_width.fitBelowFloats(m_lineInfo.isFirstLine()); |
| 1148 // If availableWidth changes by moving the line below floats, needs to | 1148 // If availableWidth changes by moving the line below floats, needs to |
| 1149 // measure midWordBreak again. | 1149 // measure midWordBreak again. |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1220 secondToLastCharacter); | 1220 secondToLastCharacter); |
| 1221 | 1221 |
| 1222 wordMeasurements.grow(wordMeasurements.size() + 1); | 1222 wordMeasurements.grow(wordMeasurements.size() + 1); |
| 1223 WordMeasurement& wordMeasurement = wordMeasurements.back(); | 1223 WordMeasurement& wordMeasurement = wordMeasurements.back(); |
| 1224 wordMeasurement.layoutText = layoutText; | 1224 wordMeasurement.layoutText = layoutText; |
| 1225 | 1225 |
| 1226 // IMPORTANT: current.offset() is > layoutText.textLength() here! | 1226 // IMPORTANT: current.offset() is > layoutText.textLength() here! |
| 1227 float lastWidthMeasurement = 0; | 1227 float lastWidthMeasurement = 0; |
| 1228 wordMeasurement.startOffset = lastSpace; | 1228 wordMeasurement.startOffset = lastSpace; |
| 1229 wordMeasurement.endOffset = m_current.offset(); | 1229 wordMeasurement.endOffset = m_current.offset(); |
| 1230 midWordBreak = false; | |
| 1231 if (!m_ignoringSpaces) { | 1230 if (!m_ignoringSpaces) { |
| 1232 lastWidthMeasurement = | 1231 lastWidthMeasurement = |
| 1233 textWidth(layoutText, lastSpace, m_current.offset() - lastSpace, font, | 1232 textWidth(layoutText, lastSpace, m_current.offset() - lastSpace, font, |
| 1234 m_width.currentWidth(), m_collapseWhiteSpace, | 1233 m_width.currentWidth(), m_collapseWhiteSpace, |
| 1235 &wordMeasurement.fallbackFonts, &wordMeasurement.glyphBounds); | 1234 &wordMeasurement.fallbackFonts, &wordMeasurement.glyphBounds); |
| 1236 wordMeasurement.width = | 1235 wordMeasurement.width = |
| 1237 lastWidthMeasurement + wordSpacingForWordMeasurement; | 1236 lastWidthMeasurement + wordSpacingForWordMeasurement; |
| 1238 wordMeasurement.glyphBounds.move(wordSpacingForWordMeasurement, 0); | 1237 wordMeasurement.glyphBounds.move(wordSpacingForWordMeasurement, 0); |
| 1239 | |
| 1240 if (canBreakMidWord && !m_width.fitsOnLine(lastWidthMeasurement) && | |
| 1241 rewindToMidWordBreak(layoutText, style, font, breakAll, | |
| 1242 wordMeasurement)) { | |
| 1243 lastWidthMeasurement = wordMeasurement.width; | |
| 1244 midWordBreak = true; | |
| 1245 } | |
| 1246 } | 1238 } |
| 1247 lastWidthMeasurement += lastSpaceWordSpacing; | 1239 lastWidthMeasurement += lastSpaceWordSpacing; |
| 1248 | 1240 |
| 1249 LayoutUnit additionalWidthFromAncestors = | 1241 LayoutUnit additionalWidthFromAncestors = |
| 1250 inlineLogicalWidthFromAncestorsIfNeeded(m_current.getLineLayoutItem(), | 1242 inlineLogicalWidthFromAncestorsIfNeeded(m_current.getLineLayoutItem(), |
| 1251 !m_appliedStartWidth, | 1243 !m_appliedStartWidth, |
| 1252 m_includeEndWidth); | 1244 m_includeEndWidth); |
| 1253 m_width.addUncommittedWidth(lastWidthMeasurement + | 1245 m_width.addUncommittedWidth(lastWidthMeasurement + |
| 1254 additionalWidthFromAncestors); | 1246 additionalWidthFromAncestors); |
| 1255 | 1247 |
| 1256 if (m_collapseWhiteSpace && m_currentCharacterIsSpace && lastWidthMeasurement) | 1248 if (m_collapseWhiteSpace && m_currentCharacterIsSpace && lastWidthMeasurement) |
| 1257 m_width.setTrailingWhitespaceWidth(lastWidthMeasurement + | 1249 m_width.setTrailingWhitespaceWidth(lastWidthMeasurement + |
| 1258 additionalWidthFromAncestors); | 1250 additionalWidthFromAncestors); |
| 1259 | 1251 |
| 1260 m_includeEndWidth = false; | 1252 m_includeEndWidth = false; |
| 1261 | 1253 |
| 1262 if (midWordBreak) { | 1254 if (!m_ignoringSpaces && !m_width.fitsOnLine()) { |
| 1263 m_width.commit(); | |
| 1264 m_atEnd = true; | |
| 1265 } else if (!m_width.fitsOnLine()) { | |
| 1266 if (hyphenation && (m_nextObject || isLineEmpty)) { | 1255 if (hyphenation && (m_nextObject || isLineEmpty)) { |
| 1267 m_width.addUncommittedWidth(-wordMeasurement.width); | 1256 m_width.addUncommittedWidth(-wordMeasurement.width); |
| 1268 DCHECK(lastSpace == static_cast<unsigned>(wordMeasurement.startOffset)); | 1257 DCHECK_EQ(lastSpace, static_cast<unsigned>(wordMeasurement.startOffset)); |
| 1269 DCHECK(m_current.offset() == | 1258 DCHECK_EQ(m_current.offset(), |
| 1270 static_cast<unsigned>(wordMeasurement.endOffset)); | 1259 static_cast<unsigned>(wordMeasurement.endOffset)); |
| 1271 if (hyphenate(layoutText, style, font, *hyphenation, lastSpaceWordSpacing, | 1260 if (hyphenate(layoutText, style, font, *hyphenation, lastSpaceWordSpacing, |
| 1272 wordMeasurement)) { | 1261 wordMeasurement)) { |
| 1273 hyphenated = true; | 1262 hyphenated = true; |
| 1274 m_atEnd = true; | 1263 m_atEnd = true; |
| 1275 } | 1264 } |
| 1276 m_width.addUncommittedWidth(wordMeasurement.width); | 1265 m_width.addUncommittedWidth(wordMeasurement.width); |
| 1277 } | 1266 } |
| 1278 if (!hyphenated && isBreakAtSoftHyphen() && !disableSoftHyphen) { | 1267 if (!hyphenated && isBreakAtSoftHyphen() && !disableSoftHyphen) { |
| 1279 hyphenated = true; | 1268 hyphenated = true; |
| 1280 m_atEnd = true; | 1269 m_atEnd = true; |
| 1281 } else if (!m_ignoringSpaces && canBreakMidWord && | 1270 } |
| 1282 m_width.committedWidth()) { | 1271 if (!hyphenated && canBreakMidWord) { |
| 1283 m_atEnd = true; | 1272 m_width.addUncommittedWidth(-wordMeasurement.width); |
| 1273 if (rewindToMidWordBreak(layoutText, style, font, breakAll, |
| 1274 wordMeasurement)) { |
| 1275 m_width.addUncommittedWidth(wordMeasurement.width); |
| 1276 m_width.commit(); |
| 1277 m_atEnd = true; |
| 1278 } else { |
| 1279 m_width.addUncommittedWidth(wordMeasurement.width); |
| 1280 if (m_width.committedWidth()) |
| 1281 m_atEnd = true; |
| 1282 } |
| 1284 } | 1283 } |
| 1285 } | 1284 } |
| 1286 return false; | 1285 return false; |
| 1287 } | 1286 } |
| 1288 | 1287 |
| 1289 inline void BreakingContext::prepareForNextCharacter( | 1288 inline void BreakingContext::prepareForNextCharacter( |
| 1290 const LineLayoutText& layoutText, | 1289 const LineLayoutText& layoutText, |
| 1291 bool& prohibitBreakInside, | 1290 bool& prohibitBreakInside, |
| 1292 bool previousCharacterIsSpace) { | 1291 bool previousCharacterIsSpace) { |
| 1293 if (layoutText.isSVGInlineText() && m_current.offset()) { | 1292 if (layoutText.isSVGInlineText() && m_current.offset()) { |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1543 | 1542 |
| 1544 if (style.getTextIndentType() == TextIndentHanging) | 1543 if (style.getTextIndentType() == TextIndentHanging) |
| 1545 indentText = indentText == IndentText ? DoNotIndentText : IndentText; | 1544 indentText = indentText == IndentText ? DoNotIndentText : IndentText; |
| 1546 | 1545 |
| 1547 return indentText; | 1546 return indentText; |
| 1548 } | 1547 } |
| 1549 | 1548 |
| 1550 } // namespace blink | 1549 } // namespace blink |
| 1551 | 1550 |
| 1552 #endif // BreakingContextInlineHeaders_h | 1551 #endif // BreakingContextInlineHeaders_h |
| OLD | NEW |