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/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 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 frames_in_progress_(0), | 720 frames_in_progress_(0), |
721 target_url_status_(TARGET_NONE), | 721 target_url_status_(TARGET_NONE), |
722 uses_temporary_zoom_level_(false), | 722 uses_temporary_zoom_level_(false), |
723 #if defined(OS_ANDROID) | 723 #if defined(OS_ANDROID) |
724 top_controls_constraints_(cc::BOTH), | 724 top_controls_constraints_(cc::BOTH), |
725 #endif | 725 #endif |
726 has_scrolled_focused_editable_node_into_rect_(false), | 726 has_scrolled_focused_editable_node_into_rect_(false), |
727 speech_recognition_dispatcher_(NULL), | 727 speech_recognition_dispatcher_(NULL), |
728 browser_plugin_manager_(NULL), | 728 browser_plugin_manager_(NULL), |
729 devtools_agent_(NULL), | 729 devtools_agent_(NULL), |
| 730 accessibility_mode_(AccessibilityModeOff), |
| 731 renderer_accessibility_(NULL), |
730 mouse_lock_dispatcher_(NULL), | 732 mouse_lock_dispatcher_(NULL), |
731 #if defined(OS_ANDROID) | 733 #if defined(OS_ANDROID) |
732 expected_content_intent_id_(0), | 734 expected_content_intent_id_(0), |
733 #endif | 735 #endif |
734 #if defined(OS_WIN) | 736 #if defined(OS_WIN) |
735 focused_plugin_id_(-1), | 737 focused_plugin_id_(-1), |
736 #endif | 738 #endif |
737 #if defined(ENABLE_PLUGINS) | 739 #if defined(ENABLE_PLUGINS) |
738 plugin_find_handler_(NULL), | 740 plugin_find_handler_(NULL), |
739 focused_pepper_plugin_(NULL), | 741 focused_pepper_plugin_(NULL), |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 // The next group of objects all implement RenderViewObserver, so are deleted | 854 // The next group of objects all implement RenderViewObserver, so are deleted |
853 // along with the RenderView automatically. | 855 // along with the RenderView automatically. |
854 devtools_agent_ = new DevToolsAgent(this); | 856 devtools_agent_ = new DevToolsAgent(this); |
855 if (RenderWidgetCompositor* rwc = compositor()) { | 857 if (RenderWidgetCompositor* rwc = compositor()) { |
856 webview()->devToolsAgent()->setLayerTreeId(rwc->GetLayerTreeId()); | 858 webview()->devToolsAgent()->setLayerTreeId(rwc->GetLayerTreeId()); |
857 } | 859 } |
858 mouse_lock_dispatcher_ = new RenderViewMouseLockDispatcher(this); | 860 mouse_lock_dispatcher_ = new RenderViewMouseLockDispatcher(this); |
859 | 861 |
860 history_controller_.reset(new HistoryController(this)); | 862 history_controller_.reset(new HistoryController(this)); |
861 | 863 |
| 864 // Create renderer_accessibility_ if needed. |
| 865 OnSetAccessibilityMode(params->accessibility_mode); |
| 866 |
862 new IdleUserDetector(this); | 867 new IdleUserDetector(this); |
863 | 868 |
864 if (command_line.HasSwitch(switches::kDomAutomationController)) | 869 if (command_line.HasSwitch(switches::kDomAutomationController)) |
865 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; | 870 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; |
866 if (command_line.HasSwitch(switches::kStatsCollectionController)) | 871 if (command_line.HasSwitch(switches::kStatsCollectionController)) |
867 enabled_bindings_ |= BINDINGS_POLICY_STATS_COLLECTION; | 872 enabled_bindings_ |= BINDINGS_POLICY_STATS_COLLECTION; |
868 | 873 |
869 ProcessViewLayoutFlags(command_line); | 874 ProcessViewLayoutFlags(command_line); |
870 | 875 |
871 GetContentClient()->renderer()->RenderViewCreated(this); | 876 GetContentClient()->renderer()->RenderViewCreated(this); |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 int32 main_frame_routing_id, | 1199 int32 main_frame_routing_id, |
1195 int32 surface_id, | 1200 int32 surface_id, |
1196 int64 session_storage_namespace_id, | 1201 int64 session_storage_namespace_id, |
1197 const base::string16& frame_name, | 1202 const base::string16& frame_name, |
1198 bool is_renderer_created, | 1203 bool is_renderer_created, |
1199 bool swapped_out, | 1204 bool swapped_out, |
1200 int32 proxy_routing_id, | 1205 int32 proxy_routing_id, |
1201 bool hidden, | 1206 bool hidden, |
1202 bool never_visible, | 1207 bool never_visible, |
1203 int32 next_page_id, | 1208 int32 next_page_id, |
1204 const blink::WebScreenInfo& screen_info) { | 1209 const blink::WebScreenInfo& screen_info, |
| 1210 AccessibilityMode accessibility_mode) { |
1205 DCHECK(routing_id != MSG_ROUTING_NONE); | 1211 DCHECK(routing_id != MSG_ROUTING_NONE); |
1206 RenderViewImplParams params(opener_id, | 1212 RenderViewImplParams params(opener_id, |
1207 window_was_created_with_opener, | 1213 window_was_created_with_opener, |
1208 renderer_prefs, | 1214 renderer_prefs, |
1209 webkit_prefs, | 1215 webkit_prefs, |
1210 routing_id, | 1216 routing_id, |
1211 main_frame_routing_id, | 1217 main_frame_routing_id, |
1212 surface_id, | 1218 surface_id, |
1213 session_storage_namespace_id, | 1219 session_storage_namespace_id, |
1214 frame_name, | 1220 frame_name, |
1215 is_renderer_created, | 1221 is_renderer_created, |
1216 swapped_out, | 1222 swapped_out, |
1217 proxy_routing_id, | 1223 proxy_routing_id, |
1218 hidden, | 1224 hidden, |
1219 never_visible, | 1225 never_visible, |
1220 next_page_id, | 1226 next_page_id, |
1221 screen_info); | 1227 screen_info, |
| 1228 accessibility_mode); |
1222 RenderViewImpl* render_view = NULL; | 1229 RenderViewImpl* render_view = NULL; |
1223 if (g_create_render_view_impl) | 1230 if (g_create_render_view_impl) |
1224 render_view = g_create_render_view_impl(¶ms); | 1231 render_view = g_create_render_view_impl(¶ms); |
1225 else | 1232 else |
1226 render_view = new RenderViewImpl(¶ms); | 1233 render_view = new RenderViewImpl(¶ms); |
1227 | 1234 |
1228 render_view->Initialize(¶ms); | 1235 render_view->Initialize(¶ms); |
1229 return render_view; | 1236 return render_view; |
1230 } | 1237 } |
1231 | 1238 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1399 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, | 1406 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, |
1400 OnGetAllSavableResourceLinksForCurrentPage) | 1407 OnGetAllSavableResourceLinksForCurrentPage) |
1401 IPC_MESSAGE_HANDLER( | 1408 IPC_MESSAGE_HANDLER( |
1402 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, | 1409 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, |
1403 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) | 1410 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) |
1404 IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu) | 1411 IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu) |
1405 // TODO(viettrungluu): Move to a separate message filter. | 1412 // TODO(viettrungluu): Move to a separate message filter. |
1406 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, | 1413 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, |
1407 OnSetHistoryLengthAndPrune) | 1414 OnSetHistoryLengthAndPrune) |
1408 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) | 1415 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) |
| 1416 IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityMode, OnSetAccessibilityMode) |
1409 IPC_MESSAGE_HANDLER(ViewMsg_DisownOpener, OnDisownOpener) | 1417 IPC_MESSAGE_HANDLER(ViewMsg_DisownOpener, OnDisownOpener) |
1410 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, | 1418 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, |
1411 OnReleaseDisambiguationPopupBitmap) | 1419 OnReleaseDisambiguationPopupBitmap) |
1412 IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted, | 1420 IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted, |
1413 OnWindowSnapshotCompleted) | 1421 OnWindowSnapshotCompleted) |
1414 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) | 1422 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) |
1415 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) | 1423 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) |
1416 #if defined(OS_ANDROID) | 1424 #if defined(OS_ANDROID) |
1417 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, | 1425 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, |
1418 OnActivateNearestFindResult) | 1426 OnActivateNearestFindResult) |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1740 main_frame_routing_id, | 1748 main_frame_routing_id, |
1741 surface_id, | 1749 surface_id, |
1742 cloned_session_storage_namespace_id, | 1750 cloned_session_storage_namespace_id, |
1743 base::string16(), // WebCore will take care of setting the correct name. | 1751 base::string16(), // WebCore will take care of setting the correct name. |
1744 true, // is_renderer_created | 1752 true, // is_renderer_created |
1745 false, // swapped_out | 1753 false, // swapped_out |
1746 MSG_ROUTING_NONE, // proxy_routing_id | 1754 MSG_ROUTING_NONE, // proxy_routing_id |
1747 params.disposition == NEW_BACKGROUND_TAB, // hidden | 1755 params.disposition == NEW_BACKGROUND_TAB, // hidden |
1748 never_visible, | 1756 never_visible, |
1749 1, // next_page_id | 1757 1, // next_page_id |
1750 screen_info_); | 1758 screen_info_, |
| 1759 accessibility_mode_); |
1751 view->opened_by_user_gesture_ = params.user_gesture; | 1760 view->opened_by_user_gesture_ = params.user_gesture; |
1752 | 1761 |
1753 // Record whether the creator frame is trying to suppress the opener field. | 1762 // Record whether the creator frame is trying to suppress the opener field. |
1754 view->opener_suppressed_ = params.opener_suppressed; | 1763 view->opener_suppressed_ = params.opener_suppressed; |
1755 | 1764 |
1756 return view->webview(); | 1765 return view->webview(); |
1757 } | 1766 } |
1758 | 1767 |
1759 WebWidget* RenderViewImpl::createPopupMenu(blink::WebPopupType popup_type) { | 1768 WebWidget* RenderViewImpl::createPopupMenu(blink::WebPopupType popup_type) { |
1760 RenderWidget* widget = | 1769 RenderWidget* widget = |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2024 void RenderViewImpl::focusPrevious() { | 2033 void RenderViewImpl::focusPrevious() { |
2025 Send(new ViewHostMsg_TakeFocus(routing_id_, true)); | 2034 Send(new ViewHostMsg_TakeFocus(routing_id_, true)); |
2026 } | 2035 } |
2027 | 2036 |
2028 void RenderViewImpl::focusedNodeChanged(const WebNode& node) { | 2037 void RenderViewImpl::focusedNodeChanged(const WebNode& node) { |
2029 has_scrolled_focused_editable_node_into_rect_ = false; | 2038 has_scrolled_focused_editable_node_into_rect_ = false; |
2030 | 2039 |
2031 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node))); | 2040 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node))); |
2032 | 2041 |
2033 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node)); | 2042 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node)); |
2034 | |
2035 // TODO(dmazzoni): this should be part of RenderFrameObserver. | |
2036 main_render_frame()->FocusedNodeChanged(node); | |
2037 } | 2043 } |
2038 | 2044 |
2039 void RenderViewImpl::didUpdateLayout() { | 2045 void RenderViewImpl::didUpdateLayout() { |
2040 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidUpdateLayout()); | 2046 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidUpdateLayout()); |
2041 | 2047 |
2042 // We don't always want to set up a timer, only if we've been put in that | 2048 // We don't always want to set up a timer, only if we've been put in that |
2043 // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| | 2049 // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| |
2044 // message. | 2050 // message. |
2045 if (!send_preferred_size_changes_ || !webview()) | 2051 if (!send_preferred_size_changes_ || !webview()) |
2046 return; | 2052 return; |
(...skipping 12 matching lines...) Expand all Loading... |
2059 int RenderViewImpl::historyBackListCount() { | 2065 int RenderViewImpl::historyBackListCount() { |
2060 return history_list_offset_ < 0 ? 0 : history_list_offset_; | 2066 return history_list_offset_ < 0 ? 0 : history_list_offset_; |
2061 } | 2067 } |
2062 | 2068 |
2063 int RenderViewImpl::historyForwardListCount() { | 2069 int RenderViewImpl::historyForwardListCount() { |
2064 return history_list_length_ - historyBackListCount() - 1; | 2070 return history_list_length_ - historyBackListCount() - 1; |
2065 } | 2071 } |
2066 | 2072 |
2067 void RenderViewImpl::postAccessibilityEvent( | 2073 void RenderViewImpl::postAccessibilityEvent( |
2068 const WebAXObject& obj, blink::WebAXEvent event) { | 2074 const WebAXObject& obj, blink::WebAXEvent event) { |
2069 main_render_frame()->HandleWebAccessibilityEvent(obj, event); | 2075 if (renderer_accessibility_) { |
| 2076 renderer_accessibility_->HandleWebAccessibilityEvent(obj, event); |
| 2077 } |
2070 } | 2078 } |
2071 | 2079 |
2072 void RenderViewImpl::didUpdateInspectorSetting(const WebString& key, | 2080 void RenderViewImpl::didUpdateInspectorSetting(const WebString& key, |
2073 const WebString& value) { | 2081 const WebString& value) { |
2074 Send(new ViewHostMsg_UpdateInspectorSetting(routing_id_, | 2082 Send(new ViewHostMsg_UpdateInspectorSetting(routing_id_, |
2075 key.utf8(), | 2083 key.utf8(), |
2076 value.utf8())); | 2084 value.utf8())); |
2077 } | 2085 } |
2078 | 2086 |
2079 // blink::WebWidgetClient ---------------------------------------------------- | 2087 // blink::WebWidgetClient ---------------------------------------------------- |
(...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3406 webview()->clearFocusedElement(); | 3414 webview()->clearFocusedElement(); |
3407 } | 3415 } |
3408 | 3416 |
3409 void RenderViewImpl::OnSetBackgroundOpaque(bool opaque) { | 3417 void RenderViewImpl::OnSetBackgroundOpaque(bool opaque) { |
3410 if (webview()) | 3418 if (webview()) |
3411 webview()->setIsTransparent(!opaque); | 3419 webview()->setIsTransparent(!opaque); |
3412 if (compositor_) | 3420 if (compositor_) |
3413 compositor_->setHasTransparentBackground(!opaque); | 3421 compositor_->setHasTransparentBackground(!opaque); |
3414 } | 3422 } |
3415 | 3423 |
| 3424 void RenderViewImpl::OnSetAccessibilityMode(AccessibilityMode new_mode) { |
| 3425 if (accessibility_mode_ == new_mode) |
| 3426 return; |
| 3427 accessibility_mode_ = new_mode; |
| 3428 if (renderer_accessibility_) { |
| 3429 delete renderer_accessibility_; |
| 3430 renderer_accessibility_ = NULL; |
| 3431 } |
| 3432 if (accessibility_mode_ == AccessibilityModeOff) |
| 3433 return; |
| 3434 |
| 3435 if (accessibility_mode_ & AccessibilityModeFlagFullTree) |
| 3436 renderer_accessibility_ = new RendererAccessibilityComplete(this); |
| 3437 #if !defined(OS_ANDROID) |
| 3438 else |
| 3439 renderer_accessibility_ = new RendererAccessibilityFocusOnly(this); |
| 3440 #endif |
| 3441 } |
| 3442 |
3416 void RenderViewImpl::OnSetActive(bool active) { | 3443 void RenderViewImpl::OnSetActive(bool active) { |
3417 if (webview()) | 3444 if (webview()) |
3418 webview()->setIsActive(active); | 3445 webview()->setIsActive(active); |
3419 | 3446 |
3420 #if defined(ENABLE_PLUGINS) && defined(OS_MACOSX) | 3447 #if defined(ENABLE_PLUGINS) && defined(OS_MACOSX) |
3421 std::set<WebPluginDelegateProxy*>::iterator plugin_it; | 3448 std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
3422 for (plugin_it = plugin_delegates_.begin(); | 3449 for (plugin_it = plugin_delegates_.begin(); |
3423 plugin_it != plugin_delegates_.end(); ++plugin_it) { | 3450 plugin_it != plugin_delegates_.end(); ++plugin_it) { |
3424 (*plugin_it)->SetWindowFocus(active); | 3451 (*plugin_it)->SetWindowFocus(active); |
3425 } | 3452 } |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4100 if (main_frame && main_frame->opener()) | 4127 if (main_frame && main_frame->opener()) |
4101 main_frame->setOpener(NULL); | 4128 main_frame->setOpener(NULL); |
4102 } | 4129 } |
4103 | 4130 |
4104 #if defined(OS_ANDROID) | 4131 #if defined(OS_ANDROID) |
4105 bool RenderViewImpl::didTapMultipleTargets( | 4132 bool RenderViewImpl::didTapMultipleTargets( |
4106 const blink::WebGestureEvent& event, | 4133 const blink::WebGestureEvent& event, |
4107 const WebVector<WebRect>& target_rects) { | 4134 const WebVector<WebRect>& target_rects) { |
4108 // Never show a disambiguation popup when accessibility is enabled, | 4135 // Never show a disambiguation popup when accessibility is enabled, |
4109 // as this interferes with "touch exploration". | 4136 // as this interferes with "touch exploration". |
4110 AccessibilityMode accessibility_mode = | 4137 bool matchesAccessibilityModeComplete = |
4111 main_render_frame()->accessibility_mode(); | 4138 (accessibility_mode_ & AccessibilityModeComplete) == |
4112 bool matches_accessibility_mode_complete = | 4139 AccessibilityModeComplete; |
4113 (accessibility_mode & AccessibilityModeComplete) == | 4140 if (matchesAccessibilityModeComplete) |
4114 AccessibilityModeComplete; | |
4115 if (matches_accessibility_mode_complete) | |
4116 return false; | 4141 return false; |
4117 | 4142 |
4118 gfx::Rect finger_rect( | 4143 gfx::Rect finger_rect( |
4119 event.x - event.data.tap.width / 2, event.y - event.data.tap.height / 2, | 4144 event.x - event.data.tap.width / 2, event.y - event.data.tap.height / 2, |
4120 event.data.tap.width, event.data.tap.height); | 4145 event.data.tap.width, event.data.tap.height); |
4121 gfx::Rect zoom_rect; | 4146 gfx::Rect zoom_rect; |
4122 float new_total_scale = | 4147 float new_total_scale = |
4123 DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( | 4148 DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( |
4124 finger_rect, target_rects, GetSize(), | 4149 finger_rect, target_rects, GetSize(), |
4125 gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(), | 4150 gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(), |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4270 std::vector<gfx::Size> sizes; | 4295 std::vector<gfx::Size> sizes; |
4271 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4296 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
4272 if (!url.isEmpty()) | 4297 if (!url.isEmpty()) |
4273 urls.push_back( | 4298 urls.push_back( |
4274 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4299 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
4275 } | 4300 } |
4276 SendUpdateFaviconURL(urls); | 4301 SendUpdateFaviconURL(urls); |
4277 } | 4302 } |
4278 | 4303 |
4279 } // namespace content | 4304 } // namespace content |
OLD | NEW |