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

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: use CharIterator 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 | « base/i18n/char_iterator.cc ('k') | 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..067f19bb911af9eab6a1c0cbb3582523f958582d 100644
--- a/ui/gfx/render_text_win.cc
+++ b/ui/gfx/render_text_win.cc
@@ -7,11 +7,14 @@
#include <algorithm>
#include "base/i18n/break_iterator.h"
+#include "base/i18n/char_iterator.h"
#include "base/i18n/rtl.h"
#include "base/logging.h"
#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 +595,26 @@ 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;
Alexei Svitkine (slow) 2013/09/04 14:42:01 I noticed that this logic doesn't check for whethe
ckocagil 2013/09/04 21:35:46 Done, fixed.
+
+ // Break runs between any two characters that are not in the same code
+ // block. http://crbug.com/278913
+ base::i18n::UTF16CharIterator iter(&text());
+ iter.SetPosition(run->range.start());
Alexei Svitkine (slow) 2013/09/04 14:42:01 This should use GetLayoutText(), not text(). Also
ckocagil 2013/09/04 21:35:46 Done, throughout the function. There was another u
+ const UBlockCode first_block = ublock_getCode(iter.get());
+ while (iter.Advance() &&
+ static_cast<size_t>(iter.array_pos()) < run_break) {
+ if (ublock_getCode(iter.get()) != first_block) {
+ DCHECK_LE(static_cast<size_t>(iter.array_pos()), run_break);
+ DCHECK_GT(static_cast<size_t>(iter.array_pos()), run->range.start());
+ run_break = iter.array_pos();
+ break;
+ }
+ }
+
style.UpdatePosition(LayoutIndexToTextIndex(run_break));
if (script_item_break == run_break)
script_item++;
« no previous file with comments | « base/i18n/char_iterator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698