OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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 "content/browser/renderer_host/legacy_render_widget_host_win.h" | 5 #include "content/browser/renderer_host/legacy_render_widget_host_win.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/win/windows_version.h" | 9 #include "base/win/windows_version.h" |
10 #include "content/browser/accessibility/browser_accessibility_manager_win.h" | 10 #include "content/browser/accessibility/browser_accessibility_manager_win.h" |
11 #include "content/browser/accessibility/browser_accessibility_win.h" | 11 #include "content/browser/accessibility/browser_accessibility_win.h" |
12 #include "content/browser/renderer_host/render_widget_host_impl.h" | 12 #include "content/browser/renderer_host/render_widget_host_impl.h" |
13 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 13 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
14 #include "content/public/browser/browser_accessibility_state.h" | 14 #include "content/public/browser/browser_accessibility_state.h" |
15 #include "content/public/common/content_switches.h" | 15 #include "content/public/common/content_switches.h" |
16 #include "ui/base/touch/touch_enabled.h" | 16 #include "ui/base/touch/touch_enabled.h" |
17 #include "ui/base/view_prop.h" | 17 #include "ui/base/view_prop.h" |
18 #include "ui/base/win/internal_constants.h" | 18 #include "ui/base/win/internal_constants.h" |
19 #include "ui/base/win/window_event_target.h" | 19 #include "ui/base/win/window_event_target.h" |
20 #include "ui/gfx/geometry/rect.h" | 20 #include "ui/gfx/geometry/rect.h" |
| 21 #include "ui/gfx/win/direct_manipulation.h" |
21 #include "ui/gfx/win/dpi.h" | 22 #include "ui/gfx/win/dpi.h" |
22 | 23 |
23 namespace content { | 24 namespace content { |
24 | 25 |
25 // A custom MSAA object id used to determine if a screen reader or some | 26 // A custom MSAA object id used to determine if a screen reader or some |
26 // other client is listening on MSAA events - if so, we enable full web | 27 // other client is listening on MSAA events - if so, we enable full web |
27 // accessibility support. | 28 // accessibility support. |
28 const int kIdScreenReaderHoneyPot = 1; | 29 const int kIdScreenReaderHoneyPot = 1; |
29 | 30 |
30 // static | 31 // static |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 ::EnableWindow(hwnd(), TRUE); | 69 ::EnableWindow(hwnd(), TRUE); |
69 } | 70 } |
70 } | 71 } |
71 | 72 |
72 HWND LegacyRenderWidgetHostHWND::GetParent() { | 73 HWND LegacyRenderWidgetHostHWND::GetParent() { |
73 return ::GetParent(hwnd()); | 74 return ::GetParent(hwnd()); |
74 } | 75 } |
75 | 76 |
76 void LegacyRenderWidgetHostHWND::Show() { | 77 void LegacyRenderWidgetHostHWND::Show() { |
77 ::ShowWindow(hwnd(), SW_SHOW); | 78 ::ShowWindow(hwnd(), SW_SHOW); |
| 79 if (direct_manipulation_helper_) |
| 80 direct_manipulation_helper_->Activate(hwnd()); |
78 } | 81 } |
79 | 82 |
80 void LegacyRenderWidgetHostHWND::Hide() { | 83 void LegacyRenderWidgetHostHWND::Hide() { |
81 ::ShowWindow(hwnd(), SW_HIDE); | 84 ::ShowWindow(hwnd(), SW_HIDE); |
82 } | 85 } |
83 | 86 |
84 void LegacyRenderWidgetHostHWND::SetBounds(const gfx::Rect& bounds) { | 87 void LegacyRenderWidgetHostHWND::SetBounds(const gfx::Rect& bounds) { |
85 gfx::Rect bounds_in_pixel = gfx::win::DIPToScreenRect(bounds); | 88 gfx::Rect bounds_in_pixel = gfx::win::DIPToScreenRect(bounds); |
86 ::SetWindowPos(hwnd(), NULL, bounds_in_pixel.x(), bounds_in_pixel.y(), | 89 ::SetWindowPos(hwnd(), NULL, bounds_in_pixel.x(), bounds_in_pixel.y(), |
87 bounds_in_pixel.width(), bounds_in_pixel.height(), | 90 bounds_in_pixel.width(), bounds_in_pixel.height(), |
88 SWP_NOREDRAW); | 91 SWP_NOREDRAW); |
| 92 if (direct_manipulation_helper_) |
| 93 direct_manipulation_helper_->SetBounds(bounds_in_pixel); |
89 } | 94 } |
90 | 95 |
91 void LegacyRenderWidgetHostHWND::OnFinalMessage(HWND hwnd) { | 96 void LegacyRenderWidgetHostHWND::OnFinalMessage(HWND hwnd) { |
92 if (host_) { | 97 if (host_) { |
93 host_->OnLegacyWindowDestroyed(); | 98 host_->OnLegacyWindowDestroyed(); |
94 host_ = NULL; | 99 host_ = NULL; |
95 } | 100 } |
96 delete this; | 101 delete this; |
97 } | 102 } |
98 | 103 |
(...skipping 20 matching lines...) Expand all Loading... |
119 reinterpret_cast<void **>(window_accessible_.Receive())); | 124 reinterpret_cast<void **>(window_accessible_.Receive())); |
120 DCHECK(SUCCEEDED(hr)); | 125 DCHECK(SUCCEEDED(hr)); |
121 | 126 |
122 if (!BrowserAccessibilityState::GetInstance()->IsAccessibleBrowser()) { | 127 if (!BrowserAccessibilityState::GetInstance()->IsAccessibleBrowser()) { |
123 // Attempt to detect screen readers or other clients who want full | 128 // Attempt to detect screen readers or other clients who want full |
124 // accessibility support, by seeing if they respond to this event. | 129 // accessibility support, by seeing if they respond to this event. |
125 NotifyWinEvent(EVENT_SYSTEM_ALERT, hwnd(), kIdScreenReaderHoneyPot, | 130 NotifyWinEvent(EVENT_SYSTEM_ALERT, hwnd(), kIdScreenReaderHoneyPot, |
126 CHILDID_SELF); | 131 CHILDID_SELF); |
127 } | 132 } |
128 | 133 |
| 134 // Direct Manipulation is enabled on Windows 10+. The CreateInstance function |
| 135 // returns NULL if Direct Manipulation is not available. |
| 136 direct_manipulation_helper_ = |
| 137 gfx::win::DirectManipulationHelper::CreateInstance(); |
| 138 if (direct_manipulation_helper_) |
| 139 direct_manipulation_helper_->Initialize(hwnd()); |
| 140 |
129 return !!SUCCEEDED(hr); | 141 return !!SUCCEEDED(hr); |
130 } | 142 } |
131 | 143 |
132 // static | 144 // static |
133 ui::WindowEventTarget* LegacyRenderWidgetHostHWND::GetWindowEventTarget( | 145 ui::WindowEventTarget* LegacyRenderWidgetHostHWND::GetWindowEventTarget( |
134 HWND parent) { | 146 HWND parent) { |
135 return reinterpret_cast<ui::WindowEventTarget*>(ui::ViewProp::GetValue( | 147 return reinterpret_cast<ui::WindowEventTarget*>(ui::ViewProp::GetValue( |
136 parent, ui::WindowEventTarget::kWin32InputEventTarget)); | 148 parent, ui::WindowEventTarget::kWin32InputEventTarget)); |
137 } | 149 } |
138 | 150 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 // If the parent did not handle non client mouse messages, we call | 247 // If the parent did not handle non client mouse messages, we call |
236 // DefWindowProc on the message with the parent window handle. This | 248 // DefWindowProc on the message with the parent window handle. This |
237 // ensures that WM_SYSCOMMAND is generated for the parent and we are | 249 // ensures that WM_SYSCOMMAND is generated for the parent and we are |
238 // out of the picture. | 250 // out of the picture. |
239 if (!handled && | 251 if (!handled && |
240 (message >= WM_NCMOUSEMOVE && message <= WM_NCXBUTTONDBLCLK)) { | 252 (message >= WM_NCMOUSEMOVE && message <= WM_NCXBUTTONDBLCLK)) { |
241 ret = ::DefWindowProc(GetParent(), message, w_param, l_param); | 253 ret = ::DefWindowProc(GetParent(), message, w_param, l_param); |
242 handled = TRUE; | 254 handled = TRUE; |
243 } | 255 } |
244 } | 256 } |
| 257 |
| 258 if (direct_manipulation_helper_ && |
| 259 (message == WM_MOUSEWHEEL || message == WM_MOUSEHWHEEL)) { |
| 260 direct_manipulation_helper_->HandleMouseWheel(hwnd(), message, w_param, |
| 261 l_param); |
| 262 } |
245 return ret; | 263 return ret; |
246 } | 264 } |
247 | 265 |
248 LRESULT LegacyRenderWidgetHostHWND::OnMouseLeave(UINT message, | 266 LRESULT LegacyRenderWidgetHostHWND::OnMouseLeave(UINT message, |
249 WPARAM w_param, | 267 WPARAM w_param, |
250 LPARAM l_param) { | 268 LPARAM l_param) { |
251 mouse_tracking_enabled_ = false; | 269 mouse_tracking_enabled_ = false; |
252 LRESULT ret = 0; | 270 LRESULT ret = 0; |
253 if ((::GetCapture() != GetParent()) && GetWindowEventTarget(GetParent())) { | 271 if ((::GetCapture() != GetParent()) && GetWindowEventTarget(GetParent())) { |
254 // We should send a WM_MOUSELEAVE to the parent window only if the mouse | 272 // We should send a WM_MOUSELEAVE to the parent window only if the mouse |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 // generate the legacy WM_VSCROLL/WM_HSCROLL messages. | 391 // generate the legacy WM_VSCROLL/WM_HSCROLL messages. |
374 // We add these styles to ensure that trackpad/trackpoint scrolling | 392 // We add these styles to ensure that trackpad/trackpoint scrolling |
375 // work. | 393 // work. |
376 long current_style = ::GetWindowLong(hwnd(), GWL_STYLE); | 394 long current_style = ::GetWindowLong(hwnd(), GWL_STYLE); |
377 ::SetWindowLong(hwnd(), GWL_STYLE, | 395 ::SetWindowLong(hwnd(), GWL_STYLE, |
378 current_style | WS_VSCROLL | WS_HSCROLL); | 396 current_style | WS_VSCROLL | WS_HSCROLL); |
379 return 0; | 397 return 0; |
380 } | 398 } |
381 | 399 |
382 } // namespace content | 400 } // namespace content |
OLD | NEW |