| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/win/win_util.h" | 10 #include "base/win/win_util.h" |
| 11 #include "base/win/windows_version.h" | 11 #include "base/win/windows_version.h" |
| 12 #include "content/browser/accessibility/browser_accessibility_manager_win.h" | 12 #include "content/browser/accessibility/browser_accessibility_manager_win.h" |
| 13 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 13 #include "content/browser/accessibility/browser_accessibility_state_impl.h" |
| 14 #include "content/browser/accessibility/browser_accessibility_win.h" | 14 #include "content/browser/accessibility/browser_accessibility_win.h" |
| 15 #include "content/browser/renderer_host/render_widget_host_impl.h" | 15 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 16 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 16 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 17 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
| 18 #include "ui/accessibility/platform/ax_fake_caret_win.h" |
| 18 #include "ui/base/view_prop.h" | 19 #include "ui/base/view_prop.h" |
| 19 #include "ui/base/win/internal_constants.h" | 20 #include "ui/base/win/internal_constants.h" |
| 20 #include "ui/base/win/window_event_target.h" | 21 #include "ui/base/win/window_event_target.h" |
| 21 #include "ui/display/win/screen_win.h" | 22 #include "ui/display/win/screen_win.h" |
| 22 #include "ui/gfx/geometry/rect.h" | 23 #include "ui/gfx/geometry/rect.h" |
| 23 #include "ui/gfx/win/direct_manipulation.h" | 24 #include "ui/gfx/win/direct_manipulation.h" |
| 24 | 25 |
| 25 namespace content { | 26 namespace content { |
| 26 | 27 |
| 27 // A custom MSAA object id used to determine if a screen reader or some | 28 // A custom MSAA object id used to determine if a screen reader or some |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 164 |
| 164 if (kIdScreenReaderHoneyPot == obj_id) { | 165 if (kIdScreenReaderHoneyPot == obj_id) { |
| 165 // When an MSAA client has responded to our fake event on this id, | 166 // When an MSAA client has responded to our fake event on this id, |
| 166 // enable basic accessibility support. (Full screen reader support is | 167 // enable basic accessibility support. (Full screen reader support is |
| 167 // detected later when specific more advanced APIs are accessed.) | 168 // detected later when specific more advanced APIs are accessed.) |
| 168 BrowserAccessibilityStateImpl::GetInstance()->AddAccessibilityModeFlags( | 169 BrowserAccessibilityStateImpl::GetInstance()->AddAccessibilityModeFlags( |
| 169 AccessibilityMode::kNativeAPIs | AccessibilityMode::kWebContents); | 170 AccessibilityMode::kNativeAPIs | AccessibilityMode::kWebContents); |
| 170 return static_cast<LRESULT>(0L); | 171 return static_cast<LRESULT>(0L); |
| 171 } | 172 } |
| 172 | 173 |
| 173 if (static_cast<DWORD>(OBJID_CLIENT) != obj_id || !host_) | 174 if (!host_) |
| 174 return static_cast<LRESULT>(0L); | 175 return static_cast<LRESULT>(0L); |
| 175 | 176 |
| 176 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From( | 177 if (static_cast<DWORD>(OBJID_CLIENT) == obj_id) { |
| 177 host_->GetRenderWidgetHost()); | 178 RenderWidgetHostImpl* rwhi = |
| 178 if (!rwhi) | 179 RenderWidgetHostImpl::From(host_->GetRenderWidgetHost()); |
| 179 return static_cast<LRESULT>(0L); | 180 if (!rwhi) |
| 181 return static_cast<LRESULT>(0L); |
| 180 | 182 |
| 181 BrowserAccessibilityManagerWin* manager = | 183 BrowserAccessibilityManagerWin* manager = |
| 182 static_cast<BrowserAccessibilityManagerWin*>( | 184 static_cast<BrowserAccessibilityManagerWin*>( |
| 183 rwhi->GetRootBrowserAccessibilityManager()); | 185 rwhi->GetRootBrowserAccessibilityManager()); |
| 184 if (!manager) | 186 if (!manager) |
| 185 return static_cast<LRESULT>(0L); | 187 return static_cast<LRESULT>(0L); |
| 186 | 188 |
| 187 base::win::ScopedComPtr<IAccessible> root( | 189 base::win::ScopedComPtr<IAccessible> root( |
| 188 ToBrowserAccessibilityWin(manager->GetRoot())); | 190 ToBrowserAccessibilityWin(manager->GetRoot())); |
| 189 return LresultFromObject(IID_IAccessible, w_param, | 191 return LresultFromObject(IID_IAccessible, w_param, |
| 190 static_cast<IAccessible*>(root.Detach())); | 192 static_cast<IAccessible*>(root.Detach())); |
| 193 } |
| 194 |
| 195 if (static_cast<DWORD>(OBJID_CARET) == obj_id && host_->HasFocus()) { |
| 196 // Used by some assistive software to retrieve the location of the caret. |
| 197 ui::AXFakeCaretWin* fake_caret = ui::g_ax_fake_caret_win.Pointer(); |
| 198 DCHECK(fake_caret); |
| 199 base::win::ScopedComPtr<IAccessible> fake_caret_accessible = |
| 200 fake_caret->GetCaret(); |
| 201 ; |
| 202 return LresultFromObject(IID_IAccessible, w_param, |
| 203 fake_caret_accessible.Detach()); |
| 204 } |
| 205 |
| 206 return static_cast<LRESULT>(0L); |
| 191 } | 207 } |
| 192 | 208 |
| 193 // We send keyboard/mouse/touch messages to the parent window via SendMessage. | 209 // We send keyboard/mouse/touch messages to the parent window via SendMessage. |
| 194 // While this works, this has the side effect of converting input messages into | 210 // While this works, this has the side effect of converting input messages into |
| 195 // sent messages which changes their priority and could technically result | 211 // sent messages which changes their priority and could technically result |
| 196 // in these messages starving other messages in the queue. Additionally | 212 // in these messages starving other messages in the queue. Additionally |
| 197 // keyboard/mouse hooks would not see these messages. The alternative approach | 213 // keyboard/mouse hooks would not see these messages. The alternative approach |
| 198 // is to set and release capture as needed on the parent to ensure that it | 214 // is to set and release capture as needed on the parent to ensure that it |
| 199 // receives all mouse events. However that was shelved due to possible issues | 215 // receives all mouse events. However that was shelved due to possible issues |
| 200 // with capture changes. | 216 // with capture changes. |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 direct_manipulation_helper_->Activate(hwnd()); | 437 direct_manipulation_helper_->Activate(hwnd()); |
| 422 } else if (window_pos->flags & SWP_HIDEWINDOW) { | 438 } else if (window_pos->flags & SWP_HIDEWINDOW) { |
| 423 direct_manipulation_helper_->Deactivate(hwnd()); | 439 direct_manipulation_helper_->Deactivate(hwnd()); |
| 424 } | 440 } |
| 425 } | 441 } |
| 426 SetMsgHandled(FALSE); | 442 SetMsgHandled(FALSE); |
| 427 return 0; | 443 return 0; |
| 428 } | 444 } |
| 429 | 445 |
| 430 } // namespace content | 446 } // namespace content |
| OLD | NEW |