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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutText.cpp

Issue 2715153003: Implement 'normal', 'strict', and 'loose' of the 'line-break' property (Closed)
Patch Set: Rebase Created 3 years, 10 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
Index: third_party/WebKit/Source/core/layout/LayoutText.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutText.cpp b/third_party/WebKit/Source/core/layout/LayoutText.cpp
index c1b3a2658ca43aa77094c04a1572c0236ab1d99c..045f3370d9a36781089d41a7963a2acbd1274f32 100644
--- a/third_party/WebKit/Source/core/layout/LayoutText.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutText.cpp
@@ -1003,7 +1003,8 @@ static float minWordFragmentWidthForBreakAll(LayoutText* layoutText,
int length,
EWordBreak breakAllOrBreakWord) {
DCHECK_GT(length, 0);
- LazyLineBreakIterator breakIterator(layoutText->text(), style.locale());
+ LazyLineBreakIterator breakIterator(layoutText->text(),
+ localeForLineBreakIterator(style));
int nextBreakable = -1;
float min = std::numeric_limits<float>::max();
int end = start + length;
@@ -1071,6 +1072,30 @@ static float maxWordFragmentWidth(LayoutText* layoutText,
return maxFragmentWidth + layoutText->hyphenWidth(font, textDirection);
}
+AtomicString localeForLineBreakIterator(const ComputedStyle& style) {
+ LineBreakIteratorMode mode = LineBreakIteratorMode::Default;
+ switch (style.getLineBreak()) {
+ default:
+ NOTREACHED();
+ // Fall through.
+ case LineBreakAuto:
+ case LineBreakAfterWhiteSpace:
+ return style.locale();
+ case LineBreakNormal:
+ mode = LineBreakIteratorMode::Normal;
+ break;
+ case LineBreakStrict:
+ mode = LineBreakIteratorMode::Strict;
+ break;
+ case LineBreakLoose:
+ mode = LineBreakIteratorMode::Loose;
+ break;
+ }
+ if (const LayoutLocale* locale = style.getFontDescription().locale())
+ return locale->localeWithBreakKeyword(mode);
+ return style.locale();
+}
+
void LayoutText::computePreferredLogicalWidths(
float leadWidth,
HashSet<const SimpleFontData*>& fallbackFonts,
@@ -1099,7 +1124,8 @@ void LayoutText::computePreferredLogicalWidths(
const Font& f = styleToUse.font(); // FIXME: This ignores first-line.
float wordSpacing = styleToUse.wordSpacing();
int len = textLength();
- LazyLineBreakIterator breakIterator(m_text, styleToUse.locale());
+ LazyLineBreakIterator breakIterator(m_text,
+ localeForLineBreakIterator(styleToUse));
bool needsWordSpacing = false;
bool ignoringSpaces = false;
bool isSpace = false;

Powered by Google App Engine
This is Rietveld 408576698