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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 // We overhang a ruby only if the neighboring layout object is a text. 295 // We overhang a ruby only if the neighboring layout object is a text.
296 // We can overhang the ruby by no more than half the width of the neighborin g text 296 // We can overhang the ruby by no more than half the width of the neighborin g text
297 // and no more than half the font size. 297 // and no more than half the font size.
298 int halfWidthOfFontSize = rubyText->style(firstLine)->fontSize() / 2; 298 int halfWidthOfFontSize = rubyText->style(firstLine)->fontSize() / 2;
299 if (startOverhang) 299 if (startOverhang)
300 startOverhang = std::min<int>(startOverhang, std::min<int>(toLayoutText( startLayoutObject)->minLogicalWidth(), halfWidthOfFontSize)); 300 startOverhang = std::min<int>(startOverhang, std::min<int>(toLayoutText( startLayoutObject)->minLogicalWidth(), halfWidthOfFontSize));
301 if (endOverhang) 301 if (endOverhang)
302 endOverhang = std::min<int>(endOverhang, std::min<int>(toLayoutText(endL ayoutObject)->minLogicalWidth(), halfWidthOfFontSize)); 302 endOverhang = std::min<int>(endOverhang, std::min<int>(toLayoutText(endL ayoutObject)->minLogicalWidth(), halfWidthOfFontSize));
303 } 303 }
304 304
305 bool LayoutRubyRun::canBreakBefore(const LazyLineBreakIterator& iterator) const
306 {
307 // TODO(kojii): It would be nice to improve this so that it isn't just
308 // hard-coded, but lookahead in this case is particularly problematic.
309 // See crbug.com/522826.
310
311 if (!iterator.priorContextLength())
312 return true;
313 UChar ch = iterator.lastCharacter();
314 ULineBreak lineBreak = static_cast<ULineBreak>(u_getIntPropertyValue(ch, UCH AR_LINE_BREAK));
315 // UNICODE LINE BREAKING ALGORITHM
316 // http://www.unicode.org/reports/tr14/
317 // And Requirements for Japanese Text Layout, 3.1.7 Characters Not Starting a Line
318 // http://www.w3.org/TR/2012/NOTE-jlreq-20120403/#characters_not_starting_a_ line
319 switch (lineBreak) {
320 case U_LB_WORD_JOINER:
321 case U_LB_GLUE:
322 case U_LB_OPEN_PUNCTUATION:
323 return false;
324 default:
325 break;
326 }
327 return true;
328 }
329
305 } // namespace blink 330 } // namespace blink
OLDNEW
« 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