 Chromium Code Reviews
 Chromium Code Reviews Issue 2832823002:
  Update avatar button to MD  (Closed)
    
  
    Issue 2832823002:
  Update avatar button to MD  (Closed) 
  | Index: chrome/browser/ui/views/frame/minimize_button_metrics_win.cc | 
| diff --git a/chrome/browser/ui/views/frame/minimize_button_metrics_win.cc b/chrome/browser/ui/views/frame/minimize_button_metrics_win.cc | 
| index 095f2574c83c9ed91b29b7ec8972c8022cbe5d8d..b84af268cda15db5c5e0c055dbbbd9814e5a2d98 100644 | 
| --- a/chrome/browser/ui/views/frame/minimize_button_metrics_win.cc | 
| +++ b/chrome/browser/ui/views/frame/minimize_button_metrics_win.cc | 
| @@ -24,6 +24,10 @@ const int kWin8ButtonBoundsPositionOffset = 10; | 
| const int kWin10ButtonBoundsPositionOffset = 6; | 
| const int kInvalidOffset = static_cast<int>(0x80000000); | 
| +// This constant was determined manually by testing on windows 10. | 
| +const int kWin10ButtonHeight = 30; | 
| +const int kInvalidHeight = static_cast<int>(0x80000000); | 
| + | 
| using base::win::GetVersion; | 
| using display::win::ScreenWin; | 
| @@ -35,6 +39,10 @@ int GetDefaultButtonBoundsOffset() { | 
| return kWin7ButtonBoundsPositionOffset; | 
| } | 
| +int GetDefaultButtonHeight() { | 
| + return kWin10ButtonHeight; | 
| +} | 
| + | 
| } // namespace | 
| // static | 
| @@ -43,6 +51,9 @@ int MinimizeButtonMetrics::last_cached_minimize_button_x_delta_ = 0; | 
| // static | 
| int MinimizeButtonMetrics::button_bounds_position_offset_ = kInvalidOffset; | 
| +// static | 
| +int MinimizeButtonMetrics::button_bounds_height_ = kInvalidHeight; | 
| + | 
| MinimizeButtonMetrics::MinimizeButtonMetrics() | 
| : hwnd_(nullptr), | 
| cached_minimize_button_x_delta_(last_cached_minimize_button_x_delta_), | 
| @@ -123,7 +134,7 @@ int MinimizeButtonMetrics::GetMinimizeButtonOffsetForWindow() const { | 
| TITLEBARINFOEX titlebar_info = {0}; | 
| titlebar_info.cbSize = sizeof(TITLEBARINFOEX); | 
| SendMessage(hwnd_, WM_GETTITLEBARINFOEX, 0, | 
| - reinterpret_cast<WPARAM>(&titlebar_info)); | 
| + reinterpret_cast<LPARAM>(&titlebar_info)); | 
| // Under DWM WM_GETTITLEBARINFOEX won't return the right thing until after | 
| // WM_NCACTIVATE (maybe it returns classic values?). In an attempt to | 
| @@ -189,3 +200,29 @@ int MinimizeButtonMetrics::GetAndCacheMinimizeButtonOffsetX() const { | 
| last_cached_minimize_button_x_delta_ = cached_minimize_button_x_delta_; | 
| return minimize_button_offset; | 
| } | 
| + | 
| +int MinimizeButtonMetrics::GetMinimizeButtonHeight() const { | 
| + // We want the "tall" avatar button to be the same height as the caption | 
| 
msarda
2017/04/21 09:43:28
Who is "we"?
Also, it is not clear why the commen
 
emx
2017/04/24 16:23:10
Done.
 | 
| + // buttons [http://crbug.com/635699] but it's very hard to get this right for | 
| + // all resolutions/DPI settings. GetSystemMetricsForDpi is probaly the real | 
| + // solution [http://crbug.com/668278]. GetSystemMetrics provides a good | 
| + // approximation for now. | 
| + | 
| + // Note that the following methods do not return the correct result with DPI | 
| + // scaling settings other than 100%: | 
| + // DwmGetWindowAttribute(hwnd_, DWMWA_CAPTION_BUTTON_BOUNDS, ...) | 
| + // SendMessage(hwnd_, WM_GETTITLEBARINFOEX, ...) | 
| + // display::win::ScreenWin::GetSystemMetricsInDIP(SM_CYSIZE) | 
| + // display::win::ScreenWin::GetSystemMetricsForHwnd(hwnd_, SM_CYSIZE) | 
| + | 
| + if (button_bounds_height_ == kInvalidHeight) { | 
| + int button_height_from_sysmetrics = GetSystemMetrics(SM_CYSIZE); | 
| + if (button_height_from_sysmetrics == 0) { | 
| + LOG(ERROR) << "GetSystemMetrics(SM_CYSIZE) error " << ::GetLastError(); | 
| 
msarda
2017/04/21 09:43:28
If the user is in this case, then I think this lin
 
emx
2017/04/24 16:23:10
Done.
 | 
| + return GetDefaultButtonHeight(); | 
| 
msarda
2017/04/21 09:43:28
From the name of the method, it looks like this fu
 
emx
2017/04/24 16:23:10
Done.
 | 
| + } | 
| + button_bounds_height_ = button_height_from_sysmetrics; | 
| + } | 
| + | 
| + return button_bounds_height_; | 
| +} |