| 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..30480b0582cb3f3bd05c8ad739419a28e1aa155a 100644
|
| --- a/chrome/browser/ui/views/tabs/tab.cc
|
| +++ b/chrome/browser/ui/views/tabs/tab.cc
|
| @@ -19,6 +19,7 @@
|
| #include "ui/base/animation/multi_animation.h"
|
| #include "ui/base/animation/throb_animation.h"
|
| #include "ui/base/resource/resource_bundle.h"
|
| +#include "ui/base/scale.h"
|
| #include "ui/base/touch/touch_mode_support.h"
|
| #include "ui/gfx/canvas.h"
|
| #include "ui/gfx/favicon_size.h"
|
| @@ -30,18 +31,59 @@
|
| #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() {
|
| + switch (ui::GetDisplayScale()) {
|
| + case ui::DS_ASH:
|
| + return 21;
|
| + case ui::DS_METRO_100:
|
| + case ui::DS_METRO_140:
|
| + case ui::DS_METRO_180:
|
| + return 20;
|
| + default:
|
| + return 16;
|
| + }
|
| +}
|
| +
|
| +const int GetTopPadding() {
|
| + switch (ui::GetDisplayScale()) {
|
| + case ui::DS_ASH:
|
| + return 8;
|
| + case ui::DS_METRO_100:
|
| + case ui::DS_METRO_140:
|
| + case ui::DS_METRO_180:
|
| + return 12;
|
| + default:
|
| + return 6;
|
| + }
|
| +}
|
| +
|
| +const int GetRightPadding() {
|
| + switch (ui::GetDisplayScale()) {
|
| + case ui::DS_ASH:
|
| + return 20;
|
| + case ui::DS_METRO_100:
|
| + case ui::DS_METRO_140:
|
| + case ui::DS_METRO_180:
|
| + return 21;
|
| + default:
|
| + return 15;
|
| + }
|
| +}
|
| +
|
| +const int GetBottomPadding() {
|
| + switch (ui::GetDisplayScale()) {
|
| + case ui::DS_METRO_100:
|
| + case ui::DS_METRO_140:
|
| + case ui::DS_METRO_180:
|
| + return 7;
|
| + case ui::DS_ASH:
|
| + default:
|
| + return 5;
|
| + }
|
| +}
|
|
|
| // Height of the shadow at the top of the tab image assets.
|
| #if defined(USE_ASH)
|
| @@ -90,10 +132,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 +152,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 +208,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 +226,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 +316,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 +329,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 +354,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 +367,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 +626,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 {
|
|
|