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

Unified Diff: ui/views/view_text_utils.cc

Issue 9232055: Clean up some code in view_text_utils.cc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/view_text_utils.cc
===================================================================
--- ui/views/view_text_utils.cc (revision 119451)
+++ ui/views/view_text_utils.cc (working copy)
@@ -91,15 +91,15 @@
bool ltr_within_rtl) {
// Iterate through line breaking opportunities (which in English would be
// spaces and such). This tells us where to wrap.
- string16 text16(text);
- base::i18n::BreakIterator iter(text16,
+ base::i18n::BreakIterator iter(text,
base::i18n::BreakIterator::BREAK_SPACE);
if (!iter.Init())
return;
int flags = (text_direction_is_rtl ? gfx::Canvas::TEXT_ALIGN_RIGHT :
gfx::Canvas::TEXT_ALIGN_LEFT);
- flags |= gfx::Canvas::MULTI_LINE | gfx::Canvas::HIDE_PREFIX;
+ flags |= gfx::Canvas::MULTI_LINE | gfx::Canvas::HIDE_PREFIX |
+ gfx::Canvas::NO_ELLIPSIS;
// Iterate over each word in the text, or put in a more locale-neutral way:
// iterate to the next line breaking opportunity.
@@ -109,9 +109,9 @@
if (!ltr_within_rtl)
word = iter.GetString(); // Get the next word.
else
- word = text16; // Draw the whole text at once.
+ word = text; // Draw the whole text at once.
- int w = font.GetStringWidth(word), h = font.GetHeight();
+ int w = 0, h = 0;
gfx::CanvasSkia::SizeStringInt(word, font, &w, &h, flags);
// If we exceed the boundaries, we need to wrap.
@@ -123,13 +123,8 @@
// When drawing LTR strings inside RTL text we need to make sure we
// draw the trailing space (if one exists after the LTR text) to the
// left of the LTR string.
- if (ltr_within_rtl && word[word.size() - 1] == ' ') {
- int space_w = font.GetStringWidth(ASCIIToUTF16(" "));
- int space_h = font.GetHeight();
- gfx::CanvasSkia::SizeStringInt(ASCIIToUTF16(" "), font, &space_w,
- &space_h, flags);
- x += space_w;
- }
+ if (ltr_within_rtl && word[word.size() - 1] == ' ')
+ x += gfx::CanvasSkia::GetStringWidth(ASCIIToUTF16(" "), font);
}
int y = position->height() + bounds.y();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698