Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(496)

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 273423004: Migrate accessibility from RenderView to RenderFrame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix win & android compile Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 surface_id_(0), 167 surface_id_(0),
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 repaint_ack_pending_(false), 171 repaint_ack_pending_(false),
175 resize_ack_pending_(false), 172 resize_ack_pending_(false),
176 screen_info_out_of_date_(false), 173 screen_info_out_of_date_(false),
177 overdraw_bottom_height_(0.f), 174 overdraw_bottom_height_(0.f),
178 should_auto_resize_(false), 175 should_auto_resize_(false),
179 waiting_for_screen_rects_ack_(false), 176 waiting_for_screen_rects_ack_(false),
180 accessibility_mode_(AccessibilityModeOff),
181 needs_repainting_on_restore_(false), 177 needs_repainting_on_restore_(false),
182 is_unresponsive_(false), 178 is_unresponsive_(false),
183 in_flight_event_count_(0), 179 in_flight_event_count_(0),
184 in_get_backing_store_(false), 180 in_get_backing_store_(false),
185 ignore_input_events_(false), 181 ignore_input_events_(false),
186 input_method_active_(false), 182 input_method_active_(false),
187 text_direction_updated_(false), 183 text_direction_updated_(false),
188 text_direction_(blink::WebTextDirectionLeftToRight), 184 text_direction_(blink::WebTextDirectionLeftToRight),
189 text_direction_canceled_(false), 185 text_direction_canceled_(false),
190 suppress_next_char_events_(false), 186 suppress_next_char_events_(false),
(...skipping 26 matching lines...) Expand all
217 g_routing_id_widget_map.Get().insert(std::make_pair( 213 g_routing_id_widget_map.Get().insert(std::make_pair(
218 RenderWidgetHostID(process->GetID(), routing_id_), this)); 214 RenderWidgetHostID(process->GetID(), routing_id_), this));
219 CHECK(result.second) << "Inserting a duplicate item!"; 215 CHECK(result.second) << "Inserting a duplicate item!";
220 process_->AddRoute(routing_id_, this); 216 process_->AddRoute(routing_id_, this);
221 217
222 // 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.
223 // 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.
224 if (!hidden) 220 if (!hidden)
225 process_->WidgetRestored(); 221 process_->WidgetRestored();
226 222
227 accessibility_mode_ =
228 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode();
229
230 input_router_.reset(new InputRouterImpl( 223 input_router_.reset(new InputRouterImpl(
231 process_, this, this, routing_id_, GetInputRouterConfigForPlatform())); 224 process_, this, this, routing_id_, GetInputRouterConfigForPlatform()));
232 225
233 touch_emulator_.reset(); 226 touch_emulator_.reset();
234 227
235 #if defined(USE_AURA) 228 #if defined(USE_AURA)
236 bool overscroll_enabled = CommandLine::ForCurrentProcess()-> 229 bool overscroll_enabled = CommandLine::ForCurrentProcess()->
237 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; 230 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0";
238 SetOverscrollControllerEnabled(overscroll_enabled); 231 SetOverscrollControllerEnabled(overscroll_enabled);
239 #endif 232 #endif
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 hang_monitor_timeout_->Restart( 849 hang_monitor_timeout_->Restart(
857 base::TimeDelta::FromMilliseconds(hung_renderer_delay_ms_)); 850 base::TimeDelta::FromMilliseconds(hung_renderer_delay_ms_));
858 } 851 }
859 852
860 void RenderWidgetHostImpl::StopHangMonitorTimeout() { 853 void RenderWidgetHostImpl::StopHangMonitorTimeout() {
861 if (hang_monitor_timeout_) 854 if (hang_monitor_timeout_)
862 hang_monitor_timeout_->Stop(); 855 hang_monitor_timeout_->Stop();
863 RendererIsResponsive(); 856 RendererIsResponsive();
864 } 857 }
865 858
866 void RenderWidgetHostImpl::EnableFullAccessibilityMode() {
867 AddAccessibilityMode(AccessibilityModeComplete);
868 }
869
870 bool RenderWidgetHostImpl::IsFullAccessibilityModeForTesting() {
871 return accessibility_mode() == AccessibilityModeComplete;
872 }
873
874 void RenderWidgetHostImpl::EnableTreeOnlyAccessibilityMode() {
875 AddAccessibilityMode(AccessibilityModeTreeOnly);
876 }
877
878 bool RenderWidgetHostImpl::IsTreeOnlyAccessibilityModeForTesting() {
879 return accessibility_mode() == AccessibilityModeTreeOnly;
880 }
881
882 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { 859 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) {
883 ForwardMouseEventWithLatencyInfo(mouse_event, ui::LatencyInfo()); 860 ForwardMouseEventWithLatencyInfo(mouse_event, ui::LatencyInfo());
884 } 861 }
885 862
886 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( 863 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo(
887 const blink::WebMouseEvent& mouse_event, 864 const blink::WebMouseEvent& mouse_event,
888 const ui::LatencyInfo& ui_latency) { 865 const ui::LatencyInfo& ui_latency) {
889 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent", 866 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent",
890 "x", mouse_event.x, "y", mouse_event.y); 867 "x", mouse_event.x, "y", mouse_event.y);
891 868
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
1946 1923
1947 void RenderWidgetHostImpl::SetBackgroundOpaque(bool opaque) { 1924 void RenderWidgetHostImpl::SetBackgroundOpaque(bool opaque) {
1948 Send(new ViewMsg_SetBackgroundOpaque(GetRoutingID(), opaque)); 1925 Send(new ViewMsg_SetBackgroundOpaque(GetRoutingID(), opaque));
1949 } 1926 }
1950 1927
1951 void RenderWidgetHostImpl::SetEditCommandsForNextKeyEvent( 1928 void RenderWidgetHostImpl::SetEditCommandsForNextKeyEvent(
1952 const std::vector<EditCommand>& commands) { 1929 const std::vector<EditCommand>& commands) {
1953 Send(new InputMsg_SetEditCommandsForNextKeyEvent(GetRoutingID(), commands)); 1930 Send(new InputMsg_SetEditCommandsForNextKeyEvent(GetRoutingID(), commands));
1954 } 1931 }
1955 1932
1956 void RenderWidgetHostImpl::AddAccessibilityMode(AccessibilityMode mode) {
1957 SetAccessibilityMode(
1958 content::AddAccessibilityModeTo(accessibility_mode_, mode));
1959 }
1960
1961 void RenderWidgetHostImpl::RemoveAccessibilityMode(AccessibilityMode mode) {
1962 SetAccessibilityMode(
1963 content::RemoveAccessibilityModeFrom(accessibility_mode_, mode));
1964 }
1965
1966 void RenderWidgetHostImpl::ResetAccessibilityMode() {
1967 SetAccessibilityMode(
1968 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode());
1969 }
1970
1971 void RenderWidgetHostImpl::SetAccessibilityMode(AccessibilityMode mode) {
1972 accessibility_mode_ = mode;
1973 Send(new ViewMsg_SetAccessibilityMode(GetRoutingID(), mode));
1974 }
1975
1976 void RenderWidgetHostImpl::AccessibilitySetFocus(int object_id) {
1977 Send(new AccessibilityMsg_SetFocus(GetRoutingID(), object_id));
1978 view_->OnAccessibilitySetFocus(object_id);
1979 }
1980
1981 void RenderWidgetHostImpl::AccessibilityDoDefaultAction(int object_id) {
1982 Send(new AccessibilityMsg_DoDefaultAction(GetRoutingID(), object_id));
1983 }
1984
1985 void RenderWidgetHostImpl::AccessibilityShowMenu(int object_id) {
1986 view_->AccessibilityShowMenu(object_id);
1987 }
1988
1989 void RenderWidgetHostImpl::AccessibilityScrollToMakeVisible(
1990 int acc_obj_id, gfx::Rect subfocus) {
1991 Send(new AccessibilityMsg_ScrollToMakeVisible(
1992 GetRoutingID(), acc_obj_id, subfocus));
1993 }
1994
1995 void RenderWidgetHostImpl::AccessibilityScrollToPoint(
1996 int acc_obj_id, gfx::Point point) {
1997 Send(new AccessibilityMsg_ScrollToPoint(
1998 GetRoutingID(), acc_obj_id, point));
1999 }
2000
2001 void RenderWidgetHostImpl::AccessibilitySetTextSelection(
2002 int object_id, int start_offset, int end_offset) {
2003 Send(new AccessibilityMsg_SetTextSelection(
2004 GetRoutingID(), object_id, start_offset, end_offset));
2005 }
2006
2007 bool RenderWidgetHostImpl::AccessibilityViewHasFocus() const {
2008 return view_->HasFocus();
2009 }
2010
2011 gfx::Rect RenderWidgetHostImpl::AccessibilityGetViewBounds() const {
2012 return view_->GetViewBounds();
2013 }
2014
2015 gfx::Point RenderWidgetHostImpl::AccessibilityOriginInScreen(
2016 const gfx::Rect& bounds) const {
2017 return view_->AccessibilityOriginInScreen(bounds);
2018 }
2019
2020 void RenderWidgetHostImpl::AccessibilityFatalError() {
2021 Send(new AccessibilityMsg_FatalError(GetRoutingID()));
2022 view_->SetBrowserAccessibilityManager(NULL);
2023 }
2024
2025 #if defined(OS_WIN)
2026 void RenderWidgetHostImpl::SetParentNativeViewAccessible(
2027 gfx::NativeViewAccessible accessible_parent) {
2028 if (view_)
2029 view_->SetParentNativeViewAccessible(accessible_parent);
2030 }
2031
2032 gfx::NativeViewAccessible
2033 RenderWidgetHostImpl::GetParentNativeViewAccessible() const {
2034 return delegate_->GetParentNativeViewAccessible();
2035 }
2036 #endif
2037
2038 void RenderWidgetHostImpl::ExecuteEditCommand(const std::string& command, 1933 void RenderWidgetHostImpl::ExecuteEditCommand(const std::string& command,
2039 const std::string& value) { 1934 const std::string& value) {
2040 Send(new InputMsg_ExecuteEditCommand(GetRoutingID(), command, value)); 1935 Send(new InputMsg_ExecuteEditCommand(GetRoutingID(), command, value));
2041 } 1936 }
2042 1937
2043 void RenderWidgetHostImpl::ScrollFocusedEditableNodeIntoRect( 1938 void RenderWidgetHostImpl::ScrollFocusedEditableNodeIntoRect(
2044 const gfx::Rect& rect) { 1939 const gfx::Rect& rect) {
2045 Send(new InputMsg_ScrollFocusedEditableNodeIntoRect(GetRoutingID(), rect)); 1940 Send(new InputMsg_ScrollFocusedEditableNodeIntoRect(GetRoutingID(), rect));
2046 } 1941 }
2047 1942
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
2308 ++lc; 2203 ++lc;
2309 } 2204 }
2310 } 2205 }
2311 2206
2312 // Add newly generated components into the latency info 2207 // Add newly generated components into the latency info
2313 for (lc = new_components.begin(); lc != new_components.end(); ++lc) { 2208 for (lc = new_components.begin(); lc != new_components.end(); ++lc) {
2314 latency_info->latency_components[lc->first] = lc->second; 2209 latency_info->latency_components[lc->first] = lc->second;
2315 } 2210 }
2316 } 2211 }
2317 2212
2213 BrowserAccessibilityManager*
2214 RenderWidgetHostImpl::GetRootBrowserAccessibilityManager() {
2215 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL;
2216 }
2217
2318 SkBitmap::Config RenderWidgetHostImpl::PreferredReadbackFormat() { 2218 SkBitmap::Config RenderWidgetHostImpl::PreferredReadbackFormat() {
2319 if (view_) 2219 if (view_)
2320 return view_->PreferredReadbackFormat(); 2220 return view_->PreferredReadbackFormat();
2321 return SkBitmap::kARGB_8888_Config; 2221 return SkBitmap::kARGB_8888_Config;
2322 } 2222 }
2323 2223
2324 } // namespace content 2224 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698