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

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

Issue 2167093002: Soft hyphens with long suffix may add unnecessary hyphens (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Stabilize test Created 4 years, 5 months 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/soft-hyphen-overflow-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 cebc93ebd42d1d9a1c77a7ec637e546bf85ce6c9..a945545dde73eed1c967c11dd320970f577d4d05 100644
--- a/third_party/WebKit/Source/core/layout/line/BreakingContextInlineHeaders.h
+++ b/third_party/WebKit/Source/core/layout/line/BreakingContextInlineHeaders.h
@@ -123,6 +123,7 @@ private:
bool rewindToFirstMidWordBreak(LineLayoutText, const ComputedStyle&, const Font&, bool breakAll, WordMeasurement&);
bool rewindToMidWordBreak(LineLayoutText, const ComputedStyle&, const Font&, bool breakAll, WordMeasurement&);
bool hyphenate(LineLayoutText, const ComputedStyle&, const Font&, const Hyphenation&, float lastSpaceWordSpacing, WordMeasurement&);
+ bool isBreakAtSoftHyphen() const;
InlineBidiResolver& m_resolver;
@@ -697,6 +698,13 @@ ALWAYS_INLINE bool BreakingContext::hyphenate(LineLayoutText text,
font.getCharacterRange(run, 0, prefixLength).width() + hyphenWidth);
}
+ALWAYS_INLINE bool BreakingContext::isBreakAtSoftHyphen() const
+{
+ return m_lineBreak != m_resolver.position()
+ ? m_lineBreak.previousInSameNode() == softHyphenCharacter
+ : m_current.previousInSameNode() == softHyphenCharacter;
+}
+
inline bool BreakingContext::handleText(WordMeasurements& wordMeasurements, bool& hyphenated)
{
if (!m_current.offset())
@@ -983,9 +991,7 @@ inline bool BreakingContext::handleText(WordMeasurements& wordMeasurements, bool
}
m_width.addUncommittedWidth(wordMeasurement.width);
}
- if (!hyphenated
- && m_lineBreak.previousInSameNode() == softHyphenCharacter
- && !disableSoftHyphen) {
+ if (!hyphenated && isBreakAtSoftHyphen() && !disableSoftHyphen) {
hyphenated = true;
m_atEnd = true;
}
@@ -1081,7 +1087,7 @@ inline bool BreakingContext::canBreakAtWhitespace(bool breakWords, WordMeasureme
m_lineInfo.setPreviousLineBrokeCleanly(true);
wordMeasurement.endOffset = m_lineBreak.offset();
}
- if (m_lineBreak.getLineLayoutItem() && m_lineBreak.offset() && m_lineBreak.getLineLayoutItem().isText() && LineLayoutText(m_lineBreak.getLineLayoutItem()).textLength() && LineLayoutText(m_lineBreak.getLineLayoutItem()).characterAt(m_lineBreak.offset() - 1) == softHyphenCharacter && !disableSoftHyphen)
+ if (isBreakAtSoftHyphen() && !disableSoftHyphen)
hyphenated = true;
if (m_lineBreak.offset() && m_lineBreak.offset() != (unsigned)wordMeasurement.endOffset && !wordMeasurement.width) {
if (charWidth) {
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/text/soft-hyphen-overflow-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698