OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_LEGACY_RENDER_WIDGET_HOST_WIN_H_ | |
6 #define CONTENT_BROWSER_RENDERER_HOST_LEGACY_RENDER_WIDGET_HOST_WIN_H_ | |
7 | |
8 #include <atlbase.h> | |
9 #include <atlwin.h> | |
10 #include <atlcrack.h> | |
11 #include <oleacc.h> | |
12 | |
13 #include "base/basictypes.h" | |
14 #include "base/win/scoped_comptr.h" | |
15 #include "content/common/content_export.h" | |
16 #include "ui/gfx/rect.h" | |
17 | |
18 namespace content { | |
19 class BrowserAccessibilityManagerWin; | |
20 | |
21 // Reasons for the existence of this class outlined below:- | |
22 // 1. Some screen readers expect every tab / every unique web content container | |
23 // to be in its own HWND with class name Chrome_RenderWidgetHostHWND. | |
24 // With Aura there is one main HWND which comprises the whole browser window | |
25 // or the whole desktop. So, we need a fake HWND with the window class as | |
26 // Chrome_RenderWidgetHostHWND as the root of the accessibility tree for | |
27 // each tab. | |
28 // 2. There are legacy drivers for trackpads/trackpoints which have special | |
29 // code for sending mouse wheel and scroll events to the | |
30 // Chrome_RenderWidgetHostHWND window. | |
31 // 3. Windowless NPAPI plugins like Flash and Silverlight which expect the | |
32 // container window to have the same bounds as the web page. In Aura, the | |
33 // default container window is the whole window which includes the web page | |
34 // TabContents, etc. This causes the plugin mouse event calculations to | |
sky
2014/02/05 15:22:44
nit: TabContents->WebContents.
ananta
2014/02/05 16:35:51
Done.
| |
35 // fail. | |
36 // We should look to get rid of this code when all of the above are fixed. | |
37 | |
38 // This class implements a child HWND with the same size as the content area, | |
39 // that delegates its accessibility implementation to the root of the | |
40 // BrowserAccessibilityManager tree. This HWND is hooked up as the parent of | |
41 // the root object in the BrowserAccessibilityManager tree, so when any | |
42 // accessibility client calls ::WindowFromAccessibleObject, they get this | |
43 // HWND instead of the DesktopWindowTreeHostWin. | |
44 class CONTENT_EXPORT LegacyRenderWidgetHostHWND | |
45 : public ATL::CWindowImpl<LegacyRenderWidgetHostHWND, | |
46 NON_EXPORTED_BASE(ATL::CWindow), | |
47 ATL::CWinTraits<WS_CHILD> > { | |
48 public: | |
49 DECLARE_WND_CLASS_EX(L"Chrome_RenderWidgetHostHWND", CS_DBLCLKS, 0); | |
50 | |
51 explicit LegacyRenderWidgetHostHWND(HWND parent); | |
52 ~LegacyRenderWidgetHostHWND(); | |
53 | |
54 BEGIN_MSG_MAP_EX(LegacyRenderWidgetHostHWND) | |
55 MESSAGE_HANDLER_EX(WM_GETOBJECT, OnGetObject) | |
56 MESSAGE_RANGE_HANDLER(WM_KEYFIRST, WM_KEYLAST, OnKeyboardRange) | |
57 MESSAGE_HANDLER_EX(WM_PAINT, OnPaint) | |
58 MESSAGE_HANDLER_EX(WM_NCPAINT, OnNCPaint) | |
59 MESSAGE_HANDLER_EX(WM_ERASEBKGND, OnEraseBkGnd) | |
60 MESSAGE_RANGE_HANDLER(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange) | |
61 MESSAGE_HANDLER_EX(WM_MOUSEACTIVATE, OnMouseActivate) | |
62 MESSAGE_HANDLER_EX(WM_SETCURSOR, OnSetCursor) | |
63 MESSAGE_HANDLER_EX(WM_TOUCH, OnTouch) | |
64 END_MSG_MAP() | |
65 | |
66 HWND hwnd() { return m_hWnd; } | |
67 | |
68 // This function handles setting the parent window if it changed, etc. | |
69 void SetParentWindow(HWND parent); | |
70 | |
71 HWND parent() { return parent_; } | |
72 | |
73 IAccessible* window_accessible() { return window_accessible_; } | |
74 | |
75 void set_browser_accessibility_manager( | |
76 content::BrowserAccessibilityManagerWin* manager) { | |
77 manager_ = manager; | |
78 } | |
79 | |
80 void OnManagerDeleted(); | |
81 | |
82 // Functions to show and hide the window. | |
83 void Show(); | |
84 void Hide(); | |
85 | |
86 // Resizes the window to the bounds passed in. | |
87 void SetBounds(const gfx::Rect& bounds); | |
88 | |
89 // Destroys the window, which in turn deletes the instance of this class. | |
90 void Destroy(); | |
91 | |
92 protected: | |
93 virtual void OnFinalMessage(HWND hwnd) OVERRIDE; | |
94 | |
95 private: | |
96 LRESULT OnEraseBkGnd(UINT message, WPARAM w_param, LPARAM l_param); | |
97 LRESULT OnGetObject(UINT message, WPARAM w_param, LPARAM l_param); | |
98 LRESULT OnKeyboardRange(UINT message, WPARAM w_param, LPARAM l_param, | |
99 BOOL& handled); | |
100 LRESULT OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param, | |
101 BOOL& handled); | |
102 LRESULT OnMouseActivate(UINT message, WPARAM w_param, LPARAM l_param); | |
103 LRESULT OnTouch(UINT message, WPARAM w_param, LPARAM l_param); | |
104 | |
105 LRESULT OnNCPaint(UINT message, WPARAM w_param, LPARAM l_param); | |
106 LRESULT OnPaint(UINT message, WPARAM w_param, LPARAM l_param); | |
107 LRESULT OnSetCursor(UINT message, WPARAM w_param, LPARAM l_param); | |
108 | |
109 content::BrowserAccessibilityManagerWin* manager_; | |
110 base::win::ScopedComPtr<IAccessible> window_accessible_; | |
111 HWND parent_; | |
112 | |
113 DISALLOW_COPY_AND_ASSIGN(LegacyRenderWidgetHostHWND); | |
114 }; | |
115 | |
116 } // namespace content | |
117 | |
118 #endif // CONTENT_BROWSER_RENDERER_HOST_LEGACY_RENDER_WIDGET_HOST_WIN_H_ | |
119 | |
OLD | NEW |