Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/tabs/base_tab.h" | 5 #include "chrome/browser/ui/views/tabs/base_tab.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 427 data().favicon.height(), | 427 data().favicon.height(), |
| 428 bounds, true); | 428 bounds, true); |
| 429 } | 429 } |
| 430 } | 430 } |
| 431 canvas->Restore(); | 431 canvas->Restore(); |
| 432 } | 432 } |
| 433 } | 433 } |
| 434 | 434 |
| 435 void BaseTab::PaintTitle(gfx::Canvas* canvas, SkColor title_color) { | 435 void BaseTab::PaintTitle(gfx::Canvas* canvas, SkColor title_color) { |
| 436 // Paint the Title. | 436 // Paint the Title. |
| 437 const gfx::Rect& title_bounds = GetTitleBounds(); | |
| 437 string16 title = data().title; | 438 string16 title = data().title; |
| 438 if (title.empty()) { | 439 if (title.empty()) { |
| 439 title = data().loading ? | 440 title = data().loading ? |
| 440 l10n_util::GetStringUTF16(IDS_TAB_LOADING_TITLE) : | 441 l10n_util::GetStringUTF16(IDS_TAB_LOADING_TITLE) : |
| 441 TabContentsWrapper::GetDefaultTitle(); | 442 TabContentsWrapper::GetDefaultTitle(); |
| 442 } else { | 443 } else { |
| 443 Browser::FormatTitleForDisplay(&title); | 444 Browser::FormatTitleForDisplay(&title); |
| 445 // If we'll need to truncate, check if we should also truncate | |
| 446 // a common prefix, but only if there is enough room for it. | |
| 447 // We arbitrarily choose to request enough room for 10 average chars. | |
| 448 if (data().common_prefix_length > 0 && | |
| 449 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
| |
| 450 font_->GetStringWidth(title) > title_bounds.width()) { | |
| 451 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...
| |
| 452 } | |
| 444 } | 453 } |
| 445 const gfx::Rect& title_bounds = GetTitleBounds(); | |
| 446 canvas->DrawStringInt(title, *font_, title_color, | 454 canvas->DrawStringInt(title, *font_, title_color, |
| 447 title_bounds.x(), title_bounds.y(), | 455 title_bounds.x(), title_bounds.y(), |
| 448 title_bounds.width(), title_bounds.height()); | 456 title_bounds.width(), title_bounds.height()); |
| 449 } | 457 } |
| 450 | 458 |
| 451 void BaseTab::AnimationProgressed(const ui::Animation* animation) { | 459 void BaseTab::AnimationProgressed(const ui::Animation* animation) { |
| 452 SchedulePaint(); | 460 SchedulePaint(); |
| 453 } | 461 } |
| 454 | 462 |
| 455 void BaseTab::AnimationCanceled(const ui::Animation* animation) { | 463 void BaseTab::AnimationCanceled(const ui::Animation* animation) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 518 // static | 526 // static |
| 519 void BaseTab::InitResources() { | 527 void BaseTab::InitResources() { |
| 520 static bool initialized = false; | 528 static bool initialized = false; |
| 521 if (!initialized) { | 529 if (!initialized) { |
| 522 initialized = true; | 530 initialized = true; |
| 523 font_ = new gfx::Font( | 531 font_ = new gfx::Font( |
| 524 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont)); | 532 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont)); |
| 525 font_height_ = font_->GetHeight(); | 533 font_height_ = font_->GetHeight(); |
| 526 } | 534 } |
| 527 } | 535 } |
| OLD | NEW |