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

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

Powered by Google App Engine
This is Rietveld 408576698