Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3634)

Unified Diff: chrome/browser/ui/views/tabs/tab.cc

Issue 247193002: Remove touch layout (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 3326c9e7e1309e90d9ba41ed6485c573cb3a2069..09d9e882c30945458f366f451e6fe52d80aa9337 100644
--- a/chrome/browser/ui/views/tabs/tab.cc
+++ b/chrome/browser/ui/views/tabs/tab.cc
@@ -56,110 +56,16 @@
namespace {
// Padding around the "content" of a tab, occupied by the tab border graphics.
-
-int left_padding() {
- static int value = -1;
- if (value == -1) {
- switch (ui::GetDisplayLayout()) {
- case ui::LAYOUT_DESKTOP:
- value = 22;
- break;
- case ui::LAYOUT_TOUCH:
- value = 30;
- break;
- default:
- NOTREACHED();
- }
- }
- return value;
-}
-
-int top_padding() {
- static int value = -1;
- if (value == -1) {
- switch (ui::GetDisplayLayout()) {
- case ui::LAYOUT_DESKTOP:
- value = 7;
- break;
- case ui::LAYOUT_TOUCH:
- value = 10;
- break;
- default:
- NOTREACHED();
- }
- }
- return value;
-}
-
-int right_padding() {
- static int value = -1;
- if (value == -1) {
- switch (ui::GetDisplayLayout()) {
- case ui::LAYOUT_DESKTOP:
- value = 17;
- break;
- case ui::LAYOUT_TOUCH:
- value = 21;
- break;
- default:
- NOTREACHED();
- }
- }
- return value;
-}
-
-int bottom_padding() {
- static int value = -1;
- if (value == -1) {
- switch (ui::GetDisplayLayout()) {
- case ui::LAYOUT_DESKTOP:
- value = 5;
- break;
- case ui::LAYOUT_TOUCH:
- value = 7;
- break;
- default:
- NOTREACHED();
- }
- }
- return value;
-}
+const int kLeftPadding = 22;
+const int kTopPadding = 7;
+const int kRightPadding = 17;
+const int kBottomPadding = 5;
// Height of the shadow at the top of the tab image assets.
-int drop_shadow_height() {
- static int value = -1;
- if (value == -1) {
- switch (ui::GetDisplayLayout()) {
- case ui::LAYOUT_DESKTOP:
- value = 4;
- break;
- case ui::LAYOUT_TOUCH:
- value = 5;
- break;
- default:
- NOTREACHED();
- }
- }
- return value;
-}
+const int kDropShadowHeight = 4;
// Size of icon used for throbber and favicon next to tab title.
-int tab_icon_size() {
- static int value = -1;
- if (value == -1) {
- switch (ui::GetDisplayLayout()) {
- case ui::LAYOUT_DESKTOP:
- value = gfx::kFaviconSize;
- break;
- case ui::LAYOUT_TOUCH:
- value = 20;
- break;
- default:
- NOTREACHED();
- }
- }
- return value;
-}
+const int kTabIconSize = gfx::kFaviconSize;
// How long the pulse throb takes.
const int kPulseDurationMs = 200;
@@ -660,7 +566,7 @@ gfx::Size Tab::GetBasicMinimumUnselectedSize() {
InitTabResources();
gfx::Size minimum_size;
- minimum_size.set_width(left_padding() + right_padding());
+ minimum_size.set_width(kLeftPadding + kRightPadding);
// Since we use image 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());
@@ -675,7 +581,7 @@ gfx::Size Tab::GetMinimumUnselectedSize() {
gfx::Size Tab::GetMinimumSelectedSize() {
gfx::Size minimum_size = GetBasicMinimumUnselectedSize();
minimum_size.set_width(
- left_padding() + gfx::kFaviconSize + right_padding());
+ kLeftPadding + gfx::kFaviconSize + kRightPadding);
return minimum_size;
}
@@ -780,11 +686,11 @@ void Tab::Layout() {
if (lb.IsEmpty())
return;
lb.Inset(
- left_padding(), top_padding(), right_padding(), bottom_padding());
+ kLeftPadding, kTopPadding, kRightPadding, kBottomPadding);
sky 2014/04/24 03:29:02 nit: I think you can fit this all on one line now.
oshima 2014/04/25 14:16:26 Done.
// The height of the content of the Tab is the largest of the favicon,
// the title text and the close button graphic.
- int content_height = std::max(tab_icon_size(), font_height_);
+ int content_height = std::max(kTabIconSize, font_height_);
close_button_->SetBorder(views::Border::NullBorder());
gfx::Size close_button_size(close_button_->GetPreferredSize());
content_height = std::max(content_height, close_button_size.height());
@@ -793,10 +699,10 @@ 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 = top_padding() + content_height / 2 - tab_icon_size() / 2;
+ int favicon_top = kTopPadding + content_height / 2 - kTabIconSize / 2;
int favicon_left = lb.x();
favicon_bounds_.SetRect(favicon_left, favicon_top,
- tab_icon_size(), tab_icon_size());
+ kTabIconSize, kTabIconSize);
MaybeAdjustLeftForMiniTab(&favicon_bounds_);
} else {
favicon_bounds_.SetRect(lb.x(), lb.y(), 0, 0);
@@ -809,7 +715,7 @@ void Tab::Layout() {
if (showing_close_button_) {
const int close_button_vert_fuzz = is_host_desktop_type_ash ?
kCloseButtonVertFuzzAsh : kCloseButtonVertFuzz;
- int close_button_top = top_padding() + close_button_vert_fuzz +
+ int close_button_top = kTopPadding + close_button_vert_fuzz +
(content_height - close_button_size.height()) / 2;
// If the ratio of the close button size to tab width exceeds the maximum.
// The close button should be as large as possible so that there is a larger
@@ -841,7 +747,7 @@ void Tab::Layout() {
media_indicator_bounds_.set_width(media_indicator_image.Width());
media_indicator_bounds_.set_height(media_indicator_image.Height());
media_indicator_bounds_.set_y(
- top_padding() +
+ kTopPadding +
(content_height - media_indicator_bounds_.height()) / 2);
const int right = showing_close_button_ ?
close_button_->x() + close_button_->GetInsets().left() : lb.right();
@@ -855,7 +761,7 @@ void Tab::Layout() {
const int title_text_offset = is_host_desktop_type_ash ?
kTitleTextOffsetYAsh : kTitleTextOffsetY;
int title_left = favicon_bounds_.right() + kFaviconTitleSpacing;
- int title_top = top_padding() + title_text_offset +
+ int title_top = kTopPadding + title_text_offset +
(content_height - font_height_) / 2;
// Size the Title text to fill the remaining space.
if (!data().mini || width() >= kMiniTabRendererAsNormalTabWidth) {
@@ -863,7 +769,7 @@ void Tab::Layout() {
// 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_ + bottom_padding();
+ int text_height = title_top + font_height_ + kBottomPadding;
if (text_height > minimum_size.height())
title_top -= (text_height - minimum_size.height()) / 2;
@@ -1362,11 +1268,11 @@ void Tab::PaintInactiveTabBackgroundUsingResourceId(gfx::Canvas* canvas,
// rectangle. And again, don't draw over the toolbar.
background_canvas.TileImageInt(*tab_bg,
offset + tab_image->l_width,
- bg_offset_y + drop_shadow_height(),
+ bg_offset_y + kDropShadowHeight,
tab_image->l_width,
- drop_shadow_height(),
+ kDropShadowHeight,
width() - tab_image->l_width - tab_image->r_width,
- height() - drop_shadow_height() - kToolbarOverlap);
+ height() - kDropShadowHeight - kToolbarOverlap);
canvas->DrawImageInt(
gfx::ImageSkia(background_canvas.ExtractImageRep()), 0, 0);
@@ -1415,11 +1321,11 @@ void Tab::PaintActiveTabBackground(gfx::Canvas* canvas) {
// by incrementing by GetDropShadowHeight(), since it's a simple rectangle.
canvas->TileImageInt(*tab_background,
offset + tab_image->l_width,
- drop_shadow_height(),
+ kDropShadowHeight,
tab_image->l_width,
- drop_shadow_height(),
+ kDropShadowHeight,
width() - tab_image->l_width - tab_image->r_width,
- height() - drop_shadow_height());
+ height() - kDropShadowHeight);
// Now draw the highlights/shadows around the tab edge.
canvas->DrawImageInt(*tab_image->image_l, 0, 0);
@@ -1565,8 +1471,8 @@ int Tab::IconCapacity() const {
if (height() < GetMinimumUnselectedSize().height())
return 0;
const int available_width =
- std::max(0, width() - left_padding() - right_padding());
- const int width_per_icon = tab_icon_size();
+ std::max(0, width() - kLeftPadding - kRightPadding);
+ const int width_per_icon = kTabIconSize;
const int kPaddingBetweenIcons = 2;
if (available_width >= width_per_icon &&
available_width < (width_per_icon + kPaddingBetweenIcons)) {

Powered by Google App Engine
This is Rietveld 408576698