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

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: mac_chromium_rel_ng bot is stuck, re-upload to see if it fixes 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
« no previous file with comments | « Source/core/layout/LayoutRubyRun.h ('k') | Source/core/layout/line/BreakingContextInlineHeaders.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/layout/LayoutRubyRun.cpp
diff --git a/Source/core/layout/LayoutRubyRun.cpp b/Source/core/layout/LayoutRubyRun.cpp
index 7f8c29ebb40be920c55315f5d75e30c339831768..3b3db21e60e545374d7fa2a1cf2d5ee89b31b29a 100644
--- a/Source/core/layout/LayoutRubyRun.cpp
+++ b/Source/core/layout/LayoutRubyRun.cpp
@@ -302,4 +302,29 @@ 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.
+ // See crbug.com/522826.
+
+ if (!iterator.priorContextLength())
+ return true;
+ UChar ch = iterator.lastCharacter();
+ ULineBreak lineBreak = static_cast<ULineBreak>(u_getIntPropertyValue(ch, UCHAR_LINE_BREAK));
+ // 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
« no previous file with comments | « Source/core/layout/LayoutRubyRun.h ('k') | Source/core/layout/line/BreakingContextInlineHeaders.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698