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 f3d43ac87067fe2614d2a059899632d7485bd4c8..202e36dedb267271d8dc44941767cebb6549afb4 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/gfx/canvas.h" |
#include "ui/gfx/favicon_size.h" |
@@ -29,18 +30,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_TOUCH: |
+ 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_TOUCH: |
+ 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_TOUCH: |
+ value = 21; |
+ break; |
+ default: |
+ value = 15; |
+ } |
+ } |
+ return value; |
+} |
+ |
+const int GetBottomPadding() { |
+ static int value = -1; |
+ if (value == -1) { |
+ switch (ui::GetDisplayLayout()) { |
+ case ui::LAYOUT_TOUCH: |
+ 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) |
@@ -88,10 +146,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; |
@@ -112,6 +166,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"; |
@@ -162,7 +222,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()); |
@@ -176,7 +236,8 @@ gfx::Size Tab::GetMinimumUnselectedSize() { |
// static |
gfx::Size Tab::GetMinimumSelectedSize() { |
gfx::Size minimum_size = GetBasicMinimumUnselectedSize(); |
- minimum_size.set_width(kLeftPadding + gfx::kFaviconSize + kRightPadding); |
+ minimum_size.set_width( |
+ GetLeftPadding() + gfx::kFaviconSize + GetRightPadding()); |
return minimum_size; |
} |
@@ -256,7 +317,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. |
@@ -268,7 +330,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); |
@@ -293,7 +355,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, |
@@ -306,15 +368,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; |
@@ -565,7 +627,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 { |