Commit 5e35d8a8 authored by Peter Boström's avatar Peter Boström Committed by Commit Bot

Remove content border for opaque frame in Refresh

Under Refresh there's no top border drawn by the tabstrip. As such the
three other strokes that form the content border look cut off and out of
place. This change removes them when Refresh is turned on.

Bug: chromium:848549
Change-Id: If77903b5b275f6d0deee6d22d88a3725885137f2
Reviewed-on: https://chromium-review.googlesource.com/1132543
Commit-Queue: Peter Boström <pbos@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576355}
parent 7a734fb2
......@@ -98,6 +98,10 @@ bool BrowserNonClientFrameView::ShouldHideTopUIForFullscreen() const {
return frame()->IsFullscreen();
}
bool BrowserNonClientFrameView::HasClientEdge() const {
return !MD::IsRefreshUi();
}
gfx::ImageSkia BrowserNonClientFrameView::GetIncognitoAvatarIcon() const {
const SkColor icon_color = color_utils::PickContrastingColor(
SK_ColorWHITE, gfx::kChromeIconGrey, GetFrameColor());
......
......@@ -75,6 +75,9 @@ class BrowserNonClientFrameView : public views::NonClientFrameView,
// Returns whether the top UI should hide.
virtual bool ShouldHideTopUIForFullscreen() const;
// Returns whether the content is painted with a client edge or not.
virtual bool HasClientEdge() const;
// Retrieves the icon to use in the frame to indicate an incognito window.
gfx::ImageSkia GetIncognitoAvatarIcon() const;
......
......@@ -500,7 +500,8 @@ gfx::Rect BrowserView::GetToolbarBounds() const {
if (toolbar_bounds.IsEmpty())
return toolbar_bounds;
// The apparent toolbar edges are outside the "real" toolbar edges.
toolbar_bounds.Inset(-views::NonClientFrameView::kClientEdgeThickness, 0);
if (HasClientEdge())
toolbar_bounds.Inset(-views::NonClientFrameView::kClientEdgeThickness, 0);
return toolbar_bounds;
}
......@@ -555,12 +556,7 @@ bool BrowserView::IsRegularOrGuestSession() const {
}
bool BrowserView::HasClientEdge() const {
#if defined(OS_WIN)
return base::win::GetVersion() < base::win::VERSION_WIN10 ||
!frame_->ShouldUseNativeFrame();
#else
return true;
#endif
return frame()->GetFrameView()->HasClientEdge();
}
bool BrowserView::GetAccelerator(int cmd_id,
......
......@@ -166,6 +166,12 @@ int GlassBrowserFrameView::GetThemeBackgroundXInset() const {
return 0;
}
bool GlassBrowserFrameView::HasClientEdge() const {
// Native Windows 10 should never paint a client edge.
return base::win::GetVersion() < base::win::VERSION_WIN10 &&
BrowserNonClientFrameView::HasClientEdge();
}
void GlassBrowserFrameView::UpdateThrobber(bool running) {
if (ShowCustomIcon())
window_icon_->Update();
......@@ -502,7 +508,7 @@ void GlassBrowserFrameView::ActivationChanged(bool active) {
int GlassBrowserFrameView::ClientBorderThickness(bool restored) const {
// The frame ends abruptly at the 1 pixel window border drawn by Windows 10.
if (!browser_view()->HasClientEdge())
if (!HasClientEdge())
return 0;
if ((IsMaximized() || frame()->IsFullscreen()) && !restored)
......
......@@ -38,6 +38,7 @@ class GlassBrowserFrameView : public BrowserNonClientFrameView,
gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const override;
int GetTopInset(bool restored) const override;
int GetThemeBackgroundXInset() const override;
bool HasClientEdge() const override;
void UpdateThrobber(bool running) override;
gfx::Size GetMinimumSize() const override;
int GetTabStripLeftInset() const override;
......
......@@ -421,6 +421,10 @@ bool OpaqueBrowserFrameView::IsTabStripVisible() const {
return browser_view()->IsTabStripVisible();
}
bool OpaqueBrowserFrameView::HasClientEdge() const {
return layout_->HasClientEdge();
}
bool OpaqueBrowserFrameView::IsToolbarVisible() const {
return browser_view()->IsToolbarVisible() &&
!browser_view()->toolbar()->GetPreferredSize().IsEmpty();
......@@ -599,7 +603,9 @@ void OpaqueBrowserFrameView::PaintClientEdge(gfx::Canvas* canvas) const {
const int w = client_bounds.width();
// If the toolbar isn't going to draw a top edge for us, draw one ourselves.
if (!tabstrip_visible) {
client_bounds.Inset(-kClientEdgeThickness, -1, -kClientEdgeThickness,
const int edge_thickness =
browser_view()->HasClientEdge() ? kClientEdgeThickness : 0;
client_bounds.Inset(-edge_thickness, -1, -edge_thickness,
client_bounds.height());
BrowserView::Paint1pxHorizontalLine(canvas, GetToolbarTopSeparatorColor(),
client_bounds, true);
......@@ -625,24 +631,26 @@ void OpaqueBrowserFrameView::PaintClientEdge(gfx::Canvas* canvas) const {
ThemeProperties::COLOR_TOOLBAR, incognito);
}
// Draw the client edges.
const gfx::ImageSkia* const right_image =
tp->GetImageSkiaNamed(IDR_CONTENT_RIGHT_SIDE);
const int img_w = right_image->width();
const int right = client_bounds.right();
const int bottom = std::max(y, height() - NonClientBorderThickness());
const int height = bottom - y;
canvas->TileImageInt(*right_image, right, y, img_w, height);
canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER),
right, bottom);
const gfx::ImageSkia* const bottom_image =
tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_CENTER);
canvas->TileImageInt(*bottom_image, x, bottom, w, bottom_image->height());
canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER),
x - img_w, bottom);
canvas->TileImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_LEFT_SIDE), x - img_w,
y, img_w, height);
FillClientEdgeRects(x, y, w, height, true, toolbar_color, canvas);
if (browser_view()->HasClientEdge()) {
// Draw the client edges.
const gfx::ImageSkia* const right_image =
tp->GetImageSkiaNamed(IDR_CONTENT_RIGHT_SIDE);
const int img_w = right_image->width();
const int right = client_bounds.right();
const int bottom = std::max(y, height() - NonClientBorderThickness());
const int height = bottom - y;
canvas->TileImageInt(*right_image, right, y, img_w, height);
canvas->DrawImageInt(
*tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER), right, bottom);
const gfx::ImageSkia* const bottom_image =
tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_CENTER);
canvas->TileImageInt(*bottom_image, x, bottom, w, bottom_image->height());
canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER),
x - img_w, bottom);
canvas->TileImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_LEFT_SIDE),
x - img_w, y, img_w, height);
FillClientEdgeRects(x, y, w, height, true, toolbar_color, canvas);
}
// For popup windows, draw location bar sides.
SkColor location_bar_border_color =
......
......@@ -68,6 +68,7 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
void UpdateWindowTitle() override;
void SizeConstraintsChanged() override;
void ActivationChanged(bool active) override;
bool HasClientEdge() const override;
// views::View:
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
......
......@@ -152,11 +152,17 @@ int OpaqueBrowserFrameViewLayout::FrameTopBorderThickness(bool restored) const {
return thickness;
}
bool OpaqueBrowserFrameViewLayout::HasClientEdge() const {
return !MD::IsRefreshUi();
}
int OpaqueBrowserFrameViewLayout::NonClientBorderThickness() const {
const int frame = FrameBorderThickness(false);
// When we fill the screen, we don't show a client edge.
return (IsTitleBarCondensed() || delegate_->IsFullscreen()) ?
frame : (frame + views::NonClientFrameView::kClientEdgeThickness);
return (!HasClientEdge() || IsTitleBarCondensed() ||
delegate_->IsFullscreen())
? frame
: (frame + views::NonClientFrameView::kClientEdgeThickness);
}
int OpaqueBrowserFrameViewLayout::NonClientTopHeight(bool restored) const {
......
......@@ -144,6 +144,8 @@ class OpaqueBrowserFrameViewLayout : public views::LayoutManager {
// is dependent on whether in material refresh mode or not.
static int GetNonClientRestoredExtraThickness();
bool HasClientEdge() const;
protected:
// Whether a specific button should be inserted on the leading or trailing
// side.
......
......@@ -21,12 +21,11 @@
#include "ui/views/controls/button/menu_button.h"
#include "ui/views/controls/label.h"
using MD = ui::MaterialDesignController;
namespace {
const int kWindowWidth = 500;
const int kNonClientBorderThickness =
OpaqueBrowserFrameViewLayout::kFrameBorderThickness +
views::NonClientFrameView::kClientEdgeThickness;
const int kMinimizeButtonWidth = 26;
const int kMaximizeButtonWidth = 25;
const int kCloseButtonWidth = 43;
......@@ -37,6 +36,12 @@ const int kCaptionButtonsWidth =
kMinimizeButtonWidth + kMaximizeButtonWidth + kCloseButtonWidth;
const int kCaptionButtonHeight = 18;
int NonClientBorderThickness() {
return OpaqueBrowserFrameViewLayout::kFrameBorderThickness +
(MD::IsRefreshUi() ? 0
: views::NonClientFrameView::kClientEdgeThickness);
}
class TestLayoutDelegate : public OpaqueBrowserFrameViewLayoutDelegate {
public:
TestLayoutDelegate() : show_caption_buttons_(true), maximized_(false) {}
......@@ -239,7 +244,6 @@ class OpaqueBrowserFrameViewLayoutTest : public ChromeViewsTestBase {
}
void ExpectTabStripAndMinimumSize(bool caption_buttons_on_left) {
using MD = ui::MaterialDesignController;
int caption_buttons_width = kCaptionButtonsWidth;
bool show_caption_buttons = delegate_->ShouldShowCaptionButtons();
bool maximized = delegate_->IsMaximized() || !show_caption_buttons;
......@@ -256,7 +260,7 @@ class OpaqueBrowserFrameViewLayoutTest : public ChromeViewsTestBase {
: OpaqueBrowserFrameViewLayout::kFrameBorderThickness;
tabstrip_x += caption_buttons_width + right_of_close;
} else if (!maximized) {
tabstrip_x += kNonClientBorderThickness;
tabstrip_x += NonClientBorderThickness();
}
gfx::Size tabstrip_min_size(delegate_->GetTabstripPreferredSize());
gfx::Rect tabstrip_bounds(
......@@ -282,7 +286,7 @@ class OpaqueBrowserFrameViewLayoutTest : public ChromeViewsTestBase {
showing_caption_buttons_on_right ? kMaximizedExtraCloseWidth : 0;
int restored_spacing =
(caption_buttons_on_left
? kNonClientBorderThickness
? NonClientBorderThickness()
: OpaqueBrowserFrameViewLayout::kFrameBorderThickness);
if (!MD::IsRefreshUi()) {
maximized_spacing +=
......@@ -297,7 +301,7 @@ class OpaqueBrowserFrameViewLayoutTest : public ChromeViewsTestBase {
EXPECT_EQ(tabstrip_width, tabstrip_bounds.width());
EXPECT_EQ(tabstrip_min_size.height(), tabstrip_bounds.height());
maximized_spacing = 0;
restored_spacing = 2 * kNonClientBorderThickness;
restored_spacing = 2 * NonClientBorderThickness();
if (!MD::IsRefreshUi()) {
maximized_spacing +=
showing_caption_buttons_on_right
......@@ -313,7 +317,7 @@ class OpaqueBrowserFrameViewLayoutTest : public ChromeViewsTestBase {
EXPECT_EQ(min_width, min_size.width());
int restored_border_height =
OpaqueBrowserFrameViewLayout::kFrameBorderThickness +
kNonClientBorderThickness;
NonClientBorderThickness();
if (MD::IsRefreshUi()) {
restored_border_height +=
OpaqueBrowserFrameViewLayout::kRefreshNonClientExtraTopThickness;
......
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