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

Unified Diff: chrome/browser/ui/views/status_bubble_views.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 round-down problems Created 7 years, 2 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: chrome/browser/ui/views/status_bubble_views.cc
diff --git a/chrome/browser/ui/views/status_bubble_views.cc b/chrome/browser/ui/views/status_bubble_views.cc
index 6e89dec5e895c237790f1d0be06bdfaaff177263..bb07dca4fa400f6f442868769f0018071eeb3c85 100644
--- a/chrome/browser/ui/views/status_bubble_views.cc
+++ b/chrome/browser/ui/views/status_bubble_views.cc
@@ -434,13 +434,13 @@ void StatusBubbleViews::StatusView::OnPaint(gfx::Canvas* canvas) {
// Draw highlight text and then the text body. In order to make sure the text
// is aligned to the right on RTL UIs, we mirror the text bounds if the
// locale is RTL.
- int text_width = std::min(
+ float text_width = std::min<float>(
views::Label::font().GetStringWidth(text_),
width - (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding);
int text_height = height - (kShadowThickness * 2);
gfx::Rect body_bounds(kShadowThickness + kTextPositionX,
kShadowThickness,
- std::max(0, text_width),
+ std::max(0.0f, text_width),
std::max(0, text_height));
body_bounds.set_x(GetMirroredXForRect(body_bounds));
SkColor text_color =
@@ -823,11 +823,11 @@ void StatusBubbleViews::ExpandBubble() {
int max_status_bubble_width = GetMaxStatusBubbleWidth();
url_text_ = gfx::ElideUrl(url_, view_->Label::font(),
max_status_bubble_width, languages_);
- int expanded_bubble_width =std::max(GetStandardStatusBubbleWidth(),
- std::min(view_->Label::font().GetStringWidth(url_text_) +
- (kShadowThickness * 2) + kTextPositionX +
- kTextHorizPadding + 1,
- max_status_bubble_width));
+ float expanded_bubble_width = std::max<float>(GetStandardStatusBubbleWidth(),
+ std::min<float>(view_->Label::font().GetStringWidth(url_text_) +
+ (kShadowThickness * 2) + kTextPositionX +
+ kTextHorizPadding + 1,
+ max_status_bubble_width));
is_expanded_ = true;
expand_view_->StartExpansion(url_text_, popup_bounds.width(),
expanded_bubble_width);

Powered by Google App Engine
This is Rietveld 408576698