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

Unified Diff: chrome/browser/ui/views/tabs/base_tab.cc

Issue 6579050: Elides the beginning of tab titles that have common prefixes. ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/browser/ui/views/tabs/base_tab_strip.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/browser/ui/views/tabs/base_tab_strip.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698