| 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 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 wordMeasurement, start + prefixLength, | 888 wordMeasurement, start + prefixLength, |
| 889 font.getCharacterRange(run, 0, prefixLength).width()); | 889 font.getCharacterRange(run, 0, prefixLength).width()); |
| 890 } | 890 } |
| 891 | 891 |
| 892 ALWAYS_INLINE bool BreakingContext::isBreakAtSoftHyphen() const { | 892 ALWAYS_INLINE bool BreakingContext::isBreakAtSoftHyphen() const { |
| 893 return m_lineBreak != m_resolver.position() | 893 return m_lineBreak != m_resolver.position() |
| 894 ? m_lineBreak.previousInSameNode() == softHyphenCharacter | 894 ? m_lineBreak.previousInSameNode() == softHyphenCharacter |
| 895 : m_current.previousInSameNode() == softHyphenCharacter; | 895 : m_current.previousInSameNode() == softHyphenCharacter; |
| 896 } | 896 } |
| 897 | 897 |
| 898 static ALWAYS_INLINE bool hasVisibleText(LineLayoutText layoutText, |
| 899 unsigned offset) { |
| 900 return !layoutText.containsOnlyWhitespace(offset, |
| 901 layoutText.textLength() - offset); |
| 902 } |
| 903 |
| 898 inline bool BreakingContext::handleText(WordMeasurements& wordMeasurements, | 904 inline bool BreakingContext::handleText(WordMeasurements& wordMeasurements, |
| 899 bool& hyphenated) { | 905 bool& hyphenated) { |
| 900 if (!m_current.offset()) | 906 if (!m_current.offset()) |
| 901 m_appliedStartWidth = false; | 907 m_appliedStartWidth = false; |
| 902 | 908 |
| 903 LineLayoutText layoutText(m_current.getLineLayoutItem()); | 909 LineLayoutText layoutText(m_current.getLineLayoutItem()); |
| 904 | 910 |
| 905 // If we have left a no-wrap inline and entered an autowrap inline while | 911 // If we have left a no-wrap inline and entered an autowrap inline while |
| 906 // ignoring spaces then we need to mark the start of the autowrap inline as a | 912 // ignoring spaces then we need to mark the start of the autowrap inline as a |
| 907 // potential linebreak now. | 913 // potential linebreak now. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 936 | 942 |
| 937 // This is currently only used for word-break: break-all, specifically for the | 943 // This is currently only used for word-break: break-all, specifically for the |
| 938 // case where we have a break opportunity within a word, then a string of non- | 944 // case where we have a break opportunity within a word, then a string of non- |
| 939 // breakable content that ends up making our word wider than the current line. | 945 // breakable content that ends up making our word wider than the current line. |
| 940 // See: fast/css3-text/css3-word-break/word-break-all-wrap-with-floats.html | 946 // See: fast/css3-text/css3-word-break/word-break-all-wrap-with-floats.html |
| 941 float widthMeasurementAtLastBreakOpportunity = 0; | 947 float widthMeasurementAtLastBreakOpportunity = 0; |
| 942 | 948 |
| 943 Hyphenation* hyphenation = style.getHyphenation(); | 949 Hyphenation* hyphenation = style.getHyphenation(); |
| 944 bool disableSoftHyphen = style.getHyphens() == HyphensNone; | 950 bool disableSoftHyphen = style.getHyphens() == HyphensNone; |
| 945 float hyphenWidth = 0; | 951 float hyphenWidth = 0; |
| 952 bool isLineEmpty = m_lineInfo.isEmpty(); |
| 946 | 953 |
| 947 if (layoutText.isSVGInlineText()) { | 954 if (layoutText.isSVGInlineText()) { |
| 948 breakWords = false; | 955 breakWords = false; |
| 949 breakAll = false; | 956 breakAll = false; |
| 950 keepAll = false; | 957 keepAll = false; |
| 951 } | 958 } |
| 952 | 959 |
| 953 // Use LineBreakType::Normal for break-all. When a word does not fit, | 960 // Use LineBreakType::Normal for break-all. When a word does not fit, |
| 954 // rewindToMidWordBreak() finds the mid-word break point. | 961 // rewindToMidWordBreak() finds the mid-word break point. |
| 955 LineBreakType lineBreakType = | 962 LineBreakType lineBreakType = |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 midWordBreak = false; | 1102 midWordBreak = false; |
| 1096 if (!m_width.fitsOnLine()) { | 1103 if (!m_width.fitsOnLine()) { |
| 1097 if (canBreakMidWord) { | 1104 if (canBreakMidWord) { |
| 1098 m_width.addUncommittedWidth(-wordMeasurement.width); | 1105 m_width.addUncommittedWidth(-wordMeasurement.width); |
| 1099 if (rewindToMidWordBreak(layoutText, style, font, breakAll, | 1106 if (rewindToMidWordBreak(layoutText, style, font, breakAll, |
| 1100 wordMeasurement)) { | 1107 wordMeasurement)) { |
| 1101 lastWidthMeasurement = wordMeasurement.width + lastSpaceWordSpacing; | 1108 lastWidthMeasurement = wordMeasurement.width + lastSpaceWordSpacing; |
| 1102 midWordBreak = true; | 1109 midWordBreak = true; |
| 1103 } | 1110 } |
| 1104 m_width.addUncommittedWidth(wordMeasurement.width); | 1111 m_width.addUncommittedWidth(wordMeasurement.width); |
| 1105 } else if (hyphenation) { | 1112 } else if (hyphenation && |
| 1113 (m_nextObject || isLineEmpty || |
| 1114 hasVisibleText(layoutText, m_current.offset()))) { |
| 1106 m_width.addUncommittedWidth(-wordMeasurement.width); | 1115 m_width.addUncommittedWidth(-wordMeasurement.width); |
| 1107 DCHECK(lastSpace == static_cast<unsigned>(wordMeasurement.startOffset)); | 1116 DCHECK(lastSpace == static_cast<unsigned>(wordMeasurement.startOffset)); |
| 1108 DCHECK(m_current.offset() == | 1117 DCHECK(m_current.offset() == |
| 1109 static_cast<unsigned>(wordMeasurement.endOffset)); | 1118 static_cast<unsigned>(wordMeasurement.endOffset)); |
| 1110 if (hyphenate(layoutText, style, font, *hyphenation, | 1119 if (hyphenate(layoutText, style, font, *hyphenation, |
| 1111 lastSpaceWordSpacing, wordMeasurement)) { | 1120 lastSpaceWordSpacing, wordMeasurement)) { |
| 1112 m_width.addUncommittedWidth(wordMeasurement.width); | 1121 m_width.addUncommittedWidth(wordMeasurement.width); |
| 1113 hyphenated = true; | 1122 hyphenated = true; |
| 1114 m_atEnd = true; | 1123 m_atEnd = true; |
| 1115 return false; | 1124 return false; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1184 m_lineMidpointState.startIgnoringSpaces(m_startOfIgnoredSpaces); | 1193 m_lineMidpointState.startIgnoringSpaces(m_startOfIgnoredSpaces); |
| 1185 m_trailingObjects.updateMidpointsForTrailingObjects( | 1194 m_trailingObjects.updateMidpointsForTrailingObjects( |
| 1186 m_lineMidpointState, InlineIterator(), | 1195 m_lineMidpointState, InlineIterator(), |
| 1187 TrailingObjects::DoNotCollapseFirstSpace); | 1196 TrailingObjects::DoNotCollapseFirstSpace); |
| 1188 } | 1197 } |
| 1189 } | 1198 } |
| 1190 | 1199 |
| 1191 prepareForNextCharacter(layoutText, prohibitBreakInside, | 1200 prepareForNextCharacter(layoutText, prohibitBreakInside, |
| 1192 previousCharacterIsSpace); | 1201 previousCharacterIsSpace); |
| 1193 m_atStart = false; | 1202 m_atStart = false; |
| 1203 isLineEmpty = m_lineInfo.isEmpty(); |
| 1194 nextCharacter(c, lastCharacter, secondToLastCharacter); | 1204 nextCharacter(c, lastCharacter, secondToLastCharacter); |
| 1195 } | 1205 } |
| 1196 | 1206 |
| 1197 m_layoutTextInfo.m_lineBreakIterator.setPriorContext(lastCharacter, | 1207 m_layoutTextInfo.m_lineBreakIterator.setPriorContext(lastCharacter, |
| 1198 secondToLastCharacter); | 1208 secondToLastCharacter); |
| 1199 | 1209 |
| 1200 wordMeasurements.grow(wordMeasurements.size() + 1); | 1210 wordMeasurements.grow(wordMeasurements.size() + 1); |
| 1201 WordMeasurement& wordMeasurement = wordMeasurements.last(); | 1211 WordMeasurement& wordMeasurement = wordMeasurements.last(); |
| 1202 wordMeasurement.layoutText = layoutText; | 1212 wordMeasurement.layoutText = layoutText; |
| 1203 | 1213 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1234 if (m_collapseWhiteSpace && m_currentCharacterIsSpace && lastWidthMeasurement) | 1244 if (m_collapseWhiteSpace && m_currentCharacterIsSpace && lastWidthMeasurement) |
| 1235 m_width.setTrailingWhitespaceWidth(lastWidthMeasurement + | 1245 m_width.setTrailingWhitespaceWidth(lastWidthMeasurement + |
| 1236 additionalWidthFromAncestors); | 1246 additionalWidthFromAncestors); |
| 1237 | 1247 |
| 1238 m_includeEndWidth = false; | 1248 m_includeEndWidth = false; |
| 1239 | 1249 |
| 1240 if (midWordBreak) { | 1250 if (midWordBreak) { |
| 1241 m_width.commit(); | 1251 m_width.commit(); |
| 1242 m_atEnd = true; | 1252 m_atEnd = true; |
| 1243 } else if (!m_width.fitsOnLine()) { | 1253 } else if (!m_width.fitsOnLine()) { |
| 1244 if (hyphenation && (m_nextObject || m_lineInfo.isEmpty())) { | 1254 if (hyphenation && (m_nextObject || isLineEmpty)) { |
| 1245 m_width.addUncommittedWidth(-wordMeasurement.width); | 1255 m_width.addUncommittedWidth(-wordMeasurement.width); |
| 1246 DCHECK(lastSpace == static_cast<unsigned>(wordMeasurement.startOffset)); | 1256 DCHECK(lastSpace == static_cast<unsigned>(wordMeasurement.startOffset)); |
| 1247 DCHECK(m_current.offset() == | 1257 DCHECK(m_current.offset() == |
| 1248 static_cast<unsigned>(wordMeasurement.endOffset)); | 1258 static_cast<unsigned>(wordMeasurement.endOffset)); |
| 1249 if (hyphenate(layoutText, style, font, *hyphenation, lastSpaceWordSpacing, | 1259 if (hyphenate(layoutText, style, font, *hyphenation, lastSpaceWordSpacing, |
| 1250 wordMeasurement)) { | 1260 wordMeasurement)) { |
| 1251 hyphenated = true; | 1261 hyphenated = true; |
| 1252 m_atEnd = true; | 1262 m_atEnd = true; |
| 1253 } | 1263 } |
| 1254 m_width.addUncommittedWidth(wordMeasurement.width); | 1264 m_width.addUncommittedWidth(wordMeasurement.width); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1521 | 1531 |
| 1522 if (style.getTextIndentType() == TextIndentHanging) | 1532 if (style.getTextIndentType() == TextIndentHanging) |
| 1523 indentText = indentText == IndentText ? DoNotIndentText : IndentText; | 1533 indentText = indentText == IndentText ? DoNotIndentText : IndentText; |
| 1524 | 1534 |
| 1525 return indentText; | 1535 return indentText; |
| 1526 } | 1536 } |
| 1527 | 1537 |
| 1528 } // namespace blink | 1538 } // namespace blink |
| 1529 | 1539 |
| 1530 #endif // BreakingContextInlineHeaders_h | 1540 #endif // BreakingContextInlineHeaders_h |
| OLD | NEW |