| 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 4010b1b5116f4eb5c13437e9328155c449f834fd..5b9f5d5cb97335db72f5cfd13ca8b58af896dae4 100644
|
| --- a/chrome/browser/ui/views/tabs/tab.cc
|
| +++ b/chrome/browser/ui/views/tabs/tab.cc
|
| @@ -18,6 +18,7 @@
|
| #include "third_party/skia/include/effects/SkGradientShader.h"
|
| #include "ui/base/animation/multi_animation.h"
|
| #include "ui/base/animation/throb_animation.h"
|
| +#include "ui/base/layout.h"
|
| #include "ui/base/resource/resource_bundle.h"
|
| #include "ui/base/touch/touch_mode_support.h"
|
| #include "ui/gfx/canvas.h"
|
| @@ -30,18 +31,75 @@
|
| #include "ui/views/widget/widget.h"
|
| #include "ui/views/window/non_client_view.h"
|
|
|
| +namespace {
|
| +
|
| // Padding around the "content" of a tab, occupied by the tab border graphics.
|
| -#if defined(USE_ASH)
|
| -static const int kLeftPadding = 21;
|
| -static const int kTopPadding = 8;
|
| -static const int kRightPadding = 20;
|
| -static const int kBottomPadding = 5;
|
| -#else
|
| -static const int kLeftPadding = 16;
|
| -static const int kTopPadding = 6;
|
| -static const int kRightPadding = 15;
|
| -static const int kBottomPadding = 5;
|
| -#endif
|
| +
|
| +const int GetLeftPadding() {
|
| + static int value = -1;
|
| + if (value == -1) {
|
| + switch (ui::GetDisplayLayout()) {
|
| + case ui::LAYOUT_ASH:
|
| + value = 21;
|
| + break;
|
| + case ui::LAYOUT_METRO:
|
| + value = 20;
|
| + break;
|
| + default:
|
| + value = 16;
|
| + }
|
| + }
|
| + return value;
|
| +}
|
| +
|
| +const int GetTopPadding() {
|
| + static int value = -1;
|
| + if (value == -1) {
|
| + switch (ui::GetDisplayLayout()) {
|
| + case ui::LAYOUT_ASH:
|
| + value = 8;
|
| + break;
|
| + case ui::LAYOUT_METRO:
|
| + value = 12;
|
| + break;
|
| + default:
|
| + value = 6;
|
| + }
|
| + }
|
| + return value;
|
| +}
|
| +
|
| +const int GetRightPadding() {
|
| + static int value = -1;
|
| + if (value == -1) {
|
| + switch (ui::GetDisplayLayout()) {
|
| + case ui::LAYOUT_ASH:
|
| + value = 20;
|
| + break;
|
| + case ui::LAYOUT_METRO:
|
| + value = 21;
|
| + break;
|
| + default:
|
| + value = 15;
|
| + }
|
| + }
|
| + return value;
|
| +}
|
| +
|
| +const int GetBottomPadding() {
|
| + static int value = -1;
|
| + if (value == -1) {
|
| + switch (ui::GetDisplayLayout()) {
|
| + case ui::LAYOUT_METRO:
|
| + value = 7;
|
| + break;
|
| + case ui::LAYOUT_ASH:
|
| + default:
|
| + value = 5;
|
| + }
|
| + }
|
| + return value;
|
| +}
|
|
|
| // Height of the shadow at the top of the tab image assets.
|
| #if defined(USE_ASH)
|
| @@ -90,10 +148,6 @@ static const double kSelectedTabOpacity = .45;
|
| // Selected (but not active) tabs have their throb value scaled down by this.
|
| static const double kSelectedTabThrobScale = .5;
|
|
|
| -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;
|
| static const int kMiniTitleChangeAnimationStart1MS = 0;
|
| @@ -114,6 +168,12 @@ static const SkColor kMiniTitleChangeGradientColor1 = SK_ColorWHITE;
|
| static const SkColor kMiniTitleChangeGradientColor2 =
|
| SkColorSetARGB(0, 255, 255, 255);
|
|
|
| +} // namespace
|
| +
|
| +Tab::TabImage Tab::tab_alpha_ = {0};
|
| +Tab::TabImage Tab::tab_active_ = {0};
|
| +Tab::TabImage Tab::tab_inactive_ = {0};
|
| +
|
| // static
|
| const char Tab::kViewClassName[] = "browser/tabs/Tab";
|
|
|
| @@ -164,7 +224,7 @@ gfx::Size Tab::GetBasicMinimumUnselectedSize() {
|
| InitTabResources();
|
|
|
| gfx::Size minimum_size;
|
| - minimum_size.set_width(kLeftPadding + kRightPadding);
|
| + minimum_size.set_width(GetLeftPadding() + GetRightPadding());
|
| // 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());
|
| @@ -182,7 +242,8 @@ gfx::Size Tab::GetMinimumSelectedSize() {
|
| if (TouchModeSupport::IsTouchOptimized())
|
| return GetTouchModeMinimumSize();
|
| gfx::Size minimum_size = GetBasicMinimumUnselectedSize();
|
| - minimum_size.set_width(kLeftPadding + gfx::kFaviconSize + kRightPadding);
|
| + minimum_size.set_width(
|
| + GetLeftPadding() + gfx::kFaviconSize + GetRightPadding());
|
| return minimum_size;
|
| }
|
|
|
| @@ -271,7 +332,8 @@ void Tab::Layout() {
|
| gfx::Rect lb = GetContentsBounds();
|
| if (lb.IsEmpty())
|
| return;
|
| - lb.Inset(kLeftPadding, kTopPadding, kRightPadding, kBottomPadding);
|
| + lb.Inset(
|
| + GetLeftPadding(), GetTopPadding(), GetRightPadding(), GetBottomPadding());
|
|
|
| // The height of the content of the Tab is the largest of the favicon,
|
| // the title text and the close button graphic.
|
| @@ -283,7 +345,7 @@ void Tab::Layout() {
|
| showing_icon_ = ShouldShowIcon();
|
| if (showing_icon_) {
|
| // Use the size of the favicon as apps use a bigger favicon size.
|
| - int favicon_top = kTopPadding + content_height / 2 - kTabIconSize / 2;
|
| + int favicon_top = GetTopPadding() + content_height / 2 - kTabIconSize / 2;
|
| int favicon_left = lb.x();
|
| favicon_bounds_.SetRect(favicon_left, favicon_top,
|
| kTabIconSize, kTabIconSize);
|
| @@ -308,7 +370,7 @@ void Tab::Layout() {
|
| // Size the Close button.
|
| showing_close_button_ = ShouldShowCloseBox();
|
| if (showing_close_button_) {
|
| - int close_button_top = kTopPadding + kCloseButtonVertFuzz +
|
| + int close_button_top = GetTopPadding() + kCloseButtonVertFuzz +
|
| (content_height - close_button_size.height()) / 2;
|
| // If the ratio of the close button size to tab width exceeds the maximum.
|
| close_button()->SetBounds(lb.width() + kCloseButtonHorzFuzz,
|
| @@ -321,15 +383,15 @@ void Tab::Layout() {
|
| }
|
|
|
| int title_left = favicon_bounds_.right() + kFaviconTitleSpacing;
|
| - int title_top =
|
| - kTopPadding + kTitleTextOffsetY + (content_height - font_height()) / 2;
|
| + int title_top = GetTopPadding() + kTitleTextOffsetY +
|
| + (content_height - font_height()) / 2;
|
| // Size the Title text to fill the remaining space.
|
| if (!data().mini || width() >= kMiniTabRendererAsNormalTabWidth) {
|
| // If the user has big fonts, the title will appear rendered too far down
|
| // on the y-axis if we use the regular top padding, so we need to adjust it
|
| // so that the text appears centered.
|
| gfx::Size minimum_size = GetMinimumUnselectedSize();
|
| - int text_height = title_top + font_height() + kBottomPadding;
|
| + int text_height = title_top + font_height() + GetBottomPadding();
|
| if (text_height > minimum_size.height())
|
| title_top -= (text_height - minimum_size.height()) / 2;
|
|
|
| @@ -580,7 +642,7 @@ void Tab::PaintActiveTabBackground(gfx::Canvas* canvas) {
|
| int Tab::IconCapacity() const {
|
| if (height() < GetMinimumUnselectedSize().height())
|
| return 0;
|
| - return (width() - kLeftPadding - kRightPadding) / kTabIconSize;
|
| + return (width() - GetLeftPadding() - GetRightPadding()) / kTabIconSize;
|
| }
|
|
|
| bool Tab::ShouldShowIcon() const {
|
|
|