Index: content/browser/renderer_host/legacy_render_widget_host_win.h |
=================================================================== |
--- content/browser/renderer_host/legacy_render_widget_host_win.h (revision 0) |
+++ content/browser/renderer_host/legacy_render_widget_host_win.h (revision 0) |
@@ -0,0 +1,134 @@ |
+// Copyright (c) 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_BROWSER_RENDERER_HOST_LEGACY_RENDER_WIDGET_HOST_WIN_H_ |
+#define CONTENT_BROWSER_RENDERER_HOST_LEGACY_RENDER_WIDGET_HOST_WIN_H_ |
+ |
+#include <atlbase.h> |
+#include <atlapp.h> |
+#include <atlcom.h> |
+#include <atlcrack.h> |
+#include <oleacc.h> |
+ |
+#include "base/basictypes.h" |
+#include "base/win/scoped_comptr.h" |
+#include "content/common/content_export.h" |
+ |
+namespace content { |
+class BrowserAccessibilityManagerWin; |
+ |
+// Some screen readers expect every tab / every unique web content container |
+// to be in its own HWND with class name Chrome_RenderWidgetHostHWND. |
+// With Aura there is one main HWND which comprises the whole browser window or |
+// the whole desktop. So, we need a fake HWND with the window class as |
+// Chrome_RenderWidgetHostHWND as the root of the accessibility tree for each |
+// tab. Additionally there are legacy drivers for trackpads/trackpoints which |
+// also have special code for sending mouse wheel and scroll events to the |
+// Chrome_RenderWidgetHostHWND window. |
+// We should get rid of this code when the latest two versions of all |
+// supported screen readers and legacy drivers no longer make this assumption. |
+ |
+// This class implements a child HWND with the same size as the content area, |
+// 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 CONTENT_EXPORT LegacyRenderWidgetHostHWND |
+ : public ATL::CWindowImpl<LegacyRenderWidgetHostHWND, |
+ NON_EXPORTED_BASE(ATL::CWindow), |
+ ATL::CWinTraits<WS_CHILD> > { |
+ public: |
+ // Unfortunately, some screen readers trackpoint drivers 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); |
+ |
+ explicit LegacyRenderWidgetHostHWND(HWND parent); |
+ ~LegacyRenderWidgetHostHWND(); |
+ |
+ BEGIN_MSG_MAP_EX(LegacyRenderWidgetHostHWND) |
+ MESSAGE_HANDLER_EX(WM_GETOBJECT, OnGetObject) |
+ MESSAGE_RANGE_HANDLER(WM_KEYFIRST, WM_KEYLAST, OnKeyboardRange) |
+ MESSAGE_HANDLER_EX(WM_PAINT, OnPaint) |
+ MESSAGE_HANDLER_EX(WM_NCPAINT, OnNCPaint) |
+ MESSAGE_HANDLER_EX(WM_ERASEBKGND, OnEraseBkGnd) |
+ MESSAGE_RANGE_HANDLER(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange) |
+ MESSAGE_HANDLER_EX(WM_SETCURSOR, OnSetCursor) |
+ MESSAGE_HANDLER_EX(WM_TOUCH, OnTouch) |
+ END_MSG_MAP() |
+ |
+ HWND hwnd() { return m_hWnd; } |
+ |
+ HWND parent() { return parent_; } |
+ |
+ IAccessible* window_accessible() { return window_accessible_; } |
+ |
+ void set_browser_accessibility_manager( |
+ content::BrowserAccessibilityManagerWin* manager) { |
+ manager_ = manager; |
+ } |
+ |
+ void OnManagerDeleted(); |
+ |
+ void Show(); |
+ void Hide(); |
+ |
+ protected: |
+ virtual void OnFinalMessage(HWND hwnd) OVERRIDE; |
+ |
+ private: |
+ // To ensure that the Legacy HWND is as non intrusive as possible, we set |
+ // capture to the parent window when we receive a mouse move. After that |
+ // all mouse messages go to the parent. We need to release capture on the |
+ // parent window when the mouse leaves the bounds of the legacy HWND. Tp |
+ // achieve this and not touch any existing code, we subclass the parent HWND |
+ // and handle mouse moves. When we find that the mouse has left the legacy |
+ // HWND or if another HWND lies beneath the mouse, we release capture. |
+ class MouseWindowBoundsTracker |
+ : public ATL::CWindowImpl<MouseWindowBoundsTracker> { |
+ public: |
+ MouseWindowBoundsTracker(); |
+ ~MouseWindowBoundsTracker(); |
+ |
+ BEGIN_MSG_MAP_EX(MouseWindowBoundsTracker) |
+ MESSAGE_HANDLER_EX(WM_MOUSEMOVE, OnMouseMove) |
+ END_MSG_MAP() |
+ |
+ void set_tracking_window(HWND tracking_window) { |
+ tracking_window_ = tracking_window; |
+ } |
+ |
+ private: |
+ LRESULT OnMouseMove(UINT message, WPARAM w_param, LPARAM l_param); |
+ |
+ // The handle to the legacy child window whose bounds are used to track |
+ // whether capture is to be released. |
+ HWND tracking_window_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(MouseWindowBoundsTracker); |
+ }; |
+ |
+ LRESULT OnEraseBkGnd(UINT message, WPARAM w_param, LPARAM l_param); |
+ LRESULT OnGetObject(UINT message, WPARAM w_param, LPARAM l_param); |
+ LRESULT OnKeyboardRange(UINT message, WPARAM w_param, LPARAM l_param, |
+ BOOL& handled); |
+ LRESULT OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param, |
+ BOOL& handled); |
+ LRESULT OnNCPaint(UINT message, WPARAM w_param, LPARAM l_param); |
+ LRESULT OnPaint(UINT message, WPARAM w_param, LPARAM l_param); |
+ LRESULT OnSetCursor(UINT message, WPARAM w_param, LPARAM l_param); |
+ LRESULT OnTouch(UINT message, WPARAM w_param, LPARAM l_param); |
+ |
+ content::BrowserAccessibilityManagerWin* manager_; |
+ base::win::ScopedComPtr<IAccessible> window_accessible_; |
+ HWND parent_; |
+ MouseWindowBoundsTracker mouse_window_bounds_tracker_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(LegacyRenderWidgetHostHWND); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_BROWSER_RENDERER_HOST_LEGACY_RENDER_WIDGET_HOST_WIN_H_ |
+ |