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

Side by Side Diff: views/view_text_utils.cc

Issue 6315002: Some wstring -> string16 conversion in src/app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/app
Patch Set: rebase Created 9 years, 11 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 | « chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "views/view_text_utils.h" 5 #include "views/view_text_utils.h"
6 6
7 #include "app/bidi_line_iterator.h" 7 #include "app/bidi_line_iterator.h"
8 #include "base/i18n/break_iterator.h" 8 #include "base/i18n/break_iterator.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 14 matching lines...) Expand all
25 bool text_direction_is_rtl, 25 bool text_direction_is_rtl,
26 const gfx::Rect& bounds, 26 const gfx::Rect& bounds,
27 const gfx::Font& font) { 27 const gfx::Font& font) {
28 DCHECK(canvas && position); 28 DCHECK(canvas && position);
29 29
30 // The |text| parameter is potentially a mix of LTR and RTL "runs," where 30 // The |text| parameter is potentially a mix of LTR and RTL "runs," where
31 // a run is a sequence of words that share the same directionality. We 31 // a run is a sequence of words that share the same directionality. We
32 // initialize a bidirectional ICU line iterator and split the text into 32 // initialize a bidirectional ICU line iterator and split the text into
33 // runs that are either strictly LTR or strictly RTL, with no mix. 33 // runs that are either strictly LTR or strictly RTL, with no mix.
34 BiDiLineIterator bidi_line; 34 BiDiLineIterator bidi_line;
35 if (!bidi_line.Open(text.c_str(), true, false)) 35 if (!bidi_line.Open(WideToUTF16Hack(text), true, false))
36 return; 36 return;
37 37
38 // Iterate over each run and draw it. 38 // Iterate over each run and draw it.
39 int run_start = 0; 39 int run_start = 0;
40 int run_end = 0; 40 int run_end = 0;
41 const int runs = bidi_line.CountRuns(); 41 const int runs = bidi_line.CountRuns();
42 for (int run = 0; run < runs; ++run) { 42 for (int run = 0; run < runs; ++run) {
43 UBiDiLevel level = 0; 43 UBiDiLevel level = 0;
44 bidi_line.GetLogicalRun(run_start, &run_end, &level); 44 bidi_line.GetLogicalRun(run_start, &run_end, &level);
45 DCHECK(run_end > run_start); 45 DCHECK(run_end > run_start);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 int font_height, 161 int font_height,
162 gfx::Size* position, 162 gfx::Size* position,
163 const gfx::Rect& bounds) { 163 const gfx::Rect& bounds) {
164 if (position->width() + word_width > bounds.right()) { 164 if (position->width() + word_width > bounds.right()) {
165 position->set_width(0); 165 position->set_width(0);
166 position->Enlarge(0, font_height); 166 position->Enlarge(0, font_height);
167 } 167 }
168 } 168 }
169 169
170 } // namespace view_text_utils 170 } // namespace view_text_utils
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698