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

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: More fixes per feedback 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
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..e8106c37efa7dcac8f5e552f4ff2ef290e6188c7 100644
--- a/ash/system/user/tray_user.cc
+++ b/ash/system/user/tray_user.cc
@@ -542,7 +542,7 @@ void PublicAccountUserDetails::CalculatePreferredSize(SystemTrayItem* owner,
int min_width = std::max(
link_size.width(),
bubble_view->GetPreferredSize().width() - (used_width + insets.width()));
- int max_width = std::min(
+ int max_width = std::min<int>(
font.GetStringWidth(text_) + space_width + link_size.width(),
sky 2013/10/01 23:53:03 Won't this round down? It seems all to easy to acc
jianli 2013/10/02 00:49:20 Does ash use the fractional width? If not, we shou
bubble_view->GetMaximumSize().width() - (used_width + insets.width()));
// Do a binary search for the minimum width that ensures no more than three
@@ -555,7 +555,7 @@ 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, width, FLT_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 +571,7 @@ 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, min_width, FLT_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 | chrome/browser/ui/autofill/autofill_popup_controller.h » ('j') | ui/gfx/canvas_unittest_mac.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698