Chromium Code Reviews| 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 93080cd5c189c62b00c9e8fe87185b438f2cf545..6885973505ba5f5e36f2c9c3244afcb71ce9fe18 100644 |
| --- a/chrome/browser/ui/views/frame/minimize_button_metrics_win.cc |
| +++ b/chrome/browser/ui/views/frame/minimize_button_metrics_win.cc |
| @@ -54,26 +54,38 @@ MinimizeButtonMetrics::~MinimizeButtonMetrics() { |
| } |
| // static |
| +int MinimizeButtonMetrics::GetCaptionButtonWidthInDIPs() { |
| + return GetCaptionButtonDimensionInDIPs(SM_CXSIZE, SM_CXSIZEFRAME); |
|
Peter Kasting
2017/05/11 01:03:43
It somewhat surprises me that the width would need
emx
2017/05/11 12:56:11
Me too! In fact, I've measured it carefully again
|
| +} |
| + |
| +// static |
| int MinimizeButtonMetrics::GetCaptionButtonHeightInDIPs() { |
| + return GetCaptionButtonDimensionInDIPs(SM_CYSIZE, SM_CYSIZEFRAME); |
| +} |
| + |
| +// static |
| +int MinimizeButtonMetrics::GetCaptionButtonDimensionInDIPs(int caption_metric, |
| + int frame_metric) { |
| // At DPI scaling settings other than 100% the result won't be exactly right. |
| // TODO: return a more accurate approximation [http://crbug.com/716365] |
| - // SM_CYSIZE returns the caption button height, but to get the full height |
| - // from the top of the window we add SM_CYSIZEFRAME. |
| - const int caption_height = GetSystemMetrics(SM_CYSIZE); |
| - const int frame_thickness = GetSystemMetrics(SM_CYSIZEFRAME); |
| + // SM_CXSIZE/SM_CYSIZE return the caption button width/height, but to get the |
| + // full width from the side/height from the top of the window we add |
| + // SM_CXSIZEFRAME/SM_CYSIZEFRAME. |
| + const int caption_dimension = GetSystemMetrics(caption_metric); |
| + const int frame_thickness = GetSystemMetrics(frame_metric); |
| // The result of GetSystemMetrics depends on the scale factor of the primary |
| - // display. Divide the sum by that to convert to DIPs. (Converting SM_CYSIZE |
| - // and SM_CYSIZEFRAME to DIPs individually adds a bigger rounding error.) |
| + // display. Divide the sum by that to convert to DIPs. (Converting the two |
| + // metrics to DIPs individually adds a bigger rounding error.) |
| float primary_device_scale_factor = |
| display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor(); |
| - float height_dips = |
| - (caption_height + frame_thickness) / primary_device_scale_factor; |
| + float dimension_dips = |
| + (caption_dimension + frame_thickness) / primary_device_scale_factor; |
| // Testing shows that floor() gives a more accurate approximation than |
| // round() here. |
| - return std::floor(height_dips); |
| + return std::floor(dimension_dips); |
| } |
| void MinimizeButtonMetrics::Init(HWND hwnd) { |