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

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

Issue 796333009: Revert "Create only a single LegacyRenderWidgetHostHWND per WebContentsViewAura." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 12 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
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_LEGACY_RENDER_WIDGET_HOST_WIN_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_LEGACY_RENDER_WIDGET_HOST_WIN_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_LEGACY_RENDER_WIDGET_HOST_WIN_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_LEGACY_RENDER_WIDGET_HOST_WIN_H_
7 7
8 #include <atlbase.h> 8 #include <atlbase.h>
9 #include <atlwin.h> 9 #include <atlwin.h>
10 #include <atlcrack.h> 10 #include <atlcrack.h>
11 #include <oleacc.h> 11 #include <oleacc.h>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/win/scoped_comptr.h" 14 #include "base/win/scoped_comptr.h"
15 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
16 #include "ui/gfx/native_widget_types.h"
17 #include "ui/gfx/rect.h" 16 #include "ui/gfx/rect.h"
18 17
19 namespace ui { 18 namespace ui {
20 class WindowEventTarget; 19 class WindowEventTarget;
21 } 20 }
22 21
23 namespace content { 22 namespace content {
23 class RenderWidgetHostViewAura;
24
24 // Reasons for the existence of this class outlined below:- 25 // Reasons for the existence of this class outlined below:-
25 // 1. Some screen readers expect every tab / every unique web content container 26 // 1. Some screen readers expect every tab / every unique web content container
26 // to be in its own HWND with class name Chrome_RenderWidgetHostHWND. 27 // to be in its own HWND with class name Chrome_RenderWidgetHostHWND.
27 // With Aura there is one main HWND which comprises the whole browser window 28 // With Aura there is one main HWND which comprises the whole browser window
28 // or the whole desktop. So, we need a fake HWND with the window class as 29 // or the whole desktop. So, we need a fake HWND with the window class as
29 // Chrome_RenderWidgetHostHWND as the root of the accessibility tree for 30 // Chrome_RenderWidgetHostHWND as the root of the accessibility tree for
30 // each tab. 31 // each tab.
31 // 2. There are legacy drivers for trackpads/trackpoints which have special 32 // 2. There are legacy drivers for trackpads/trackpoints which have special
32 // code for sending mouse wheel and scroll events to the 33 // code for sending mouse wheel and scroll events to the
33 // Chrome_RenderWidgetHostHWND window. 34 // Chrome_RenderWidgetHostHWND window.
34 // 3. Windowless NPAPI plugins like Flash and Silverlight which expect the 35 // 3. Windowless NPAPI plugins like Flash and Silverlight which expect the
35 // container window to have the same bounds as the web page. In Aura, the 36 // container window to have the same bounds as the web page. In Aura, the
36 // default container window is the whole window which includes the web page 37 // default container window is the whole window which includes the web page
37 // WebContents, etc. This causes the plugin mouse event calculations to 38 // WebContents, etc. This causes the plugin mouse event calculations to
38 // fail. 39 // fail.
39 // We should look to get rid of this code when all of the above are fixed. 40 // We should look to get rid of this code when all of the above are fixed.
40 41
41 class LegacyRenderWidgetHostHWNDDelegate;
42
43 // This class implements a child HWND with the same size as the content area, 42 // This class implements a child HWND with the same size as the content area,
44 // and delegates its accessibility implementation to the 43 // that delegates its accessibility implementation to the root of the
45 // gfx::NativeViewAccessible provided by the owner class. 44 // BrowserAccessibilityManager tree. This HWND is hooked up as the parent of
45 // the root object in the BrowserAccessibilityManager tree, so when any
46 // accessibility client calls ::WindowFromAccessibleObject, they get this
47 // HWND instead of the DesktopWindowTreeHostWin.
46 class CONTENT_EXPORT LegacyRenderWidgetHostHWND 48 class CONTENT_EXPORT LegacyRenderWidgetHostHWND
47 : public ATL::CWindowImpl<LegacyRenderWidgetHostHWND, 49 : public ATL::CWindowImpl<LegacyRenderWidgetHostHWND,
48 NON_EXPORTED_BASE(ATL::CWindow), 50 NON_EXPORTED_BASE(ATL::CWindow),
49 ATL::CWinTraits<WS_CHILD> > { 51 ATL::CWinTraits<WS_CHILD> > {
50 public: 52 public:
51 DECLARE_WND_CLASS_EX(L"Chrome_RenderWidgetHostHWND", CS_DBLCLKS, 0); 53 DECLARE_WND_CLASS_EX(L"Chrome_RenderWidgetHostHWND", CS_DBLCLKS, 0);
52 54
53 typedef ATL::CWindowImpl<LegacyRenderWidgetHostHWND, 55 typedef ATL::CWindowImpl<LegacyRenderWidgetHostHWND,
54 NON_EXPORTED_BASE(ATL::CWindow), 56 NON_EXPORTED_BASE(ATL::CWindow),
55 ATL::CWinTraits<WS_CHILD> > Base; 57 ATL::CWinTraits<WS_CHILD> > Base;
56 58
57 virtual ~LegacyRenderWidgetHostHWND();
58
59 // Creates and returns an instance of the LegacyRenderWidgetHostHWND class on 59 // Creates and returns an instance of the LegacyRenderWidgetHostHWND class on
60 // successful creation of a child window parented to the parent window passed 60 // successful creation of a child window parented to the parent window passed
61 // in. 61 // in.
62 static LegacyRenderWidgetHostHWND* Create( 62 static LegacyRenderWidgetHostHWND* Create(HWND parent);
63 HWND parent, 63
64 LegacyRenderWidgetHostHWNDDelegate* delegate); 64 // Destroys the HWND managed by this class.
65 void Destroy();
65 66
66 BEGIN_MSG_MAP_EX(LegacyRenderWidgetHostHWND) 67 BEGIN_MSG_MAP_EX(LegacyRenderWidgetHostHWND)
67 MESSAGE_HANDLER_EX(WM_GETOBJECT, OnGetObject) 68 MESSAGE_HANDLER_EX(WM_GETOBJECT, OnGetObject)
68 MESSAGE_RANGE_HANDLER(WM_KEYFIRST, WM_KEYLAST, OnKeyboardRange) 69 MESSAGE_RANGE_HANDLER(WM_KEYFIRST, WM_KEYLAST, OnKeyboardRange)
69 MESSAGE_HANDLER_EX(WM_PAINT, OnPaint) 70 MESSAGE_HANDLER_EX(WM_PAINT, OnPaint)
70 MESSAGE_HANDLER_EX(WM_NCPAINT, OnNCPaint) 71 MESSAGE_HANDLER_EX(WM_NCPAINT, OnNCPaint)
71 MESSAGE_HANDLER_EX(WM_ERASEBKGND, OnEraseBkGnd) 72 MESSAGE_HANDLER_EX(WM_ERASEBKGND, OnEraseBkGnd)
72 MESSAGE_RANGE_HANDLER(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange) 73 MESSAGE_RANGE_HANDLER(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange)
73 MESSAGE_HANDLER_EX(WM_MOUSELEAVE, OnMouseLeave) 74 MESSAGE_HANDLER_EX(WM_MOUSELEAVE, OnMouseLeave)
74 MESSAGE_HANDLER_EX(WM_MOUSEACTIVATE, OnMouseActivate) 75 MESSAGE_HANDLER_EX(WM_MOUSEACTIVATE, OnMouseActivate)
75 MESSAGE_HANDLER_EX(WM_SETCURSOR, OnSetCursor) 76 MESSAGE_HANDLER_EX(WM_SETCURSOR, OnSetCursor)
76 MESSAGE_HANDLER_EX(WM_TOUCH, OnTouch) 77 MESSAGE_HANDLER_EX(WM_TOUCH, OnTouch)
77 MESSAGE_HANDLER_EX(WM_HSCROLL, OnScroll) 78 MESSAGE_HANDLER_EX(WM_HSCROLL, OnScroll)
78 MESSAGE_HANDLER_EX(WM_VSCROLL, OnScroll) 79 MESSAGE_HANDLER_EX(WM_VSCROLL, OnScroll)
79 MESSAGE_HANDLER_EX(WM_NCHITTEST, OnNCHitTest) 80 MESSAGE_HANDLER_EX(WM_NCHITTEST, OnNCHitTest)
80 MESSAGE_RANGE_HANDLER(WM_NCMOUSEMOVE, WM_NCXBUTTONDBLCLK, 81 MESSAGE_RANGE_HANDLER(WM_NCMOUSEMOVE, WM_NCXBUTTONDBLCLK,
81 OnMouseRange) 82 OnMouseRange)
82 MESSAGE_HANDLER_EX(WM_NCCALCSIZE, OnNCCalcSize) 83 MESSAGE_HANDLER_EX(WM_NCCALCSIZE, OnNCCalcSize)
83 MESSAGE_HANDLER_EX(WM_SIZE, OnSize) 84 MESSAGE_HANDLER_EX(WM_SIZE, OnSize)
84 END_MSG_MAP() 85 END_MSG_MAP()
85 86
86 // May be deleted at any time by Windows! Other classes should never store
87 // this value.
88 HWND hwnd() { return m_hWnd; } 87 HWND hwnd() { return m_hWnd; }
89 88
90 // Called when the child window is to be reparented to a new window. 89 // Called when the child window is to be reparented to a new window.
91 // The |parent| parameter contains the new parent window. 90 // The |parent| parameter contains the new parent window.
92 void UpdateParent(HWND parent); 91 void UpdateParent(HWND parent);
93 HWND GetParent(); 92 HWND GetParent();
94 93
95 IAccessible* window_accessible() { return window_accessible_.get(); } 94 IAccessible* window_accessible() { return window_accessible_.get(); }
96 95
97 // Functions to show and hide the window. 96 // Functions to show and hide the window.
98 void Show(); 97 void Show();
99 void Hide(); 98 void Hide();
100 99
101 // Resizes the window to the bounds passed in. 100 // Resizes the window to the bounds passed in.
102 void SetBounds(const gfx::Rect& bounds); 101 void SetBounds(const gfx::Rect& bounds);
103 102
103 // The pointer to the containing RenderWidgetHostViewAura instance is passed
104 // here.
105 void set_host(RenderWidgetHostViewAura* host) {
106 host_ = host;
107 }
108
109 protected:
110 virtual void OnFinalMessage(HWND hwnd) override;
111
104 private: 112 private:
105 LegacyRenderWidgetHostHWND(HWND parent, 113 LegacyRenderWidgetHostHWND(HWND parent);
106 LegacyRenderWidgetHostHWNDDelegate* delegate); 114 ~LegacyRenderWidgetHostHWND();
107 115
108 bool Init(); 116 bool Init();
109 117
110 // Returns the target to which the windows input events are forwarded. 118 // Returns the target to which the windows input events are forwarded.
111 static ui::WindowEventTarget* GetWindowEventTarget(HWND parent); 119 static ui::WindowEventTarget* GetWindowEventTarget(HWND parent);
112 120
113 LRESULT OnEraseBkGnd(UINT message, WPARAM w_param, LPARAM l_param); 121 LRESULT OnEraseBkGnd(UINT message, WPARAM w_param, LPARAM l_param);
114 LRESULT OnGetObject(UINT message, WPARAM w_param, LPARAM l_param); 122 LRESULT OnGetObject(UINT message, WPARAM w_param, LPARAM l_param);
115 LRESULT OnKeyboardRange(UINT message, WPARAM w_param, LPARAM l_param, 123 LRESULT OnKeyboardRange(UINT message, WPARAM w_param, LPARAM l_param,
116 BOOL& handled); 124 BOOL& handled);
117 LRESULT OnMouseLeave(UINT message, WPARAM w_param, LPARAM l_param); 125 LRESULT OnMouseLeave(UINT message, WPARAM w_param, LPARAM l_param);
118 LRESULT OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param, 126 LRESULT OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param,
119 BOOL& handled); 127 BOOL& handled);
120 LRESULT OnMouseActivate(UINT message, WPARAM w_param, LPARAM l_param); 128 LRESULT OnMouseActivate(UINT message, WPARAM w_param, LPARAM l_param);
121 LRESULT OnTouch(UINT message, WPARAM w_param, LPARAM l_param); 129 LRESULT OnTouch(UINT message, WPARAM w_param, LPARAM l_param);
122 LRESULT OnScroll(UINT message, WPARAM w_param, LPARAM l_param); 130 LRESULT OnScroll(UINT message, WPARAM w_param, LPARAM l_param);
123 LRESULT OnNCHitTest(UINT message, WPARAM w_param, LPARAM l_param); 131 LRESULT OnNCHitTest(UINT message, WPARAM w_param, LPARAM l_param);
124 132
125 LRESULT OnNCPaint(UINT message, WPARAM w_param, LPARAM l_param); 133 LRESULT OnNCPaint(UINT message, WPARAM w_param, LPARAM l_param);
126 LRESULT OnPaint(UINT message, WPARAM w_param, LPARAM l_param); 134 LRESULT OnPaint(UINT message, WPARAM w_param, LPARAM l_param);
127 LRESULT OnSetCursor(UINT message, WPARAM w_param, LPARAM l_param); 135 LRESULT OnSetCursor(UINT message, WPARAM w_param, LPARAM l_param);
128 LRESULT OnNCCalcSize(UINT message, WPARAM w_param, LPARAM l_param); 136 LRESULT OnNCCalcSize(UINT message, WPARAM w_param, LPARAM l_param);
129 LRESULT OnSize(UINT message, WPARAM w_param, LPARAM l_param); 137 LRESULT OnSize(UINT message, WPARAM w_param, LPARAM l_param);
130 138
131 LegacyRenderWidgetHostHWNDDelegate* delegate_;
132
133 base::win::ScopedComPtr<IAccessible> window_accessible_; 139 base::win::ScopedComPtr<IAccessible> window_accessible_;
134 140
135 // Set to true if we turned on mouse tracking. 141 // Set to true if we turned on mouse tracking.
136 bool mouse_tracking_enabled_; 142 bool mouse_tracking_enabled_;
137 143
144 RenderWidgetHostViewAura* host_;
145
138 DISALLOW_COPY_AND_ASSIGN(LegacyRenderWidgetHostHWND); 146 DISALLOW_COPY_AND_ASSIGN(LegacyRenderWidgetHostHWND);
139 }; 147 };
140 148
141 } // namespace content 149 } // namespace content
142 150
143 #endif // CONTENT_BROWSER_RENDERER_HOST_LEGACY_RENDER_WIDGET_HOST_WIN_H_ 151 #endif // CONTENT_BROWSER_RENDERER_HOST_LEGACY_RENDER_WIDGET_HOST_WIN_H_
152
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698