| 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/public/browser/browser_accessibility_state.h" | 12 #include "content/public/browser/browser_accessibility_state.h" |
| 13 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
| 14 #include "ui/base/touch/touch_enabled.h" | 14 #include "ui/base/touch/touch_enabled.h" |
| 15 #include "ui/base/view_prop.h" | 15 #include "ui/base/view_prop.h" |
| 16 #include "ui/base/win/internal_constants.h" | 16 #include "ui/base/win/internal_constants.h" |
| 17 #include "ui/base/win/window_event_target.h" | 17 #include "ui/base/win/window_event_target.h" |
| 18 #include "ui/gfx/geometry/rect.h" | 18 #include "ui/gfx/geometry/rect.h" |
| 19 #include "ui/gfx/win/dpi.h" | 19 #include "ui/gfx/win/dpi.h" |
| 20 | 20 |
| 21 namespace content { | 21 namespace content { |
| 22 | 22 |
| 23 // A custom MSAA object id used to determine if a screen reader or some | 23 // A custom MSAA object id used to determine if a screen reader or some |
| 24 // other client is listening on MSAA events - if so, we enable full web | 24 // other client is listening on MSAA events - if so, we enable full web |
| 25 // accessibility support. | 25 // accessibility support. |
| 26 const int kIdScreenReaderHoneyPot = 1; | 26 const int kIdScreenReaderHoneyPot = 1; |
| 27 | 27 |
| 28 // A version of the OBJID_CLIENT constant that works in 64-bit mode too. | |
| 29 static const LPARAM kObjIdClient = static_cast<ULONG>(OBJID_CLIENT); | |
| 30 | |
| 31 LegacyRenderWidgetHostHWND::~LegacyRenderWidgetHostHWND() { | 28 LegacyRenderWidgetHostHWND::~LegacyRenderWidgetHostHWND() { |
| 32 ::DestroyWindow(hwnd()); | 29 ::DestroyWindow(hwnd()); |
| 33 } | 30 } |
| 34 | 31 |
| 35 // static | 32 // static |
| 36 scoped_ptr<LegacyRenderWidgetHostHWND> LegacyRenderWidgetHostHWND::Create( | 33 scoped_ptr<LegacyRenderWidgetHostHWND> LegacyRenderWidgetHostHWND::Create( |
| 37 HWND parent) { | 34 HWND parent) { |
| 38 // content_unittests passes in the desktop window as the parent. We allow | 35 // content_unittests passes in the desktop window as the parent. We allow |
| 39 // the LegacyRenderWidgetHostHWND instance to be created in this case for | 36 // the LegacyRenderWidgetHostHWND instance to be created in this case for |
| 40 // these tests to pass. | 37 // these tests to pass. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 128 |
| 132 LRESULT LegacyRenderWidgetHostHWND::OnEraseBkGnd(UINT message, | 129 LRESULT LegacyRenderWidgetHostHWND::OnEraseBkGnd(UINT message, |
| 133 WPARAM w_param, | 130 WPARAM w_param, |
| 134 LPARAM l_param) { | 131 LPARAM l_param) { |
| 135 return 1; | 132 return 1; |
| 136 } | 133 } |
| 137 | 134 |
| 138 LRESULT LegacyRenderWidgetHostHWND::OnGetObject(UINT message, | 135 LRESULT LegacyRenderWidgetHostHWND::OnGetObject(UINT message, |
| 139 WPARAM w_param, | 136 WPARAM w_param, |
| 140 LPARAM l_param) { | 137 LPARAM l_param) { |
| 141 if (kIdScreenReaderHoneyPot == l_param) { | 138 // Only the lower 32 bits of l_param are valid when checking the object id |
| 139 // because it sometimes gets sign-extended incorrectly (but not always). |
| 140 DWORD obj_id = static_cast<DWORD>(static_cast<DWORD_PTR>(l_param)); |
| 141 |
| 142 if (kIdScreenReaderHoneyPot == obj_id) { |
| 142 // When an MSAA client has responded to our fake event on this id, | 143 // When an MSAA client has responded to our fake event on this id, |
| 143 // enable screen reader support. | 144 // enable screen reader support. |
| 144 BrowserAccessibilityState::GetInstance()->OnScreenReaderDetected(); | 145 BrowserAccessibilityState::GetInstance()->OnScreenReaderDetected(); |
| 145 return static_cast<LRESULT>(0L); | 146 return static_cast<LRESULT>(0L); |
| 146 } | 147 } |
| 147 | 148 |
| 148 if (kObjIdClient != l_param || !manager_) | 149 if (OBJID_CLIENT != obj_id || !manager_) |
| 149 return static_cast<LRESULT>(0L); | 150 return static_cast<LRESULT>(0L); |
| 150 | 151 |
| 151 base::win::ScopedComPtr<IAccessible> root( | 152 base::win::ScopedComPtr<IAccessible> root( |
| 152 manager_->GetRoot()->ToBrowserAccessibilityWin()); | 153 manager_->GetRoot()->ToBrowserAccessibilityWin()); |
| 153 return LresultFromObject(IID_IAccessible, w_param, | 154 return LresultFromObject(IID_IAccessible, w_param, |
| 154 static_cast<IAccessible*>(root.Detach())); | 155 static_cast<IAccessible*>(root.Detach())); |
| 155 } | 156 } |
| 156 | 157 |
| 157 // We send keyboard/mouse/touch messages to the parent window via SendMessage. | 158 // We send keyboard/mouse/touch messages to the parent window via SendMessage. |
| 158 // While this works, this has the side effect of converting input messages into | 159 // While this works, this has the side effect of converting input messages into |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 // generate the legacy WM_VSCROLL/WM_HSCROLL messages. | 324 // generate the legacy WM_VSCROLL/WM_HSCROLL messages. |
| 324 // We add these styles to ensure that trackpad/trackpoint scrolling | 325 // We add these styles to ensure that trackpad/trackpoint scrolling |
| 325 // work. | 326 // work. |
| 326 long current_style = ::GetWindowLong(hwnd(), GWL_STYLE); | 327 long current_style = ::GetWindowLong(hwnd(), GWL_STYLE); |
| 327 ::SetWindowLong(hwnd(), GWL_STYLE, | 328 ::SetWindowLong(hwnd(), GWL_STYLE, |
| 328 current_style | WS_VSCROLL | WS_HSCROLL); | 329 current_style | WS_VSCROLL | WS_HSCROLL); |
| 329 return 0; | 330 return 0; |
| 330 } | 331 } |
| 331 | 332 |
| 332 } // namespace content | 333 } // namespace content |
| OLD | NEW |