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

Side by Side Diff: trunk/src/content/renderer/render_view_impl.cc

Issue 408663006: Revert 284065 "Revert of Revert of Migrate accessibility from Re..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 5 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/renderer/render_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 frames_in_progress_(0), 721 frames_in_progress_(0),
722 target_url_status_(TARGET_NONE), 722 target_url_status_(TARGET_NONE),
723 uses_temporary_zoom_level_(false), 723 uses_temporary_zoom_level_(false),
724 #if defined(OS_ANDROID) 724 #if defined(OS_ANDROID)
725 top_controls_constraints_(cc::BOTH), 725 top_controls_constraints_(cc::BOTH),
726 #endif 726 #endif
727 has_scrolled_focused_editable_node_into_rect_(false), 727 has_scrolled_focused_editable_node_into_rect_(false),
728 speech_recognition_dispatcher_(NULL), 728 speech_recognition_dispatcher_(NULL),
729 browser_plugin_manager_(NULL), 729 browser_plugin_manager_(NULL),
730 devtools_agent_(NULL), 730 devtools_agent_(NULL),
731 accessibility_mode_(AccessibilityModeOff),
732 renderer_accessibility_(NULL),
731 mouse_lock_dispatcher_(NULL), 733 mouse_lock_dispatcher_(NULL),
732 #if defined(OS_ANDROID) 734 #if defined(OS_ANDROID)
733 expected_content_intent_id_(0), 735 expected_content_intent_id_(0),
734 #endif 736 #endif
735 #if defined(OS_WIN) 737 #if defined(OS_WIN)
736 focused_plugin_id_(-1), 738 focused_plugin_id_(-1),
737 #endif 739 #endif
738 #if defined(ENABLE_PLUGINS) 740 #if defined(ENABLE_PLUGINS)
739 plugin_find_handler_(NULL), 741 plugin_find_handler_(NULL),
740 focused_pepper_plugin_(NULL), 742 focused_pepper_plugin_(NULL),
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 // The next group of objects all implement RenderViewObserver, so are deleted 855 // The next group of objects all implement RenderViewObserver, so are deleted
854 // along with the RenderView automatically. 856 // along with the RenderView automatically.
855 devtools_agent_ = new DevToolsAgent(this); 857 devtools_agent_ = new DevToolsAgent(this);
856 if (RenderWidgetCompositor* rwc = compositor()) { 858 if (RenderWidgetCompositor* rwc = compositor()) {
857 webview()->devToolsAgent()->setLayerTreeId(rwc->GetLayerTreeId()); 859 webview()->devToolsAgent()->setLayerTreeId(rwc->GetLayerTreeId());
858 } 860 }
859 mouse_lock_dispatcher_ = new RenderViewMouseLockDispatcher(this); 861 mouse_lock_dispatcher_ = new RenderViewMouseLockDispatcher(this);
860 862
861 history_controller_.reset(new HistoryController(this)); 863 history_controller_.reset(new HistoryController(this));
862 864
865 // Create renderer_accessibility_ if needed.
866 OnSetAccessibilityMode(params->accessibility_mode);
867
863 new IdleUserDetector(this); 868 new IdleUserDetector(this);
864 869
865 if (command_line.HasSwitch(switches::kDomAutomationController)) 870 if (command_line.HasSwitch(switches::kDomAutomationController))
866 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; 871 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION;
867 if (command_line.HasSwitch(switches::kStatsCollectionController)) 872 if (command_line.HasSwitch(switches::kStatsCollectionController))
868 enabled_bindings_ |= BINDINGS_POLICY_STATS_COLLECTION; 873 enabled_bindings_ |= BINDINGS_POLICY_STATS_COLLECTION;
869 874
870 ProcessViewLayoutFlags(command_line); 875 ProcessViewLayoutFlags(command_line);
871 876
872 GetContentClient()->renderer()->RenderViewCreated(this); 877 GetContentClient()->renderer()->RenderViewCreated(this);
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 int32 main_frame_routing_id, 1200 int32 main_frame_routing_id,
1196 int32 surface_id, 1201 int32 surface_id,
1197 int64 session_storage_namespace_id, 1202 int64 session_storage_namespace_id,
1198 const base::string16& frame_name, 1203 const base::string16& frame_name,
1199 bool is_renderer_created, 1204 bool is_renderer_created,
1200 bool swapped_out, 1205 bool swapped_out,
1201 int32 proxy_routing_id, 1206 int32 proxy_routing_id,
1202 bool hidden, 1207 bool hidden,
1203 bool never_visible, 1208 bool never_visible,
1204 int32 next_page_id, 1209 int32 next_page_id,
1205 const blink::WebScreenInfo& screen_info) { 1210 const blink::WebScreenInfo& screen_info,
1211 AccessibilityMode accessibility_mode) {
1206 DCHECK(routing_id != MSG_ROUTING_NONE); 1212 DCHECK(routing_id != MSG_ROUTING_NONE);
1207 RenderViewImplParams params(opener_id, 1213 RenderViewImplParams params(opener_id,
1208 window_was_created_with_opener, 1214 window_was_created_with_opener,
1209 renderer_prefs, 1215 renderer_prefs,
1210 webkit_prefs, 1216 webkit_prefs,
1211 routing_id, 1217 routing_id,
1212 main_frame_routing_id, 1218 main_frame_routing_id,
1213 surface_id, 1219 surface_id,
1214 session_storage_namespace_id, 1220 session_storage_namespace_id,
1215 frame_name, 1221 frame_name,
1216 is_renderer_created, 1222 is_renderer_created,
1217 swapped_out, 1223 swapped_out,
1218 proxy_routing_id, 1224 proxy_routing_id,
1219 hidden, 1225 hidden,
1220 never_visible, 1226 never_visible,
1221 next_page_id, 1227 next_page_id,
1222 screen_info); 1228 screen_info,
1229 accessibility_mode);
1223 RenderViewImpl* render_view = NULL; 1230 RenderViewImpl* render_view = NULL;
1224 if (g_create_render_view_impl) 1231 if (g_create_render_view_impl)
1225 render_view = g_create_render_view_impl(&params); 1232 render_view = g_create_render_view_impl(&params);
1226 else 1233 else
1227 render_view = new RenderViewImpl(&params); 1234 render_view = new RenderViewImpl(&params);
1228 1235
1229 render_view->Initialize(&params); 1236 render_view->Initialize(&params);
1230 return render_view; 1237 return render_view;
1231 } 1238 }
1232 1239
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, 1407 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage,
1401 OnGetAllSavableResourceLinksForCurrentPage) 1408 OnGetAllSavableResourceLinksForCurrentPage)
1402 IPC_MESSAGE_HANDLER( 1409 IPC_MESSAGE_HANDLER(
1403 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, 1410 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks,
1404 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) 1411 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks)
1405 IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu) 1412 IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu)
1406 // TODO(viettrungluu): Move to a separate message filter. 1413 // TODO(viettrungluu): Move to a separate message filter.
1407 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, 1414 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune,
1408 OnSetHistoryLengthAndPrune) 1415 OnSetHistoryLengthAndPrune)
1409 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) 1416 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode)
1417 IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityMode, OnSetAccessibilityMode)
1410 IPC_MESSAGE_HANDLER(ViewMsg_DisownOpener, OnDisownOpener) 1418 IPC_MESSAGE_HANDLER(ViewMsg_DisownOpener, OnDisownOpener)
1411 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, 1419 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap,
1412 OnReleaseDisambiguationPopupBitmap) 1420 OnReleaseDisambiguationPopupBitmap)
1413 IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted, 1421 IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted,
1414 OnWindowSnapshotCompleted) 1422 OnWindowSnapshotCompleted)
1415 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) 1423 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw)
1416 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) 1424 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret)
1417 #if defined(OS_ANDROID) 1425 #if defined(OS_ANDROID)
1418 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, 1426 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult,
1419 OnActivateNearestFindResult) 1427 OnActivateNearestFindResult)
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1741 main_frame_routing_id, 1749 main_frame_routing_id,
1742 surface_id, 1750 surface_id,
1743 cloned_session_storage_namespace_id, 1751 cloned_session_storage_namespace_id,
1744 base::string16(), // WebCore will take care of setting the correct name. 1752 base::string16(), // WebCore will take care of setting the correct name.
1745 true, // is_renderer_created 1753 true, // is_renderer_created
1746 false, // swapped_out 1754 false, // swapped_out
1747 MSG_ROUTING_NONE, // proxy_routing_id 1755 MSG_ROUTING_NONE, // proxy_routing_id
1748 params.disposition == NEW_BACKGROUND_TAB, // hidden 1756 params.disposition == NEW_BACKGROUND_TAB, // hidden
1749 never_visible, 1757 never_visible,
1750 1, // next_page_id 1758 1, // next_page_id
1751 screen_info_); 1759 screen_info_,
1760 accessibility_mode_);
1752 view->opened_by_user_gesture_ = params.user_gesture; 1761 view->opened_by_user_gesture_ = params.user_gesture;
1753 1762
1754 // Record whether the creator frame is trying to suppress the opener field. 1763 // Record whether the creator frame is trying to suppress the opener field.
1755 view->opener_suppressed_ = params.opener_suppressed; 1764 view->opener_suppressed_ = params.opener_suppressed;
1756 1765
1757 return view->webview(); 1766 return view->webview();
1758 } 1767 }
1759 1768
1760 WebWidget* RenderViewImpl::createPopupMenu(blink::WebPopupType popup_type) { 1769 WebWidget* RenderViewImpl::createPopupMenu(blink::WebPopupType popup_type) {
1761 RenderWidget* widget = 1770 RenderWidget* widget =
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
2025 void RenderViewImpl::focusPrevious() { 2034 void RenderViewImpl::focusPrevious() {
2026 Send(new ViewHostMsg_TakeFocus(routing_id_, true)); 2035 Send(new ViewHostMsg_TakeFocus(routing_id_, true));
2027 } 2036 }
2028 2037
2029 void RenderViewImpl::focusedNodeChanged(const WebNode& node) { 2038 void RenderViewImpl::focusedNodeChanged(const WebNode& node) {
2030 has_scrolled_focused_editable_node_into_rect_ = false; 2039 has_scrolled_focused_editable_node_into_rect_ = false;
2031 2040
2032 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node))); 2041 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node)));
2033 2042
2034 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node)); 2043 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node));
2035
2036 // TODO(dmazzoni): this should be part of RenderFrameObserver.
2037 main_render_frame()->FocusedNodeChanged(node);
2038 } 2044 }
2039 2045
2040 void RenderViewImpl::didUpdateLayout() { 2046 void RenderViewImpl::didUpdateLayout() {
2041 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidUpdateLayout()); 2047 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidUpdateLayout());
2042 2048
2043 // We don't always want to set up a timer, only if we've been put in that 2049 // We don't always want to set up a timer, only if we've been put in that
2044 // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| 2050 // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode|
2045 // message. 2051 // message.
2046 if (!send_preferred_size_changes_ || !webview()) 2052 if (!send_preferred_size_changes_ || !webview())
2047 return; 2053 return;
(...skipping 12 matching lines...) Expand all
2060 int RenderViewImpl::historyBackListCount() { 2066 int RenderViewImpl::historyBackListCount() {
2061 return history_list_offset_ < 0 ? 0 : history_list_offset_; 2067 return history_list_offset_ < 0 ? 0 : history_list_offset_;
2062 } 2068 }
2063 2069
2064 int RenderViewImpl::historyForwardListCount() { 2070 int RenderViewImpl::historyForwardListCount() {
2065 return history_list_length_ - historyBackListCount() - 1; 2071 return history_list_length_ - historyBackListCount() - 1;
2066 } 2072 }
2067 2073
2068 void RenderViewImpl::postAccessibilityEvent( 2074 void RenderViewImpl::postAccessibilityEvent(
2069 const WebAXObject& obj, blink::WebAXEvent event) { 2075 const WebAXObject& obj, blink::WebAXEvent event) {
2070 main_render_frame()->HandleWebAccessibilityEvent(obj, event); 2076 if (renderer_accessibility_) {
2077 renderer_accessibility_->HandleWebAccessibilityEvent(obj, event);
2078 }
2071 } 2079 }
2072 2080
2073 void RenderViewImpl::didUpdateInspectorSetting(const WebString& key, 2081 void RenderViewImpl::didUpdateInspectorSetting(const WebString& key,
2074 const WebString& value) { 2082 const WebString& value) {
2075 Send(new ViewHostMsg_UpdateInspectorSetting(routing_id_, 2083 Send(new ViewHostMsg_UpdateInspectorSetting(routing_id_,
2076 key.utf8(), 2084 key.utf8(),
2077 value.utf8())); 2085 value.utf8()));
2078 } 2086 }
2079 2087
2080 // blink::WebWidgetClient ---------------------------------------------------- 2088 // blink::WebWidgetClient ----------------------------------------------------
(...skipping 1342 matching lines...) Expand 10 before | Expand all | Expand 10 after
3423 webview()->clearFocusedElement(); 3431 webview()->clearFocusedElement();
3424 } 3432 }
3425 3433
3426 void RenderViewImpl::OnSetBackgroundOpaque(bool opaque) { 3434 void RenderViewImpl::OnSetBackgroundOpaque(bool opaque) {
3427 if (webview()) 3435 if (webview())
3428 webview()->setIsTransparent(!opaque); 3436 webview()->setIsTransparent(!opaque);
3429 if (compositor_) 3437 if (compositor_)
3430 compositor_->setHasTransparentBackground(!opaque); 3438 compositor_->setHasTransparentBackground(!opaque);
3431 } 3439 }
3432 3440
3441 void RenderViewImpl::OnSetAccessibilityMode(AccessibilityMode new_mode) {
3442 if (accessibility_mode_ == new_mode)
3443 return;
3444 accessibility_mode_ = new_mode;
3445 if (renderer_accessibility_) {
3446 delete renderer_accessibility_;
3447 renderer_accessibility_ = NULL;
3448 }
3449 if (accessibility_mode_ == AccessibilityModeOff)
3450 return;
3451
3452 if (accessibility_mode_ & AccessibilityModeFlagFullTree)
3453 renderer_accessibility_ = new RendererAccessibilityComplete(this);
3454 #if !defined(OS_ANDROID)
3455 else
3456 renderer_accessibility_ = new RendererAccessibilityFocusOnly(this);
3457 #endif
3458 }
3459
3433 void RenderViewImpl::OnSetActive(bool active) { 3460 void RenderViewImpl::OnSetActive(bool active) {
3434 if (webview()) 3461 if (webview())
3435 webview()->setIsActive(active); 3462 webview()->setIsActive(active);
3436 3463
3437 #if defined(ENABLE_PLUGINS) && defined(OS_MACOSX) 3464 #if defined(ENABLE_PLUGINS) && defined(OS_MACOSX)
3438 std::set<WebPluginDelegateProxy*>::iterator plugin_it; 3465 std::set<WebPluginDelegateProxy*>::iterator plugin_it;
3439 for (plugin_it = plugin_delegates_.begin(); 3466 for (plugin_it = plugin_delegates_.begin();
3440 plugin_it != plugin_delegates_.end(); ++plugin_it) { 3467 plugin_it != plugin_delegates_.end(); ++plugin_it) {
3441 (*plugin_it)->SetWindowFocus(active); 3468 (*plugin_it)->SetWindowFocus(active);
3442 } 3469 }
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
4117 if (main_frame && main_frame->opener()) 4144 if (main_frame && main_frame->opener())
4118 main_frame->setOpener(NULL); 4145 main_frame->setOpener(NULL);
4119 } 4146 }
4120 4147
4121 #if defined(OS_ANDROID) 4148 #if defined(OS_ANDROID)
4122 bool RenderViewImpl::didTapMultipleTargets( 4149 bool RenderViewImpl::didTapMultipleTargets(
4123 const blink::WebGestureEvent& event, 4150 const blink::WebGestureEvent& event,
4124 const WebVector<WebRect>& target_rects) { 4151 const WebVector<WebRect>& target_rects) {
4125 // Never show a disambiguation popup when accessibility is enabled, 4152 // Never show a disambiguation popup when accessibility is enabled,
4126 // as this interferes with "touch exploration". 4153 // as this interferes with "touch exploration".
4127 AccessibilityMode accessibility_mode = 4154 bool matchesAccessibilityModeComplete =
4128 main_render_frame()->accessibility_mode(); 4155 (accessibility_mode_ & AccessibilityModeComplete) ==
4129 bool matches_accessibility_mode_complete = 4156 AccessibilityModeComplete;
4130 (accessibility_mode & AccessibilityModeComplete) == 4157 if (matchesAccessibilityModeComplete)
4131 AccessibilityModeComplete;
4132 if (matches_accessibility_mode_complete)
4133 return false; 4158 return false;
4134 4159
4135 gfx::Rect finger_rect( 4160 gfx::Rect finger_rect(
4136 event.x - event.data.tap.width / 2, event.y - event.data.tap.height / 2, 4161 event.x - event.data.tap.width / 2, event.y - event.data.tap.height / 2,
4137 event.data.tap.width, event.data.tap.height); 4162 event.data.tap.width, event.data.tap.height);
4138 gfx::Rect zoom_rect; 4163 gfx::Rect zoom_rect;
4139 float new_total_scale = 4164 float new_total_scale =
4140 DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( 4165 DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor(
4141 finger_rect, target_rects, GetSize(), 4166 finger_rect, target_rects, GetSize(),
4142 gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(), 4167 gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(),
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
4287 std::vector<gfx::Size> sizes; 4312 std::vector<gfx::Size> sizes;
4288 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); 4313 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes);
4289 if (!url.isEmpty()) 4314 if (!url.isEmpty())
4290 urls.push_back( 4315 urls.push_back(
4291 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); 4316 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes));
4292 } 4317 }
4293 SendUpdateFaviconURL(urls); 4318 SendUpdateFaviconURL(urls);
4294 } 4319 }
4295 4320
4296 } // namespace content 4321 } // namespace content
OLDNEW
« no previous file with comments | « trunk/src/content/renderer/render_view_impl.h ('k') | trunk/src/content/renderer/render_view_impl_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698