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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/i18n/char_iterator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/render_text_win.h" 5 #include "ui/gfx/render_text_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/break_iterator.h" 9 #include "base/i18n/break_iterator.h"
10 #include "base/i18n/char_iterator.h"
10 #include "base/i18n/rtl.h" 11 #include "base/i18n/rtl.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
14 #include "base/win/windows_version.h" 15 #include "base/win/windows_version.h"
16 #include "third_party/icu/source/common/unicode/uchar.h"
17 #include "third_party/icu/source/common/unicode/utf16.h"
15 #include "ui/base/text/utf16_indexing.h" 18 #include "ui/base/text/utf16_indexing.h"
16 #include "ui/gfx/canvas.h" 19 #include "ui/gfx/canvas.h"
17 #include "ui/gfx/font_fallback_win.h" 20 #include "ui/gfx/font_fallback_win.h"
18 #include "ui/gfx/font_smoothing_win.h" 21 #include "ui/gfx/font_smoothing_win.h"
19 #include "ui/gfx/platform_font_win.h" 22 #include "ui/gfx/platform_font_win.h"
20 23
21 namespace gfx { 24 namespace gfx {
22 25
23 namespace { 26 namespace {
24 27
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 run->font_style, &run->font); 588 run->font_style, &run->font);
586 run->strike = style.style(STRIKE); 589 run->strike = style.style(STRIKE);
587 run->diagonal_strike = style.style(DIAGONAL_STRIKE); 590 run->diagonal_strike = style.style(DIAGONAL_STRIKE);
588 run->underline = style.style(UNDERLINE); 591 run->underline = style.style(UNDERLINE);
589 run->script_analysis = script_item->a; 592 run->script_analysis = script_item->a;
590 593
591 // Find the next break and advance the iterators as needed. 594 // Find the next break and advance the iterators as needed.
592 const size_t script_item_break = (script_item + 1)->iCharPos; 595 const size_t script_item_break = (script_item + 1)->iCharPos;
593 run_break = std::min(script_item_break, 596 run_break = std::min(script_item_break,
594 TextIndexToLayoutIndex(style.GetRange().end())); 597 TextIndexToLayoutIndex(style.GetRange().end()));
598
595 // Clamp run lengths to avoid exceeding the maximum supported glyph count. 599 // Clamp run lengths to avoid exceeding the maximum supported glyph count.
596 if ((run_break - run->range.start()) > max_run_length) 600 if ((run_break - run->range.start()) > max_run_length)
597 run_break = run->range.start() + max_run_length; 601 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.
602
603 // Break runs between any two characters that are not in the same code
604 // block. http://crbug.com/278913
605 base::i18n::UTF16CharIterator iter(&text());
606 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
607 const UBlockCode first_block = ublock_getCode(iter.get());
608 while (iter.Advance() &&
609 static_cast<size_t>(iter.array_pos()) < run_break) {
610 if (ublock_getCode(iter.get()) != first_block) {
611 DCHECK_LE(static_cast<size_t>(iter.array_pos()), run_break);
612 DCHECK_GT(static_cast<size_t>(iter.array_pos()), run->range.start());
613 run_break = iter.array_pos();
614 break;
615 }
616 }
617
598 style.UpdatePosition(LayoutIndexToTextIndex(run_break)); 618 style.UpdatePosition(LayoutIndexToTextIndex(run_break));
599 if (script_item_break == run_break) 619 if (script_item_break == run_break)
600 script_item++; 620 script_item++;
601 run->range.set_end(run_break); 621 run->range.set_end(run_break);
602 runs_.push_back(run); 622 runs_.push_back(run);
603 } 623 }
604 624
605 // Undo the temporarily applied composition underlines and selection colors. 625 // Undo the temporarily applied composition underlines and selection colors.
606 UndoCompositionAndSelectionStyles(); 626 UndoCompositionAndSelectionStyles();
607 } 627 }
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 size_t position = LayoutIndexToTextIndex(run->range.end()); 917 size_t position = LayoutIndexToTextIndex(run->range.end());
898 position = IndexOfAdjacentGrapheme(position, CURSOR_BACKWARD); 918 position = IndexOfAdjacentGrapheme(position, CURSOR_BACKWARD);
899 return SelectionModel(position, CURSOR_FORWARD); 919 return SelectionModel(position, CURSOR_FORWARD);
900 } 920 }
901 921
902 RenderText* RenderText::CreateInstance() { 922 RenderText* RenderText::CreateInstance() {
903 return new RenderTextWin; 923 return new RenderTextWin;
904 } 924 }
905 925
906 } // namespace gfx 926 } // namespace gfx
OLDNEW
« 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