| Index: ui/views/controls/label.cc
|
| diff --git a/ui/views/controls/label.cc b/ui/views/controls/label.cc
|
| index 7d4bc7e84703c03dfcbb50ed1f231e991e3b7590..550d2b95dd3af11dd82429900b97e00b786a3adb 100644
|
| --- a/ui/views/controls/label.cc
|
| +++ b/ui/views/controls/label.cc
|
| @@ -186,7 +186,7 @@ void Label::SizeToFit(int max_width) {
|
| std::vector<string16> lines;
|
| base::SplitString(text_, '\n', &lines);
|
|
|
| - int label_width = 0;
|
| + float label_width = 0;
|
| for (std::vector<string16>::const_iterator iter = lines.begin();
|
| iter != lines.end(); ++iter) {
|
| label_width = std::max(label_width, gfx::GetStringWidth(*iter, font_list_));
|
| @@ -195,9 +195,9 @@ void Label::SizeToFit(int max_width) {
|
| label_width += GetInsets().width();
|
|
|
| if (max_width > 0)
|
| - label_width = std::min(label_width, max_width);
|
| + label_width = std::min<float>(label_width, max_width);
|
|
|
| - SetBounds(x(), y(), label_width, 0);
|
| + SetBounds(x(), y(), std::ceil(label_width), 0);
|
| SizeToPreferredSize();
|
| }
|
|
|
| @@ -249,12 +249,11 @@ int Label::GetHeightForWidth(int w) {
|
| return s.height() + GetInsets().height();
|
| }
|
|
|
| - int cache_width = w;
|
| -
|
| - int h = font_list_.GetHeight();
|
| + float fw = w;
|
| + float h = font_list_.GetHeight();
|
| const int flags = ComputeDrawStringFlags();
|
| - gfx::Canvas::SizeStringInt(text_, font_list_, &w, &h, line_height_, flags);
|
| - cached_heights_[cached_heights_cursor_] = gfx::Size(cache_width, h);
|
| + gfx::Canvas::SizeStringToFit(text_, font_list_, &fw, &h, line_height_, flags);
|
| + cached_heights_[cached_heights_cursor_] = gfx::Size(w, h);
|
| cached_heights_cursor_ = (cached_heights_cursor_ + 1) % kCachedSizeLimit;
|
| return h + GetInsets().height();
|
| }
|
| @@ -329,17 +328,18 @@ gfx::Size Label::GetTextSize() const {
|
| if (!text_size_valid_) {
|
| // For single-line strings, we supply the largest possible width, because
|
| // while adding NO_ELLIPSIS to the flags works on Windows for forcing
|
| - // SizeStringInt() to calculate the desired width, it doesn't seem to work
|
| + // SizeStringToFit() to calculate the desired width, it doesn't seem to work
|
| // on Linux.
|
| - int w = is_multi_line_ ?
|
| + float w = is_multi_line_ ?
|
| GetAvailableRect().width() : std::numeric_limits<int>::max();
|
| - int h = font_list_.GetHeight();
|
| + float h = font_list_.GetHeight();
|
| // For single-line strings, ignore the available width and calculate how
|
| // wide the text wants to be.
|
| int flags = ComputeDrawStringFlags();
|
| if (!is_multi_line_)
|
| flags |= gfx::Canvas::NO_ELLIPSIS;
|
| - gfx::Canvas::SizeStringInt(text_, font_list_, &w, &h, line_height_, flags);
|
| + gfx::Canvas::SizeStringToFit(
|
| + text_, font_list_, &w, &h, line_height_, flags);
|
| text_size_.SetSize(w, h);
|
| text_size_valid_ = true;
|
| }
|
|
|