OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h" | 38 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h" |
39 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" | 39 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" |
40 #include "content/browser/renderer_host/input/timeout_monitor.h" | 40 #include "content/browser/renderer_host/input/timeout_monitor.h" |
41 #include "content/browser/renderer_host/input/touch_emulator.h" | 41 #include "content/browser/renderer_host/input/touch_emulator.h" |
42 #include "content/browser/renderer_host/render_process_host_impl.h" | 42 #include "content/browser/renderer_host/render_process_host_impl.h" |
43 #include "content/browser/renderer_host/render_view_host_impl.h" | 43 #include "content/browser/renderer_host/render_view_host_impl.h" |
44 #include "content/browser/renderer_host/render_widget_helper.h" | 44 #include "content/browser/renderer_host/render_widget_helper.h" |
45 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 45 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
46 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 46 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
47 #include "content/browser/renderer_host/render_widget_resize_helper.h" | 47 #include "content/browser/renderer_host/render_widget_resize_helper.h" |
| 48 #include "content/common/accessibility_messages.h" |
48 #include "content/common/content_constants_internal.h" | 49 #include "content/common/content_constants_internal.h" |
49 #include "content/common/cursors/webcursor.h" | 50 #include "content/common/cursors/webcursor.h" |
50 #include "content/common/gpu/gpu_messages.h" | 51 #include "content/common/gpu/gpu_messages.h" |
51 #include "content/common/host_shared_bitmap_manager.h" | 52 #include "content/common/host_shared_bitmap_manager.h" |
52 #include "content/common/input_messages.h" | 53 #include "content/common/input_messages.h" |
53 #include "content/common/view_messages.h" | 54 #include "content/common/view_messages.h" |
54 #include "content/public/browser/native_web_keyboard_event.h" | 55 #include "content/public/browser/native_web_keyboard_event.h" |
55 #include "content/public/browser/notification_service.h" | 56 #include "content/public/browser/notification_service.h" |
56 #include "content/public/browser/notification_types.h" | 57 #include "content/public/browser/notification_types.h" |
57 #include "content/public/browser/render_widget_host_iterator.h" | 58 #include "content/public/browser/render_widget_host_iterator.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 surface_id_(0), | 165 surface_id_(0), |
165 is_loading_(false), | 166 is_loading_(false), |
166 is_hidden_(hidden), | 167 is_hidden_(hidden), |
167 is_fullscreen_(false), | 168 is_fullscreen_(false), |
168 repaint_ack_pending_(false), | 169 repaint_ack_pending_(false), |
169 resize_ack_pending_(false), | 170 resize_ack_pending_(false), |
170 screen_info_out_of_date_(false), | 171 screen_info_out_of_date_(false), |
171 overdraw_bottom_height_(0.f), | 172 overdraw_bottom_height_(0.f), |
172 should_auto_resize_(false), | 173 should_auto_resize_(false), |
173 waiting_for_screen_rects_ack_(false), | 174 waiting_for_screen_rects_ack_(false), |
| 175 accessibility_mode_(AccessibilityModeOff), |
174 needs_repainting_on_restore_(false), | 176 needs_repainting_on_restore_(false), |
175 is_unresponsive_(false), | 177 is_unresponsive_(false), |
176 in_flight_event_count_(0), | 178 in_flight_event_count_(0), |
177 in_get_backing_store_(false), | 179 in_get_backing_store_(false), |
178 ignore_input_events_(false), | 180 ignore_input_events_(false), |
179 input_method_active_(false), | 181 input_method_active_(false), |
180 text_direction_updated_(false), | 182 text_direction_updated_(false), |
181 text_direction_(blink::WebTextDirectionLeftToRight), | 183 text_direction_(blink::WebTextDirectionLeftToRight), |
182 text_direction_canceled_(false), | 184 text_direction_canceled_(false), |
183 suppress_next_char_events_(false), | 185 suppress_next_char_events_(false), |
(...skipping 27 matching lines...) Expand all Loading... |
211 g_routing_id_widget_map.Get().insert(std::make_pair( | 213 g_routing_id_widget_map.Get().insert(std::make_pair( |
212 RenderWidgetHostID(process->GetID(), routing_id_), this)); | 214 RenderWidgetHostID(process->GetID(), routing_id_), this)); |
213 CHECK(result.second) << "Inserting a duplicate item!"; | 215 CHECK(result.second) << "Inserting a duplicate item!"; |
214 process_->AddRoute(routing_id_, this); | 216 process_->AddRoute(routing_id_, this); |
215 | 217 |
216 // If we're initially visible, tell the process host that we're alive. | 218 // If we're initially visible, tell the process host that we're alive. |
217 // Otherwise we'll notify the process host when we are first shown. | 219 // Otherwise we'll notify the process host when we are first shown. |
218 if (!hidden) | 220 if (!hidden) |
219 process_->WidgetRestored(); | 221 process_->WidgetRestored(); |
220 | 222 |
| 223 accessibility_mode_ = |
| 224 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode(); |
| 225 |
221 input_router_.reset(new InputRouterImpl( | 226 input_router_.reset(new InputRouterImpl( |
222 process_, this, this, routing_id_, GetInputRouterConfigForPlatform())); | 227 process_, this, this, routing_id_, GetInputRouterConfigForPlatform())); |
223 | 228 |
224 touch_emulator_.reset(); | 229 touch_emulator_.reset(); |
225 | 230 |
226 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 231 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
227 IsRenderView() ? RenderViewHost::From(this) : NULL); | 232 IsRenderView() ? RenderViewHost::From(this) : NULL); |
228 if (BrowserPluginGuest::IsGuest(rvh) || | 233 if (BrowserPluginGuest::IsGuest(rvh) || |
229 !CommandLine::ForCurrentProcess()->HasSwitch( | 234 !CommandLine::ForCurrentProcess()->HasSwitch( |
230 switches::kDisableHangMonitor)) { | 235 switches::kDisableHangMonitor)) { |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 hang_monitor_timeout_->Restart( | 839 hang_monitor_timeout_->Restart( |
835 base::TimeDelta::FromMilliseconds(hung_renderer_delay_ms_)); | 840 base::TimeDelta::FromMilliseconds(hung_renderer_delay_ms_)); |
836 } | 841 } |
837 | 842 |
838 void RenderWidgetHostImpl::StopHangMonitorTimeout() { | 843 void RenderWidgetHostImpl::StopHangMonitorTimeout() { |
839 if (hang_monitor_timeout_) | 844 if (hang_monitor_timeout_) |
840 hang_monitor_timeout_->Stop(); | 845 hang_monitor_timeout_->Stop(); |
841 RendererIsResponsive(); | 846 RendererIsResponsive(); |
842 } | 847 } |
843 | 848 |
| 849 void RenderWidgetHostImpl::EnableFullAccessibilityMode() { |
| 850 AddAccessibilityMode(AccessibilityModeComplete); |
| 851 } |
| 852 |
| 853 bool RenderWidgetHostImpl::IsFullAccessibilityModeForTesting() { |
| 854 return accessibility_mode() == AccessibilityModeComplete; |
| 855 } |
| 856 |
| 857 void RenderWidgetHostImpl::EnableTreeOnlyAccessibilityMode() { |
| 858 AddAccessibilityMode(AccessibilityModeTreeOnly); |
| 859 } |
| 860 |
| 861 bool RenderWidgetHostImpl::IsTreeOnlyAccessibilityModeForTesting() { |
| 862 return accessibility_mode() == AccessibilityModeTreeOnly; |
| 863 } |
| 864 |
844 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { | 865 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { |
845 ForwardMouseEventWithLatencyInfo(mouse_event, ui::LatencyInfo()); | 866 ForwardMouseEventWithLatencyInfo(mouse_event, ui::LatencyInfo()); |
846 } | 867 } |
847 | 868 |
848 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( | 869 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( |
849 const blink::WebMouseEvent& mouse_event, | 870 const blink::WebMouseEvent& mouse_event, |
850 const ui::LatencyInfo& ui_latency) { | 871 const ui::LatencyInfo& ui_latency) { |
851 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent", | 872 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent", |
852 "x", mouse_event.x, "y", mouse_event.y); | 873 "x", mouse_event.x, "y", mouse_event.y); |
853 | 874 |
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1878 | 1899 |
1879 void RenderWidgetHostImpl::SetBackgroundOpaque(bool opaque) { | 1900 void RenderWidgetHostImpl::SetBackgroundOpaque(bool opaque) { |
1880 Send(new ViewMsg_SetBackgroundOpaque(GetRoutingID(), opaque)); | 1901 Send(new ViewMsg_SetBackgroundOpaque(GetRoutingID(), opaque)); |
1881 } | 1902 } |
1882 | 1903 |
1883 void RenderWidgetHostImpl::SetEditCommandsForNextKeyEvent( | 1904 void RenderWidgetHostImpl::SetEditCommandsForNextKeyEvent( |
1884 const std::vector<EditCommand>& commands) { | 1905 const std::vector<EditCommand>& commands) { |
1885 Send(new InputMsg_SetEditCommandsForNextKeyEvent(GetRoutingID(), commands)); | 1906 Send(new InputMsg_SetEditCommandsForNextKeyEvent(GetRoutingID(), commands)); |
1886 } | 1907 } |
1887 | 1908 |
| 1909 void RenderWidgetHostImpl::AddAccessibilityMode(AccessibilityMode mode) { |
| 1910 SetAccessibilityMode( |
| 1911 content::AddAccessibilityModeTo(accessibility_mode_, mode)); |
| 1912 } |
| 1913 |
| 1914 void RenderWidgetHostImpl::RemoveAccessibilityMode(AccessibilityMode mode) { |
| 1915 SetAccessibilityMode( |
| 1916 content::RemoveAccessibilityModeFrom(accessibility_mode_, mode)); |
| 1917 } |
| 1918 |
| 1919 void RenderWidgetHostImpl::ResetAccessibilityMode() { |
| 1920 SetAccessibilityMode( |
| 1921 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()); |
| 1922 } |
| 1923 |
| 1924 void RenderWidgetHostImpl::SetAccessibilityMode(AccessibilityMode mode) { |
| 1925 accessibility_mode_ = mode; |
| 1926 Send(new ViewMsg_SetAccessibilityMode(GetRoutingID(), mode)); |
| 1927 } |
| 1928 |
| 1929 void RenderWidgetHostImpl::AccessibilitySetFocus(int object_id) { |
| 1930 Send(new AccessibilityMsg_SetFocus(GetRoutingID(), object_id)); |
| 1931 view_->OnAccessibilitySetFocus(object_id); |
| 1932 } |
| 1933 |
| 1934 void RenderWidgetHostImpl::AccessibilityDoDefaultAction(int object_id) { |
| 1935 Send(new AccessibilityMsg_DoDefaultAction(GetRoutingID(), object_id)); |
| 1936 } |
| 1937 |
| 1938 void RenderWidgetHostImpl::AccessibilityShowMenu(int object_id) { |
| 1939 view_->AccessibilityShowMenu(object_id); |
| 1940 } |
| 1941 |
| 1942 void RenderWidgetHostImpl::AccessibilityScrollToMakeVisible( |
| 1943 int acc_obj_id, gfx::Rect subfocus) { |
| 1944 Send(new AccessibilityMsg_ScrollToMakeVisible( |
| 1945 GetRoutingID(), acc_obj_id, subfocus)); |
| 1946 } |
| 1947 |
| 1948 void RenderWidgetHostImpl::AccessibilityScrollToPoint( |
| 1949 int acc_obj_id, gfx::Point point) { |
| 1950 Send(new AccessibilityMsg_ScrollToPoint( |
| 1951 GetRoutingID(), acc_obj_id, point)); |
| 1952 } |
| 1953 |
| 1954 void RenderWidgetHostImpl::AccessibilitySetTextSelection( |
| 1955 int object_id, int start_offset, int end_offset) { |
| 1956 Send(new AccessibilityMsg_SetTextSelection( |
| 1957 GetRoutingID(), object_id, start_offset, end_offset)); |
| 1958 } |
| 1959 |
| 1960 bool RenderWidgetHostImpl::AccessibilityViewHasFocus() const { |
| 1961 return view_->HasFocus(); |
| 1962 } |
| 1963 |
| 1964 gfx::Rect RenderWidgetHostImpl::AccessibilityGetViewBounds() const { |
| 1965 return view_->GetViewBounds(); |
| 1966 } |
| 1967 |
| 1968 gfx::Point RenderWidgetHostImpl::AccessibilityOriginInScreen( |
| 1969 const gfx::Rect& bounds) const { |
| 1970 return view_->AccessibilityOriginInScreen(bounds); |
| 1971 } |
| 1972 |
| 1973 void RenderWidgetHostImpl::AccessibilityHitTest(const gfx::Point& point) { |
| 1974 Send(new AccessibilityMsg_HitTest(GetRoutingID(), point)); |
| 1975 } |
| 1976 |
| 1977 void RenderWidgetHostImpl::AccessibilityFatalError() { |
| 1978 Send(new AccessibilityMsg_FatalError(GetRoutingID())); |
| 1979 view_->SetBrowserAccessibilityManager(NULL); |
| 1980 } |
| 1981 |
| 1982 #if defined(OS_WIN) |
| 1983 void RenderWidgetHostImpl::SetParentNativeViewAccessible( |
| 1984 gfx::NativeViewAccessible accessible_parent) { |
| 1985 if (view_) |
| 1986 view_->SetParentNativeViewAccessible(accessible_parent); |
| 1987 } |
| 1988 |
| 1989 gfx::NativeViewAccessible |
| 1990 RenderWidgetHostImpl::GetParentNativeViewAccessible() const { |
| 1991 return delegate_->GetParentNativeViewAccessible(); |
| 1992 } |
| 1993 #endif |
| 1994 |
1888 void RenderWidgetHostImpl::ExecuteEditCommand(const std::string& command, | 1995 void RenderWidgetHostImpl::ExecuteEditCommand(const std::string& command, |
1889 const std::string& value) { | 1996 const std::string& value) { |
1890 Send(new InputMsg_ExecuteEditCommand(GetRoutingID(), command, value)); | 1997 Send(new InputMsg_ExecuteEditCommand(GetRoutingID(), command, value)); |
1891 } | 1998 } |
1892 | 1999 |
1893 void RenderWidgetHostImpl::ScrollFocusedEditableNodeIntoRect( | 2000 void RenderWidgetHostImpl::ScrollFocusedEditableNodeIntoRect( |
1894 const gfx::Rect& rect) { | 2001 const gfx::Rect& rect) { |
1895 Send(new InputMsg_ScrollFocusedEditableNodeIntoRect(GetRoutingID(), rect)); | 2002 Send(new InputMsg_ScrollFocusedEditableNodeIntoRect(GetRoutingID(), rect)); |
1896 } | 2003 } |
1897 | 2004 |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2227 ++lc; | 2334 ++lc; |
2228 } | 2335 } |
2229 } | 2336 } |
2230 | 2337 |
2231 // Add newly generated components into the latency info | 2338 // Add newly generated components into the latency info |
2232 for (lc = new_components.begin(); lc != new_components.end(); ++lc) { | 2339 for (lc = new_components.begin(); lc != new_components.end(); ++lc) { |
2233 latency_info->latency_components[lc->first] = lc->second; | 2340 latency_info->latency_components[lc->first] = lc->second; |
2234 } | 2341 } |
2235 } | 2342 } |
2236 | 2343 |
2237 BrowserAccessibilityManager* | |
2238 RenderWidgetHostImpl::GetRootBrowserAccessibilityManager() { | |
2239 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; | |
2240 } | |
2241 | |
2242 BrowserAccessibilityManager* | |
2243 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { | |
2244 return delegate_ ? | |
2245 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; | |
2246 } | |
2247 | |
2248 #if defined(OS_WIN) | |
2249 gfx::NativeViewAccessible | |
2250 RenderWidgetHostImpl::GetParentNativeViewAccessible() { | |
2251 return delegate_ ? delegate_->GetParentNativeViewAccessible() : NULL; | |
2252 } | |
2253 #endif | |
2254 | |
2255 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { | 2344 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { |
2256 if (view_) | 2345 if (view_) |
2257 return view_->PreferredReadbackFormat(); | 2346 return view_->PreferredReadbackFormat(); |
2258 return kN32_SkColorType; | 2347 return kN32_SkColorType; |
2259 } | 2348 } |
2260 | 2349 |
2261 } // namespace content | 2350 } // namespace content |
OLD | NEW |