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) {
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:
return gfx::Insets(touch_optimized_material ? 12 : 6);
......
......@@ -107,9 +107,6 @@ enum LayoutInset {
// (e.g. does not highlight on hover).
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).
TOOLBAR_BUTTON,
......
......@@ -332,8 +332,8 @@ void BrowserNonClientFrameView::PaintToolbarBackground(
if (tp->HasCustomImage(IDR_THEME_TOOLBAR)) {
canvas->TileImageInt(*tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR),
x + GetThemeBackgroundXInset(),
y - GetTopInset(false) - GetLayoutInsets(TAB).top(), x,
y, w, toolbar_bounds.height());
y - GetTopInset(false) - Tab::GetStrokeHeight(), x, y,
w, toolbar_bounds.height());
} else {
canvas->FillRect(toolbar_bounds,
tp->GetColor(ThemeProperties::COLOR_TOOLBAR));
......
......@@ -513,19 +513,16 @@ int GlassBrowserFrameView::TopAreaHeight(bool restored) const {
if (frame()->IsFullscreen() && !restored)
return 0;
const int top = 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 (IsMaximized() && !restored)
return top - GetLayoutInsets(TAB).top() + 1;
// Besides the frame border, there's empty space atop the window in restored
// mode, to use to drag the window around.
constexpr int kNonClientRestoredExtraThickness = 11;
constexpr int kRefreshNonClientRestoredExtraThickness = 4;
return top + (MD::IsRefreshUi() ? kRefreshNonClientRestoredExtraThickness
: kNonClientRestoredExtraThickness);
int top = FrameTopBorderThickness(restored);
if (!IsMaximized() || restored) {
// Besides the frame border, there's empty space atop the window in restored
// mode, to use to drag the window around.
constexpr int kNonClientRestoredExtraThickness = 11;
constexpr int kRefreshNonClientRestoredExtraThickness = 4;
top += MD::IsRefreshUi() ? kRefreshNonClientRestoredExtraThickness
: kNonClientRestoredExtraThickness;
}
return top;
}
int GlassBrowserFrameView::TitlebarMaximizedVisualHeight() const {
......
......@@ -161,24 +161,17 @@ int OpaqueBrowserFrameViewLayout::NonClientBorderThickness() const {
}
int OpaqueBrowserFrameViewLayout::NonClientTopHeight(bool restored) const {
if (delegate_->ShouldShowWindowTitle()) {
// The + 2 here puts at least 1 px of space on top and bottom of the icon.
const int icon_height =
TitlebarTopThickness(restored) + delegate_->GetIconSize() + 2;
const int caption_button_height = DefaultCaptionButtonY(restored) +
kCaptionButtonHeight +
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;
if (!delegate_->ShouldShowWindowTitle())
return FrameTopBorderThickness(restored);
// The + 2 here puts at least 1 px of space on top and bottom of the icon.
const int icon_height =
TitlebarTopThickness(restored) + delegate_->GetIconSize() + 2;
const int caption_button_height = DefaultCaptionButtonY(restored) +
kCaptionButtonHeight +
kCaptionButtonBottomPadding;
return std::max(icon_height, caption_button_height) +
kContentEdgeShadowThickness;
}
int OpaqueBrowserFrameViewLayout::GetTabStripInsetsTop(bool restored) const {
......
......@@ -261,9 +261,8 @@ class OpaqueBrowserFrameViewLayoutTest : public views::ViewsTestBase {
gfx::Rect tabstrip_bounds(
layout_manager_->GetBoundsForTabStrip(tabstrip_min_size, kWindowWidth));
EXPECT_EQ(tabstrip_x, tabstrip_bounds.x());
int maximized_top_border_height = -GetLayoutInsets(TAB).top() + 1;
if (maximized) {
EXPECT_EQ(maximized_top_border_height, tabstrip_bounds.y());
EXPECT_EQ(0, tabstrip_bounds.y());
} else {
int tabstrip_nonexcluded_y =
OpaqueBrowserFrameViewLayout::kFrameBorderThickness +
......@@ -318,8 +317,7 @@ class OpaqueBrowserFrameViewLayoutTest : public views::ViewsTestBase {
restored_border_height +=
OpaqueBrowserFrameViewLayout::kRefreshNonClientExtraTopThickness;
}
int top_border_height =
maximized ? maximized_top_border_height : restored_border_height;
int top_border_height = maximized ? 0 : restored_border_height;
int min_height = top_border_height + browser_view_min_size.height();
EXPECT_EQ(min_height, min_size.height());
}
......
......@@ -455,7 +455,7 @@ void NewTabButton::PaintFill(bool pressed,
// For touch, the background matches the active tab background
// positioning in Tab::PaintTab().
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
// background should never be mirrored. Mirror it here to compensate.
float x_scale = 1.0f;
......
This diff is collapsed.
......@@ -187,6 +187,10 @@ class Tab : public gfx::AnimationDelegate,
// Returns the width for pinned tabs. Pinned tabs always have this width.
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
// border. (This is a positive value, so it's specifically for the slope of
// 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