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

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 <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 // WebContents, etc. This causes the plugin mouse event calculations to
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 typedef ATL::CWindowImpl<LegacyRenderWidgetHostHWND,
52 NON_EXPORTED_BASE(ATL::CWindow),
53 ATL::CWinTraits<WS_CHILD> > Base;
54
55 // Creates and returns an instance of the LegacyRenderWidgetHostHWND class on
56 // successful creation of a child window parented to the parent window passed
57 // in. Returns NULL on failure to create the child window.
58 static LegacyRenderWidgetHostHWND* Create(HWND parent);
sky 2014/02/05 23:56:41 nit: make this return a scoped_ptr.
ananta 2014/02/06 00:42:04 Done.
59
60 ~LegacyRenderWidgetHostHWND();
61
62 BEGIN_MSG_MAP_EX(LegacyRenderWidgetHostHWND)
63 MESSAGE_HANDLER_EX(WM_GETOBJECT, OnGetObject)
64 MESSAGE_RANGE_HANDLER(WM_KEYFIRST, WM_KEYLAST, OnKeyboardRange)
65 MESSAGE_HANDLER_EX(WM_PAINT, OnPaint)
66 MESSAGE_HANDLER_EX(WM_NCPAINT, OnNCPaint)
67 MESSAGE_HANDLER_EX(WM_ERASEBKGND, OnEraseBkGnd)
68 MESSAGE_RANGE_HANDLER(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange)
69 MESSAGE_HANDLER_EX(WM_MOUSEACTIVATE, OnMouseActivate)
70 MESSAGE_HANDLER_EX(WM_SETCURSOR, OnSetCursor)
71 MESSAGE_HANDLER_EX(WM_TOUCH, OnTouch)
72 END_MSG_MAP()
73
74 HWND hwnd() { return m_hWnd; }
75
76 // Called when the child window is to be reparented to a new window.
77 // The |parent| parameter contains the new parent window.
78 void UpdateParent(HWND parent);
79 HWND GetParent();
80
81 IAccessible* window_accessible() { return window_accessible_; }
82
83 void set_browser_accessibility_manager(
84 content::BrowserAccessibilityManagerWin* manager) {
85 manager_ = manager;
86 }
87
88 void OnManagerDeleted();
89
90 // Functions to show and hide the window.
91 void Show();
92 void Hide();
93
94 // Resizes the window to the bounds passed in.
95 void SetBounds(const gfx::Rect& bounds);
96
97 protected:
98 virtual void OnFinalMessage(HWND hwnd) OVERRIDE;
99
100 private:
101 LegacyRenderWidgetHostHWND(HWND parent);
102
103 bool Init();
104
105 LRESULT OnEraseBkGnd(UINT message, WPARAM w_param, LPARAM l_param);
106 LRESULT OnGetObject(UINT message, WPARAM w_param, LPARAM l_param);
107 LRESULT OnKeyboardRange(UINT message, WPARAM w_param, LPARAM l_param,
108 BOOL& handled);
109 LRESULT OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param,
110 BOOL& handled);
111 LRESULT OnMouseActivate(UINT message, WPARAM w_param, LPARAM l_param);
112 LRESULT OnTouch(UINT message, WPARAM w_param, LPARAM l_param);
113
114 LRESULT OnNCPaint(UINT message, WPARAM w_param, LPARAM l_param);
115 LRESULT OnPaint(UINT message, WPARAM w_param, LPARAM l_param);
116 LRESULT OnSetCursor(UINT message, WPARAM w_param, LPARAM l_param);
117
118 content::BrowserAccessibilityManagerWin* manager_;
119 base::win::ScopedComPtr<IAccessible> window_accessible_;
120
121 DISALLOW_COPY_AND_ASSIGN(LegacyRenderWidgetHostHWND);
122 };
123
124 } // namespace content
125
126 #endif // CONTENT_BROWSER_RENDERER_HOST_LEGACY_RENDER_WIDGET_HOST_WIN_H_
127
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698