| 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..5a746e254a4b8a341e663ae7dd45775eebd46051 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);
|
| @@ -136,15 +136,18 @@ std::vector<string16> InnerBoundedLabel::GetWrappedText(int width, int lines) {
|
| height = (lines + 1) * line_height;
|
| }
|
|
|
| + // If |width| is -1, it means no wrapping.
|
| + float wrap_width = (width < 0) ? FLT_MAX : width;
|
| +
|
| // 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")));
|
| + wrap_width =
|
| + std::max(wrap_width, 2 * font().GetStringWidth(UTF8ToUTF16("W")));
|
|
|
| - // Wrap, using INT_MAX for -1 widths that indicate no wrapping.
|
| + // Wrap the text.
|
| std::vector<string16> wrapped;
|
| - gfx::ElideRectangleText(text(), font_list(),
|
| - (width < 0) ? std::numeric_limits<int>::max() : width,
|
| + gfx::ElideRectangleText(text(), font_list(), wrap_width,
|
| height, gfx::WRAP_LONG_WORDS, &wrapped);
|
|
|
| // Elide if necessary.
|
|
|