summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Kasting <pkasting@chromium.org>2015-11-06 19:51:00 -0800
committerPeter Kasting <pkasting@chromium.org>2015-11-07 03:53:14 +0000
commit8788219e9968bb22f4b850e3c129419fddf3dd21 (patch)
treea2a5c723e3478b5eddc07b17ef22de8fdf7f1f6f
parent0f4c24aa707bbecc888e6c77ba03fec58ed011d1 (diff)
downloadchromium_src-8788219e9968bb22f4b850e3c129419fddf3dd21.zip
chromium_src-8788219e9968bb22f4b850e3c129419fddf3dd21.tar.gz
chromium_src-8788219e9968bb22f4b850e3c129419fddf3dd21.tar.bz2
Draw the same portion of the frame background behind the tabstrip in maximized
mode as in restored mode. Themes which tried to align the tab and frame images couldn't do so in both maximized and restored modes, since the alignment changed; so they had to pick one. This makes the alignment the same in both modes so that themes which looked correct in restored mode will now look correct in maximized mode as well. The other way to fix this -- make restored mode match maximized mode -- isn't possible, as that would put the top of the frame background image in the middle of the top section of the frame in restored windows, leaving nothing above it. This also means that for themes which chose to look correct in maximized mode and wrong in restored mode, they'll now look wrong all the time :(. BUG=none TEST=Apply the "Dots" theme from the webstore. The alignment of the tab and new tab button images against the frame background should be the same in maximized mode as in restored mode. R=sky@chromium.org Review URL: https://codereview.chromium.org/1412833008 . Cr-Commit-Position: refs/heads/master@{#358512}
-rw-r--r--chrome/browser/ui/views/frame/browser_frame.cc4
-rw-r--r--chrome/browser/ui/views/frame/browser_frame.h6
-rw-r--r--chrome/browser/ui/views/frame/browser_non_client_frame_view.h4
-rw-r--r--chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc22
-rw-r--r--chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h2
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc6
-rw-r--r--chrome/browser/ui/views/frame/browser_view_layout.cc17
-rw-r--r--chrome/browser/ui/views/frame/browser_view_layout_delegate.h2
-rw-r--r--chrome/browser/ui/views/frame/browser_view_layout_unittest.cc2
-rw-r--r--chrome/browser/ui/views/frame/browser_view_unittest.cc4
-rw-r--r--chrome/browser/ui/views/frame/glass_browser_frame_view.cc54
-rw-r--r--chrome/browser/ui/views/frame/glass_browser_frame_view.h25
-rw-r--r--chrome/browser/ui/views/frame/opaque_browser_frame_view.cc24
-rw-r--r--chrome/browser/ui/views/frame/opaque_browser_frame_view.h6
14 files changed, 93 insertions, 85 deletions
diff --git a/chrome/browser/ui/views/frame/browser_frame.cc b/chrome/browser/ui/views/frame/browser_frame.cc
index 16f7826..35bb565 100644
--- a/chrome/browser/ui/views/frame/browser_frame.cc
+++ b/chrome/browser/ui/views/frame/browser_frame.cc
@@ -102,8 +102,8 @@ gfx::Rect BrowserFrame::GetBoundsForTabStrip(views::View* tabstrip) const {
browser_frame_view_->GetBoundsForTabStrip(tabstrip) : gfx::Rect();
}
-int BrowserFrame::GetTopInset() const {
- return browser_frame_view_->GetTopInset();
+int BrowserFrame::GetTopInset(bool restored) const {
+ return browser_frame_view_->GetTopInset(restored);
}
int BrowserFrame::GetThemeBackgroundXInset() const {
diff --git a/chrome/browser/ui/views/frame/browser_frame.h b/chrome/browser/ui/views/frame/browser_frame.h
index f9984a8..721ba2c 100644
--- a/chrome/browser/ui/views/frame/browser_frame.h
+++ b/chrome/browser/ui/views/frame/browser_frame.h
@@ -63,8 +63,10 @@ class BrowserFrame
// Returns the inset of the topmost view in the client view from the top of
// the non-client view. The topmost view depends on the window type. The
// topmost view is the tab strip for tabbed browser windows, the toolbar for
- // popups, the web contents for app windows and varies for fullscreen windows
- int GetTopInset() const;
+ // popups, the web contents for app windows and varies for fullscreen windows.
+ // If |restored| is true, this is calculated as if the window was restored,
+ // regardless of its current state.
+ int GetTopInset(bool restored) const;
// Returns the amount that the theme background should be inset.
int GetThemeBackgroundXInset() const;
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view.h b/chrome/browser/ui/views/frame/browser_non_client_frame_view.h
index 9da2a5d..30abb5938 100644
--- a/chrome/browser/ui/views/frame/browser_non_client_frame_view.h
+++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view.h
@@ -49,7 +49,9 @@ class BrowserNonClientFrameView : public views::NonClientFrameView,
// the non-client view. The topmost view depends on the window type. The
// topmost view is the tab strip for tabbed browser windows, the toolbar for
// popups, the web contents for app windows and varies for fullscreen windows.
- virtual int GetTopInset() const = 0;
+ // If |restored| is true, this is calculated as if the window was restored,
+ // regardless of its current state.
+ virtual int GetTopInset(bool restored) const = 0;
// Returns the amount that the theme background should be inset.
virtual int GetThemeBackgroundXInset() const = 0;
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc
index 444aad2..cc6a6bc 100644
--- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc
+++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc
@@ -166,17 +166,17 @@ gfx::Rect BrowserNonClientFrameViewAsh::GetBoundsForTabStrip(
int left_inset = GetTabStripLeftInset();
int right_inset = GetTabStripRightInset();
return gfx::Rect(left_inset,
- GetTopInset(),
+ GetTopInset(false),
std::max(0, width() - left_inset - right_inset),
tabstrip->GetPreferredSize().height());
}
-int BrowserNonClientFrameViewAsh::GetTopInset() const {
+int BrowserNonClientFrameViewAsh::GetTopInset(bool restored) const {
if (!ShouldPaint() || UseImmersiveLightbarHeaderStyle())
return 0;
if (browser_view()->IsTabStripVisible()) {
- return (frame()->IsMaximized() || frame()->IsFullscreen()) ?
+ return ((frame()->IsMaximized() || frame()->IsFullscreen()) && !restored) ?
kTabstripTopSpacingShort : kTabstripTopSpacingTall;
}
@@ -332,14 +332,14 @@ void BrowserNonClientFrameViewAsh::Layout() {
int painted_height = 0;
if (browser_view()->IsTabStripVisible()) {
- painted_height = GetTopInset() +
+ painted_height = GetTopInset(false) +
browser_view()->tabstrip()->GetPreferredSize().height();
} else if (browser_view()->IsToolbarVisible()) {
// Paint the header so that it overlaps with the top few pixels of the
// toolbar because the top few pixels of the toolbar are not opaque.
- painted_height = GetTopInset() + kFrameShadowThickness * 2;
+ painted_height = GetTopInset(false) + kFrameShadowThickness * 2;
} else {
- painted_height = GetTopInset();
+ painted_height = GetTopInset(false);
}
header_painter_->SetHeaderHeightForPainting(painted_height);
@@ -491,7 +491,7 @@ bool BrowserNonClientFrameViewAsh::DoesIntersectRect(
}
// Claim |rect| if it is above the top of the topmost view in the client area.
- return rect.y() < GetTopInset();
+ return rect.y() < GetTopInset(false);
}
int BrowserNonClientFrameViewAsh::GetTabStripLeftInset() const {
@@ -547,13 +547,13 @@ void BrowserNonClientFrameViewAsh::LayoutAvatar() {
#endif
gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon();
gfx::Insets avatar_insets = GetLayoutInsets(AVATAR_ICON);
- int avatar_bottom = GetTopInset() + browser_view()->GetTabStripHeight() -
+ int avatar_bottom = GetTopInset(false) + browser_view()->GetTabStripHeight() -
avatar_insets.bottom();
int avatar_y = avatar_bottom - incognito_icon.height();
if (!ui::MaterialDesignController::IsModeMaterial() &&
browser_view()->IsTabStripVisible() &&
(frame()->IsMaximized() || frame()->IsFullscreen())) {
- avatar_y = GetTopInset() + kContentShadowHeight;
+ avatar_y = GetTopInset(false) + kContentShadowHeight;
}
// Hide the incognito icon in immersive fullscreen when the tab light bar is
@@ -631,7 +631,7 @@ void BrowserNonClientFrameViewAsh::PaintToolbarBackground(gfx::Canvas* canvas) {
canvas->TileImageInt(
*theme_toolbar,
x + GetThemeBackgroundXInset(),
- y - GetTopInset(),
+ y - GetTopInset(false),
x, y,
w, theme_toolbar->height());
@@ -665,7 +665,7 @@ void BrowserNonClientFrameViewAsh::PaintToolbarBackground(gfx::Canvas* canvas) {
canvas->TileImageInt(
*theme_toolbar,
x + GetThemeBackgroundXInset(),
- bottom_y - GetTopInset(),
+ bottom_y - GetTopInset(false),
x, bottom_y,
w, theme_toolbar->height());
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h
index 708ada0..0361acd 100644
--- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h
+++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h
@@ -41,7 +41,7 @@ class BrowserNonClientFrameViewAsh : public BrowserNonClientFrameView,
// BrowserNonClientFrameView:
gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const override;
- int GetTopInset() const override;
+ int GetTopInset(bool restored) const override;
int GetThemeBackgroundXInset() const override;
void UpdateThrobber(bool running) override;
void UpdateToolbar() override;
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index e6665e7..b9183f5 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -335,8 +335,8 @@ class BrowserViewLayoutDelegateImpl : public BrowserViewLayoutDelegate {
return gfx::ToEnclosingRect(bounds_f);
}
- int GetTopInsetInBrowserView() const override {
- return browser_view_->frame()->GetTopInset() -
+ int GetTopInsetInBrowserView(bool restored) const override {
+ return browser_view_->frame()->GetTopInset(restored) -
browser_view_->y();
}
@@ -594,7 +594,7 @@ gfx::Point BrowserView::OffsetPointForToolbarBackgroundImage(
// be). We expect our parent's origin to be the window origin.
gfx::Point window_point(point + GetMirroredPosition().OffsetFromOrigin());
window_point.Offset(frame_->GetThemeBackgroundXInset(),
- -frame_->GetTopInset());
+ -frame_->GetTopInset(false));
return window_point;
}
diff --git a/chrome/browser/ui/views/frame/browser_view_layout.cc b/chrome/browser/ui/views/frame/browser_view_layout.cc
index 25e1df6..2535853 100644
--- a/chrome/browser/ui/views/frame/browser_view_layout.cc
+++ b/chrome/browser/ui/views/frame/browser_view_layout.cc
@@ -186,7 +186,7 @@ gfx::Size BrowserViewLayout::GetMinimumSize() {
gfx::Size contents_size(contents_container_->GetMinimumSize());
- int min_height = delegate_->GetTopInsetInBrowserView() +
+ int min_height = delegate_->GetTopInsetInBrowserView(false) +
tabstrip_size.height() + toolbar_size.height() +
bookmark_bar_size.height() + infobar_container_size.height() +
contents_size.height();
@@ -318,13 +318,22 @@ int BrowserViewLayout::NonClientHitTest(const gfx::Point& point) {
void BrowserViewLayout::Layout(views::View* browser_view) {
vertical_layout_rect_ = browser_view->GetLocalBounds();
- int top = delegate_->GetTopInsetInBrowserView();
+ int top = delegate_->GetTopInsetInBrowserView(false);
top = LayoutTabStripRegion(top);
if (delegate_->IsTabStripVisible()) {
+ // Set the position of the background image in tabs and the new tab button.
int x = tab_strip_->GetMirroredX() +
browser_view_->GetMirroredX() +
delegate_->GetThemeBackgroundXInset();
- int y = browser_view_->y() + delegate_->GetTopInsetInBrowserView();
+ // By passing true here, we position the tab background to vertically align
+ // with the frame background image of a restored-mode frame, even in a
+ // maximized window. Then in the frame code, we position the frame so the
+ // portion of the image that's behind the restored-mode tabstrip is always
+ // behind the tabstrip. Together these ensure that the tab and frame images
+ // are always aligned, and that their relative alignment with the toolbar
+ // image is always the same, so themes which try to align all three will
+ // look correct in both restored and maximized windows.
+ int y = browser_view_->y() + delegate_->GetTopInsetInBrowserView(true);
tab_strip_->SetBackgroundOffset(gfx::Point(x, y));
}
top = LayoutToolbar(top);
@@ -499,7 +508,7 @@ void BrowserViewLayout::UpdateTopContainerBounds() {
// Ensure that the top container view reaches the topmost view in the
// ClientView because the bounds of the top container view are used in
// layout and we assume that this is the case.
- height = std::max(height, delegate_->GetTopInsetInBrowserView());
+ height = std::max(height, delegate_->GetTopInsetInBrowserView(false));
gfx::Rect top_container_bounds(vertical_layout_rect_.width(), height);
diff --git a/chrome/browser/ui/views/frame/browser_view_layout_delegate.h b/chrome/browser/ui/views/frame/browser_view_layout_delegate.h
index 5c01a53..abbded5 100644
--- a/chrome/browser/ui/views/frame/browser_view_layout_delegate.h
+++ b/chrome/browser/ui/views/frame/browser_view_layout_delegate.h
@@ -23,7 +23,7 @@ class BrowserViewLayoutDelegate {
virtual views::View* GetContentsWebView() const = 0;
virtual bool IsTabStripVisible() const = 0;
virtual gfx::Rect GetBoundsForTabStripInBrowserView() const = 0;
- virtual int GetTopInsetInBrowserView() const = 0;
+ virtual int GetTopInsetInBrowserView(bool restored) const = 0;
virtual int GetThemeBackgroundXInset() const = 0;
virtual bool IsToolbarVisible() const = 0;
virtual bool IsBookmarkBarVisible() const = 0;
diff --git a/chrome/browser/ui/views/frame/browser_view_layout_unittest.cc b/chrome/browser/ui/views/frame/browser_view_layout_unittest.cc
index 87dd583..5befe13 100644
--- a/chrome/browser/ui/views/frame/browser_view_layout_unittest.cc
+++ b/chrome/browser/ui/views/frame/browser_view_layout_unittest.cc
@@ -45,7 +45,7 @@ class MockBrowserViewLayoutDelegate : public BrowserViewLayoutDelegate {
gfx::Rect GetBoundsForTabStripInBrowserView() const override {
return gfx::Rect();
}
- int GetTopInsetInBrowserView() const override { return 0; }
+ int GetTopInsetInBrowserView(bool restored) const override { return 0; }
int GetThemeBackgroundXInset() const override { return 0; }
bool IsToolbarVisible() const override { return toolbar_visible_; }
bool IsBookmarkBarVisible() const override { return bookmark_bar_visible_; }
diff --git a/chrome/browser/ui/views/frame/browser_view_unittest.cc b/chrome/browser/ui/views/frame/browser_view_unittest.cc
index 23f3e7d..1d31c65 100644
--- a/chrome/browser/ui/views/frame/browser_view_unittest.cc
+++ b/chrome/browser/ui/views/frame/browser_view_unittest.cc
@@ -193,7 +193,7 @@ TEST_F(BrowserViewHostedAppTest, Layout) {
// The position of the bottom of the header (the bar with the window
// controls) in the coordinates of BrowserView.
- int bottom_of_header = browser_view()->frame()->GetTopInset() -
+ int bottom_of_header = browser_view()->frame()->GetTopInset(false) -
header_offset.y();
// The web contents should be flush with the bottom of the header.
@@ -202,5 +202,5 @@ TEST_F(BrowserViewHostedAppTest, Layout) {
// The find bar should overlap the 1px header/web-contents separator at the
// bottom of the header.
EXPECT_LT(browser_view()->GetFindBarBoundingBox().y(),
- browser_view()->frame()->GetTopInset());
+ browser_view()->frame()->GetTopInset(false));
}
diff --git a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc
index c4a9c0d..d5cbd78 100644
--- a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc
+++ b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc
@@ -105,7 +105,7 @@ gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip(
!frame()->IsMaximized()) ?
GetLayoutInsets(AVATAR_ICON).right() : 0;
const int x = incognito_bounds_.right() + offset;
- int end_x = width() - NonClientBorderThickness();
+ int end_x = width() - NonClientBorderThickness(false);
if (!base::i18n::IsRTL()) {
end_x = std::min(frame()->GetMinimizeButtonOffset(), end_x) -
(frame()->IsMaximized() ?
@@ -126,12 +126,12 @@ gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip(
}
}
}
- return gfx::Rect(x, NonClientTopBorderHeight(), std::max(0, end_x - x),
+ return gfx::Rect(x, NonClientTopBorderHeight(false), std::max(0, end_x - x),
tabstrip->GetPreferredSize().height());
}
-int GlassBrowserFrameView::GetTopInset() const {
- return GetClientAreaInsets().top();
+int GlassBrowserFrameView::GetTopInset(bool restored) const {
+ return GetClientAreaInsets(restored).top();
}
int GlassBrowserFrameView::GetThemeBackgroundXInset() const {
@@ -154,7 +154,7 @@ gfx::Size GlassBrowserFrameView::GetMinimumSize() const {
gfx::Size min_size(browser_view()->GetMinimumSize());
// Account for the client area insets.
- gfx::Insets insets = GetClientAreaInsets();
+ gfx::Insets insets = GetClientAreaInsets(false);
min_size.Enlarge(insets.width(), insets.height());
// Client area insets do not include the shadow thickness.
min_size.Enlarge(2 * kContentEdgeShadowThickness, 0);
@@ -193,7 +193,7 @@ gfx::Rect GlassBrowserFrameView::GetWindowBoundsForClientBounds(
return gfx::Rect(rect);
}
- gfx::Insets insets = GetClientAreaInsets();
+ gfx::Insets insets = GetClientAreaInsets(false);
return gfx::Rect(std::max(0, client_bounds.x() - insets.left()),
std::max(0, client_bounds.y() - insets.top()),
client_bounds.width() + insets.width(),
@@ -219,7 +219,7 @@ int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
// See if we're in the sysmenu region. We still have to check the tabstrip
// first so that clicks in a tab don't get treated as sysmenu clicks.
- int nonclient_border_thickness = NonClientBorderThickness();
+ int nonclient_border_thickness = NonClientBorderThickness(false);
if (gfx::Rect(nonclient_border_thickness,
gfx::win::GetSystemMetricsInDIP(SM_CYSIZEFRAME),
gfx::win::GetSystemMetricsInDIP(SM_CXSMICON),
@@ -229,7 +229,7 @@ int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
if (frame_component != HTNOWHERE)
return frame_component;
- int frame_top_border_height = FrameTopBorderHeight();
+ int frame_top_border_height = FrameTopBorderHeight(false);
// We want the resize corner behavior to apply to the kResizeCornerWidth
// pixels at each end of the top and bottom edges. Because |point|'s x
// coordinate is based on the DWM-inset portion of the window (so, it's 0 at
@@ -307,16 +307,16 @@ int GlassBrowserFrameView::FrameBorderThickness() const {
0 : gfx::win::GetSystemMetricsInDIP(SM_CXSIZEFRAME);
}
-int GlassBrowserFrameView::FrameTopBorderHeight() const {
+int GlassBrowserFrameView::FrameTopBorderHeight(bool restored) const {
// We'd like to use FrameBorderThickness() here, but the maximized Aero glass
// frame has a 0 frame border around most edges and a CYSIZEFRAME-thick border
// at the top (see AeroGlassFrame::OnGetMinMaxInfo()).
- return frame()->IsFullscreen() ?
+ return (frame()->IsFullscreen() && !restored) ?
0 : gfx::win::GetSystemMetricsInDIP(SM_CYSIZEFRAME);
}
-int GlassBrowserFrameView::NonClientBorderThickness() const {
- if (frame()->IsMaximized() || frame()->IsFullscreen())
+int GlassBrowserFrameView::NonClientBorderThickness(bool restored) const {
+ if ((frame()->IsMaximized() || frame()->IsFullscreen()) && !restored)
return 0;
return (base::win::GetVersion() <= base::win::VERSION_WIN8_1)
@@ -324,11 +324,11 @@ int GlassBrowserFrameView::NonClientBorderThickness() const {
: kNonClientBorderThicknessWin10;
}
-int GlassBrowserFrameView::NonClientTopBorderHeight() const {
- if (frame()->IsFullscreen())
+int GlassBrowserFrameView::NonClientTopBorderHeight(bool restored) const {
+ if (frame()->IsFullscreen() && !restored)
return 0;
- const int top = FrameTopBorderHeight();
+ const int top = FrameTopBorderHeight(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.
@@ -337,7 +337,7 @@ int GlassBrowserFrameView::NonClientTopBorderHeight() const {
// so that the region above the tab's hit-test zone matches) versus the shadow
// thickness.
const int exclusion = GetLayoutConstant(TAB_TOP_EXCLUSION_HEIGHT);
- return frame()->IsMaximized() ?
+ return (frame()->IsMaximized() && !restored) ?
(top - GetLayoutInsets(TAB).top() + 1) :
(top + kNonClientRestoredExtraThickness - exclusion);
}
@@ -367,7 +367,7 @@ void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
dest_y += kPreMDToolbarTopEdgeExclusion;
canvas->TileImageInt(
*theme_toolbar, x + GetThemeBackgroundXInset(),
- dest_y - GetTopInset() + Tab::GetYOffsetForActiveTabBackground(),
+ dest_y - GetTopInset(false) + Tab::GetYOffsetForActiveTabBackground(),
x, dest_y, w, theme_toolbar->height());
// Toolbar edges.
@@ -437,7 +437,7 @@ void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
browser_view()->GetToolbarBounds().y() +
tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height();
int client_area_bottom =
- std::max(client_area_top, height() - NonClientBorderThickness());
+ std::max(client_area_top, height() - NonClientBorderThickness(false));
int client_area_height = client_area_bottom - client_area_top;
// Draw the client edge images.
@@ -502,7 +502,7 @@ void GlassBrowserFrameView::LayoutNewStyleAvatar() {
// To match both of these, we size the button as if it's always the extra one
// pixel in height, then we place it at the correct position in restored mode,
// or one pixel above the top of the screen in maximized mode.
- int button_y = frame()->IsMaximized() ? (FrameTopBorderHeight() - 1) : 1;
+ int button_y = frame()->IsMaximized() ? (FrameTopBorderHeight(false) - 1) : 1;
new_avatar_button()->SetBounds(
button_x,
button_y,
@@ -521,18 +521,18 @@ void GlassBrowserFrameView::LayoutIncognitoIcon() {
// another layout call after the browser view has a widget anyway.
if (browser_view()->GetWidget())
size = browser_view()->GetOTRAvatarIcon().size();
- int x = NonClientBorderThickness();
+ int x = NonClientBorderThickness(false);
// In RTL, the icon needs to start after the caption buttons.
if (base::i18n::IsRTL()) {
x = width() - frame()->GetMinimizeButtonOffset() +
(new_avatar_button() ?
(new_avatar_button()->width() + kNewAvatarButtonOffset) : 0);
}
- const int bottom =
- GetTopInset() + browser_view()->GetTabStripHeight() - insets.bottom();
+ const int bottom = GetTopInset(false) + browser_view()->GetTabStripHeight() -
+ insets.bottom();
const int y = (ui::MaterialDesignController::IsModeMaterial() ||
!frame()->IsMaximized()) ?
- (bottom - size.height()) : FrameTopBorderHeight();
+ (bottom - size.height()) : FrameTopBorderHeight(false);
incognito_bounds_.SetRect(x + (avatar_button() ? insets.left() : 0), y,
avatar_button() ? size.width() : 0, bottom - y);
if (avatar_button())
@@ -543,12 +543,12 @@ void GlassBrowserFrameView::LayoutClientView() {
client_view_bounds_ = CalculateClientAreaBounds(width(), height());
}
-gfx::Insets GlassBrowserFrameView::GetClientAreaInsets() const {
+gfx::Insets GlassBrowserFrameView::GetClientAreaInsets(bool restored) const {
if (!browser_view()->IsTabStripVisible())
return gfx::Insets();
- const int top_height = NonClientTopBorderHeight();
- const int border_thickness = NonClientBorderThickness();
+ const int top_height = NonClientTopBorderHeight(restored);
+ const int border_thickness = NonClientBorderThickness(restored);
return gfx::Insets(top_height,
border_thickness,
border_thickness,
@@ -558,7 +558,7 @@ gfx::Insets GlassBrowserFrameView::GetClientAreaInsets() const {
gfx::Rect GlassBrowserFrameView::CalculateClientAreaBounds(int width,
int height) const {
gfx::Rect bounds(0, 0, width, height);
- bounds.Inset(GetClientAreaInsets());
+ bounds.Inset(GetClientAreaInsets(false));
return bounds;
}
diff --git a/chrome/browser/ui/views/frame/glass_browser_frame_view.h b/chrome/browser/ui/views/frame/glass_browser_frame_view.h
index 21871be..0bf9fa5 100644
--- a/chrome/browser/ui/views/frame/glass_browser_frame_view.h
+++ b/chrome/browser/ui/views/frame/glass_browser_frame_view.h
@@ -21,7 +21,7 @@ class GlassBrowserFrameView : public BrowserNonClientFrameView,
// BrowserNonClientFrameView:
gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const override;
- int GetTopInset() const override;
+ int GetTopInset(bool restored) const override;
int GetThemeBackgroundXInset() const override;
void UpdateThrobber(bool running) override;
gfx::Size GetMinimumSize() const override;
@@ -57,16 +57,22 @@ class GlassBrowserFrameView : public BrowserNonClientFrameView,
// and bottom frame edges. This does not include any client edge.
int FrameBorderThickness() const;
- // Returns the height of the window top frame edge.
- int FrameTopBorderHeight() const;
+ // Returns the height of the window top frame edge. If |restored| is true,
+ // this is calculated as if the window was restored, regardless of its current
+ // state.
+ int FrameTopBorderHeight(bool restored) const;
// Returns the thickness of the entire nonclient left, right, and bottom
- // borders, including both the window frame and any client edge.
- int NonClientBorderThickness() const;
+ // borders, including both the window frame and any client edge. If |restored|
+ // is true, this is calculated as if the window was restored, regardless of
+ // its current state.
+ int NonClientBorderThickness(bool restored) const;
// Returns the height of the entire nonclient top border, including the window
- // frame, any title area, and any connected client edge.
- int NonClientTopBorderHeight() const;
+ // frame, any title area, and any connected client edge. If |restored| is
+ // true, this is calculated as if the window was restored, regardless of its
+ // current state.
+ int NonClientTopBorderHeight(bool restored) const;
// Paint various sub-components of this view.
void PaintToolbarBackground(gfx::Canvas* canvas);
@@ -77,8 +83,9 @@ class GlassBrowserFrameView : public BrowserNonClientFrameView,
void LayoutNewStyleAvatar();
void LayoutClientView();
- // Returns the insets of the client area.
- gfx::Insets GetClientAreaInsets() const;
+ // Returns the insets of the client area. If |restored| is true, this is
+ // calculated as if the window was restored, regardless of its current state.
+ gfx::Insets GetClientAreaInsets(bool restored) const;
// Returns the bounds of the client area for the specified view size.
gfx::Rect CalculateClientAreaBounds(int width, int height) const;
diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
index daa3b3a..d9a744a 100644
--- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
+++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
@@ -82,12 +82,6 @@ const int kContentEdgeShadowThickness = 2;
const int kIconMinimumSize = 16;
#endif
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
-// The number of pixels to move the frame background image upwards when using
-// the GTK+ theme and the titlebar is condensed.
-const int kGTKThemeCondensedFrameTopInset = 15;
-#endif
-
} // namespace
///////////////////////////////////////////////////////////////////////////////
@@ -170,10 +164,10 @@ gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip(
return layout_->GetBoundsForTabStrip(tabstrip->GetPreferredSize(), width());
}
-int OpaqueBrowserFrameView::GetTopInset() const {
+int OpaqueBrowserFrameView::GetTopInset(bool restored) const {
return browser_view()->IsTabStripVisible() ?
- layout_->GetTabStripInsetsTop(false) :
- layout_->NonClientTopBorderHeight(false);
+ layout_->GetTabStripInsetsTop(restored) :
+ layout_->NonClientTopBorderHeight(restored);
}
int OpaqueBrowserFrameView::GetThemeBackgroundXInset() const {
@@ -626,14 +620,8 @@ void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
frame_background_->set_theme_image(GetFrameImage());
frame_background_->set_theme_overlay_image(GetFrameOverlayImage());
frame_background_->set_top_area_height(GetTopAreaHeight());
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
- // The window manager typically shows a gradient in the native title bar (when
- // the system title bar pref is set, or when maximized on Ubuntu). Hide the
- // gradient in the tab strip (by shifting it up vertically) to avoid a
- // double-gradient effect.
- if (tp->UsingSystemTheme())
- frame_background_->set_maximized_top_inset(kGTKThemeCondensedFrameTopInset);
-#endif
+ frame_background_->set_maximized_top_inset(
+ GetTopInset(true) - GetTopInset(false));
frame_background_->PaintMaximized(canvas, this);
@@ -688,7 +676,7 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
gfx::ImageSkia* theme_toolbar = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR);
canvas->TileImageInt(
*theme_toolbar, x + GetThemeBackgroundXInset(),
- bottom_y - GetTopInset() + Tab::GetYOffsetForActiveTabBackground(),
+ bottom_y - GetTopInset(false) + Tab::GetYOffsetForActiveTabBackground(),
x, bottom_y, w, theme_toolbar->height());
// Draw rounded corners for the tab.
diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.h b/chrome/browser/ui/views/frame/opaque_browser_frame_view.h
index e105486..83647be1 100644
--- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.h
+++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.h
@@ -39,7 +39,7 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
// BrowserNonClientFrameView:
gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const override;
- int GetTopInset() const override;
+ int GetTopInset(bool restored) const override;
int GetThemeBackgroundXInset() const override;
void UpdateThrobber(bool running) override;
gfx::Size GetMinimumSize() const override;
@@ -114,8 +114,8 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
ViewID view_id);
// Returns the thickness of the border that makes up the window frame edges.
- // This does not include any client edge. If |restored| is true, acts as if
- // the window is restored regardless of the real mode.
+ // This does not include any client edge. If |restored| is true, this is
+ // calculated as if the window was restored, regardless of its current state.
int FrameBorderThickness(bool restored) const;
// Returns the height of the top resize area. This is smaller than the frame