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

Unified Diff: Source/core/layout/LayoutRubyRun.cpp

Issue 1304993003: Fix Japanese line breaking rule before and after ruby (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add NeedsRebaseline Created 5 years, 4 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: Source/core/layout/LayoutRubyRun.cpp
diff --git a/Source/core/layout/LayoutRubyRun.cpp b/Source/core/layout/LayoutRubyRun.cpp
index 7f8c29ebb40be920c55315f5d75e30c339831768..c5eef9107ffa7b3bcab972459f6d5217ace9be12 100644
--- a/Source/core/layout/LayoutRubyRun.cpp
+++ b/Source/core/layout/LayoutRubyRun.cpp
@@ -302,4 +302,28 @@ void LayoutRubyRun::getOverhang(bool firstLine, LayoutObject* startLayoutObject,
endOverhang = std::min<int>(endOverhang, std::min<int>(toLayoutText(endLayoutObject)->minLogicalWidth(), halfWidthOfFontSize));
}
+bool LayoutRubyRun::canBreakBefore(const LazyLineBreakIterator& iterator) const
+{
+ // TODO(kojii): It would be nice to improve this so that it isn't just
+ // hard-coded, but lookahead in this case is particularly problematic.
eae 2015/08/21 20:47:06 Could you add a crbug link here?
kojii 2015/08/22 03:49:34 Done.
+
+ if (!iterator.priorContextLength())
+ return true;
+ UChar ch = iterator.lastCharacter();
+ ULineBreak lineBreak = (ULineBreak)u_getIntPropertyValue(ch, UCHAR_LINE_BREAK);
eae 2015/08/21 20:47:06 static_cast
kojii 2015/08/22 03:49:34 Done.
+ // UNICODE LINE BREAKING ALGORITHM
+ // http://www.unicode.org/reports/tr14/
+ // And Requirements for Japanese Text Layout, 3.1.7 Characters Not Starting a Line
+ // http://www.w3.org/TR/2012/NOTE-jlreq-20120403/#characters_not_starting_a_line
+ switch (lineBreak) {
+ case U_LB_WORD_JOINER:
+ case U_LB_GLUE:
+ case U_LB_OPEN_PUNCTUATION:
+ return false;
+ default:
+ break;
+ }
+ return true;
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698