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

Unified Diff: ash/system/user/tray_user.cc

Issue 24883002: Uses and returns the fractional width in text eliding (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/gfx/canvas.h » ('j') | ui/gfx/canvas.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/user/tray_user.cc
diff --git a/ash/system/user/tray_user.cc b/ash/system/user/tray_user.cc
index e83272758273f147848c66cb83b11b77f66a634c..5c97c80119bc36a3219c4f48fc678a611cf687f2 100644
--- a/ash/system/user/tray_user.cc
+++ b/ash/system/user/tray_user.cc
@@ -455,8 +455,11 @@ void PublicAccountUserDetails::Layout() {
// Word-wrap the label text.
const gfx::Font font;
std::vector<base::string16> lines;
- gfx::ElideRectangleText(text_, font, contents_area.width(),
- contents_area.height(), gfx::ELIDE_LONG_WORDS,
+ gfx::ElideRectangleText(text_,
+ font,
+ static_cast<float>(contents_area.width()),
msw 2013/09/27 21:54:48 Won't int->float implicit type conversion work her
jianli 2013/10/01 00:32:58 Reverted. Changed INT_MAX to FLT_MAX in the follow
+ static_cast<float>(contents_area.height()),
+ gfx::ELIDE_LONG_WORDS,
&lines);
// Loop through the lines, creating a renderer for each.
gfx::Point position = contents_area.origin();
@@ -555,7 +558,8 @@ void PublicAccountUserDetails::CalculatePreferredSize(SystemTrayItem* owner,
lines.clear();
const int width = (min_width + max_width) / 2;
const bool too_narrow = gfx::ElideRectangleText(
- text_, font, width, INT_MAX, gfx::TRUNCATE_LONG_WORDS, &lines) != 0;
+ text_, font, static_cast<float>(width), static_cast<float>(INT_MAX),
+ gfx::TRUNCATE_LONG_WORDS, &lines) != 0;
int line_count = lines.size();
if (!too_narrow && line_count == 3 &&
width - font.GetStringWidth(lines.back()) <=
@@ -571,7 +575,8 @@ void PublicAccountUserDetails::CalculatePreferredSize(SystemTrayItem* owner,
// Calculate the corresponding height and set the preferred size.
lines.clear();
gfx::ElideRectangleText(
- text_, font, min_width, INT_MAX, gfx::TRUNCATE_LONG_WORDS, &lines);
+ text_, font, static_cast<float>(min_width), static_cast<float>(INT_MAX),
+ gfx::TRUNCATE_LONG_WORDS, &lines);
int line_count = lines.size();
if (min_width - font.GetStringWidth(lines.back()) <=
space_width + link_size.width()) {
« no previous file with comments | « no previous file | ui/gfx/canvas.h » ('j') | ui/gfx/canvas.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698