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

Unified Diff: third_party/WebKit/Source/core/layout/line/BreakingContextInlineHeaders.h

Issue 2560453002: Prioritize hyphenations over break-word/break-all (Closed)
Patch Set: Fix 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/text/hyphens/midword-break-priority-expected.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/line/BreakingContextInlineHeaders.h
diff --git a/third_party/WebKit/Source/core/layout/line/BreakingContextInlineHeaders.h b/third_party/WebKit/Source/core/layout/line/BreakingContextInlineHeaders.h
index 38199e93b1a26097a67652a32439fab8b37cc0b6..8751b161f36d3d21196b102f5c8f9a5fe4efc986 100644
--- a/third_party/WebKit/Source/core/layout/line/BreakingContextInlineHeaders.h
+++ b/third_party/WebKit/Source/core/layout/line/BreakingContextInlineHeaders.h
@@ -1101,19 +1101,10 @@ inline bool BreakingContext::handleText(WordMeasurements& wordMeasurements,
midWordBreak = false;
if (!m_width.fitsOnLine()) {
- if (canBreakMidWord) {
- m_width.addUncommittedWidth(-wordMeasurement.width);
- if (rewindToMidWordBreak(layoutText, style, font, breakAll,
- wordMeasurement)) {
- lastWidthMeasurement = wordMeasurement.width + lastSpaceWordSpacing;
- midWordBreak = true;
- }
- m_width.addUncommittedWidth(wordMeasurement.width);
- } else if (hyphenation &&
- (m_nextObject || isLineEmpty ||
- !layoutText.containsOnlyWhitespace(
- m_current.offset(),
- layoutText.textLength() - m_current.offset()))) {
+ if (hyphenation && (m_nextObject || isLineEmpty ||
eae 2016/12/07 07:16:20 This is pretty hard to read, how about adding a st
+ !layoutText.containsOnlyWhitespace(
+ m_current.offset(),
+ layoutText.textLength() - m_current.offset()))) {
m_width.addUncommittedWidth(-wordMeasurement.width);
DCHECK(lastSpace == static_cast<unsigned>(wordMeasurement.startOffset));
DCHECK(m_current.offset() ==
@@ -1127,6 +1118,15 @@ inline bool BreakingContext::handleText(WordMeasurements& wordMeasurements,
}
m_width.addUncommittedWidth(wordMeasurement.width);
}
+ if (canBreakMidWord) {
+ m_width.addUncommittedWidth(-wordMeasurement.width);
+ if (rewindToMidWordBreak(layoutText, style, font, breakAll,
+ wordMeasurement)) {
+ lastWidthMeasurement = wordMeasurement.width + lastSpaceWordSpacing;
+ midWordBreak = true;
+ }
+ m_width.addUncommittedWidth(wordMeasurement.width);
+ }
}
// If we haven't hit a breakable position yet and already don't fit on the
@@ -1217,7 +1217,6 @@ inline bool BreakingContext::handleText(WordMeasurements& wordMeasurements,
float lastWidthMeasurement = 0;
wordMeasurement.startOffset = lastSpace;
wordMeasurement.endOffset = m_current.offset();
- midWordBreak = false;
if (!m_ignoringSpaces) {
lastWidthMeasurement =
textWidth(layoutText, lastSpace, m_current.offset() - lastSpace, font,
@@ -1226,13 +1225,6 @@ inline bool BreakingContext::handleText(WordMeasurements& wordMeasurements,
wordMeasurement.width =
lastWidthMeasurement + wordSpacingForWordMeasurement;
wordMeasurement.glyphBounds.move(wordSpacingForWordMeasurement, 0);
-
- if (canBreakMidWord && !m_width.fitsOnLine(lastWidthMeasurement) &&
- rewindToMidWordBreak(layoutText, style, font, breakAll,
- wordMeasurement)) {
- lastWidthMeasurement = wordMeasurement.width;
- midWordBreak = true;
- }
}
lastWidthMeasurement += lastSpaceWordSpacing;
@@ -1249,15 +1241,12 @@ inline bool BreakingContext::handleText(WordMeasurements& wordMeasurements,
m_includeEndWidth = false;
- if (midWordBreak) {
- m_width.commit();
- m_atEnd = true;
- } else if (!m_width.fitsOnLine()) {
+ if (!m_ignoringSpaces && !m_width.fitsOnLine()) {
if (hyphenation && (m_nextObject || isLineEmpty)) {
m_width.addUncommittedWidth(-wordMeasurement.width);
- DCHECK(lastSpace == static_cast<unsigned>(wordMeasurement.startOffset));
- DCHECK(m_current.offset() ==
- static_cast<unsigned>(wordMeasurement.endOffset));
+ DCHECK_EQ(lastSpace, static_cast<unsigned>(wordMeasurement.startOffset));
+ DCHECK_EQ(m_current.offset(),
+ static_cast<unsigned>(wordMeasurement.endOffset));
if (hyphenate(layoutText, style, font, *hyphenation, lastSpaceWordSpacing,
wordMeasurement)) {
hyphenated = true;
@@ -1268,9 +1257,19 @@ inline bool BreakingContext::handleText(WordMeasurements& wordMeasurements,
if (!hyphenated && isBreakAtSoftHyphen() && !disableSoftHyphen) {
hyphenated = true;
m_atEnd = true;
- } else if (!m_ignoringSpaces && canBreakMidWord &&
- m_width.committedWidth()) {
- m_atEnd = true;
+ }
+ if (!hyphenated && canBreakMidWord) {
+ m_width.addUncommittedWidth(-wordMeasurement.width);
+ if (rewindToMidWordBreak(layoutText, style, font, breakAll,
+ wordMeasurement)) {
+ m_width.addUncommittedWidth(wordMeasurement.width);
+ m_width.commit();
+ m_atEnd = true;
+ } else {
+ m_width.addUncommittedWidth(wordMeasurement.width);
+ if (m_width.committedWidth())
+ m_atEnd = true;
+ }
}
}
return false;
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/text/hyphens/midword-break-priority-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698