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

Side by Side Diff: views/view_text_utils.cc

Issue 6334152: Clean up RTL methods.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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 | « views/view.cc ('k') | views/window/custom_frame_view.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/i18n/bidi_line_iterator.h" 7 #include "base/i18n/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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 word = iter.GetString(); // Get the next word. 115 word = iter.GetString(); // Get the next word.
116 else 116 else
117 word = text16; // Draw the whole text at once. 117 word = text16; // Draw the whole text at once.
118 118
119 int w = font.GetStringWidth(word), h = font.GetHeight(); 119 int w = font.GetStringWidth(word), h = font.GetHeight();
120 gfx::CanvasSkia::SizeStringInt(word, font, &w, &h, flags); 120 gfx::CanvasSkia::SizeStringInt(word, font, &w, &h, flags);
121 121
122 // If we exceed the boundaries, we need to wrap. 122 // If we exceed the boundaries, we need to wrap.
123 WrapIfWordDoesntFit(w, font.GetHeight(), position, bounds); 123 WrapIfWordDoesntFit(w, font.GetHeight(), position, bounds);
124 124
125 int x = label->MirroredXCoordinateInsideView(position->width()) + 125 int x = label->GetMirroredXInView(position->width()) + bounds.x();
126 bounds.x();
127 if (text_direction_is_rtl) { 126 if (text_direction_is_rtl) {
128 x -= w; 127 x -= w;
129 // When drawing LTR strings inside RTL text we need to make sure we 128 // When drawing LTR strings inside RTL text we need to make sure we
130 // draw the trailing space (if one exists after the LTR text) to the 129 // draw the trailing space (if one exists after the LTR text) to the
131 // left of the LTR string. 130 // left of the LTR string.
132 if (ltr_within_rtl && word[word.size() - 1] == ' ') { 131 if (ltr_within_rtl && word[word.size() - 1] == ' ') {
133 int space_w = font.GetStringWidth(ASCIIToUTF16(" ")); 132 int space_w = font.GetStringWidth(ASCIIToUTF16(" "));
134 int space_h = font.GetHeight(); 133 int space_h = font.GetHeight();
135 gfx::CanvasSkia::SizeStringInt(ASCIIToUTF16(" "), font, &space_w, 134 gfx::CanvasSkia::SizeStringInt(ASCIIToUTF16(" "), font, &space_w,
136 &space_h, flags); 135 &space_h, flags);
(...skipping 24 matching lines...) Expand all
161 int font_height, 160 int font_height,
162 gfx::Size* position, 161 gfx::Size* position,
163 const gfx::Rect& bounds) { 162 const gfx::Rect& bounds) {
164 if (position->width() + word_width > bounds.right()) { 163 if (position->width() + word_width > bounds.right()) {
165 position->set_width(0); 164 position->set_width(0);
166 position->Enlarge(0, font_height); 165 position->Enlarge(0, font_height);
167 } 166 }
168 } 167 }
169 168
170 } // namespace view_text_utils 169 } // namespace view_text_utils
OLDNEW
« no previous file with comments | « views/view.cc ('k') | views/window/custom_frame_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698