OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/render_widget_host_view_win.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_win.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/process_util.h" | 14 #include "base/process_util.h" |
15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
16 #include "base/win/scoped_comptr.h" | 16 #include "base/win/scoped_comptr.h" |
17 #include "base/win/scoped_gdi_object.h" | 17 #include "base/win/scoped_gdi_object.h" |
18 #include "base/win/win_util.h" | 18 #include "base/win/win_util.h" |
19 #include "base/win/windows_version.h" | 19 #include "base/win/windows_version.h" |
20 #include "base/win/wrapped_window_proc.h" | 20 #include "base/win/wrapped_window_proc.h" |
21 #include "content/browser/accessibility/browser_accessibility_manager.h" | |
22 #include "content/browser/accessibility/browser_accessibility_state.h" | 21 #include "content/browser/accessibility/browser_accessibility_state.h" |
23 #include "content/browser/accessibility/browser_accessibility_win.h" | 22 #include "content/browser/accessibility/browser_accessibility_win.h" |
24 #include "content/browser/gpu/gpu_process_host.h" | 23 #include "content/browser/gpu/gpu_process_host.h" |
25 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 24 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
26 #include "content/browser/plugin_process_host.h" | 25 #include "content/browser/plugin_process_host.h" |
27 #include "content/browser/renderer_host/backing_store.h" | 26 #include "content/browser/renderer_host/backing_store.h" |
28 #include "content/browser/renderer_host/backing_store_win.h" | 27 #include "content/browser/renderer_host/backing_store_win.h" |
29 #include "content/browser/renderer_host/render_process_host_impl.h" | 28 #include "content/browser/renderer_host/render_process_host_impl.h" |
30 #include "content/browser/renderer_host/render_widget_host.h" | 29 #include "content/browser/renderer_host/render_widget_host.h" |
31 #include "content/common/gpu/gpu_messages.h" | 30 #include "content/common/gpu/gpu_messages.h" |
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 return 1; | 1090 return 1; |
1092 } | 1091 } |
1093 | 1092 |
1094 LRESULT RenderWidgetHostViewWin::OnSetCursor(HWND window, UINT hittest_code, | 1093 LRESULT RenderWidgetHostViewWin::OnSetCursor(HWND window, UINT hittest_code, |
1095 UINT mouse_message_id) { | 1094 UINT mouse_message_id) { |
1096 UpdateCursorIfOverSelf(); | 1095 UpdateCursorIfOverSelf(); |
1097 return 0; | 1096 return 0; |
1098 } | 1097 } |
1099 | 1098 |
1100 void RenderWidgetHostViewWin::OnSetFocus(HWND window) { | 1099 void RenderWidgetHostViewWin::OnSetFocus(HWND window) { |
1101 if (browser_accessibility_manager_.get()) | 1100 if (GetBrowserAccessibilityManager()) |
1102 browser_accessibility_manager_->GotFocus(); | 1101 GetBrowserAccessibilityManager()->GotFocus(); |
1103 if (render_widget_host_) { | 1102 if (render_widget_host_) { |
1104 render_widget_host_->GotFocus(); | 1103 render_widget_host_->GotFocus(); |
1105 render_widget_host_->SetActive(true); | 1104 render_widget_host_->SetActive(true); |
1106 } | 1105 } |
1107 if (touch_state_.ReleaseTouchPoints()) | 1106 if (touch_state_.ReleaseTouchPoints()) |
1108 render_widget_host_->ForwardTouchEvent(touch_state_.touch_event()); | 1107 render_widget_host_->ForwardTouchEvent(touch_state_.touch_event()); |
1109 } | 1108 } |
1110 | 1109 |
1111 void RenderWidgetHostViewWin::OnKillFocus(HWND window) { | 1110 void RenderWidgetHostViewWin::OnKillFocus(HWND window) { |
1112 if (render_widget_host_) { | 1111 if (render_widget_host_) { |
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1824 render_widget_host_->ForwardWheelEvent( | 1823 render_widget_host_->ForwardWheelEvent( |
1825 MakeFakeScrollWheelEvent(m_hWnd, start, delta)); | 1824 MakeFakeScrollWheelEvent(m_hWnd, start, delta)); |
1826 } | 1825 } |
1827 } | 1826 } |
1828 ::CloseGestureInfoHandle(gi_handle); | 1827 ::CloseGestureInfoHandle(gi_handle); |
1829 return 0; | 1828 return 0; |
1830 } | 1829 } |
1831 | 1830 |
1832 void RenderWidgetHostViewWin::OnAccessibilityNotifications( | 1831 void RenderWidgetHostViewWin::OnAccessibilityNotifications( |
1833 const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params) { | 1832 const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params) { |
1834 if (!browser_accessibility_manager_.get()) { | 1833 if (!GetBrowserAccessibilityManager()) { |
1835 browser_accessibility_manager_.reset( | 1834 SetBrowserAccessibilityManager( |
1836 BrowserAccessibilityManager::CreateEmptyDocument( | 1835 BrowserAccessibilityManager::CreateEmptyDocument( |
1837 m_hWnd, static_cast<WebAccessibility::State>(0), this)); | 1836 m_hWnd, static_cast<WebAccessibility::State>(0), this)); |
1838 } | 1837 } |
1839 browser_accessibility_manager_->OnAccessibilityNotifications(params); | 1838 GetBrowserAccessibilityManager()->OnAccessibilityNotifications(params); |
1840 } | 1839 } |
1841 | 1840 |
1842 bool RenderWidgetHostViewWin::LockMouse() { | 1841 bool RenderWidgetHostViewWin::LockMouse() { |
1843 if (mouse_locked_) | 1842 if (mouse_locked_) |
1844 return true; | 1843 return true; |
1845 | 1844 |
1846 mouse_locked_ = true; | 1845 mouse_locked_ = true; |
1847 | 1846 |
1848 // Hide the tooltip window if it is currently visible. When the mouse is | 1847 // Hide the tooltip window if it is currently visible. When the mouse is |
1849 // locked, no mouse message is relayed to the tooltip window, so we don't need | 1848 // locked, no mouse message is relayed to the tooltip window, so we don't need |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1897 content::RenderProcessHost* render_process_host = | 1896 content::RenderProcessHost* render_process_host = |
1898 content::Source<content::RenderProcessHost>(source).ptr(); | 1897 content::Source<content::RenderProcessHost>(source).ptr(); |
1899 DCHECK(render_process_host); | 1898 DCHECK(render_process_host); |
1900 if (!render_widget_host_ || | 1899 if (!render_widget_host_ || |
1901 render_process_host != render_widget_host_->process()) | 1900 render_process_host != render_widget_host_->process()) |
1902 return; | 1901 return; |
1903 | 1902 |
1904 // If it was our RenderProcessHost that posted the notification, | 1903 // If it was our RenderProcessHost that posted the notification, |
1905 // clear the BrowserAccessibilityManager, because the renderer is | 1904 // clear the BrowserAccessibilityManager, because the renderer is |
1906 // dead and any accessibility information we have is now stale. | 1905 // dead and any accessibility information we have is now stale. |
1907 browser_accessibility_manager_.reset(NULL); | 1906 SetBrowserAccessibilityManager(NULL); |
1908 } | 1907 } |
1909 | 1908 |
1910 static void PaintCompositorHostWindow(HWND hWnd) { | 1909 static void PaintCompositorHostWindow(HWND hWnd) { |
1911 PAINTSTRUCT paint; | 1910 PAINTSTRUCT paint; |
1912 BeginPaint(hWnd, &paint); | 1911 BeginPaint(hWnd, &paint); |
1913 | 1912 |
1914 RenderWidgetHostViewWin* win = static_cast<RenderWidgetHostViewWin*>( | 1913 RenderWidgetHostViewWin* win = static_cast<RenderWidgetHostViewWin*>( |
1915 ui::GetWindowUserData(hWnd)); | 1914 ui::GetWindowUserData(hWnd)); |
1916 // Trigger composite to rerender window. | 1915 // Trigger composite to rerender window. |
1917 if (win) | 1916 if (win) |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2104 render_widget_host_->AccessibilitySetTextSelection( | 2103 render_widget_host_->AccessibilitySetTextSelection( |
2105 acc_obj_id, start_offset, end_offset); | 2104 acc_obj_id, start_offset, end_offset); |
2106 } | 2105 } |
2107 | 2106 |
2108 IAccessible* RenderWidgetHostViewWin::GetIAccessible() { | 2107 IAccessible* RenderWidgetHostViewWin::GetIAccessible() { |
2109 if (render_widget_host_ && !render_widget_host_->renderer_accessible()) { | 2108 if (render_widget_host_ && !render_widget_host_->renderer_accessible()) { |
2110 // Attempt to detect screen readers by sending an event with our custom id. | 2109 // Attempt to detect screen readers by sending an event with our custom id. |
2111 NotifyWinEvent(EVENT_SYSTEM_ALERT, m_hWnd, kIdCustom, CHILDID_SELF); | 2110 NotifyWinEvent(EVENT_SYSTEM_ALERT, m_hWnd, kIdCustom, CHILDID_SELF); |
2112 } | 2111 } |
2113 | 2112 |
2114 if (!browser_accessibility_manager_.get()) { | 2113 if (!GetBrowserAccessibilityManager()) { |
2115 // Return busy document tree while renderer accessibility tree loads. | 2114 // Return busy document tree while renderer accessibility tree loads. |
2116 WebAccessibility::State busy_state = | 2115 WebAccessibility::State busy_state = |
2117 static_cast<WebAccessibility::State>(1 << WebAccessibility::STATE_BUSY); | 2116 static_cast<WebAccessibility::State>(1 << WebAccessibility::STATE_BUSY); |
2118 browser_accessibility_manager_.reset( | 2117 SetBrowserAccessibilityManager( |
2119 BrowserAccessibilityManager::CreateEmptyDocument( | 2118 BrowserAccessibilityManager::CreateEmptyDocument( |
2120 m_hWnd, busy_state, this)); | 2119 m_hWnd, busy_state, this)); |
2121 } | 2120 } |
2122 | 2121 |
2123 return browser_accessibility_manager_->GetRoot()->toBrowserAccessibilityWin(); | 2122 return GetBrowserAccessibilityManager()->GetRoot()-> |
| 2123 toBrowserAccessibilityWin(); |
2124 } | 2124 } |
2125 | 2125 |
2126 LRESULT RenderWidgetHostViewWin::OnGetObject(UINT message, WPARAM wparam, | 2126 LRESULT RenderWidgetHostViewWin::OnGetObject(UINT message, WPARAM wparam, |
2127 LPARAM lparam, BOOL& handled) { | 2127 LPARAM lparam, BOOL& handled) { |
2128 if (kIdCustom == lparam) { | 2128 if (kIdCustom == lparam) { |
2129 // An MSAA client requestes our custom id. Assume that we have detected an | 2129 // An MSAA client requestes our custom id. Assume that we have detected an |
2130 // active windows screen reader. | 2130 // active windows screen reader. |
2131 BrowserAccessibilityState::GetInstance()->OnScreenReaderDetected(); | 2131 BrowserAccessibilityState::GetInstance()->OnScreenReaderDetected(); |
2132 render_widget_host_->EnableRendererAccessibility(); | 2132 render_widget_host_->EnableRendererAccessibility(); |
2133 | 2133 |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2492 | 2492 |
2493 size_t offset = selection_range_.GetMin() - selection_text_offset_; | 2493 size_t offset = selection_range_.GetMin() - selection_text_offset_; |
2494 memcpy(reinterpret_cast<char*>(reconv) + sizeof(RECONVERTSTRING), | 2494 memcpy(reinterpret_cast<char*>(reconv) + sizeof(RECONVERTSTRING), |
2495 selection_text_.c_str() + offset, len * sizeof(WCHAR)); | 2495 selection_text_.c_str() + offset, len * sizeof(WCHAR)); |
2496 | 2496 |
2497 // According to Microsft API document, IMR_RECONVERTSTRING and | 2497 // According to Microsft API document, IMR_RECONVERTSTRING and |
2498 // IMR_DOCUMENTFEED should return reconv, but some applications return | 2498 // IMR_DOCUMENTFEED should return reconv, but some applications return |
2499 // need_size. | 2499 // need_size. |
2500 return reinterpret_cast<LRESULT>(reconv); | 2500 return reinterpret_cast<LRESULT>(reconv); |
2501 } | 2501 } |
OLD | NEW |