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

Unified Diff: ui/gfx/render_text_win.cc

Issue 23522018: RenderTextWin: Break runs between any two characters that are not in the same code block (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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++;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698