| Index: chrome/browser/ui/views/tabs/tab.cc
|
| diff --git a/chrome/browser/ui/views/tabs/tab.cc b/chrome/browser/ui/views/tabs/tab.cc
|
| index 59cab0472843fbdfa1520fd07593e73047e7a12a..07998d253d24ebee1e923509da02d31e96ef4f47 100644
|
| --- a/chrome/browser/ui/views/tabs/tab.cc
|
| +++ b/chrome/browser/ui/views/tabs/tab.cc
|
| @@ -53,9 +53,9 @@ static const int kMiniTabRendererAsNormalTabWidth =
|
| // How opaque to make the hover state (out of 1).
|
| static const double kHoverOpacity = 0.33;
|
|
|
| -Tab::TabImage Tab::tab_alpha = {0};
|
| -Tab::TabImage Tab::tab_active = {0};
|
| -Tab::TabImage Tab::tab_inactive = {0};
|
| +Tab::TabImage Tab::tab_alpha_ = {0};
|
| +Tab::TabImage Tab::tab_active_ = {0};
|
| +Tab::TabImage Tab::tab_inactive_ = {0};
|
|
|
| // Durations for the various parts of the mini tab title animation.
|
| static const int kMiniTitleChangeAnimationDuration1MS = 1600;
|
| @@ -82,19 +82,6 @@ static const SkScalar kTabCapWidth = 15;
|
| static const SkScalar kTabTopCurveWidth = 4;
|
| static const SkScalar kTabBottomCurveWidth = 3;
|
|
|
| -namespace {
|
| -
|
| -void InitTabResources() {
|
| - static bool initialized = false;
|
| - if (initialized)
|
| - return;
|
| -
|
| - initialized = true;
|
| - Tab::LoadTabImages();
|
| -}
|
| -
|
| -} // namespace
|
| -
|
| // static
|
| const char Tab::kViewClassName[] = "browser/tabs/Tab";
|
|
|
| @@ -137,10 +124,6 @@ void Tab::StopMiniTabTitleAnimation() {
|
| mini_title_animation_->Stop();
|
| }
|
|
|
| -void Tab::PaintIcon(gfx::Canvas* canvas) {
|
| - BaseTab::PaintIcon(canvas, favicon_bounds_.x(), favicon_bounds_.y());
|
| -}
|
| -
|
| // static
|
| gfx::Size Tab::GetMinimumUnselectedSize() {
|
| InitTabResources();
|
| @@ -149,7 +132,7 @@ gfx::Size Tab::GetMinimumUnselectedSize() {
|
| minimum_size.set_width(kLeftPadding + kRightPadding);
|
| // Since we use bitmap images, the real minimum height of the image is
|
| // defined most accurately by the height of the end cap images.
|
| - minimum_size.set_height(tab_active.image_l->height());
|
| + minimum_size.set_height(tab_active_.image_l->height());
|
| return minimum_size;
|
| }
|
|
|
| @@ -318,7 +301,7 @@ void Tab::Layout() {
|
| }
|
|
|
| void Tab::OnThemeChanged() {
|
| - Tab::LoadTabImages();
|
| + LoadTabImages();
|
| }
|
|
|
| bool Tab::HasHitTestMask() const {
|
| @@ -367,6 +350,10 @@ void Tab::OnMouseMoved(const views::MouseEvent& e) {
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // Tab, private
|
|
|
| +void Tab::PaintIcon(gfx::Canvas* canvas) {
|
| + BaseTab::PaintIcon(canvas, favicon_bounds_.x(), favicon_bounds_.y());
|
| +}
|
| +
|
| void Tab::PaintTabBackground(gfx::Canvas* canvas) {
|
| if (IsSelected()) {
|
| PaintActiveTabBackground(canvas);
|
| @@ -462,9 +449,9 @@ void Tab::PaintInactiveTabBackground(gfx::Canvas* canvas) {
|
|
|
| SkBitmap* tab_bg = GetThemeProvider()->GetBitmapNamed(tab_id);
|
|
|
| - TabImage* tab_image = &tab_active;
|
| - TabImage* tab_inactive_image = &tab_inactive;
|
| - TabImage* alpha = &tab_alpha;
|
| + TabImage* tab_image = &tab_active_;
|
| + TabImage* tab_inactive_image = &tab_inactive_;
|
| + TabImage* alpha = &tab_alpha_;
|
|
|
| // If the theme is providing a custom background image, then its top edge
|
| // should be at the top of the tab. Otherwise, we assume that the background
|
| @@ -536,13 +523,12 @@ void Tab::PaintActiveTabBackground(gfx::Canvas* canvas) {
|
| int offset = GetX(views::View::APPLY_MIRRORING_TRANSFORMATION) +
|
| background_offset_.x();
|
| ThemeProvider* tp = GetThemeProvider();
|
| - if (!tp)
|
| - NOTREACHED() << "Unable to get theme provider";
|
| + DCHECK(tp) << "Unable to get theme provider";
|
|
|
| SkBitmap* tab_bg = GetThemeProvider()->GetBitmapNamed(IDR_THEME_TOOLBAR);
|
|
|
| - TabImage* tab_image = &tab_active;
|
| - TabImage* alpha = &tab_alpha;
|
| + TabImage* tab_image = &tab_active_;
|
| + TabImage* alpha = &tab_alpha_;
|
|
|
| // Draw left edge.
|
| SkBitmap tab_l = SkBitmapOperations::CreateTiledBitmap(
|
| @@ -649,22 +635,34 @@ double Tab::GetThrobValue() {
|
| // Tab, private:
|
|
|
| // static
|
| +void Tab::InitTabResources() {
|
| + static bool initialized = false;
|
| + if (initialized)
|
| + return;
|
| +
|
| + initialized = true;
|
| +
|
| + // Load the tab images once now, and maybe again later if the theme changes.
|
| + LoadTabImages();
|
| +}
|
| +
|
| +// static
|
| void Tab::LoadTabImages() {
|
| // We're not letting people override tab images just yet.
|
| ResourceBundle& rb = ResourceBundle::GetSharedInstance();
|
|
|
| - tab_alpha.image_l = rb.GetBitmapNamed(IDR_TAB_ALPHA_LEFT);
|
| - tab_alpha.image_r = rb.GetBitmapNamed(IDR_TAB_ALPHA_RIGHT);
|
| + tab_alpha_.image_l = rb.GetBitmapNamed(IDR_TAB_ALPHA_LEFT);
|
| + tab_alpha_.image_r = rb.GetBitmapNamed(IDR_TAB_ALPHA_RIGHT);
|
|
|
| - tab_active.image_l = rb.GetBitmapNamed(IDR_TAB_ACTIVE_LEFT);
|
| - tab_active.image_c = rb.GetBitmapNamed(IDR_TAB_ACTIVE_CENTER);
|
| - tab_active.image_r = rb.GetBitmapNamed(IDR_TAB_ACTIVE_RIGHT);
|
| - tab_active.l_width = tab_active.image_l->width();
|
| - tab_active.r_width = tab_active.image_r->width();
|
| + tab_active_.image_l = rb.GetBitmapNamed(IDR_TAB_ACTIVE_LEFT);
|
| + tab_active_.image_c = rb.GetBitmapNamed(IDR_TAB_ACTIVE_CENTER);
|
| + tab_active_.image_r = rb.GetBitmapNamed(IDR_TAB_ACTIVE_RIGHT);
|
| + tab_active_.l_width = tab_active_.image_l->width();
|
| + tab_active_.r_width = tab_active_.image_r->width();
|
|
|
| - tab_inactive.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT);
|
| - tab_inactive.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER);
|
| - tab_inactive.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT);
|
| - tab_inactive.l_width = tab_inactive.image_l->width();
|
| - tab_inactive.r_width = tab_inactive.image_r->width();
|
| + tab_inactive_.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT);
|
| + tab_inactive_.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER);
|
| + tab_inactive_.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT);
|
| + tab_inactive_.l_width = tab_inactive_.image_l->width();
|
| + tab_inactive_.r_width = tab_inactive_.image_r->width();
|
| }
|
|
|