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

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

Issue 2560383002: Merge 2924: Apply hyphenation when there is only one word in a paragraph (Closed)
Patch Set: 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/Source/core/layout/api/LineLayoutText.h ('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 d7daadd88e4b7af220139a239a014dfc61ad1af2..513b3b414de99d61155bc7e21a7bdb49266043d0 100644
--- a/third_party/WebKit/Source/core/layout/line/BreakingContextInlineHeaders.h
+++ b/third_party/WebKit/Source/core/layout/line/BreakingContextInlineHeaders.h
@@ -895,6 +895,12 @@ ALWAYS_INLINE bool BreakingContext::isBreakAtSoftHyphen() const {
: m_current.previousInSameNode() == softHyphenCharacter;
}
+static ALWAYS_INLINE bool hasVisibleText(LineLayoutText layoutText,
+ unsigned offset) {
+ return !layoutText.containsOnlyWhitespace(offset,
+ layoutText.textLength() - offset);
+}
+
inline bool BreakingContext::handleText(WordMeasurements& wordMeasurements,
bool& hyphenated) {
if (!m_current.offset())
@@ -943,6 +949,7 @@ inline bool BreakingContext::handleText(WordMeasurements& wordMeasurements,
Hyphenation* hyphenation = style.getHyphenation();
bool disableSoftHyphen = style.getHyphens() == HyphensNone;
float hyphenWidth = 0;
+ bool isLineEmpty = m_lineInfo.isEmpty();
if (layoutText.isSVGInlineText()) {
breakWords = false;
@@ -1102,7 +1109,9 @@ inline bool BreakingContext::handleText(WordMeasurements& wordMeasurements,
midWordBreak = true;
}
m_width.addUncommittedWidth(wordMeasurement.width);
- } else if (hyphenation) {
+ } else if (hyphenation &&
+ (m_nextObject || isLineEmpty ||
+ hasVisibleText(layoutText, m_current.offset()))) {
m_width.addUncommittedWidth(-wordMeasurement.width);
DCHECK(lastSpace == static_cast<unsigned>(wordMeasurement.startOffset));
DCHECK(m_current.offset() ==
@@ -1191,6 +1200,7 @@ inline bool BreakingContext::handleText(WordMeasurements& wordMeasurements,
prepareForNextCharacter(layoutText, prohibitBreakInside,
previousCharacterIsSpace);
m_atStart = false;
+ isLineEmpty = m_lineInfo.isEmpty();
nextCharacter(c, lastCharacter, secondToLastCharacter);
}
@@ -1241,7 +1251,7 @@ inline bool BreakingContext::handleText(WordMeasurements& wordMeasurements,
m_width.commit();
m_atEnd = true;
} else if (!m_width.fitsOnLine()) {
- if (hyphenation && (m_nextObject || m_lineInfo.isEmpty())) {
+ if (hyphenation && (m_nextObject || isLineEmpty)) {
m_width.addUncommittedWidth(-wordMeasurement.width);
DCHECK(lastSpace == static_cast<unsigned>(wordMeasurement.startOffset));
DCHECK(m_current.offset() ==
« no previous file with comments | « third_party/WebKit/Source/core/layout/api/LineLayoutText.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698