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

Unified Diff: chrome/browser/ui/views/frame/glass_browser_frame_view.cc

Issue 2381283003: Have Chrome draw top window border when using custom titlebar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix nits Created 4 years, 2 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/frame/glass_browser_frame_view.cc
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 98d1063b2ea1f5353d5ccd642c28927d41fbee11..ab6dc571ebd138efb9768bdacdc7d7c7ba325064 100644
--- a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc
+++ b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc
@@ -509,14 +509,38 @@ void GlassBrowserFrameView::PaintTitlebar(gfx::Canvas* canvas) const {
// BrowserDesktopWindowTreeHostWin::UpdateDWMFrame()).
const int y = IsMaximized() ? FrameTopBorderThicknessPx(false) : 1;
SkPaint paint;
+
+ // Draw the top of the accent border.
+ //
+ // We let the DWM do this for the other sides of the window by insetting the
+ // client area to leave nonclient area available. However, along the top
+ // window edge, we have to have zero nonclient area or the DWM will draw a
+ // full native titlebar outside our client area. See
+ // BrowserDesktopWindowTreeHostWin::GetClientAreaInsets().
+ //
+ // We could ask the DWM to draw the top accent border in the client area (by
+ // calling DwmExtendFrameIntoClientArea in
Peter Kasting 2016/10/11 20:01:38 Nit: Add () after function name
+ // BrowserDesktopWindowTreeHostWin::UpdateDWMFrame()), but this requires
+ // that we leave part of the client surface transparent. Forcing DWM to
+ // blend with us costs power even when it has no effect. If we draw this
Peter Kasting 2016/10/11 20:01:38 Nit: What does "even when it has no effect" mean h
+ // ourselves, we can make the client surface fully opaque and avoid this
+ // cost.
+ //
+ // So the accent border also has to be opaque, but native inactive borders
+ // are #565656 with 80% alpha. We copy Edge (which also custom-draws its top
+ // border) and use #A2A2A2 instead.
+ // TODO(jbauman): Match Edge's #090909 when using the dark theme.
Peter Kasting 2016/10/11 20:01:38 Which dark theme are you referring to? Chrome inc
Bret 2016/10/11 20:48:19 In Edge it's a user setting, but that's just becau
Peter Kasting 2016/10/11 20:56:51 I see. I use a dark frame color on my own system
Bret 2016/10/11 21:10:15 I think it's somewhere between extremely difficult
+ constexpr SkColor inactive_border_color = 0xFFA2A2A2;
+ paint.setColor(
+ ShouldPaintAsActive()
+ ? GetThemeProvider()->GetColor(ThemeProperties::COLOR_ACCENT_BORDER)
+ : inactive_border_color);
+ canvas->DrawRect(gfx::RectF(0, 0, width() * scale, y), paint);
+
paint.setColor(frame_color);
canvas->DrawRect(
gfx::RectF(0, y, width() * scale, tabstrip_bounds.bottom() * scale - y),
paint);
-
- // The 1 pixel line at the top is drawn by Windows when we leave that section
- // of the window blank because we have called DwmExtendFrameIntoClientArea()
- // inside BrowserDesktopWindowTreeHostWin::UpdateDWMFrame().
}
void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) const {

Powered by Google App Engine
This is Rietveld 408576698