Chromium Code Reviews| Index: chrome/browser/ui/views/tabs/base_tab.cc |
| =================================================================== |
| --- chrome/browser/ui/views/tabs/base_tab.cc (revision 76049) |
| +++ chrome/browser/ui/views/tabs/base_tab.cc (working copy) |
| @@ -434,6 +434,7 @@ |
| void BaseTab::PaintTitle(gfx::Canvas* canvas, SkColor title_color) { |
| // Paint the Title. |
| + const gfx::Rect& title_bounds = GetTitleBounds(); |
| string16 title = data().title; |
| if (title.empty()) { |
| title = data().loading ? |
| @@ -441,8 +442,15 @@ |
| TabContentsWrapper::GetDefaultTitle(); |
| } else { |
| Browser::FormatTitleForDisplay(&title); |
| + // If we'll need to truncate, check if we should also truncate |
| + // a common prefix, but only if there is enough room for it. |
| + // We arbitrarily choose to request enough room for 10 average chars. |
| + if (data().common_prefix_length > 0 && |
| + font_->GetExpectedTextWidth(10) < title_bounds.width() && |
|
sky
2011/02/25 21:04:44
I thought this became more important once the stri
MAD
2011/02/25 21:49:24
Because we may end up with something like ...x...
sky
2011/02/25 22:59:27
Good point.
Different suggestion then. For folks w
MAD
2011/03/10 19:03:44
That would be hard, since the title_bounds and fon
sky
2011/03/11 00:00:45
Do you even need that? For horizontal tabs (TabStr
MAD
2011/03/11 03:01:37
Hum... I'm not sure what would be a good "some val
|
| + font_->GetStringWidth(title) > title_bounds.width()) { |
| + title.replace(0, data().common_prefix_length, ASCIIToUTF16("...")); |
|
sky
2011/02/25 21:04:44
I think you should use the same string as in text_
MAD
2011/02/25 21:49:24
Ho, thanks, I didn't know about that...
Done...
|
| + } |
| } |
| - const gfx::Rect& title_bounds = GetTitleBounds(); |
| canvas->DrawStringInt(title, *font_, title_color, |
| title_bounds.x(), title_bounds.y(), |
| title_bounds.width(), title_bounds.height()); |