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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/frame/glass_browser_frame_view.h" 5 #include "chrome/browser/ui/views/frame/glass_browser_frame_view.h"
6 6
7 #include <dwmapi.h> 7 #include <dwmapi.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/win/windows_version.h" 10 #include "base/win/windows_version.h"
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 gfx::Rect tabstrip_bounds = GetBoundsForTabStrip(browser_view()->tabstrip()); 502 gfx::Rect tabstrip_bounds = GetBoundsForTabStrip(browser_view()->tabstrip());
503 503
504 gfx::ScopedCanvas scoped_canvas(canvas); 504 gfx::ScopedCanvas scoped_canvas(canvas);
505 float scale = canvas->UndoDeviceScaleFactor(); 505 float scale = canvas->UndoDeviceScaleFactor();
506 // This is the pixel-accurate version of WindowTopY(). Scaling the DIP values 506 // This is the pixel-accurate version of WindowTopY(). Scaling the DIP values
507 // here compounds precision error, which exposes the native Windows caption 507 // here compounds precision error, which exposes the native Windows caption
508 // buttons we need to draw over. (see the comment in 508 // buttons we need to draw over. (see the comment in
509 // BrowserDesktopWindowTreeHostWin::UpdateDWMFrame()). 509 // BrowserDesktopWindowTreeHostWin::UpdateDWMFrame()).
510 const int y = IsMaximized() ? FrameTopBorderThicknessPx(false) : 1; 510 const int y = IsMaximized() ? FrameTopBorderThicknessPx(false) : 1;
511 SkPaint paint; 511 SkPaint paint;
512
513 // Draw the top of the accent border.
514 //
515 // We let the DWM do this for the other sides of the window by insetting the
516 // client area to leave nonclient area available. However, along the top
517 // window edge, we have to have zero nonclient area or the DWM will draw a
518 // full native titlebar outside our client area. See
519 // BrowserDesktopWindowTreeHostWin::GetClientAreaInsets().
520 //
521 // We could ask the DWM to draw the top accent border in the client area (by
522 // calling DwmExtendFrameIntoClientArea in
Peter Kasting 2016/10/11 20:01:38 Nit: Add () after function name
523 // BrowserDesktopWindowTreeHostWin::UpdateDWMFrame()), but this requires
524 // that we leave part of the client surface transparent. Forcing DWM to
525 // 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
526 // ourselves, we can make the client surface fully opaque and avoid this
527 // cost.
528 //
529 // So the accent border also has to be opaque, but native inactive borders
530 // are #565656 with 80% alpha. We copy Edge (which also custom-draws its top
531 // border) and use #A2A2A2 instead.
532 // 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
533 constexpr SkColor inactive_border_color = 0xFFA2A2A2;
534 paint.setColor(
535 ShouldPaintAsActive()
536 ? GetThemeProvider()->GetColor(ThemeProperties::COLOR_ACCENT_BORDER)
537 : inactive_border_color);
538 canvas->DrawRect(gfx::RectF(0, 0, width() * scale, y), paint);
539
512 paint.setColor(frame_color); 540 paint.setColor(frame_color);
513 canvas->DrawRect( 541 canvas->DrawRect(
514 gfx::RectF(0, y, width() * scale, tabstrip_bounds.bottom() * scale - y), 542 gfx::RectF(0, y, width() * scale, tabstrip_bounds.bottom() * scale - y),
515 paint); 543 paint);
516
517 // The 1 pixel line at the top is drawn by Windows when we leave that section
518 // of the window blank because we have called DwmExtendFrameIntoClientArea()
519 // inside BrowserDesktopWindowTreeHostWin::UpdateDWMFrame().
520 } 544 }
521 545
522 void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) const { 546 void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) const {
523 // TODO(estade): can this be shared with OpaqueBrowserFrameView? 547 // TODO(estade): can this be shared with OpaqueBrowserFrameView?
524 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); 548 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds());
525 if (toolbar_bounds.IsEmpty()) 549 if (toolbar_bounds.IsEmpty())
526 return; 550 return;
527 gfx::Point toolbar_origin(toolbar_bounds.origin()); 551 gfx::Point toolbar_origin(toolbar_bounds.origin());
528 ConvertPointToTarget(browser_view(), this, &toolbar_origin); 552 ConvertPointToTarget(browser_view(), this, &toolbar_origin);
529 toolbar_bounds.set_origin(toolbar_origin); 553 toolbar_bounds.set_origin(toolbar_origin);
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 static bool initialized = false; 799 static bool initialized = false;
776 if (!initialized) { 800 if (!initialized) {
777 for (int i = 0; i < kThrobberIconCount; ++i) { 801 for (int i = 0; i < kThrobberIconCount; ++i) {
778 throbber_icons_[i] = 802 throbber_icons_[i] =
779 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); 803 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i);
780 DCHECK(throbber_icons_[i]); 804 DCHECK(throbber_icons_[i]);
781 } 805 }
782 initialized = true; 806 initialized = true;
783 } 807 }
784 } 808 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698