Index: content/browser/accessibility/browser_accessibility_manager_win.cc |
=================================================================== |
--- content/browser/accessibility/browser_accessibility_manager_win.cc (revision 249488) |
+++ content/browser/accessibility/browser_accessibility_manager_win.cc (working copy) |
@@ -4,104 +4,24 @@ |
#include "content/browser/accessibility/browser_accessibility_manager_win.h" |
-#include <atlbase.h> |
-#include <atlapp.h> |
-#include <atlcom.h> |
-#include <atlcrack.h> |
-#include <oleacc.h> |
- |
#include "base/command_line.h" |
#include "base/win/scoped_comptr.h" |
#include "base/win/windows_version.h" |
#include "content/browser/accessibility/browser_accessibility_state_impl.h" |
#include "content/browser/accessibility/browser_accessibility_win.h" |
+#include "content/browser/renderer_host/legacy_render_widget_host_win.h" |
#include "content/common/accessibility_messages.h" |
namespace content { |
-// Some screen readers expect every tab / every unique web content container |
-// to be in its own HWND, like it was before Aura, but with Aura there's just |
-// one main HWND for a frame, or even for the whole desktop. So, we need a |
-// fake HWND as the root of the accessibility tree for each tab. |
-// We should get rid of this code when the latest two versions of all |
-// supported screen readers no longer make this assumption. |
-// |
-// This class implements a child HWND with zero size, that delegates its |
-// accessibility implementation to the root of the BrowserAccessibilityManager |
-// tree. This HWND is hooked up as the parent of the root object in the |
-// BrowserAccessibilityManager tree, so when any accessibility client |
-// calls ::WindowFromAccessibleObject, they get this HWND instead of the |
-// DesktopWindowTreeHostWin. |
-class AccessibleHWND |
- : public ATL::CWindowImpl<AccessibleHWND, |
- ATL::CWindow, |
- ATL::CWinTraits<WS_CHILD> > { |
- public: |
- // Unfortunately, some screen readers look for this exact window class |
- // to enable certain features. It'd be great to remove this. |
- DECLARE_WND_CLASS_EX(L"Chrome_RenderWidgetHostHWND", CS_DBLCLKS, 0); |
- |
- BEGIN_MSG_MAP_EX(AccessibleHWND) |
- MESSAGE_HANDLER_EX(WM_GETOBJECT, OnGetObject) |
- END_MSG_MAP() |
- |
- AccessibleHWND(HWND parent, BrowserAccessibilityManagerWin* manager) |
- : manager_(manager) { |
- Create(parent); |
- ShowWindow(true); |
- MoveWindow(0, 0, 0, 0); |
- |
- HRESULT hr = ::CreateStdAccessibleObject( |
- hwnd(), OBJID_WINDOW, IID_IAccessible, |
- reinterpret_cast<void **>(window_accessible_.Receive())); |
- DCHECK(SUCCEEDED(hr)); |
- } |
- |
- HWND hwnd() { |
- DCHECK(::IsWindow(m_hWnd)); |
- return m_hWnd; |
- } |
- |
- IAccessible* window_accessible() { return window_accessible_; } |
- |
- void OnManagerDeleted() { |
- manager_ = NULL; |
- } |
- |
- protected: |
- virtual void OnFinalMessage(HWND hwnd) OVERRIDE { |
- if (manager_) |
- manager_->OnAccessibleHwndDeleted(); |
- delete this; |
- } |
- |
- private: |
- LRESULT OnGetObject(UINT message, |
- WPARAM w_param, |
- LPARAM l_param) { |
- if (OBJID_CLIENT != l_param || !manager_) |
- return static_cast<LRESULT>(0L); |
- |
- base::win::ScopedComPtr<IAccessible> root( |
- manager_->GetRoot()->ToBrowserAccessibilityWin()); |
- return LresultFromObject(IID_IAccessible, w_param, |
- static_cast<IAccessible*>(root.Detach())); |
- } |
- |
- BrowserAccessibilityManagerWin* manager_; |
- base::win::ScopedComPtr<IAccessible> window_accessible_; |
- |
- DISALLOW_COPY_AND_ASSIGN(AccessibleHWND); |
-}; |
- |
- |
// static |
BrowserAccessibilityManager* BrowserAccessibilityManager::Create( |
const ui::AXNodeData& src, |
BrowserAccessibilityDelegate* delegate, |
BrowserAccessibilityFactory* factory) { |
return new BrowserAccessibilityManagerWin( |
- GetDesktopWindow(), NULL, src, delegate, factory); |
+ content::LegacyRenderWidgetHostHWND::Create(GetDesktopWindow()).get(), |
+ NULL, src, delegate, factory); |
} |
BrowserAccessibilityManagerWin* |
@@ -110,16 +30,16 @@ |
} |
BrowserAccessibilityManagerWin::BrowserAccessibilityManagerWin( |
- HWND parent_hwnd, |
+ LegacyRenderWidgetHostHWND* accessible_hwnd, |
IAccessible* parent_iaccessible, |
const ui::AXNodeData& src, |
BrowserAccessibilityDelegate* delegate, |
BrowserAccessibilityFactory* factory) |
: BrowserAccessibilityManager(src, delegate, factory), |
- parent_hwnd_(parent_hwnd), |
+ parent_hwnd_(accessible_hwnd->GetParent()), |
parent_iaccessible_(parent_iaccessible), |
tracked_scroll_object_(NULL), |
- accessible_hwnd_(NULL) { |
+ accessible_hwnd_(accessible_hwnd) { |
} |
BrowserAccessibilityManagerWin::~BrowserAccessibilityManagerWin() { |
@@ -149,16 +69,15 @@ |
if (!parent_iaccessible()) |
return; |
- // If on Win 7 and complete accessibility is enabled, create a fake child HWND |
+ // If on Win 7 and complete accessibility is enabled, use the fake child HWND |
// to use as the root of the accessibility tree. See comments above |
- // AccessibleHWND for details. |
- if (BrowserAccessibilityStateImpl::GetInstance()->IsAccessibleBrowser() && |
- !accessible_hwnd_) { |
- accessible_hwnd_ = new AccessibleHWND(parent_hwnd_, this); |
+ // LegacyRenderWidgetHostHWND for details. |
+ if (BrowserAccessibilityStateImpl::GetInstance()->IsAccessibleBrowser()) { |
+ DCHECK(accessible_hwnd_); |
+ accessible_hwnd_->set_browser_accessibility_manager(this); |
parent_hwnd_ = accessible_hwnd_->hwnd(); |
parent_iaccessible_ = accessible_hwnd_->window_accessible(); |
} |
- |
::NotifyWinEvent(event, parent_hwnd(), OBJID_CLIENT, child_id); |
} |