Index: ui/views/controls/label.cc |
diff --git a/ui/views/controls/label.cc b/ui/views/controls/label.cc |
index 7d4bc7e84703c03dfcbb50ed1f231e991e3b7590..f6e86499910b4027af62f808f85aeb00fb56702a 100644 |
--- a/ui/views/controls/label.cc |
+++ b/ui/views/controls/label.cc |
@@ -189,7 +189,8 @@ void Label::SizeToFit(int max_width) { |
int 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_)); |
+ label_width = std::max<int>( |
+ label_width, gfx::GetStringWidth(*iter, font_list_)); |
} |
label_width += GetInsets().width(); |
@@ -249,12 +250,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 +329,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; |
} |