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

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

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 #include "content/browser/renderer_host/legacy_render_widget_host_win.h"
6
7 #include "base/win/windows_version.h"
8 #include "content/browser/accessibility/browser_accessibility_manager_win.h"
9 #include "content/browser/accessibility/browser_accessibility_win.h"
10 #include "ui/base/touch/touch_enabled.h"
11 #include "ui/gfx/geometry/rect.h"
12
13 namespace content {
14
15 LegacyRenderWidgetHostHWND::LegacyRenderWidgetHostHWND(HWND parent)
16 : manager_(NULL),
17 parent_(NULL) {
18 RECT rect = {0};
19 Create(parent, rect, L"Chrome Legacy Window",
20 WS_CHILDWINDOW, WS_EX_TRANSPARENT);
21
sky 2014/02/05 15:22:44 CheckWindowCreated(hwnd())
ananta 2014/02/05 16:35:51 Cannot use that as this code would also run for Wi
22 if (base::win::GetVersion() >= base::win::VERSION_WIN7 &&
23 ui::AreTouchEventsEnabled())
24 RegisterTouchWindow(hwnd(), TWF_WANTPALM);
25
26 HRESULT hr = ::CreateStdAccessibleObject(
sky 2014/02/05 15:22:44 Did you intend to check the result? If not, no nee
ananta 2014/02/05 16:35:51 Added a DCHECK for hr.
27 hwnd(), OBJID_WINDOW, IID_IAccessible,
28 reinterpret_cast<void **>(window_accessible_.Receive()));
29
30 if (::IsWindow(hwnd()))
sky 2014/02/05 15:22:44 I don't think this if should be necessary.
ananta 2014/02/05 16:35:51 Done.
31 SetParentWindow(parent);
32 }
33
34 LegacyRenderWidgetHostHWND::~LegacyRenderWidgetHostHWND() {
35 }
36
37 void LegacyRenderWidgetHostHWND::SetParentWindow(HWND parent) {
38 ::SetParent(hwnd(), parent);
39 parent_ = parent;
40 }
41
42 void LegacyRenderWidgetHostHWND::OnManagerDeleted() {
43 manager_ = NULL;
44 }
45
46 void LegacyRenderWidgetHostHWND::Show() {
47 ::ShowWindow(hwnd(), SW_SHOW);
48 }
49
50 void LegacyRenderWidgetHostHWND::Hide() {
51 ::ShowWindow(hwnd(), SW_HIDE);
52 }
53
54 void LegacyRenderWidgetHostHWND::SetBounds(const gfx::Rect& bounds) {
55 if (::IsWindow(hwnd())) {
56 ::SetWindowPos(hwnd(), NULL, bounds.x(), bounds.y(), bounds.width(),
57 bounds.height(), 0);
58 }
59 }
60
61 void LegacyRenderWidgetHostHWND::Destroy() {
62 if (::IsWindow(hwnd()))
sky 2014/02/05 15:22:44 Can this be moved to the destructor instead? That
ananta 2014/02/05 16:35:51 Done.
63 ::DestroyWindow(hwnd());
64 delete this;
65 }
66
67 void LegacyRenderWidgetHostHWND::OnFinalMessage(HWND hwnd) {
68 if (manager_)
69 manager_->OnAccessibleHwndDeleted();
70 }
71
72 LRESULT LegacyRenderWidgetHostHWND::OnEraseBkGnd(UINT message,
73 WPARAM w_param,
74 LPARAM l_param) {
75 return 1;
76 }
77
78 LRESULT LegacyRenderWidgetHostHWND::OnGetObject(UINT message,
79 WPARAM w_param,
80 LPARAM l_param) {
81 if (OBJID_CLIENT != l_param || !manager_)
82 return static_cast<LRESULT>(0L);
83
84 base::win::ScopedComPtr<IAccessible> root(
85 manager_->GetRoot()->ToBrowserAccessibilityWin());
86 return LresultFromObject(IID_IAccessible, w_param,
87 static_cast<IAccessible*>(root.Detach()));
88 }
89
90 // We send keyboard/mouse/touch messages to the parent window via SendMessage.
91 // While this works, this has the side effect of converting input messages into
92 // sent messages which changes their priority and could technically result
93 // in these messages starving other messages in the queue. Additionally
94 // keyboard/mouse hooks would not see these messages. The alternative approach
95 // is to set and release capture as needed on the parent to ensure that it
96 // receives all mouse events. However that was shelved due to possible issues
97 // with capture changes.
98 LRESULT LegacyRenderWidgetHostHWND::OnKeyboardRange(UINT message,
99 WPARAM w_param,
100 LPARAM l_param,
101 BOOL& handled) {
102 return ::SendMessage(parent_, message, w_param, l_param);
103 }
104
105 LRESULT LegacyRenderWidgetHostHWND::OnMouseRange(UINT message,
106 WPARAM w_param,
107 LPARAM l_param,
108 BOOL& handled) {
109 POINT mouse_coords;
110 mouse_coords.x = GET_X_LPARAM(l_param);
111 mouse_coords.y = GET_Y_LPARAM(l_param);
112 ::MapWindowPoints(hwnd(), parent_, &mouse_coords, 1);
113 return ::SendMessage(parent_, message, w_param,
114 MAKELPARAM(mouse_coords.x, mouse_coords.y));
115 }
116
117 LRESULT LegacyRenderWidgetHostHWND::OnMouseActivate(UINT message,
118 WPARAM w_param,
119 LPARAM l_param) {
120 // Don't pass this to DefWindowProc. That results in the WM_MOUSEACTIVATE
121 // message going all the way to the parent which then messes up state
122 // related to focused views, etc. This is because it treats this as if
123 // it lost activation.
124 // Our dummy window should not interfere with focus and activation in
125 // the parent. Return MA_ACTIVATE here ensures that focus state in the parent
126 // is preserved.
127 return MA_ACTIVATE;
128 }
129
130 LRESULT LegacyRenderWidgetHostHWND::OnTouch(UINT message,
131 WPARAM w_param,
132 LPARAM l_param) {
133 return ::SendMessage(parent_, message, w_param, l_param);
134 }
135
136 LRESULT LegacyRenderWidgetHostHWND::OnNCPaint(UINT message,
137 WPARAM w_param,
138 LPARAM l_param) {
139 return 0;
140 }
141
142 LRESULT LegacyRenderWidgetHostHWND::OnPaint(UINT message,
143 WPARAM w_param,
144 LPARAM l_param) {
145 PAINTSTRUCT ps = {0};
146 ::BeginPaint(hwnd(), &ps);
147 ::EndPaint(hwnd(), &ps);
148 return 0;
149 }
150
151 LRESULT LegacyRenderWidgetHostHWND::OnSetCursor(UINT message,
152 WPARAM w_param,
153 LPARAM l_param) {
154 return 0;
155 }
156
157 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698