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 <objbase.h> | 7 #include <objbase.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/win/win_util.h" | 13 #include "base/win/win_util.h" |
14 #include "content/browser/accessibility/browser_accessibility_manager_win.h" | 14 #include "content/browser/accessibility/browser_accessibility_manager_win.h" |
15 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 15 #include "content/browser/accessibility/browser_accessibility_state_impl.h" |
16 #include "content/browser/accessibility/browser_accessibility_win.h" | 16 #include "content/browser/accessibility/browser_accessibility_win.h" |
17 #include "content/browser/renderer_host/render_widget_host_impl.h" | 17 #include "content/browser/renderer_host/render_widget_host_impl.h" |
18 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 18 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
19 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
20 #include "ui/accessibility/platform/ax_fake_caret_win.h" | 20 #include "ui/accessibility/platform/ax_system_caret_win.h" |
21 #include "ui/base/view_prop.h" | 21 #include "ui/base/view_prop.h" |
22 #include "ui/base/win/internal_constants.h" | 22 #include "ui/base/win/internal_constants.h" |
23 #include "ui/base/win/window_event_target.h" | 23 #include "ui/base/win/window_event_target.h" |
24 #include "ui/display/win/screen_win.h" | 24 #include "ui/display/win/screen_win.h" |
25 #include "ui/gfx/geometry/rect.h" | 25 #include "ui/gfx/geometry/rect.h" |
26 #include "ui/gfx/win/direct_manipulation.h" | 26 #include "ui/gfx/win/direct_manipulation.h" |
27 | 27 |
28 namespace content { | 28 namespace content { |
29 | 29 |
30 // A custom MSAA object id used to determine if a screen reader or some | 30 // A custom MSAA object id used to determine if a screen reader or some |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 gfx::Rect bounds_in_pixel = display::win::ScreenWin::DIPToClientRect(hwnd(), | 82 gfx::Rect bounds_in_pixel = display::win::ScreenWin::DIPToClientRect(hwnd(), |
83 bounds); | 83 bounds); |
84 ::SetWindowPos(hwnd(), NULL, bounds_in_pixel.x(), bounds_in_pixel.y(), | 84 ::SetWindowPos(hwnd(), NULL, bounds_in_pixel.x(), bounds_in_pixel.y(), |
85 bounds_in_pixel.width(), bounds_in_pixel.height(), | 85 bounds_in_pixel.width(), bounds_in_pixel.height(), |
86 SWP_NOREDRAW); | 86 SWP_NOREDRAW); |
87 if (direct_manipulation_helper_) | 87 if (direct_manipulation_helper_) |
88 direct_manipulation_helper_->SetBounds(bounds_in_pixel); | 88 direct_manipulation_helper_->SetBounds(bounds_in_pixel); |
89 } | 89 } |
90 | 90 |
91 void LegacyRenderWidgetHostHWND::MoveCaretTo(const gfx::Rect& bounds) { | 91 void LegacyRenderWidgetHostHWND::MoveCaretTo(const gfx::Rect& bounds) { |
92 DCHECK(ax_fake_caret_); | 92 DCHECK(ax_system_caret_); |
93 ax_fake_caret_->MoveCaretTo(bounds); | 93 ax_system_caret_->MoveCaretTo(bounds); |
94 } | 94 } |
95 | 95 |
96 void LegacyRenderWidgetHostHWND::OnFinalMessage(HWND hwnd) { | 96 void LegacyRenderWidgetHostHWND::OnFinalMessage(HWND hwnd) { |
97 if (host_) { | 97 if (host_) { |
98 host_->OnLegacyWindowDestroyed(); | 98 host_->OnLegacyWindowDestroyed(); |
99 host_ = NULL; | 99 host_ = NULL; |
100 } | 100 } |
101 | 101 |
102 // Re-enable flicks for just a moment | 102 // Re-enable flicks for just a moment |
103 base::win::EnableFlicks(hwnd); | 103 base::win::EnableFlicks(hwnd); |
104 | 104 |
105 delete this; | 105 delete this; |
106 } | 106 } |
107 | 107 |
108 LegacyRenderWidgetHostHWND::LegacyRenderWidgetHostHWND(HWND parent) | 108 LegacyRenderWidgetHostHWND::LegacyRenderWidgetHostHWND(HWND parent) |
109 : mouse_tracking_enabled_(false), host_(nullptr) { | 109 : mouse_tracking_enabled_(false), host_(nullptr) { |
110 RECT rect = {0}; | 110 RECT rect = {0}; |
111 Base::Create(parent, rect, L"Chrome Legacy Window", | 111 Base::Create(parent, rect, L"Chrome Legacy Window", |
112 WS_CHILDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, | 112 WS_CHILDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, |
113 WS_EX_TRANSPARENT); | 113 WS_EX_TRANSPARENT); |
114 // We create the fake caret regardless of accessibility mode since not all | 114 // We create a system caret regardless of accessibility mode since not all |
115 // assistive software that makes use of a fake caret is classified as a screen | 115 // assistive software that makes use of a caret is classified as a screen |
116 // reader, e.g. the built-in Windows Magnifier. | 116 // reader, e.g. the built-in Windows Magnifier. |
117 ax_fake_caret_ = std::make_unique<ui::AXFakeCaretWin>(hwnd()); | 117 ax_system_caret_ = std::make_unique<ui::AXSystemCaretWin>(hwnd()); |
118 } | 118 } |
119 | 119 |
120 LegacyRenderWidgetHostHWND::~LegacyRenderWidgetHostHWND() { | 120 LegacyRenderWidgetHostHWND::~LegacyRenderWidgetHostHWND() { |
121 DCHECK(!::IsWindow(hwnd())); | 121 DCHECK(!::IsWindow(hwnd())); |
122 } | 122 } |
123 | 123 |
124 bool LegacyRenderWidgetHostHWND::Init() { | 124 bool LegacyRenderWidgetHostHWND::Init() { |
125 RegisterTouchWindow(hwnd(), TWF_WANTPALM); | 125 RegisterTouchWindow(hwnd(), TWF_WANTPALM); |
126 | 126 |
127 HRESULT hr = ::CreateStdAccessibleObject(hwnd(), OBJID_WINDOW, | 127 HRESULT hr = ::CreateStdAccessibleObject(hwnd(), OBJID_WINDOW, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 if (!manager || !manager->GetRoot()) | 194 if (!manager || !manager->GetRoot()) |
195 return static_cast<LRESULT>(0L); | 195 return static_cast<LRESULT>(0L); |
196 | 196 |
197 base::win::ScopedComPtr<IAccessible> root( | 197 base::win::ScopedComPtr<IAccessible> root( |
198 ToBrowserAccessibilityWin(manager->GetRoot())->GetCOM()); | 198 ToBrowserAccessibilityWin(manager->GetRoot())->GetCOM()); |
199 return LresultFromObject(IID_IAccessible, w_param, | 199 return LresultFromObject(IID_IAccessible, w_param, |
200 static_cast<IAccessible*>(root.Detach())); | 200 static_cast<IAccessible*>(root.Detach())); |
201 } | 201 } |
202 | 202 |
203 if (static_cast<DWORD>(OBJID_CARET) == obj_id && host_->HasFocus()) { | 203 if (static_cast<DWORD>(OBJID_CARET) == obj_id && host_->HasFocus()) { |
204 DCHECK(ax_fake_caret_); | 204 DCHECK(ax_system_caret_); |
205 base::win::ScopedComPtr<IAccessible> fake_caret_accessible = | 205 base::win::ScopedComPtr<IAccessible> ax_system_caret_accessible = |
206 ax_fake_caret_->GetCaret(); | 206 ax_system_caret_->GetCaret(); |
207 return LresultFromObject(IID_IAccessible, w_param, | 207 return LresultFromObject(IID_IAccessible, w_param, |
208 fake_caret_accessible.Detach()); | 208 ax_system_caret_accessible.Detach()); |
209 } | 209 } |
210 | 210 |
211 return static_cast<LRESULT>(0L); | 211 return static_cast<LRESULT>(0L); |
212 } | 212 } |
213 | 213 |
214 // We send keyboard/mouse/touch messages to the parent window via SendMessage. | 214 // We send keyboard/mouse/touch messages to the parent window via SendMessage. |
215 // While this works, this has the side effect of converting input messages into | 215 // While this works, this has the side effect of converting input messages into |
216 // sent messages which changes their priority and could technically result | 216 // sent messages which changes their priority and could technically result |
217 // in these messages starving other messages in the queue. Additionally | 217 // in these messages starving other messages in the queue. Additionally |
218 // keyboard/mouse hooks would not see these messages. The alternative approach | 218 // keyboard/mouse hooks would not see these messages. The alternative approach |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 direct_manipulation_helper_->Activate(hwnd()); | 442 direct_manipulation_helper_->Activate(hwnd()); |
443 } else if (window_pos->flags & SWP_HIDEWINDOW) { | 443 } else if (window_pos->flags & SWP_HIDEWINDOW) { |
444 direct_manipulation_helper_->Deactivate(hwnd()); | 444 direct_manipulation_helper_->Deactivate(hwnd()); |
445 } | 445 } |
446 } | 446 } |
447 SetMsgHandled(FALSE); | 447 SetMsgHandled(FALSE); |
448 return 0; | 448 return 0; |
449 } | 449 } |
450 | 450 |
451 } // namespace content | 451 } // namespace content |
OLD | NEW |