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/overscroll_controller.h" | 42 #include "content/browser/renderer_host/overscroll_controller.h" |
43 #include "content/browser/renderer_host/render_process_host_impl.h" | 43 #include "content/browser/renderer_host/render_process_host_impl.h" |
44 #include "content/browser/renderer_host/render_view_host_impl.h" | 44 #include "content/browser/renderer_host/render_view_host_impl.h" |
45 #include "content/browser/renderer_host/render_widget_helper.h" | 45 #include "content/browser/renderer_host/render_widget_helper.h" |
46 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 46 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
47 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 47 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
48 #include "content/common/accessibility_messages.h" | |
49 #include "content/common/content_constants_internal.h" | 48 #include "content/common/content_constants_internal.h" |
50 #include "content/common/cursors/webcursor.h" | 49 #include "content/common/cursors/webcursor.h" |
51 #include "content/common/gpu/gpu_messages.h" | 50 #include "content/common/gpu/gpu_messages.h" |
52 #include "content/common/host_shared_bitmap_manager.h" | 51 #include "content/common/host_shared_bitmap_manager.h" |
53 #include "content/common/input_messages.h" | 52 #include "content/common/input_messages.h" |
54 #include "content/common/view_messages.h" | 53 #include "content/common/view_messages.h" |
55 #include "content/public/browser/native_web_keyboard_event.h" | 54 #include "content/public/browser/native_web_keyboard_event.h" |
56 #include "content/public/browser/notification_service.h" | 55 #include "content/public/browser/notification_service.h" |
57 #include "content/public/browser/notification_types.h" | 56 #include "content/public/browser/notification_types.h" |
58 #include "content/public/browser/render_widget_host_iterator.h" | 57 #include "content/public/browser/render_widget_host_iterator.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 surface_id_(0), | 170 surface_id_(0), |
172 is_loading_(false), | 171 is_loading_(false), |
173 is_hidden_(hidden), | 172 is_hidden_(hidden), |
174 is_fullscreen_(false), | 173 is_fullscreen_(false), |
175 repaint_ack_pending_(false), | 174 repaint_ack_pending_(false), |
176 resize_ack_pending_(false), | 175 resize_ack_pending_(false), |
177 screen_info_out_of_date_(false), | 176 screen_info_out_of_date_(false), |
178 overdraw_bottom_height_(0.f), | 177 overdraw_bottom_height_(0.f), |
179 should_auto_resize_(false), | 178 should_auto_resize_(false), |
180 waiting_for_screen_rects_ack_(false), | 179 waiting_for_screen_rects_ack_(false), |
181 accessibility_mode_(AccessibilityModeOff), | |
182 needs_repainting_on_restore_(false), | 180 needs_repainting_on_restore_(false), |
183 is_unresponsive_(false), | 181 is_unresponsive_(false), |
184 in_flight_event_count_(0), | 182 in_flight_event_count_(0), |
185 in_get_backing_store_(false), | 183 in_get_backing_store_(false), |
186 ignore_input_events_(false), | 184 ignore_input_events_(false), |
187 input_method_active_(false), | 185 input_method_active_(false), |
188 text_direction_updated_(false), | 186 text_direction_updated_(false), |
189 text_direction_(blink::WebTextDirectionLeftToRight), | 187 text_direction_(blink::WebTextDirectionLeftToRight), |
190 text_direction_canceled_(false), | 188 text_direction_canceled_(false), |
191 suppress_next_char_events_(false), | 189 suppress_next_char_events_(false), |
(...skipping 26 matching lines...) Expand all Loading... |
218 g_routing_id_widget_map.Get().insert(std::make_pair( | 216 g_routing_id_widget_map.Get().insert(std::make_pair( |
219 RenderWidgetHostID(process->GetID(), routing_id_), this)); | 217 RenderWidgetHostID(process->GetID(), routing_id_), this)); |
220 CHECK(result.second) << "Inserting a duplicate item!"; | 218 CHECK(result.second) << "Inserting a duplicate item!"; |
221 process_->AddRoute(routing_id_, this); | 219 process_->AddRoute(routing_id_, this); |
222 | 220 |
223 // If we're initially visible, tell the process host that we're alive. | 221 // If we're initially visible, tell the process host that we're alive. |
224 // Otherwise we'll notify the process host when we are first shown. | 222 // Otherwise we'll notify the process host when we are first shown. |
225 if (!hidden) | 223 if (!hidden) |
226 process_->WidgetRestored(); | 224 process_->WidgetRestored(); |
227 | 225 |
228 accessibility_mode_ = | |
229 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode(); | |
230 | |
231 input_router_.reset(new InputRouterImpl( | 226 input_router_.reset(new InputRouterImpl( |
232 process_, this, this, routing_id_, GetInputRouterConfigForPlatform())); | 227 process_, this, this, routing_id_, GetInputRouterConfigForPlatform())); |
233 | 228 |
234 touch_emulator_.reset(); | 229 touch_emulator_.reset(); |
235 | 230 |
236 #if defined(USE_AURA) | 231 #if defined(USE_AURA) |
237 bool overscroll_enabled = CommandLine::ForCurrentProcess()-> | 232 bool overscroll_enabled = CommandLine::ForCurrentProcess()-> |
238 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; | 233 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; |
239 SetOverscrollControllerEnabled(overscroll_enabled); | 234 SetOverscrollControllerEnabled(overscroll_enabled); |
240 #endif | 235 #endif |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 hang_monitor_timeout_->Restart( | 854 hang_monitor_timeout_->Restart( |
860 base::TimeDelta::FromMilliseconds(hung_renderer_delay_ms_)); | 855 base::TimeDelta::FromMilliseconds(hung_renderer_delay_ms_)); |
861 } | 856 } |
862 | 857 |
863 void RenderWidgetHostImpl::StopHangMonitorTimeout() { | 858 void RenderWidgetHostImpl::StopHangMonitorTimeout() { |
864 if (hang_monitor_timeout_) | 859 if (hang_monitor_timeout_) |
865 hang_monitor_timeout_->Stop(); | 860 hang_monitor_timeout_->Stop(); |
866 RendererIsResponsive(); | 861 RendererIsResponsive(); |
867 } | 862 } |
868 | 863 |
869 void RenderWidgetHostImpl::EnableFullAccessibilityMode() { | |
870 AddAccessibilityMode(AccessibilityModeComplete); | |
871 } | |
872 | |
873 bool RenderWidgetHostImpl::IsFullAccessibilityModeForTesting() { | |
874 return accessibility_mode() == AccessibilityModeComplete; | |
875 } | |
876 | |
877 void RenderWidgetHostImpl::EnableTreeOnlyAccessibilityMode() { | |
878 AddAccessibilityMode(AccessibilityModeTreeOnly); | |
879 } | |
880 | |
881 bool RenderWidgetHostImpl::IsTreeOnlyAccessibilityModeForTesting() { | |
882 return accessibility_mode() == AccessibilityModeTreeOnly; | |
883 } | |
884 | |
885 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { | 864 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { |
886 ForwardMouseEventWithLatencyInfo(mouse_event, ui::LatencyInfo()); | 865 ForwardMouseEventWithLatencyInfo(mouse_event, ui::LatencyInfo()); |
887 } | 866 } |
888 | 867 |
889 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( | 868 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( |
890 const blink::WebMouseEvent& mouse_event, | 869 const blink::WebMouseEvent& mouse_event, |
891 const ui::LatencyInfo& ui_latency) { | 870 const ui::LatencyInfo& ui_latency) { |
892 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent", | 871 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent", |
893 "x", mouse_event.x, "y", mouse_event.y); | 872 "x", mouse_event.x, "y", mouse_event.y); |
894 | 873 |
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1954 | 1933 |
1955 void RenderWidgetHostImpl::SetBackgroundOpaque(bool opaque) { | 1934 void RenderWidgetHostImpl::SetBackgroundOpaque(bool opaque) { |
1956 Send(new ViewMsg_SetBackgroundOpaque(GetRoutingID(), opaque)); | 1935 Send(new ViewMsg_SetBackgroundOpaque(GetRoutingID(), opaque)); |
1957 } | 1936 } |
1958 | 1937 |
1959 void RenderWidgetHostImpl::SetEditCommandsForNextKeyEvent( | 1938 void RenderWidgetHostImpl::SetEditCommandsForNextKeyEvent( |
1960 const std::vector<EditCommand>& commands) { | 1939 const std::vector<EditCommand>& commands) { |
1961 Send(new InputMsg_SetEditCommandsForNextKeyEvent(GetRoutingID(), commands)); | 1940 Send(new InputMsg_SetEditCommandsForNextKeyEvent(GetRoutingID(), commands)); |
1962 } | 1941 } |
1963 | 1942 |
1964 void RenderWidgetHostImpl::AddAccessibilityMode(AccessibilityMode mode) { | |
1965 SetAccessibilityMode( | |
1966 content::AddAccessibilityModeTo(accessibility_mode_, mode)); | |
1967 } | |
1968 | |
1969 void RenderWidgetHostImpl::RemoveAccessibilityMode(AccessibilityMode mode) { | |
1970 SetAccessibilityMode( | |
1971 content::RemoveAccessibilityModeFrom(accessibility_mode_, mode)); | |
1972 } | |
1973 | |
1974 void RenderWidgetHostImpl::ResetAccessibilityMode() { | |
1975 SetAccessibilityMode( | |
1976 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()); | |
1977 } | |
1978 | |
1979 void RenderWidgetHostImpl::SetAccessibilityMode(AccessibilityMode mode) { | |
1980 accessibility_mode_ = mode; | |
1981 Send(new ViewMsg_SetAccessibilityMode(GetRoutingID(), mode)); | |
1982 } | |
1983 | |
1984 void RenderWidgetHostImpl::AccessibilitySetFocus(int object_id) { | |
1985 Send(new AccessibilityMsg_SetFocus(GetRoutingID(), object_id)); | |
1986 view_->OnAccessibilitySetFocus(object_id); | |
1987 } | |
1988 | |
1989 void RenderWidgetHostImpl::AccessibilityDoDefaultAction(int object_id) { | |
1990 Send(new AccessibilityMsg_DoDefaultAction(GetRoutingID(), object_id)); | |
1991 } | |
1992 | |
1993 void RenderWidgetHostImpl::AccessibilityShowMenu(int object_id) { | |
1994 view_->AccessibilityShowMenu(object_id); | |
1995 } | |
1996 | |
1997 void RenderWidgetHostImpl::AccessibilityScrollToMakeVisible( | |
1998 int acc_obj_id, gfx::Rect subfocus) { | |
1999 Send(new AccessibilityMsg_ScrollToMakeVisible( | |
2000 GetRoutingID(), acc_obj_id, subfocus)); | |
2001 } | |
2002 | |
2003 void RenderWidgetHostImpl::AccessibilityScrollToPoint( | |
2004 int acc_obj_id, gfx::Point point) { | |
2005 Send(new AccessibilityMsg_ScrollToPoint( | |
2006 GetRoutingID(), acc_obj_id, point)); | |
2007 } | |
2008 | |
2009 void RenderWidgetHostImpl::AccessibilitySetTextSelection( | |
2010 int object_id, int start_offset, int end_offset) { | |
2011 Send(new AccessibilityMsg_SetTextSelection( | |
2012 GetRoutingID(), object_id, start_offset, end_offset)); | |
2013 } | |
2014 | |
2015 bool RenderWidgetHostImpl::AccessibilityViewHasFocus() const { | |
2016 return view_->HasFocus(); | |
2017 } | |
2018 | |
2019 gfx::Rect RenderWidgetHostImpl::AccessibilityGetViewBounds() const { | |
2020 return view_->GetViewBounds(); | |
2021 } | |
2022 | |
2023 gfx::Point RenderWidgetHostImpl::AccessibilityOriginInScreen( | |
2024 const gfx::Rect& bounds) const { | |
2025 return view_->AccessibilityOriginInScreen(bounds); | |
2026 } | |
2027 | |
2028 void RenderWidgetHostImpl::AccessibilityHitTest(const gfx::Point& point) { | |
2029 Send(new AccessibilityMsg_HitTest(GetRoutingID(), point)); | |
2030 } | |
2031 | |
2032 void RenderWidgetHostImpl::AccessibilityFatalError() { | |
2033 Send(new AccessibilityMsg_FatalError(GetRoutingID())); | |
2034 view_->SetBrowserAccessibilityManager(NULL); | |
2035 } | |
2036 | |
2037 #if defined(OS_WIN) | |
2038 void RenderWidgetHostImpl::SetParentNativeViewAccessible( | |
2039 gfx::NativeViewAccessible accessible_parent) { | |
2040 if (view_) | |
2041 view_->SetParentNativeViewAccessible(accessible_parent); | |
2042 } | |
2043 | |
2044 gfx::NativeViewAccessible | |
2045 RenderWidgetHostImpl::GetParentNativeViewAccessible() const { | |
2046 return delegate_->GetParentNativeViewAccessible(); | |
2047 } | |
2048 #endif | |
2049 | |
2050 void RenderWidgetHostImpl::ExecuteEditCommand(const std::string& command, | 1943 void RenderWidgetHostImpl::ExecuteEditCommand(const std::string& command, |
2051 const std::string& value) { | 1944 const std::string& value) { |
2052 Send(new InputMsg_ExecuteEditCommand(GetRoutingID(), command, value)); | 1945 Send(new InputMsg_ExecuteEditCommand(GetRoutingID(), command, value)); |
2053 } | 1946 } |
2054 | 1947 |
2055 void RenderWidgetHostImpl::ScrollFocusedEditableNodeIntoRect( | 1948 void RenderWidgetHostImpl::ScrollFocusedEditableNodeIntoRect( |
2056 const gfx::Rect& rect) { | 1949 const gfx::Rect& rect) { |
2057 Send(new InputMsg_ScrollFocusedEditableNodeIntoRect(GetRoutingID(), rect)); | 1950 Send(new InputMsg_ScrollFocusedEditableNodeIntoRect(GetRoutingID(), rect)); |
2058 } | 1951 } |
2059 | 1952 |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2320 ++lc; | 2213 ++lc; |
2321 } | 2214 } |
2322 } | 2215 } |
2323 | 2216 |
2324 // Add newly generated components into the latency info | 2217 // Add newly generated components into the latency info |
2325 for (lc = new_components.begin(); lc != new_components.end(); ++lc) { | 2218 for (lc = new_components.begin(); lc != new_components.end(); ++lc) { |
2326 latency_info->latency_components[lc->first] = lc->second; | 2219 latency_info->latency_components[lc->first] = lc->second; |
2327 } | 2220 } |
2328 } | 2221 } |
2329 | 2222 |
| 2223 BrowserAccessibilityManager* |
| 2224 RenderWidgetHostImpl::GetRootBrowserAccessibilityManager() { |
| 2225 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; |
| 2226 } |
| 2227 |
2330 SkBitmap::Config RenderWidgetHostImpl::PreferredReadbackFormat() { | 2228 SkBitmap::Config RenderWidgetHostImpl::PreferredReadbackFormat() { |
2331 if (view_) | 2229 if (view_) |
2332 return view_->PreferredReadbackFormat(); | 2230 return view_->PreferredReadbackFormat(); |
2333 return SkBitmap::kARGB_8888_Config; | 2231 return SkBitmap::kARGB_8888_Config; |
2334 } | 2232 } |
2335 | 2233 |
2336 } // namespace content | 2234 } // namespace content |
OLD | NEW |