| 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 |
| 11 #include "base/auto_reset.h" | 11 #include "base/auto_reset.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
| 15 #include "base/debug/trace_event.h" | 15 #include "base/debug/trace_event.h" |
| 16 #include "base/i18n/rtl.h" | 16 #include "base/i18n/rtl.h" |
| 17 #include "base/lazy_instance.h" | 17 #include "base/lazy_instance.h" |
| 18 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
| 19 #include "base/metrics/field_trial.h" | 19 #include "base/metrics/field_trial.h" |
| 20 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
| 21 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
| 22 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
| 23 #include "base/thread_task_runner_handle.h" | 23 #include "base/thread_task_runner_handle.h" |
| 24 #include "cc/base/switches.h" | 24 #include "cc/base/switches.h" |
| 25 #include "cc/output/compositor_frame.h" | 25 #include "cc/output/compositor_frame.h" |
| 26 #include "cc/output/compositor_frame_ack.h" | 26 #include "cc/output/compositor_frame_ack.h" |
| 27 #include "content/browser/accessibility/accessibility_mode_helper.h" | |
| 28 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | |
| 29 #include "content/browser/gpu/compositor_util.h" | 27 #include "content/browser/gpu/compositor_util.h" |
| 30 #include "content/browser/gpu/gpu_process_host.h" | 28 #include "content/browser/gpu/gpu_process_host.h" |
| 31 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 29 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| 32 #include "content/browser/gpu/gpu_surface_tracker.h" | 30 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 33 #include "content/browser/renderer_host/dip_util.h" | 31 #include "content/browser/renderer_host/dip_util.h" |
| 34 #include "content/browser/renderer_host/input/input_router_config_helper.h" | 32 #include "content/browser/renderer_host/input/input_router_config_helper.h" |
| 35 #include "content/browser/renderer_host/input/input_router_impl.h" | 33 #include "content/browser/renderer_host/input/input_router_impl.h" |
| 36 #include "content/browser/renderer_host/input/synthetic_gesture.h" | 34 #include "content/browser/renderer_host/input/synthetic_gesture.h" |
| 37 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h" | 35 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h" |
| 38 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" | 36 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" |
| 39 #include "content/browser/renderer_host/input/timeout_monitor.h" | 37 #include "content/browser/renderer_host/input/timeout_monitor.h" |
| 40 #include "content/browser/renderer_host/input/touch_emulator.h" | 38 #include "content/browser/renderer_host/input/touch_emulator.h" |
| 41 #include "content/browser/renderer_host/overscroll_controller.h" | 39 #include "content/browser/renderer_host/overscroll_controller.h" |
| 42 #include "content/browser/renderer_host/render_process_host_impl.h" | 40 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 43 #include "content/browser/renderer_host/render_view_host_impl.h" | 41 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 44 #include "content/browser/renderer_host/render_widget_helper.h" | 42 #include "content/browser/renderer_host/render_widget_helper.h" |
| 45 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 43 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 46 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 44 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 47 #include "content/common/accessibility_messages.h" | |
| 48 #include "content/common/content_constants_internal.h" | 45 #include "content/common/content_constants_internal.h" |
| 49 #include "content/common/cursors/webcursor.h" | 46 #include "content/common/cursors/webcursor.h" |
| 50 #include "content/common/gpu/gpu_messages.h" | 47 #include "content/common/gpu/gpu_messages.h" |
| 51 #include "content/common/host_shared_bitmap_manager.h" | 48 #include "content/common/host_shared_bitmap_manager.h" |
| 52 #include "content/common/input_messages.h" | 49 #include "content/common/input_messages.h" |
| 53 #include "content/common/view_messages.h" | 50 #include "content/common/view_messages.h" |
| 54 #include "content/public/browser/native_web_keyboard_event.h" | 51 #include "content/public/browser/native_web_keyboard_event.h" |
| 55 #include "content/public/browser/notification_service.h" | 52 #include "content/public/browser/notification_service.h" |
| 56 #include "content/public/browser/notification_types.h" | 53 #include "content/public/browser/notification_types.h" |
| 57 #include "content/public/browser/render_widget_host_iterator.h" | 54 #include "content/public/browser/render_widget_host_iterator.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 is_loading_(false), | 168 is_loading_(false), |
| 172 is_hidden_(hidden), | 169 is_hidden_(hidden), |
| 173 is_fullscreen_(false), | 170 is_fullscreen_(false), |
| 174 is_accelerated_compositing_active_(false), | 171 is_accelerated_compositing_active_(false), |
| 175 repaint_ack_pending_(false), | 172 repaint_ack_pending_(false), |
| 176 resize_ack_pending_(false), | 173 resize_ack_pending_(false), |
| 177 screen_info_out_of_date_(false), | 174 screen_info_out_of_date_(false), |
| 178 overdraw_bottom_height_(0.f), | 175 overdraw_bottom_height_(0.f), |
| 179 should_auto_resize_(false), | 176 should_auto_resize_(false), |
| 180 waiting_for_screen_rects_ack_(false), | 177 waiting_for_screen_rects_ack_(false), |
| 181 accessibility_mode_(AccessibilityModeOff), | |
| 182 needs_repainting_on_restore_(false), | 178 needs_repainting_on_restore_(false), |
| 183 is_unresponsive_(false), | 179 is_unresponsive_(false), |
| 184 in_flight_event_count_(0), | 180 in_flight_event_count_(0), |
| 185 in_get_backing_store_(false), | 181 in_get_backing_store_(false), |
| 186 abort_get_backing_store_(false), | 182 abort_get_backing_store_(false), |
| 187 view_being_painted_(false), | 183 view_being_painted_(false), |
| 188 ignore_input_events_(false), | 184 ignore_input_events_(false), |
| 189 input_method_active_(false), | 185 input_method_active_(false), |
| 190 text_direction_updated_(false), | 186 text_direction_updated_(false), |
| 191 text_direction_(blink::WebTextDirectionLeftToRight), | 187 text_direction_(blink::WebTextDirectionLeftToRight), |
| (...skipping 28 matching lines...) Expand all Loading... |
| 220 g_routing_id_widget_map.Get().insert(std::make_pair( | 216 g_routing_id_widget_map.Get().insert(std::make_pair( |
| 221 RenderWidgetHostID(process->GetID(), routing_id_), this)); | 217 RenderWidgetHostID(process->GetID(), routing_id_), this)); |
| 222 CHECK(result.second) << "Inserting a duplicate item!"; | 218 CHECK(result.second) << "Inserting a duplicate item!"; |
| 223 process_->AddRoute(routing_id_, this); | 219 process_->AddRoute(routing_id_, this); |
| 224 | 220 |
| 225 // 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. |
| 226 // 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. |
| 227 if (!hidden) | 223 if (!hidden) |
| 228 process_->WidgetRestored(); | 224 process_->WidgetRestored(); |
| 229 | 225 |
| 230 accessibility_mode_ = | |
| 231 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode(); | |
| 232 | |
| 233 input_router_.reset(new InputRouterImpl( | 226 input_router_.reset(new InputRouterImpl( |
| 234 process_, this, this, routing_id_, GetInputRouterConfigForPlatform())); | 227 process_, this, this, routing_id_, GetInputRouterConfigForPlatform())); |
| 235 | 228 |
| 236 touch_emulator_.reset(); | 229 touch_emulator_.reset(); |
| 237 | 230 |
| 238 #if defined(USE_AURA) | 231 #if defined(USE_AURA) |
| 239 bool overscroll_enabled = CommandLine::ForCurrentProcess()-> | 232 bool overscroll_enabled = CommandLine::ForCurrentProcess()-> |
| 240 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; | 233 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; |
| 241 SetOverscrollControllerEnabled(overscroll_enabled); | 234 SetOverscrollControllerEnabled(overscroll_enabled); |
| 242 #endif | 235 #endif |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 hang_monitor_timeout_->Restart( | 864 hang_monitor_timeout_->Restart( |
| 872 base::TimeDelta::FromMilliseconds(hung_renderer_delay_ms_)); | 865 base::TimeDelta::FromMilliseconds(hung_renderer_delay_ms_)); |
| 873 } | 866 } |
| 874 | 867 |
| 875 void RenderWidgetHostImpl::StopHangMonitorTimeout() { | 868 void RenderWidgetHostImpl::StopHangMonitorTimeout() { |
| 876 if (hang_monitor_timeout_) | 869 if (hang_monitor_timeout_) |
| 877 hang_monitor_timeout_->Stop(); | 870 hang_monitor_timeout_->Stop(); |
| 878 RendererIsResponsive(); | 871 RendererIsResponsive(); |
| 879 } | 872 } |
| 880 | 873 |
| 881 void RenderWidgetHostImpl::EnableFullAccessibilityMode() { | |
| 882 AddAccessibilityMode(AccessibilityModeComplete); | |
| 883 } | |
| 884 | |
| 885 bool RenderWidgetHostImpl::IsFullAccessibilityModeForTesting() { | |
| 886 return accessibility_mode() == AccessibilityModeComplete; | |
| 887 } | |
| 888 | |
| 889 void RenderWidgetHostImpl::EnableTreeOnlyAccessibilityMode() { | |
| 890 AddAccessibilityMode(AccessibilityModeTreeOnly); | |
| 891 } | |
| 892 | |
| 893 bool RenderWidgetHostImpl::IsTreeOnlyAccessibilityModeForTesting() { | |
| 894 return accessibility_mode() == AccessibilityModeTreeOnly; | |
| 895 } | |
| 896 | |
| 897 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { | 874 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { |
| 898 ForwardMouseEventWithLatencyInfo(mouse_event, ui::LatencyInfo()); | 875 ForwardMouseEventWithLatencyInfo(mouse_event, ui::LatencyInfo()); |
| 899 } | 876 } |
| 900 | 877 |
| 901 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( | 878 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( |
| 902 const blink::WebMouseEvent& mouse_event, | 879 const blink::WebMouseEvent& mouse_event, |
| 903 const ui::LatencyInfo& ui_latency) { | 880 const ui::LatencyInfo& ui_latency) { |
| 904 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent", | 881 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent", |
| 905 "x", mouse_event.x, "y", mouse_event.y); | 882 "x", mouse_event.x, "y", mouse_event.y); |
| 906 | 883 |
| (...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1976 | 1953 |
| 1977 void RenderWidgetHostImpl::SetBackground(const SkBitmap& background) { | 1954 void RenderWidgetHostImpl::SetBackground(const SkBitmap& background) { |
| 1978 Send(new ViewMsg_SetBackground(GetRoutingID(), background)); | 1955 Send(new ViewMsg_SetBackground(GetRoutingID(), background)); |
| 1979 } | 1956 } |
| 1980 | 1957 |
| 1981 void RenderWidgetHostImpl::SetEditCommandsForNextKeyEvent( | 1958 void RenderWidgetHostImpl::SetEditCommandsForNextKeyEvent( |
| 1982 const std::vector<EditCommand>& commands) { | 1959 const std::vector<EditCommand>& commands) { |
| 1983 Send(new InputMsg_SetEditCommandsForNextKeyEvent(GetRoutingID(), commands)); | 1960 Send(new InputMsg_SetEditCommandsForNextKeyEvent(GetRoutingID(), commands)); |
| 1984 } | 1961 } |
| 1985 | 1962 |
| 1986 void RenderWidgetHostImpl::AddAccessibilityMode(AccessibilityMode mode) { | |
| 1987 SetAccessibilityMode( | |
| 1988 content::AddAccessibilityModeTo(accessibility_mode_, mode)); | |
| 1989 } | |
| 1990 | |
| 1991 void RenderWidgetHostImpl::RemoveAccessibilityMode(AccessibilityMode mode) { | |
| 1992 SetAccessibilityMode( | |
| 1993 content::RemoveAccessibilityModeFrom(accessibility_mode_, mode)); | |
| 1994 } | |
| 1995 | |
| 1996 void RenderWidgetHostImpl::ResetAccessibilityMode() { | |
| 1997 SetAccessibilityMode( | |
| 1998 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()); | |
| 1999 } | |
| 2000 | |
| 2001 void RenderWidgetHostImpl::SetAccessibilityMode(AccessibilityMode mode) { | |
| 2002 accessibility_mode_ = mode; | |
| 2003 Send(new ViewMsg_SetAccessibilityMode(GetRoutingID(), mode)); | |
| 2004 } | |
| 2005 | |
| 2006 void RenderWidgetHostImpl::AccessibilitySetFocus(int object_id) { | |
| 2007 Send(new AccessibilityMsg_SetFocus(GetRoutingID(), object_id)); | |
| 2008 view_->OnAccessibilitySetFocus(object_id); | |
| 2009 } | |
| 2010 | |
| 2011 void RenderWidgetHostImpl::AccessibilityDoDefaultAction(int object_id) { | |
| 2012 Send(new AccessibilityMsg_DoDefaultAction(GetRoutingID(), object_id)); | |
| 2013 } | |
| 2014 | |
| 2015 void RenderWidgetHostImpl::AccessibilityShowMenu(int object_id) { | |
| 2016 view_->AccessibilityShowMenu(object_id); | |
| 2017 } | |
| 2018 | |
| 2019 void RenderWidgetHostImpl::AccessibilityScrollToMakeVisible( | |
| 2020 int acc_obj_id, gfx::Rect subfocus) { | |
| 2021 Send(new AccessibilityMsg_ScrollToMakeVisible( | |
| 2022 GetRoutingID(), acc_obj_id, subfocus)); | |
| 2023 } | |
| 2024 | |
| 2025 void RenderWidgetHostImpl::AccessibilityScrollToPoint( | |
| 2026 int acc_obj_id, gfx::Point point) { | |
| 2027 Send(new AccessibilityMsg_ScrollToPoint( | |
| 2028 GetRoutingID(), acc_obj_id, point)); | |
| 2029 } | |
| 2030 | |
| 2031 void RenderWidgetHostImpl::AccessibilitySetTextSelection( | |
| 2032 int object_id, int start_offset, int end_offset) { | |
| 2033 Send(new AccessibilityMsg_SetTextSelection( | |
| 2034 GetRoutingID(), object_id, start_offset, end_offset)); | |
| 2035 } | |
| 2036 | |
| 2037 bool RenderWidgetHostImpl::AccessibilityViewHasFocus() const { | |
| 2038 return view_->HasFocus(); | |
| 2039 } | |
| 2040 | |
| 2041 gfx::Rect RenderWidgetHostImpl::AccessibilityGetViewBounds() const { | |
| 2042 return view_->GetViewBounds(); | |
| 2043 } | |
| 2044 | |
| 2045 gfx::Point RenderWidgetHostImpl::AccessibilityOriginInScreen( | |
| 2046 const gfx::Rect& bounds) const { | |
| 2047 return view_->AccessibilityOriginInScreen(bounds); | |
| 2048 } | |
| 2049 | |
| 2050 void RenderWidgetHostImpl::AccessibilityFatalError() { | |
| 2051 Send(new AccessibilityMsg_FatalError(GetRoutingID())); | |
| 2052 view_->SetBrowserAccessibilityManager(NULL); | |
| 2053 } | |
| 2054 | |
| 2055 #if defined(OS_WIN) | |
| 2056 void RenderWidgetHostImpl::SetParentNativeViewAccessible( | |
| 2057 gfx::NativeViewAccessible accessible_parent) { | |
| 2058 if (view_) | |
| 2059 view_->SetParentNativeViewAccessible(accessible_parent); | |
| 2060 } | |
| 2061 | |
| 2062 gfx::NativeViewAccessible | |
| 2063 RenderWidgetHostImpl::GetParentNativeViewAccessible() const { | |
| 2064 return delegate_->GetParentNativeViewAccessible(); | |
| 2065 } | |
| 2066 #endif | |
| 2067 | |
| 2068 void RenderWidgetHostImpl::ExecuteEditCommand(const std::string& command, | 1963 void RenderWidgetHostImpl::ExecuteEditCommand(const std::string& command, |
| 2069 const std::string& value) { | 1964 const std::string& value) { |
| 2070 Send(new InputMsg_ExecuteEditCommand(GetRoutingID(), command, value)); | 1965 Send(new InputMsg_ExecuteEditCommand(GetRoutingID(), command, value)); |
| 2071 } | 1966 } |
| 2072 | 1967 |
| 2073 void RenderWidgetHostImpl::ScrollFocusedEditableNodeIntoRect( | 1968 void RenderWidgetHostImpl::ScrollFocusedEditableNodeIntoRect( |
| 2074 const gfx::Rect& rect) { | 1969 const gfx::Rect& rect) { |
| 2075 Send(new InputMsg_ScrollFocusedEditableNodeIntoRect(GetRoutingID(), rect)); | 1970 Send(new InputMsg_ScrollFocusedEditableNodeIntoRect(GetRoutingID(), rect)); |
| 2076 } | 1971 } |
| 2077 | 1972 |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2345 } | 2240 } |
| 2346 } | 2241 } |
| 2347 | 2242 |
| 2348 SkBitmap::Config RenderWidgetHostImpl::PreferredReadbackFormat() { | 2243 SkBitmap::Config RenderWidgetHostImpl::PreferredReadbackFormat() { |
| 2349 if (view_) | 2244 if (view_) |
| 2350 return view_->PreferredReadbackFormat(); | 2245 return view_->PreferredReadbackFormat(); |
| 2351 return SkBitmap::kARGB_8888_Config; | 2246 return SkBitmap::kARGB_8888_Config; |
| 2352 } | 2247 } |
| 2353 | 2248 |
| 2354 } // namespace content | 2249 } // namespace content |
| OLD | NEW |