OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/renderer_host/render_widget_host_view_win.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_win.h" |
6 | 6 |
7 #include "app/gfx/chrome_canvas.h" | 7 #include "app/gfx/chrome_canvas.h" |
8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
9 #include "app/l10n_util_win.h" | 9 #include "app/l10n_util_win.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/gfx/gdi_util.h" | 12 #include "base/gfx/gdi_util.h" |
13 #include "base/gfx/rect.h" | 13 #include "base/gfx/rect.h" |
14 #include "base/histogram.h" | 14 #include "base/histogram.h" |
15 #include "base/win_util.h" | 15 #include "base/win_util.h" |
16 #include "chrome/browser/browser_accessibility.h" | |
17 #include "chrome/browser/browser_accessibility_manager.h" | 16 #include "chrome/browser/browser_accessibility_manager.h" |
18 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
19 #include "chrome/browser/browser_trial.h" | 18 #include "chrome/browser/browser_trial.h" |
20 #include "chrome/browser/plugin_process_host.h" | 19 #include "chrome/browser/plugin_process_host.h" |
21 #include "chrome/browser/renderer_host/backing_store.h" | 20 #include "chrome/browser/renderer_host/backing_store.h" |
22 #include "chrome/browser/renderer_host/render_process_host.h" | 21 #include "chrome/browser/renderer_host/render_process_host.h" |
23 #include "chrome/browser/renderer_host/render_widget_host.h" | 22 #include "chrome/browser/renderer_host/render_widget_host.h" |
24 #include "chrome/common/chrome_constants.h" | 23 #include "chrome/common/chrome_constants.h" |
25 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/common/native_web_keyboard_event.h" | 25 #include "chrome/common/native_web_keyboard_event.h" |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 // will get a change to override the default handling | 677 // will get a change to override the default handling |
679 SendMessage(WM_CANCELMODE); | 678 SendMessage(WM_CANCELMODE); |
680 } | 679 } |
681 } | 680 } |
682 | 681 |
683 void RenderWidgetHostViewWin::OnDestroy() { | 682 void RenderWidgetHostViewWin::OnDestroy() { |
684 ResetTooltip(); | 683 ResetTooltip(); |
685 TrackMouseLeave(false); | 684 TrackMouseLeave(false); |
686 #ifdef ENABLE_TRACK_HWND_DESTRUCTION | 685 #ifdef ENABLE_TRACK_HWND_DESTRUCTION |
687 TRACK_HWND_DESTRUCTION(m_hWnd); | 686 TRACK_HWND_DESTRUCTION(m_hWnd); |
688 #endif // ENABLE_TRACK_HWND_DESTRUCTION | 687 #endif // ENABLE_TRACK_HWND_DESTRUCTION |
689 } | 688 } |
690 | 689 |
691 void RenderWidgetHostViewWin::OnPaint(HDC dc) { | 690 void RenderWidgetHostViewWin::OnPaint(HDC dc) { |
692 DCHECK(render_widget_host_->process()->channel()); | 691 DCHECK(render_widget_host_->process()->channel()); |
693 | 692 |
694 about_to_validate_and_paint_ = true; | 693 about_to_validate_and_paint_ = true; |
695 BackingStore* backing_store = render_widget_host_->GetBackingStore(); | 694 BackingStore* backing_store = render_widget_host_->GetBackingStore(); |
696 | 695 |
697 // We initialize |paint_dc| (and thus call BeginPaint()) after calling | 696 // We initialize |paint_dc| (and thus call BeginPaint()) after calling |
698 // GetBackingStore(), so that if it updates the invalid rect we'll catch the | 697 // GetBackingStore(), so that if it updates the invalid rect we'll catch the |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 // TODO(jcampan): http://b/issue?id=1432077 Disabling accessibility in the | 1186 // TODO(jcampan): http://b/issue?id=1432077 Disabling accessibility in the |
1188 // renderer is a temporary work-around until that bug is fixed. | 1187 // renderer is a temporary work-around until that bug is fixed. |
1189 if (!renderer_accessible_) | 1188 if (!renderer_accessible_) |
1190 return reference_result; | 1189 return reference_result; |
1191 | 1190 |
1192 // Accessibility readers will send an OBJID_CLIENT message. | 1191 // Accessibility readers will send an OBJID_CLIENT message. |
1193 if (OBJID_CLIENT == lparam) { | 1192 if (OBJID_CLIENT == lparam) { |
1194 // If our MSAA DOM root is already created, reuse that pointer. Otherwise, | 1193 // If our MSAA DOM root is already created, reuse that pointer. Otherwise, |
1195 // create a new one. | 1194 // create a new one. |
1196 if (!browser_accessibility_root_) { | 1195 if (!browser_accessibility_root_) { |
1197 CComObject<BrowserAccessibility>* accessibility = NULL; | 1196 // Create a new instance of IAccessible. Root id is always 0. |
1198 | 1197 BrowserAccessibilityManager::GetInstance()-> |
1199 if (!SUCCEEDED(CComObject<BrowserAccessibility>::CreateInstance( | 1198 CreateAccessibilityInstance(IID_IAccessible, 0, |
1200 &accessibility)) || !accessibility) { | 1199 render_widget_host_->routing_id(), |
1201 // Return with failure. | 1200 render_widget_host_->process()->pid(), |
1202 return static_cast<LRESULT>(0L); | 1201 m_hWnd, reinterpret_cast<void **> |
1203 } | 1202 (&browser_accessibility_root_)); |
1204 | |
1205 CComPtr<IAccessible> accessibility_comptr(accessibility); | |
1206 | |
1207 // Root id is always 0, to distinguish this particular instance when | |
1208 // mapping to the render-side IAccessible. | |
1209 accessibility->set_iaccessible_id(0); | |
1210 | |
1211 // Set the unique member variables of this particular process. | |
1212 accessibility->set_instance_id( | |
1213 BrowserAccessibilityManager::GetInstance()-> | |
1214 SetMembers(accessibility, m_hWnd, render_widget_host_)); | |
1215 | |
1216 // All is well, assign the temp instance to the class smart pointer. | |
1217 browser_accessibility_root_.Attach(accessibility_comptr.Detach()); | |
1218 | 1203 |
1219 if (!browser_accessibility_root_) { | 1204 if (!browser_accessibility_root_) { |
1220 // Paranoia check. Return with failure. | 1205 // No valid root found, return with failure. |
1221 NOTREACHED(); | 1206 NOTREACHED(); |
1222 return static_cast<LRESULT>(0L); | 1207 return static_cast<LRESULT>(0L); |
1223 } | 1208 } |
1224 | |
1225 // Notify that an instance of IAccessible was allocated for m_hWnd. | |
1226 ::NotifyWinEvent(EVENT_OBJECT_CREATE, m_hWnd, OBJID_CLIENT, | |
1227 CHILDID_SELF); | |
1228 } | 1209 } |
1229 | 1210 |
1230 // Create a reference to ViewAccessibility that MSAA will marshall | 1211 // Create a reference to BrowserAccessibility which MSAA will marshall to |
1231 // to the client. | 1212 // the client. |
1232 reference_result = LresultFromObject(IID_IAccessible, wparam, | 1213 reference_result = LresultFromObject(IID_IAccessible, wparam, |
1233 static_cast<IAccessible*>(browser_accessibility_root_)); | 1214 static_cast<IAccessible*>(browser_accessibility_root_)); |
1234 } | 1215 } |
1235 return reference_result; | 1216 return reference_result; |
1236 } | 1217 } |
1237 | 1218 |
1238 void RenderWidgetHostViewWin::OnFinalMessage(HWND window) { | 1219 void RenderWidgetHostViewWin::OnFinalMessage(HWND window) { |
1239 render_widget_host_->ViewDestroyed(); | 1220 render_widget_host_->ViewDestroyed(); |
1240 delete this; | 1221 delete this; |
1241 } | 1222 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 // WM_LBUTTONDOWN. | 1300 // WM_LBUTTONDOWN. |
1320 SetFocus(); | 1301 SetFocus(); |
1321 } | 1302 } |
1322 } | 1303 } |
1323 | 1304 |
1324 void RenderWidgetHostViewWin::ShutdownHost() { | 1305 void RenderWidgetHostViewWin::ShutdownHost() { |
1325 shutdown_factory_.RevokeAll(); | 1306 shutdown_factory_.RevokeAll(); |
1326 render_widget_host_->Shutdown(); | 1307 render_widget_host_->Shutdown(); |
1327 // Do not touch any members at this point, |this| has been deleted. | 1308 // Do not touch any members at this point, |this| has been deleted. |
1328 } | 1309 } |
OLD | NEW |