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

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

Issue 6783015: Improvements to tab title prefix eliding as per email discussions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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/tabs/base_tab.cc
===================================================================
--- chrome/browser/ui/views/tabs/base_tab.cc (revision 79877)
+++ chrome/browser/ui/views/tabs/base_tab.cc (working copy)
@@ -479,11 +479,15 @@
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() &&
+ // We arbitrarily choose to request enough room for 6 average chars.
+ // Also, we want to show the last 4 common chars, so we only do it if
+ // the common prefix is at least 7 characters long, otherwise, we would be
+ // replacing 3 or less characters with a 3 dot ellipsis... not worth it.
+ if (data().common_prefix_length > 7 &&
+ font_->GetExpectedTextWidth(6) < title_bounds.width() &&
font_->GetStringWidth(title) > title_bounds.width()) {
- title.replace(0, data().common_prefix_length, UTF8ToUTF16(ui::kEllipsis));
+ title.replace(0, data().common_prefix_length - 4,
+ UTF8ToUTF16(ui::kEllipsis));
}
}
canvas->DrawStringInt(title, *font_, title_color,

Powered by Google App Engine
This is Rietveld 408576698