Chromium Code Reviews| Index: chrome/browser/ui/extensions/icon_with_badge_image_source.cc |
| diff --git a/chrome/browser/ui/extensions/icon_with_badge_image_source.cc b/chrome/browser/ui/extensions/icon_with_badge_image_source.cc |
| index a1ed4b846515cf55a16466d1dd0c86d736a37a66..37e7d396a34b182c2059cc7785aad6f566bed566 100644 |
| --- a/chrome/browser/ui/extensions/icon_with_badge_image_source.cc |
| +++ b/chrome/browser/ui/extensions/icon_with_badge_image_source.cc |
| @@ -180,6 +180,20 @@ void IconWithBadgeImageSource::PaintBadge(gfx::Canvas* canvas) { |
| gfx::FontList base_font = rb->GetFontList(ResourceBundle::BaseFont) |
| .DeriveWithHeightUpperBound(kBadgeHeight); |
| base::string16 utf16_text = base::UTF8ToUTF16(badge_->text); |
| + |
| + // See if we can squeeze a slightly larger font into the badge given the |
| + // actual string that is to be displayed. |
| + const int kMaxIncrementAttempts = 5; |
| + for (size_t i = 0; i < kMaxIncrementAttempts; ++i) { |
| + int w, h; |
|
Devlin
2016/05/26 20:50:25
nit: I think style requires these to be initialize
Evan Stade
2016/05/26 21:49:38
Done.
|
| + gfx::FontList bigger_font = base_font.Derive(1, 0); |
| + gfx::Canvas::SizeStringInt(utf16_text, bigger_font, &w, &h, 0, |
| + gfx::Canvas::NO_ELLIPSIS); |
| + if (h > kBadgeHeight) |
| + break; |
| + base_font = bigger_font; |
| + } |
| + |
| if (ui::MaterialDesignController::IsModeMaterial()) { |
| text_width = |
| std::min(kMaxTextWidth, canvas->GetStringWidth(utf16_text, base_font)); |