| 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" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 ::EnableWindow(hwnd(), TRUE); | 68 ::EnableWindow(hwnd(), TRUE); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 HWND LegacyRenderWidgetHostHWND::GetParent() { | 72 HWND LegacyRenderWidgetHostHWND::GetParent() { |
| 73 return ::GetParent(hwnd()); | 73 return ::GetParent(hwnd()); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void LegacyRenderWidgetHostHWND::Show() { | 76 void LegacyRenderWidgetHostHWND::Show() { |
| 77 ::ShowWindow(hwnd(), SW_SHOW); | 77 ::ShowWindow(hwnd(), SW_SHOW); |
| 78 if (direct_manipulation_helper_) |
| 79 direct_manipulation_helper_->Activate(hwnd()); |
| 78 } | 80 } |
| 79 | 81 |
| 80 void LegacyRenderWidgetHostHWND::Hide() { | 82 void LegacyRenderWidgetHostHWND::Hide() { |
| 81 ::ShowWindow(hwnd(), SW_HIDE); | 83 ::ShowWindow(hwnd(), SW_HIDE); |
| 82 } | 84 } |
| 83 | 85 |
| 84 void LegacyRenderWidgetHostHWND::SetBounds(const gfx::Rect& bounds) { | 86 void LegacyRenderWidgetHostHWND::SetBounds(const gfx::Rect& bounds) { |
| 85 gfx::Rect bounds_in_pixel = gfx::win::DIPToScreenRect(bounds); | 87 gfx::Rect bounds_in_pixel = gfx::win::DIPToScreenRect(bounds); |
| 86 ::SetWindowPos(hwnd(), NULL, bounds_in_pixel.x(), bounds_in_pixel.y(), | 88 ::SetWindowPos(hwnd(), NULL, bounds_in_pixel.x(), bounds_in_pixel.y(), |
| 87 bounds_in_pixel.width(), bounds_in_pixel.height(), | 89 bounds_in_pixel.width(), bounds_in_pixel.height(), |
| 88 SWP_NOREDRAW); | 90 SWP_NOREDRAW); |
| 91 if (direct_manipulation_helper_) |
| 92 direct_manipulation_helper_->SetBounds(bounds_in_pixel); |
| 89 } | 93 } |
| 90 | 94 |
| 91 void LegacyRenderWidgetHostHWND::OnFinalMessage(HWND hwnd) { | 95 void LegacyRenderWidgetHostHWND::OnFinalMessage(HWND hwnd) { |
| 92 if (host_) { | 96 if (host_) { |
| 93 host_->OnLegacyWindowDestroyed(); | 97 host_->OnLegacyWindowDestroyed(); |
| 94 host_ = NULL; | 98 host_ = NULL; |
| 95 } | 99 } |
| 96 delete this; | 100 delete this; |
| 97 } | 101 } |
| 98 | 102 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 119 reinterpret_cast<void **>(window_accessible_.Receive())); | 123 reinterpret_cast<void **>(window_accessible_.Receive())); |
| 120 DCHECK(SUCCEEDED(hr)); | 124 DCHECK(SUCCEEDED(hr)); |
| 121 | 125 |
| 122 if (!BrowserAccessibilityState::GetInstance()->IsAccessibleBrowser()) { | 126 if (!BrowserAccessibilityState::GetInstance()->IsAccessibleBrowser()) { |
| 123 // Attempt to detect screen readers or other clients who want full | 127 // Attempt to detect screen readers or other clients who want full |
| 124 // accessibility support, by seeing if they respond to this event. | 128 // accessibility support, by seeing if they respond to this event. |
| 125 NotifyWinEvent(EVENT_SYSTEM_ALERT, hwnd(), kIdScreenReaderHoneyPot, | 129 NotifyWinEvent(EVENT_SYSTEM_ALERT, hwnd(), kIdScreenReaderHoneyPot, |
| 126 CHILDID_SELF); | 130 CHILDID_SELF); |
| 127 } | 131 } |
| 128 | 132 |
| 133 // Direct Manipulation is enabled on Windows 10+. The CreateInstance function |
| 134 // returns NULL if Direct Manipulation is not available. |
| 135 direct_manipulation_helper_.reset( |
| 136 gfx::win::DirectManipulationHelper::CreateInstance()); |
| 137 if (direct_manipulation_helper_) |
| 138 direct_manipulation_helper_->Initialize(hwnd()); |
| 139 |
| 129 return !!SUCCEEDED(hr); | 140 return !!SUCCEEDED(hr); |
| 130 } | 141 } |
| 131 | 142 |
| 132 // static | 143 // static |
| 133 ui::WindowEventTarget* LegacyRenderWidgetHostHWND::GetWindowEventTarget( | 144 ui::WindowEventTarget* LegacyRenderWidgetHostHWND::GetWindowEventTarget( |
| 134 HWND parent) { | 145 HWND parent) { |
| 135 return reinterpret_cast<ui::WindowEventTarget*>(ui::ViewProp::GetValue( | 146 return reinterpret_cast<ui::WindowEventTarget*>(ui::ViewProp::GetValue( |
| 136 parent, ui::WindowEventTarget::kWin32InputEventTarget)); | 147 parent, ui::WindowEventTarget::kWin32InputEventTarget)); |
| 137 } | 148 } |
| 138 | 149 |
| (...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 | 246 // If the parent did not handle non client mouse messages, we call |
| 236 // DefWindowProc on the message with the parent window handle. This | 247 // DefWindowProc on the message with the parent window handle. This |
| 237 // ensures that WM_SYSCOMMAND is generated for the parent and we are | 248 // ensures that WM_SYSCOMMAND is generated for the parent and we are |
| 238 // out of the picture. | 249 // out of the picture. |
| 239 if (!handled && | 250 if (!handled && |
| 240 (message >= WM_NCMOUSEMOVE && message <= WM_NCXBUTTONDBLCLK)) { | 251 (message >= WM_NCMOUSEMOVE && message <= WM_NCXBUTTONDBLCLK)) { |
| 241 ret = ::DefWindowProc(GetParent(), message, w_param, l_param); | 252 ret = ::DefWindowProc(GetParent(), message, w_param, l_param); |
| 242 handled = TRUE; | 253 handled = TRUE; |
| 243 } | 254 } |
| 244 } | 255 } |
| 256 |
| 257 if (direct_manipulation_helper_ && |
| 258 (message == WM_MOUSEWHEEL || message == WM_MOUSEHWHEEL)) { |
| 259 direct_manipulation_helper_->HandleMouseWheel(hwnd(), message, w_param, |
| 260 l_param); |
| 261 } |
| 245 return ret; | 262 return ret; |
| 246 } | 263 } |
| 247 | 264 |
| 248 LRESULT LegacyRenderWidgetHostHWND::OnMouseLeave(UINT message, | 265 LRESULT LegacyRenderWidgetHostHWND::OnMouseLeave(UINT message, |
| 249 WPARAM w_param, | 266 WPARAM w_param, |
| 250 LPARAM l_param) { | 267 LPARAM l_param) { |
| 251 mouse_tracking_enabled_ = false; | 268 mouse_tracking_enabled_ = false; |
| 252 LRESULT ret = 0; | 269 LRESULT ret = 0; |
| 253 if ((::GetCapture() != GetParent()) && GetWindowEventTarget(GetParent())) { | 270 if ((::GetCapture() != GetParent()) && GetWindowEventTarget(GetParent())) { |
| 254 // We should send a WM_MOUSELEAVE to the parent window only if the mouse | 271 // 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. | 390 // generate the legacy WM_VSCROLL/WM_HSCROLL messages. |
| 374 // We add these styles to ensure that trackpad/trackpoint scrolling | 391 // We add these styles to ensure that trackpad/trackpoint scrolling |
| 375 // work. | 392 // work. |
| 376 long current_style = ::GetWindowLong(hwnd(), GWL_STYLE); | 393 long current_style = ::GetWindowLong(hwnd(), GWL_STYLE); |
| 377 ::SetWindowLong(hwnd(), GWL_STYLE, | 394 ::SetWindowLong(hwnd(), GWL_STYLE, |
| 378 current_style | WS_VSCROLL | WS_HSCROLL); | 395 current_style | WS_VSCROLL | WS_HSCROLL); |
| 379 return 0; | 396 return 0; |
| 380 } | 397 } |
| 381 | 398 |
| 382 } // namespace content | 399 } // namespace content |
| OLD | NEW |