OLD | NEW |
---|---|
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/browser_desktop_window_tree_host_win.h" | 5 #include "chrome/browser/ui/views/frame/browser_desktop_window_tree_host_win.h" |
6 | 6 |
7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
8 | 8 |
9 #include "base/process/process_handle.h" | 9 #include "base/process/process_handle.h" |
10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
11 #include "chrome/browser/lifetime/application_lifetime.h" | 11 #include "chrome/browser/lifetime/application_lifetime.h" |
12 #include "chrome/browser/themes/theme_service.h" | 12 #include "chrome/browser/themes/theme_service.h" |
13 #include "chrome/browser/themes/theme_service_factory.h" | 13 #include "chrome/browser/themes/theme_service_factory.h" |
14 #include "chrome/browser/ui/views/frame/browser_frame.h" | 14 #include "chrome/browser/ui/views/frame/browser_frame.h" |
15 #include "chrome/browser/ui/views/frame/browser_frame_common_win.h" | 15 #include "chrome/browser/ui/views/frame/browser_frame_common_win.h" |
16 #include "chrome/browser/ui/views/frame/browser_view.h" | 16 #include "chrome/browser/ui/views/frame/browser_view.h" |
17 #include "chrome/browser/ui/views/frame/browser_window_property_manager_win.h" | 17 #include "chrome/browser/ui/views/frame/browser_window_property_manager_win.h" |
18 #include "chrome/browser/ui/views/frame/system_menu_insertion_delegate_win.h" | 18 #include "chrome/browser/ui/views/frame/system_menu_insertion_delegate_win.h" |
19 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 19 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
20 #include "chrome/browser/ui/views/theme_image_mapper.h" | 20 #include "chrome/browser/ui/views/theme_image_mapper.h" |
21 #include "chrome/common/chrome_constants.h" | 21 #include "chrome/common/chrome_constants.h" |
22 #include "ui/base/theme_provider.h" | 22 #include "ui/base/theme_provider.h" |
23 #include "ui/gfx/win/dpi.h" | 23 #include "ui/gfx/screen_win.h" |
24 #include "ui/views/controls/menu/native_menu_win.h" | 24 #include "ui/views/controls/menu/native_menu_win.h" |
25 | 25 |
26 #pragma comment(lib, "dwmapi.lib") | 26 #pragma comment(lib, "dwmapi.lib") |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 const int kClientEdgeThickness = 3; | 30 const int kClientEdgeThickness = 3; |
31 | 31 |
32 // DesktopThemeProvider maps resource ids using MapThemeImage(). This is | 32 // DesktopThemeProvider maps resource ids using MapThemeImage(). This is |
33 // necessary for BrowserDesktopWindowTreeHostWin so that it uses the windows | 33 // necessary for BrowserDesktopWindowTreeHostWin so that it uses the windows |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 margins.cxLeftWidth = kClientEdgeThickness + 1; | 313 margins.cxLeftWidth = kClientEdgeThickness + 1; |
314 margins.cxRightWidth = kClientEdgeThickness + 1; | 314 margins.cxRightWidth = kClientEdgeThickness + 1; |
315 margins.cyBottomHeight = kClientEdgeThickness + 1; | 315 margins.cyBottomHeight = kClientEdgeThickness + 1; |
316 } | 316 } |
317 } | 317 } |
318 // In maximized mode, we only have a titlebar strip of glass, no side/bottom | 318 // In maximized mode, we only have a titlebar strip of glass, no side/bottom |
319 // borders. | 319 // borders. |
320 if (!browser_view_->IsFullscreen()) { | 320 if (!browser_view_->IsFullscreen()) { |
321 gfx::Rect tabstrip_bounds( | 321 gfx::Rect tabstrip_bounds( |
322 browser_frame_->GetBoundsForTabStrip(browser_view_->tabstrip())); | 322 browser_frame_->GetBoundsForTabStrip(browser_view_->tabstrip())); |
323 tabstrip_bounds = gfx::win::DIPToScreenRect(tabstrip_bounds); | 323 tabstrip_bounds = gfx::ScreenWin::DIPToClientRect(GetHWND(), |
sky
2015/10/29 15:51:50
Is there a reason for changing the name of these f
robliao
2015/11/07 00:56:40
When I audited this function, I found the calculat
| |
324 tabstrip_bounds); | |
324 margins.cyTopHeight = tabstrip_bounds.bottom(); | 325 margins.cyTopHeight = tabstrip_bounds.bottom(); |
325 | 326 |
326 // On pre-Win 10, we need to offset the DWM frame into the toolbar so that | 327 // On pre-Win 10, we need to offset the DWM frame into the toolbar so that |
327 // the blackness doesn't show up on our rounded toolbar corners. In Win | 328 // the blackness doesn't show up on our rounded toolbar corners. In Win |
328 // 10 and above there are no rounded corners, so this is unnecessary. | 329 // 10 and above there are no rounded corners, so this is unnecessary. |
329 const int kDWMFrameTopOffset = 3; | 330 const int kDWMFrameTopOffset = 3; |
330 if (base::win::GetVersion() < base::win::VERSION_WIN10) | 331 if (base::win::GetVersion() < base::win::VERSION_WIN10) |
331 margins.cyTopHeight += kDWMFrameTopOffset; | 332 margins.cyTopHeight += kDWMFrameTopOffset; |
332 } | 333 } |
333 } | 334 } |
334 return margins; | 335 return margins; |
335 } | 336 } |
336 | 337 |
337 //////////////////////////////////////////////////////////////////////////////// | 338 //////////////////////////////////////////////////////////////////////////////// |
338 // BrowserDesktopWindowTreeHost, public: | 339 // BrowserDesktopWindowTreeHost, public: |
339 | 340 |
340 // static | 341 // static |
341 BrowserDesktopWindowTreeHost* | 342 BrowserDesktopWindowTreeHost* |
342 BrowserDesktopWindowTreeHost::CreateBrowserDesktopWindowTreeHost( | 343 BrowserDesktopWindowTreeHost::CreateBrowserDesktopWindowTreeHost( |
343 views::internal::NativeWidgetDelegate* native_widget_delegate, | 344 views::internal::NativeWidgetDelegate* native_widget_delegate, |
344 views::DesktopNativeWidgetAura* desktop_native_widget_aura, | 345 views::DesktopNativeWidgetAura* desktop_native_widget_aura, |
345 BrowserView* browser_view, | 346 BrowserView* browser_view, |
346 BrowserFrame* browser_frame) { | 347 BrowserFrame* browser_frame) { |
347 return new BrowserDesktopWindowTreeHostWin(native_widget_delegate, | 348 return new BrowserDesktopWindowTreeHostWin(native_widget_delegate, |
348 desktop_native_widget_aura, | 349 desktop_native_widget_aura, |
349 browser_view, | 350 browser_view, |
350 browser_frame); | 351 browser_frame); |
351 } | 352 } |
OLD | NEW |