diff options
Diffstat (limited to 'chrome/browser/ui/views/tabs/base_tab.cc')
| -rw-r--r-- | chrome/browser/ui/views/tabs/base_tab.cc | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/chrome/browser/ui/views/tabs/base_tab.cc b/chrome/browser/ui/views/tabs/base_tab.cc index 81a7262..f954081 100644 --- a/chrome/browser/ui/views/tabs/base_tab.cc +++ b/chrome/browser/ui/views/tabs/base_tab.cc @@ -471,6 +471,7 @@ void BaseTab::PaintTitle(gfx::Canvas* canvas, SkColor title_color) { // Paint the Title. const gfx::Rect& title_bounds = GetTitleBounds(); string16 title = data().title; + bool should_truncate = false; if (title.empty()) { title = data().loading ? l10n_util::GetStringUTF16(IDS_TAB_LOADING_TITLE) : @@ -480,15 +481,23 @@ void BaseTab::PaintTitle(gfx::Canvas* canvas, SkColor title_color) { // 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() && - font_->GetStringWidth(title) > title_bounds.width()) { - title.replace(0, data().common_prefix_length, UTF8ToUTF16(ui::kEllipsis)); - } + should_truncate = data().common_prefix_length > 0 && + font_->GetExpectedTextWidth(10) < title_bounds.width() && + font_->GetStringWidth(title) > title_bounds.width(); } + +#if defined(OS_WIN) + canvas->AsCanvasSkia()->DrawFadeTruncatingString(title, + should_truncate ? gfx::CanvasSkia::TruncateFadeHeadAndTail : + gfx::CanvasSkia::TruncateFadeTail, + data().common_prefix_length, *font_, title_color, title_bounds); +#else + if (should_truncate) + title.replace(0, data().common_prefix_length, UTF8ToUTF16(ui::kEllipsis)); canvas->DrawStringInt(title, *font_, title_color, title_bounds.x(), title_bounds.y(), title_bounds.width(), title_bounds.height()); +#endif } void BaseTab::AnimationProgressed(const ui::Animation* animation) { |
