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 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 target_url_status_(TARGET_NONE), | 660 target_url_status_(TARGET_NONE), |
661 selection_text_offset_(0), | 661 selection_text_offset_(0), |
662 selection_range_(gfx::Range::InvalidRange()), | 662 selection_range_(gfx::Range::InvalidRange()), |
663 #if defined(OS_ANDROID) | 663 #if defined(OS_ANDROID) |
664 top_controls_constraints_(cc::BOTH), | 664 top_controls_constraints_(cc::BOTH), |
665 #endif | 665 #endif |
666 cached_is_main_frame_pinned_to_left_(false), | 666 cached_is_main_frame_pinned_to_left_(false), |
667 cached_is_main_frame_pinned_to_right_(false), | 667 cached_is_main_frame_pinned_to_right_(false), |
668 cached_has_main_frame_horizontal_scrollbar_(false), | 668 cached_has_main_frame_horizontal_scrollbar_(false), |
669 cached_has_main_frame_vertical_scrollbar_(false), | 669 cached_has_main_frame_vertical_scrollbar_(false), |
| 670 has_scrolled_focused_editable_node_into_rect_(false), |
670 notification_provider_(NULL), | 671 notification_provider_(NULL), |
671 geolocation_dispatcher_(NULL), | 672 geolocation_dispatcher_(NULL), |
672 input_tag_speech_dispatcher_(NULL), | 673 input_tag_speech_dispatcher_(NULL), |
673 speech_recognition_dispatcher_(NULL), | 674 speech_recognition_dispatcher_(NULL), |
674 media_stream_dispatcher_(NULL), | 675 media_stream_dispatcher_(NULL), |
675 browser_plugin_manager_(NULL), | 676 browser_plugin_manager_(NULL), |
676 media_stream_client_(NULL), | 677 media_stream_client_(NULL), |
677 web_user_media_client_(NULL), | 678 web_user_media_client_(NULL), |
678 midi_dispatcher_(NULL), | 679 midi_dispatcher_(NULL), |
679 devtools_agent_(NULL), | 680 devtools_agent_(NULL), |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1156 IPC_MESSAGE_HANDLER(ViewMsg_DisownOpener, OnDisownOpener) | 1157 IPC_MESSAGE_HANDLER(ViewMsg_DisownOpener, OnDisownOpener) |
1157 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupDIB, | 1158 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupDIB, |
1158 OnReleaseDisambiguationPopupDIB) | 1159 OnReleaseDisambiguationPopupDIB) |
1159 IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted, | 1160 IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted, |
1160 OnWindowSnapshotCompleted) | 1161 OnWindowSnapshotCompleted) |
1161 #if defined(OS_ANDROID) | 1162 #if defined(OS_ANDROID) |
1162 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, | 1163 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, |
1163 OnActivateNearestFindResult) | 1164 OnActivateNearestFindResult) |
1164 IPC_MESSAGE_HANDLER(ViewMsg_FindMatchRects, OnFindMatchRects) | 1165 IPC_MESSAGE_HANDLER(ViewMsg_FindMatchRects, OnFindMatchRects) |
1165 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItems, OnSelectPopupMenuItems) | 1166 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItems, OnSelectPopupMenuItems) |
1166 IPC_MESSAGE_HANDLER(ViewMsg_UndoScrollFocusedEditableNodeIntoView, | |
1167 OnUndoScrollFocusedEditableNodeIntoRect) | |
1168 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState, | 1167 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState, |
1169 OnUpdateTopControlsState) | 1168 OnUpdateTopControlsState) |
1170 IPC_MESSAGE_HANDLER(ViewMsg_PauseVideo, OnPauseVideo) | 1169 IPC_MESSAGE_HANDLER(ViewMsg_PauseVideo, OnPauseVideo) |
1171 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData) | 1170 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData) |
1172 #elif defined(OS_MACOSX) | 1171 #elif defined(OS_MACOSX) |
1173 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard) | 1172 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard) |
1174 IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionCompleted, | 1173 IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionCompleted, |
1175 OnPluginImeCompositionCompleted) | 1174 OnPluginImeCompositionCompleted) |
1176 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) | 1175 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) |
1177 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) | 1176 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1328 | 1327 |
1329 WebFrame* frame = webview()->focusedFrame(); | 1328 WebFrame* frame = webview()->focusedFrame(); |
1330 if (!frame->hasSelection()) | 1329 if (!frame->hasSelection()) |
1331 return; | 1330 return; |
1332 | 1331 |
1333 frame->replaceMisspelledRange(text); | 1332 frame->replaceMisspelledRange(text); |
1334 } | 1333 } |
1335 | 1334 |
1336 void RenderViewImpl::OnScrollFocusedEditableNodeIntoRect( | 1335 void RenderViewImpl::OnScrollFocusedEditableNodeIntoRect( |
1337 const gfx::Rect& rect) { | 1336 const gfx::Rect& rect) { |
| 1337 if (has_scrolled_focused_editable_node_into_rect_ && |
| 1338 rect == rect_for_scrolled_focused_editable_node_) { |
| 1339 return; |
| 1340 } |
| 1341 |
1338 blink::WebElement element = GetFocusedElement(); | 1342 blink::WebElement element = GetFocusedElement(); |
1339 if (!element.isNull()) { | 1343 if (!element.isNull() && IsEditableNode(element)) { |
1340 if (IsEditableNode(element)) { | 1344 rect_for_scrolled_focused_editable_node_ = rect; |
1341 webview()->saveScrollAndScaleState(); | 1345 has_scrolled_focused_editable_node_into_rect_ = true; |
1342 webview()->scrollFocusedNodeIntoRect(rect); | 1346 webview()->scrollFocusedNodeIntoRect(rect); |
1343 } | |
1344 } | 1347 } |
1345 } | 1348 } |
1346 | 1349 |
1347 void RenderViewImpl::OnSelectAll() { | 1350 void RenderViewImpl::OnSelectAll() { |
1348 if (!webview()) | 1351 if (!webview()) |
1349 return; | 1352 return; |
1350 | 1353 |
1351 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); | 1354 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); |
1352 webview()->focusedFrame()->executeCommand( | 1355 webview()->focusedFrame()->executeCommand( |
1353 WebString::fromUTF8("SelectAll"), GetFocusedElement()); | 1356 WebString::fromUTF8("SelectAll"), GetFocusedElement()); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1465 if (!webview()) | 1468 if (!webview()) |
1466 return; | 1469 return; |
1467 if (in_live_resize) | 1470 if (in_live_resize) |
1468 webview()->willStartLiveResize(); | 1471 webview()->willStartLiveResize(); |
1469 else | 1472 else |
1470 webview()->willEndLiveResize(); | 1473 webview()->willEndLiveResize(); |
1471 } | 1474 } |
1472 #endif | 1475 #endif |
1473 | 1476 |
1474 #if defined(OS_ANDROID) | 1477 #if defined(OS_ANDROID) |
1475 void RenderViewImpl::OnUndoScrollFocusedEditableNodeIntoRect() { | |
1476 const WebElement element = GetFocusedElement(); | |
1477 if (!element.isNull() && IsEditableNode(element)) | |
1478 webview()->restoreScrollAndScaleState(); | |
1479 } | |
1480 | |
1481 void RenderViewImpl::OnPauseVideo() { | 1478 void RenderViewImpl::OnPauseVideo() { |
1482 // Inform RendererMediaPlayerManager to release all video player resources. | 1479 // Inform RendererMediaPlayerManager to release all video player resources. |
1483 // If something is in progress the resource will not be freed, it will | 1480 // If something is in progress the resource will not be freed, it will |
1484 // only be freed once the tab is destroyed or if the user navigates away | 1481 // only be freed once the tab is destroyed or if the user navigates away |
1485 // via WebMediaPlayerAndroid::Destroy. | 1482 // via WebMediaPlayerAndroid::Destroy. |
1486 media_player_manager_->ReleaseVideoResources(); | 1483 media_player_manager_->ReleaseVideoResources(); |
1487 } | 1484 } |
1488 #endif | 1485 #endif |
1489 | 1486 |
1490 /////////////////////////////////////////////////////////////////////////////// | 1487 /////////////////////////////////////////////////////////////////////////////// |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2154 | 2151 |
2155 void RenderViewImpl::focusNext() { | 2152 void RenderViewImpl::focusNext() { |
2156 Send(new ViewHostMsg_TakeFocus(routing_id_, false)); | 2153 Send(new ViewHostMsg_TakeFocus(routing_id_, false)); |
2157 } | 2154 } |
2158 | 2155 |
2159 void RenderViewImpl::focusPrevious() { | 2156 void RenderViewImpl::focusPrevious() { |
2160 Send(new ViewHostMsg_TakeFocus(routing_id_, true)); | 2157 Send(new ViewHostMsg_TakeFocus(routing_id_, true)); |
2161 } | 2158 } |
2162 | 2159 |
2163 void RenderViewImpl::focusedNodeChanged(const WebNode& node) { | 2160 void RenderViewImpl::focusedNodeChanged(const WebNode& node) { |
| 2161 has_scrolled_focused_editable_node_into_rect_ = false; |
| 2162 |
2164 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node))); | 2163 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node))); |
2165 | 2164 |
2166 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node)); | 2165 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node)); |
2167 } | 2166 } |
2168 | 2167 |
2169 void RenderViewImpl::numberOfWheelEventHandlersChanged(unsigned num_handlers) { | 2168 void RenderViewImpl::numberOfWheelEventHandlersChanged(unsigned num_handlers) { |
2170 Send(new ViewHostMsg_DidChangeNumWheelEvents(routing_id_, num_handlers)); | 2169 Send(new ViewHostMsg_DidChangeNumWheelEvents(routing_id_, num_handlers)); |
2171 } | 2170 } |
2172 | 2171 |
2173 void RenderViewImpl::didUpdateLayout() { | 2172 void RenderViewImpl::didUpdateLayout() { |
(...skipping 2937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5111 for (size_t i = 0; i < icon_urls.size(); i++) { | 5110 for (size_t i = 0; i < icon_urls.size(); i++) { |
5112 WebURL url = icon_urls[i].iconURL(); | 5111 WebURL url = icon_urls[i].iconURL(); |
5113 if (!url.isEmpty()) | 5112 if (!url.isEmpty()) |
5114 urls.push_back(FaviconURL(url, | 5113 urls.push_back(FaviconURL(url, |
5115 ToFaviconType(icon_urls[i].iconType()))); | 5114 ToFaviconType(icon_urls[i].iconType()))); |
5116 } | 5115 } |
5117 SendUpdateFaviconURL(urls); | 5116 SendUpdateFaviconURL(urls); |
5118 } | 5117 } |
5119 | 5118 |
5120 } // namespace content | 5119 } // namespace content |
OLD | NEW |