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

Unified Diff: ui/message_center/views/bounded_label.cc

Issue 24883002: Uses and returns the fractional width in text eliding (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix win bots 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: ui/message_center/views/bounded_label.cc
diff --git a/ui/message_center/views/bounded_label.cc b/ui/message_center/views/bounded_label.cc
index 9c6f4df5840afe0c412a3bf41f54469de012e14c..a99f38e1f86680ee815bd7d04409db9173de6803 100644
--- a/ui/message_center/views/bounded_label.cc
+++ b/ui/message_center/views/bounded_label.cc
@@ -106,14 +106,14 @@ gfx::Size InnerBoundedLabel::GetSizeForWidthAndLines(int width, int lines) {
gfx::Size size = GetCachedSize(key);
if (size.height() == std::numeric_limits<int>::max()) {
gfx::Insets insets = owner_->GetInsets();
- int text_width = (width < 0) ? std::numeric_limits<int>::max() :
- std::max(width - insets.width(), 0);
- int text_height = std::numeric_limits<int>::max();
+ float text_width = (width < 0) ? std::numeric_limits<int>::max() :
+ std::max(width - insets.width(), 0);
+ float text_height = std::numeric_limits<int>::max();
std::vector<string16> wrapped = GetWrappedText(text_width, lines);
- gfx::Canvas::SizeStringInt(JoinString(wrapped, '\n'), font(),
- &text_width, &text_height,
- owner_->GetLineHeight(),
- GetTextFlags());
+ gfx::Canvas::SizeStringToFit(JoinString(wrapped, '\n'), font(),
+ &text_width, &text_height,
+ owner_->GetLineHeight(),
+ GetTextFlags());
size.set_width(text_width + insets.width());
size.set_height(text_height + insets.height());
SetCachedSize(key, size);
@@ -139,7 +139,7 @@ std::vector<string16> InnerBoundedLabel::GetWrappedText(int width, int lines) {
// Try to ensure that the width is no smaller than the width of the text's
// characters to avoid the http://crbug.com/237700 infinite loop.
// TODO(dharcourt): Remove when http://crbug.com/237700 is fixed.
- width = std::max(width, 2 * font().GetStringWidth(UTF8ToUTF16("W")));
+ width = std::max<int>(width, 2 * font().GetStringWidth(UTF8ToUTF16("W")));
// Wrap, using INT_MAX for -1 widths that indicate no wrapping.
std::vector<string16> wrapped;

Powered by Google App Engine
This is Rietveld 408576698