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

Unified Diff: ui/gfx/render_text_win.cc

Issue 324983002: Move unusual character block logic to a helper function (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: eol Created 6 years, 6 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
« ui/gfx/render_text_harfbuzz.cc ('K') | « ui/gfx/render_text_harfbuzz.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 0b2cd4c7c955b52c8926d5a74a3c1d28b8e68d8c..5700c755102b683924400a9f7469fafeb1d16091 100644
--- a/ui/gfx/render_text_win.cc
+++ b/ui/gfx/render_text_win.cc
@@ -264,6 +264,27 @@ bool IsUnusualBlockCode(const UBlockCode block_code) {
block_code == UBLOCK_MISCELLANEOUS_SYMBOLS;
}
+// Returns the index of the first unusual character after a usual character or
+// vice versa. Unusual characters are defined by |IsUnusualBlockCode|.
+size_t FindUnusualCharacter(const base::string16& text,
+ size_t run_start,
+ size_t run_break) {
+ const int32 run_length = static_cast<int32>(run_break - run_start);
+ base::i18n::UTF16CharIterator iter(text.c_str() + run_start,
+ run_length);
+ const UBlockCode first_block_code = ublock_getCode(iter.get());
+ const bool first_block_unusual = IsUnusualBlockCode(first_block_code);
+ while (iter.Advance() && iter.array_pos() < run_length) {
+ const UBlockCode current_block_code = ublock_getCode(iter.get());
+ if (current_block_code != first_block_code &&
+ (first_block_unusual || IsUnusualBlockCode(current_block_code))) {
+ run_break = run_start + iter.array_pos();
msw 2014/06/10 18:03:15 ditto
ckocagil 2014/06/11 07:49:37 Done.
+ break;
+ }
+ }
+ return run_break;
+}
+
} // namespace
namespace internal {
@@ -955,20 +976,8 @@ void RenderTextWin::ItemizeLogicalText() {
// This avoids using their fallback fonts for more characters than needed,
// in cases like "\x25B6 Media Title", etc. http://crbug.com/278913
if (run_break > run->range.start()) {
- const size_t run_start = run->range.start();
- const int32 run_length = static_cast<int32>(run_break - run_start);
- base::i18n::UTF16CharIterator iter(layout_text.c_str() + run_start,
- run_length);
- const UBlockCode first_block_code = ublock_getCode(iter.get());
- const bool first_block_unusual = IsUnusualBlockCode(first_block_code);
- while (iter.Advance() && iter.array_pos() < run_length) {
- const UBlockCode current_block_code = ublock_getCode(iter.get());
- if (current_block_code != first_block_code &&
- (first_block_unusual || IsUnusualBlockCode(current_block_code))) {
- run_break = run_start + iter.array_pos();
- break;
- }
- }
+ run_break =
+ FindUnusualCharacter(layout_text, run->range.start(), run_break);
}
DCHECK(IsValidCodePointIndex(layout_text, run_break));
« ui/gfx/render_text_harfbuzz.cc ('K') | « ui/gfx/render_text_harfbuzz.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698