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