Commit b8f425da authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Eliminate GetLayoutInsets(TAB).

Callers outside Tab only referred to the vertical insets, which are now either 0
or Tab::GetStrokeWidth(), a new function added for this purpose, depending on
the context.

Inside Tab this is subsumed into GetTabEndcapWidth(), which itself has been
split into two parts: a general-purpose routine and a pre-refresh-specific
"paint" width routine.  This may be cleaned up further depending on how I solve
narrow tabs in the end.

BUG=none
TEST=none

Change-Id: Ifca96b76b694f3f922e0252cf5198c7a9bb475e3
Reviewed-on: https://chromium-review.googlesource.com/1112773Reviewed-by: default avatarAllen Bauer <kylixrd@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570168}
parent 856dfa81
...@@ -110,13 +110,6 @@ gfx::Insets GetLayoutInsets(LayoutInset inset) { ...@@ -110,13 +110,6 @@ gfx::Insets GetLayoutInsets(LayoutInset inset) {
return touch_optimized_material ? gfx::Insets(5) : gfx::Insets(4); return touch_optimized_material ? gfx::Insets(5) : gfx::Insets(4);
} }
case TAB: {
// TODO(pkasting): This should disappear; the horizontal portion should
// be computed in tab.cc, and the vertical portion become a standalone
// value (that should perhaps be 0 in Refresh).
constexpr int kTabHorizontalInset[] = {16, 18, 24, 16, 16};
return gfx::Insets(1, kTabHorizontalInset[mode]);
}
case TOOLBAR_BUTTON: case TOOLBAR_BUTTON:
return gfx::Insets(touch_optimized_material ? 12 : 6); return gfx::Insets(touch_optimized_material ? 12 : 6);
......
...@@ -107,9 +107,6 @@ enum LayoutInset { ...@@ -107,9 +107,6 @@ enum LayoutInset {
// (e.g. does not highlight on hover). // (e.g. does not highlight on hover).
LOCATION_BAR_ICON_INTERIOR_PADDING, LOCATION_BAR_ICON_INTERIOR_PADDING,
// The padding inside the tab bounds that defines the tab contents region.
TAB,
// The padding inside the border of a toolbar button (around the image). // The padding inside the border of a toolbar button (around the image).
TOOLBAR_BUTTON, TOOLBAR_BUTTON,
......
...@@ -332,8 +332,8 @@ void BrowserNonClientFrameView::PaintToolbarBackground( ...@@ -332,8 +332,8 @@ void BrowserNonClientFrameView::PaintToolbarBackground(
if (tp->HasCustomImage(IDR_THEME_TOOLBAR)) { if (tp->HasCustomImage(IDR_THEME_TOOLBAR)) {
canvas->TileImageInt(*tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR), canvas->TileImageInt(*tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR),
x + GetThemeBackgroundXInset(), x + GetThemeBackgroundXInset(),
y - GetTopInset(false) - GetLayoutInsets(TAB).top(), x, y - GetTopInset(false) - Tab::GetStrokeHeight(), x, y,
y, w, toolbar_bounds.height()); w, toolbar_bounds.height());
} else { } else {
canvas->FillRect(toolbar_bounds, canvas->FillRect(toolbar_bounds,
tp->GetColor(ThemeProperties::COLOR_TOOLBAR)); tp->GetColor(ThemeProperties::COLOR_TOOLBAR));
......
...@@ -513,19 +513,16 @@ int GlassBrowserFrameView::TopAreaHeight(bool restored) const { ...@@ -513,19 +513,16 @@ int GlassBrowserFrameView::TopAreaHeight(bool restored) const {
if (frame()->IsFullscreen() && !restored) if (frame()->IsFullscreen() && !restored)
return 0; return 0;
const int top = FrameTopBorderThickness(restored); int top = FrameTopBorderThickness(restored);
// The tab top inset is equal to the height of any shadow region above the if (!IsMaximized() || restored) {
// tabs, plus a 1 px top stroke. In maximized mode, we want to push the // Besides the frame border, there's empty space atop the window in restored
// shadow region off the top of the screen but leave the top stroke. // mode, to use to drag the window around.
if (IsMaximized() && !restored) constexpr int kNonClientRestoredExtraThickness = 11;
return top - GetLayoutInsets(TAB).top() + 1; constexpr int kRefreshNonClientRestoredExtraThickness = 4;
top += MD::IsRefreshUi() ? kRefreshNonClientRestoredExtraThickness
// Besides the frame border, there's empty space atop the window in restored : kNonClientRestoredExtraThickness;
// mode, to use to drag the window around. }
constexpr int kNonClientRestoredExtraThickness = 11; return top;
constexpr int kRefreshNonClientRestoredExtraThickness = 4;
return top + (MD::IsRefreshUi() ? kRefreshNonClientRestoredExtraThickness
: kNonClientRestoredExtraThickness);
} }
int GlassBrowserFrameView::TitlebarMaximizedVisualHeight() const { int GlassBrowserFrameView::TitlebarMaximizedVisualHeight() const {
......
...@@ -161,24 +161,17 @@ int OpaqueBrowserFrameViewLayout::NonClientBorderThickness() const { ...@@ -161,24 +161,17 @@ int OpaqueBrowserFrameViewLayout::NonClientBorderThickness() const {
} }
int OpaqueBrowserFrameViewLayout::NonClientTopHeight(bool restored) const { int OpaqueBrowserFrameViewLayout::NonClientTopHeight(bool restored) const {
if (delegate_->ShouldShowWindowTitle()) { if (!delegate_->ShouldShowWindowTitle())
// The + 2 here puts at least 1 px of space on top and bottom of the icon. return FrameTopBorderThickness(restored);
const int icon_height =
TitlebarTopThickness(restored) + delegate_->GetIconSize() + 2; // The + 2 here puts at least 1 px of space on top and bottom of the icon.
const int caption_button_height = DefaultCaptionButtonY(restored) + const int icon_height =
kCaptionButtonHeight + TitlebarTopThickness(restored) + delegate_->GetIconSize() + 2;
kCaptionButtonBottomPadding; const int caption_button_height = DefaultCaptionButtonY(restored) +
return std::max(icon_height, caption_button_height) + kCaptionButtonHeight +
kContentEdgeShadowThickness; kCaptionButtonBottomPadding;
} return std::max(icon_height, caption_button_height) +
kContentEdgeShadowThickness;
int thickness = FrameTopBorderThickness(restored);
// The tab top inset is equal to the height of any shadow region above the
// tabs, plus a 1 px top stroke. In maximized mode, we want to push the
// shadow region off the top of the screen but leave the top stroke.
if (!restored && delegate_->IsTabStripVisible() && IsTitleBarCondensed())
thickness -= GetLayoutInsets(TAB).top() - 1;
return thickness;
} }
int OpaqueBrowserFrameViewLayout::GetTabStripInsetsTop(bool restored) const { int OpaqueBrowserFrameViewLayout::GetTabStripInsetsTop(bool restored) const {
......
...@@ -261,9 +261,8 @@ class OpaqueBrowserFrameViewLayoutTest : public views::ViewsTestBase { ...@@ -261,9 +261,8 @@ class OpaqueBrowserFrameViewLayoutTest : public views::ViewsTestBase {
gfx::Rect tabstrip_bounds( gfx::Rect tabstrip_bounds(
layout_manager_->GetBoundsForTabStrip(tabstrip_min_size, kWindowWidth)); layout_manager_->GetBoundsForTabStrip(tabstrip_min_size, kWindowWidth));
EXPECT_EQ(tabstrip_x, tabstrip_bounds.x()); EXPECT_EQ(tabstrip_x, tabstrip_bounds.x());
int maximized_top_border_height = -GetLayoutInsets(TAB).top() + 1;
if (maximized) { if (maximized) {
EXPECT_EQ(maximized_top_border_height, tabstrip_bounds.y()); EXPECT_EQ(0, tabstrip_bounds.y());
} else { } else {
int tabstrip_nonexcluded_y = int tabstrip_nonexcluded_y =
OpaqueBrowserFrameViewLayout::kFrameBorderThickness + OpaqueBrowserFrameViewLayout::kFrameBorderThickness +
...@@ -318,8 +317,7 @@ class OpaqueBrowserFrameViewLayoutTest : public views::ViewsTestBase { ...@@ -318,8 +317,7 @@ class OpaqueBrowserFrameViewLayoutTest : public views::ViewsTestBase {
restored_border_height += restored_border_height +=
OpaqueBrowserFrameViewLayout::kRefreshNonClientExtraTopThickness; OpaqueBrowserFrameViewLayout::kRefreshNonClientExtraTopThickness;
} }
int top_border_height = int top_border_height = maximized ? 0 : restored_border_height;
maximized ? maximized_top_border_height : restored_border_height;
int min_height = top_border_height + browser_view_min_size.height(); int min_height = top_border_height + browser_view_min_size.height();
EXPECT_EQ(min_height, min_size.height()); EXPECT_EQ(min_height, min_size.height());
} }
......
...@@ -455,7 +455,7 @@ void NewTabButton::PaintFill(bool pressed, ...@@ -455,7 +455,7 @@ void NewTabButton::PaintFill(bool pressed,
// For touch, the background matches the active tab background // For touch, the background matches the active tab background
// positioning in Tab::PaintTab(). // positioning in Tab::PaintTab().
const int offset_y = const int offset_y =
is_touch_ui ? -GetLayoutInsets(TAB).top() : non_touch_offset_y; is_touch_ui ? -Tab::GetStrokeHeight() : non_touch_offset_y;
// The new tab background is mirrored in RTL mode, but the theme // The new tab background is mirrored in RTL mode, but the theme
// background should never be mirrored. Mirror it here to compensate. // background should never be mirrored. Mirror it here to compensate.
float x_scale = 1.0f; float x_scale = 1.0f;
......
This diff is collapsed.
...@@ -187,6 +187,10 @@ class Tab : public gfx::AnimationDelegate, ...@@ -187,6 +187,10 @@ class Tab : public gfx::AnimationDelegate,
// Returns the width for pinned tabs. Pinned tabs always have this width. // Returns the width for pinned tabs. Pinned tabs always have this width.
static int GetPinnedWidth(); static int GetPinnedWidth();
// Returns the height of any area reserved for a stroke at the top and bottom
// of the tab, in DIP.
static int GetStrokeHeight();
// Returns the inverse of the slope of the diagonal portion of the tab outer // Returns the inverse of the slope of the diagonal portion of the tab outer
// border. (This is a positive value, so it's specifically for the slope of // border. (This is a positive value, so it's specifically for the slope of
// the leading edge.) // the leading edge.)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment