Index: ui/gfx/render_text_win.cc |
diff --git a/ui/gfx/render_text_win.cc b/ui/gfx/render_text_win.cc |
index ac018de3f446226f8e39276ee65f24ebf1e76478..0b5694e94031af49e21a61fce26050a70a402d41 100644 |
--- a/ui/gfx/render_text_win.cc |
+++ b/ui/gfx/render_text_win.cc |
@@ -12,6 +12,8 @@ |
#include "base/strings/string_util.h" |
#include "base/strings/utf_string_conversions.h" |
#include "base/win/windows_version.h" |
+#include "third_party/icu/source/common/unicode/uchar.h" |
+#include "third_party/icu/source/common/unicode/utf16.h" |
#include "ui/base/text/utf16_indexing.h" |
#include "ui/gfx/canvas.h" |
#include "ui/gfx/font_fallback_win.h" |
@@ -592,9 +594,28 @@ void RenderTextWin::ItemizeLogicalText() { |
const size_t script_item_break = (script_item + 1)->iCharPos; |
run_break = std::min(script_item_break, |
TextIndexToLayoutIndex(style.GetRange().end())); |
+ |
// Clamp run lengths to avoid exceeding the maximum supported glyph count. |
if ((run_break - run->range.start()) > max_run_length) |
run_break = run->range.start() + max_run_length; |
+ |
+ // Break runs between any two characters that are not in the same code |
msw
2013/09/03 16:15:31
Can you explain why you chose to break runs betwee
ckocagil
2013/09/04 13:02:50
I simply didn't know Unicode had classification by
|
+ // block. http://crbug.com/278913 |
msw
2013/09/03 16:15:31
nit: consider using a comment like:
// Break runs
ckocagil
2013/09/04 13:02:50
Done.
|
+ size_t i = run->range.start(); |
+ UChar32 current_char = 0; |
+ U16_NEXT(text().c_str(), i, text().length(), current_char); |
msw
2013/09/03 16:15:31
Use base::i18n::UTF16CharIterator instead.
ckocagil
2013/09/04 13:02:50
Done.
|
+ const UBlockCode first_block = ublock_getCode(current_char); |
+ while (i < run_break) { |
+ const size_t current_index = i; |
+ U16_NEXT(text().c_str(), i, text().length(), current_char); |
+ if (ublock_getCode(current_char) != first_block) { |
+ DCHECK_LE(current_index, run_break); |
+ run_break = current_index; |
+ break; |
+ } |
+ } |
+ DCHECK_LT(run->range.start(), run_break); |
+ |
style.UpdatePosition(LayoutIndexToTextIndex(run_break)); |
if (script_item_break == run_break) |
script_item++; |