Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Side by Side Diff: content/browser/renderer_host/legacy_render_widget_host_win.h

Issue 151083002: Create a visible window with class name Chrome_RenderWidgetHostHWND which corresponds to the bounds… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 <atlapp.h>
10 #include <atlcom.h>
11 #include <atlcrack.h>
12 #include <oleacc.h>
13
14 #include "base/basictypes.h"
15 #include "base/win/scoped_comptr.h"
16 #include "content/common/content_export.h"
17
18 namespace content {
19 class BrowserAccessibilityManagerWin;
20
21 // Some screen readers expect every tab / every unique web content container
22 // to be in its own HWND with class name Chrome_RenderWidgetHostHWND.
23 // With Aura there is one main HWND which comprises the whole browser window or
24 // the whole desktop. So, we need a fake HWND with the window class as
25 // Chrome_RenderWidgetHostHWND as the root of the accessibility tree for each
26 // tab. Additionally there are legacy drivers for trackpads/trackpoints which
27 // also have special code for sending mouse wheel and scroll events to the
28 // Chrome_RenderWidgetHostHWND window.
29 // We should get rid of this code when the latest two versions of all
30 // supported screen readers and legacy drivers no longer make this assumption.
31
32 // This class implements a child HWND with the same size as the content area,
33 // that delegates its accessibility implementation to the root of the
34 // BrowserAccessibilityManager tree. This HWND is hooked up as the parent of
35 // the root object in the BrowserAccessibilityManager tree, so when any
36 // accessibility client calls ::WindowFromAccessibleObject, they get this
37 // HWND instead of the DesktopWindowTreeHostWin.
38 class CONTENT_EXPORT LegacyRenderWidgetHostHWND
39 : public ATL::CWindowImpl<LegacyRenderWidgetHostHWND,
40 NON_EXPORTED_BASE(ATL::CWindow),
41 ATL::CWinTraits<WS_CHILD> > {
42 public:
43 // Unfortunately, some screen readers trackpoint drivers look for this exact
44 //window class to enable certain features. It'd be great to remove this.
45 DECLARE_WND_CLASS_EX(L"Chrome_RenderWidgetHostHWND", CS_DBLCLKS, 0);
46
47 explicit LegacyRenderWidgetHostHWND(HWND parent);
48 ~LegacyRenderWidgetHostHWND();
49
50 BEGIN_MSG_MAP_EX(LegacyRenderWidgetHostHWND)
51 MESSAGE_HANDLER_EX(WM_GETOBJECT, OnGetObject)
52 MESSAGE_RANGE_HANDLER(WM_KEYFIRST, WM_KEYLAST, OnKeyboardRange)
53 MESSAGE_HANDLER_EX(WM_PAINT, OnPaint)
54 MESSAGE_HANDLER_EX(WM_NCPAINT, OnNCPaint)
55 MESSAGE_HANDLER_EX(WM_ERASEBKGND, OnEraseBkGnd)
56 MESSAGE_RANGE_HANDLER(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange)
57 MESSAGE_HANDLER_EX(WM_SETCURSOR, OnSetCursor)
58 MESSAGE_HANDLER_EX(WM_TOUCH, OnTouch)
59 END_MSG_MAP()
60
61 HWND hwnd() { return m_hWnd; }
62
63 HWND parent() { return parent_; }
64
65 IAccessible* window_accessible() { return window_accessible_; }
66
67 void set_browser_accessibility_manager(
68 content::BrowserAccessibilityManagerWin* manager) {
69 manager_ = manager;
70 }
71
72 void OnManagerDeleted();
73
74 void Show();
75 void Hide();
76
77 protected:
78 virtual void OnFinalMessage(HWND hwnd) OVERRIDE;
79
80 private:
81 // To ensure that the Legacy HWND is as non intrusive as possible, we set
82 // capture to the parent window when we receive a mouse move. After that
83 // all mouse messages go to the parent. We need to release capture on the
84 // parent window when the mouse leaves the bounds of the legacy HWND. Tp
85 // achieve this and not touch any existing code, we subclass the parent HWND
86 // and handle mouse moves. When we find that the mouse has left the legacy
87 // HWND or if another HWND lies beneath the mouse, we release capture.
88 class MouseWindowBoundsTracker
89 : public ATL::CWindowImpl<MouseWindowBoundsTracker> {
90 public:
91 MouseWindowBoundsTracker();
92 ~MouseWindowBoundsTracker();
93
94 BEGIN_MSG_MAP_EX(MouseWindowBoundsTracker)
95 MESSAGE_HANDLER_EX(WM_MOUSEMOVE, OnMouseMove)
96 END_MSG_MAP()
97
98 void set_tracking_window(HWND tracking_window) {
99 tracking_window_ = tracking_window;
100 }
101
102 private:
103 LRESULT OnMouseMove(UINT message, WPARAM w_param, LPARAM l_param);
104
105 // The handle to the legacy child window whose bounds are used to track
106 // whether capture is to be released.
107 HWND tracking_window_;
108
109 DISALLOW_COPY_AND_ASSIGN(MouseWindowBoundsTracker);
110 };
111
112 LRESULT OnEraseBkGnd(UINT message, WPARAM w_param, LPARAM l_param);
113 LRESULT OnGetObject(UINT message, WPARAM w_param, LPARAM l_param);
114 LRESULT OnKeyboardRange(UINT message, WPARAM w_param, LPARAM l_param,
115 BOOL& handled);
116 LRESULT OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param,
117 BOOL& handled);
118 LRESULT OnNCPaint(UINT message, WPARAM w_param, LPARAM l_param);
119 LRESULT OnPaint(UINT message, WPARAM w_param, LPARAM l_param);
120 LRESULT OnSetCursor(UINT message, WPARAM w_param, LPARAM l_param);
121 LRESULT OnTouch(UINT message, WPARAM w_param, LPARAM l_param);
122
123 content::BrowserAccessibilityManagerWin* manager_;
124 base::win::ScopedComPtr<IAccessible> window_accessible_;
125 HWND parent_;
126 MouseWindowBoundsTracker mouse_window_bounds_tracker_;
127
128 DISALLOW_COPY_AND_ASSIGN(LegacyRenderWidgetHostHWND);
129 };
130
131 } // namespace content
132
133 #endif // CONTENT_BROWSER_RENDERER_HOST_LEGACY_RENDER_WIDGET_HOST_WIN_H_
134
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698