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

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

Issue 415633002: Simplify access to LegacyRenderWidgetHostHWND. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@render_frame_ax_4
Patch Set: Rebase and fix style issue Created 6 years, 4 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 #include "content/browser/renderer_host/legacy_render_widget_host_win.h" 5 #include "content/browser/renderer_host/legacy_render_widget_host_win.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/win/windows_version.h" 9 #include "base/win/windows_version.h"
10 #include "content/browser/accessibility/browser_accessibility_manager_win.h" 10 #include "content/browser/accessibility/browser_accessibility_manager_win.h"
11 #include "content/browser/accessibility/browser_accessibility_win.h" 11 #include "content/browser/accessibility/browser_accessibility_win.h"
12 #include "content/browser/renderer_host/render_widget_host_impl.h"
12 #include "content/browser/renderer_host/render_widget_host_view_aura.h" 13 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
13 #include "content/public/browser/browser_accessibility_state.h" 14 #include "content/public/browser/browser_accessibility_state.h"
14 #include "content/public/common/content_switches.h" 15 #include "content/public/common/content_switches.h"
15 #include "ui/base/touch/touch_enabled.h" 16 #include "ui/base/touch/touch_enabled.h"
16 #include "ui/base/view_prop.h" 17 #include "ui/base/view_prop.h"
17 #include "ui/base/win/internal_constants.h" 18 #include "ui/base/win/internal_constants.h"
18 #include "ui/base/win/window_event_target.h" 19 #include "ui/base/win/window_event_target.h"
19 #include "ui/gfx/geometry/rect.h" 20 #include "ui/gfx/geometry/rect.h"
20 #include "ui/gfx/win/dpi.h" 21 #include "ui/gfx/win/dpi.h"
21 22
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 ::EnableWindow(hwnd(), FALSE); 64 ::EnableWindow(hwnd(), FALSE);
64 } else { 65 } else {
65 ::EnableWindow(hwnd(), TRUE); 66 ::EnableWindow(hwnd(), TRUE);
66 } 67 }
67 } 68 }
68 69
69 HWND LegacyRenderWidgetHostHWND::GetParent() { 70 HWND LegacyRenderWidgetHostHWND::GetParent() {
70 return ::GetParent(hwnd()); 71 return ::GetParent(hwnd());
71 } 72 }
72 73
73 void LegacyRenderWidgetHostHWND::OnManagerDeleted(
74 content::BrowserAccessibilityManagerWin* manager) {
75 if (manager_ == manager)
76 manager_ = NULL;
77 }
78
79 void LegacyRenderWidgetHostHWND::Show() { 74 void LegacyRenderWidgetHostHWND::Show() {
80 ::ShowWindow(hwnd(), SW_SHOW); 75 ::ShowWindow(hwnd(), SW_SHOW);
81 } 76 }
82 77
83 void LegacyRenderWidgetHostHWND::Hide() { 78 void LegacyRenderWidgetHostHWND::Hide() {
84 ::ShowWindow(hwnd(), SW_HIDE); 79 ::ShowWindow(hwnd(), SW_HIDE);
85 } 80 }
86 81
87 void LegacyRenderWidgetHostHWND::SetBounds(const gfx::Rect& bounds) { 82 void LegacyRenderWidgetHostHWND::SetBounds(const gfx::Rect& bounds) {
88 gfx::Rect bounds_in_pixel = gfx::win::DIPToScreenRect(bounds); 83 gfx::Rect bounds_in_pixel = gfx::win::DIPToScreenRect(bounds);
89 ::SetWindowPos(hwnd(), NULL, bounds_in_pixel.x(), bounds_in_pixel.y(), 84 ::SetWindowPos(hwnd(), NULL, bounds_in_pixel.x(), bounds_in_pixel.y(),
90 bounds_in_pixel.width(), bounds_in_pixel.height(), 0); 85 bounds_in_pixel.width(), bounds_in_pixel.height(), 0);
91 } 86 }
92 87
93 void LegacyRenderWidgetHostHWND::OnFinalMessage(HWND hwnd) { 88 void LegacyRenderWidgetHostHWND::OnFinalMessage(HWND hwnd) {
94 if (manager_)
95 manager_->OnAccessibleHwndDeleted();
96 if (host_) { 89 if (host_) {
97 host_->OnLegacyWindowDestroyed(); 90 host_->OnLegacyWindowDestroyed();
98 host_ = NULL; 91 host_ = NULL;
99 } 92 }
100 delete this; 93 delete this;
101 } 94 }
102 95
103 LegacyRenderWidgetHostHWND::LegacyRenderWidgetHostHWND(HWND parent) 96 LegacyRenderWidgetHostHWND::LegacyRenderWidgetHostHWND(HWND parent)
104 : manager_(NULL), 97 : mouse_tracking_enabled_(false),
105 mouse_tracking_enabled_(false),
106 host_(NULL) { 98 host_(NULL) {
107 RECT rect = {0}; 99 RECT rect = {0};
108 Base::Create(parent, rect, L"Chrome Legacy Window", 100 Base::Create(parent, rect, L"Chrome Legacy Window",
109 WS_CHILDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 101 WS_CHILDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
110 WS_EX_TRANSPARENT); 102 WS_EX_TRANSPARENT);
111 } 103 }
112 104
113 LegacyRenderWidgetHostHWND::~LegacyRenderWidgetHostHWND() { 105 LegacyRenderWidgetHostHWND::~LegacyRenderWidgetHostHWND() {
114 DCHECK(!::IsWindow(hwnd())); 106 DCHECK(!::IsWindow(hwnd()));
115 } 107 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // because it sometimes gets sign-extended incorrectly (but not always). 146 // because it sometimes gets sign-extended incorrectly (but not always).
155 DWORD obj_id = static_cast<DWORD>(static_cast<DWORD_PTR>(l_param)); 147 DWORD obj_id = static_cast<DWORD>(static_cast<DWORD_PTR>(l_param));
156 148
157 if (kIdScreenReaderHoneyPot == obj_id) { 149 if (kIdScreenReaderHoneyPot == obj_id) {
158 // When an MSAA client has responded to our fake event on this id, 150 // When an MSAA client has responded to our fake event on this id,
159 // enable screen reader support. 151 // enable screen reader support.
160 BrowserAccessibilityState::GetInstance()->OnScreenReaderDetected(); 152 BrowserAccessibilityState::GetInstance()->OnScreenReaderDetected();
161 return static_cast<LRESULT>(0L); 153 return static_cast<LRESULT>(0L);
162 } 154 }
163 155
164 if (OBJID_CLIENT != obj_id || !manager_) 156 if (OBJID_CLIENT != obj_id || !host_)
157 return static_cast<LRESULT>(0L);
158
159 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(
160 host_->GetRenderWidgetHost());
161 if (!rwhi)
162 return static_cast<LRESULT>(0L);
163
164 BrowserAccessibilityManagerWin* manager =
165 static_cast<BrowserAccessibilityManagerWin*>(
166 rwhi->GetRootBrowserAccessibilityManager());
167 if (!manager)
165 return static_cast<LRESULT>(0L); 168 return static_cast<LRESULT>(0L);
166 169
167 base::win::ScopedComPtr<IAccessible> root( 170 base::win::ScopedComPtr<IAccessible> root(
168 manager_->GetRoot()->ToBrowserAccessibilityWin()); 171 manager->GetRoot()->ToBrowserAccessibilityWin());
169 return LresultFromObject(IID_IAccessible, w_param, 172 return LresultFromObject(IID_IAccessible, w_param,
170 static_cast<IAccessible*>(root.Detach())); 173 static_cast<IAccessible*>(root.Detach()));
171 } 174 }
172 175
173 // We send keyboard/mouse/touch messages to the parent window via SendMessage. 176 // We send keyboard/mouse/touch messages to the parent window via SendMessage.
174 // While this works, this has the side effect of converting input messages into 177 // While this works, this has the side effect of converting input messages into
175 // sent messages which changes their priority and could technically result 178 // sent messages which changes their priority and could technically result
176 // in these messages starving other messages in the queue. Additionally 179 // in these messages starving other messages in the queue. Additionally
177 // keyboard/mouse hooks would not see these messages. The alternative approach 180 // keyboard/mouse hooks would not see these messages. The alternative approach
178 // is to set and release capture as needed on the parent to ensure that it 181 // is to set and release capture as needed on the parent to ensure that it
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 // generate the legacy WM_VSCROLL/WM_HSCROLL messages. 370 // generate the legacy WM_VSCROLL/WM_HSCROLL messages.
368 // We add these styles to ensure that trackpad/trackpoint scrolling 371 // We add these styles to ensure that trackpad/trackpoint scrolling
369 // work. 372 // work.
370 long current_style = ::GetWindowLong(hwnd(), GWL_STYLE); 373 long current_style = ::GetWindowLong(hwnd(), GWL_STYLE);
371 ::SetWindowLong(hwnd(), GWL_STYLE, 374 ::SetWindowLong(hwnd(), GWL_STYLE,
372 current_style | WS_VSCROLL | WS_HSCROLL); 375 current_style | WS_VSCROLL | WS_HSCROLL);
373 return 0; 376 return 0;
374 } 377 }
375 378
376 } // namespace content 379 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698