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 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 IPC_MESSAGE_HANDLER(ViewMsg_Cut, OnCut) | 868 IPC_MESSAGE_HANDLER(ViewMsg_Cut, OnCut) |
869 IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy) | 869 IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy) |
870 #if defined(OS_MACOSX) | 870 #if defined(OS_MACOSX) |
871 IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard) | 871 IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard) |
872 #endif | 872 #endif |
873 IPC_MESSAGE_HANDLER(ViewMsg_Paste, OnPaste) | 873 IPC_MESSAGE_HANDLER(ViewMsg_Paste, OnPaste) |
874 IPC_MESSAGE_HANDLER(ViewMsg_PasteAndMatchStyle, OnPasteAndMatchStyle) | 874 IPC_MESSAGE_HANDLER(ViewMsg_PasteAndMatchStyle, OnPasteAndMatchStyle) |
875 IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace) | 875 IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace) |
876 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete) | 876 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete) |
877 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll) | 877 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll) |
| 878 IPC_MESSAGE_HANDLER(ViewMsg_ReplaceAll, OnReplaceAll) |
| 879 IPC_MESSAGE_HANDLER(ViewMsg_Unselect, OnUnselect) |
| 880 IPC_MESSAGE_HANDLER(ViewMsg_SetEditableSelectionOffsets, |
| 881 OnSetEditableSelectionOffsets) |
| 882 IPC_MESSAGE_HANDLER(ViewMsg_SetCompositionFromExistingText, |
| 883 OnSetCompositionFromExistingText) |
| 884 IPC_MESSAGE_HANDLER(ViewMsg_ExtendSelectionAndDelete, |
| 885 OnExtendSelectionAndDelete) |
878 IPC_MESSAGE_HANDLER(ViewMsg_SelectRange, OnSelectRange) | 886 IPC_MESSAGE_HANDLER(ViewMsg_SelectRange, OnSelectRange) |
879 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) | 887 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) |
880 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand) | 888 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand) |
881 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) | 889 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) |
882 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) | 890 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) |
883 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) | 891 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) |
884 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel) | 892 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel) |
885 IPC_MESSAGE_HANDLER(ViewMsg_ZoomFactor, OnZoomFactor) | 893 IPC_MESSAGE_HANDLER(ViewMsg_ZoomFactor, OnZoomFactor) |
886 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, | 894 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, |
887 OnSetZoomLevelForLoadingURL) | 895 OnSetZoomLevelForLoadingURL) |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1287 } | 1295 } |
1288 | 1296 |
1289 void RenderViewImpl::OnSelectAll() { | 1297 void RenderViewImpl::OnSelectAll() { |
1290 if (!webview()) | 1298 if (!webview()) |
1291 return; | 1299 return; |
1292 | 1300 |
1293 webview()->focusedFrame()->executeCommand( | 1301 webview()->focusedFrame()->executeCommand( |
1294 WebString::fromUTF8("SelectAll")); | 1302 WebString::fromUTF8("SelectAll")); |
1295 } | 1303 } |
1296 | 1304 |
| 1305 void RenderViewImpl::OnReplaceAll(const string16& text) { |
| 1306 WebKit::WebNode node = GetFocusedNode(); |
| 1307 if (node.isNull() || !IsEditableNode(node)) |
| 1308 return; |
| 1309 |
| 1310 OnSelectAll(); |
| 1311 OnReplace(text); |
| 1312 } |
| 1313 |
| 1314 void RenderViewImpl::OnUnselect() { |
| 1315 if (!webview()) |
| 1316 return; |
| 1317 |
| 1318 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Unselect")); |
| 1319 } |
| 1320 |
| 1321 void RenderViewImpl::OnSetEditableSelectionOffsets(int start, int end) { |
| 1322 webview()->setEditableSelectionOffsets(start, end); |
| 1323 } |
| 1324 |
| 1325 void RenderViewImpl::OnSetCompositionFromExistingText( |
| 1326 int start, int end, |
| 1327 const std::vector<WebKit::WebCompositionUnderline>& underlines) { |
| 1328 if (!webview()) |
| 1329 return; |
| 1330 webview()->setCompositionFromExistingText(start, end, underlines); |
| 1331 } |
| 1332 |
| 1333 void RenderViewImpl::OnExtendSelectionAndDelete(int before, int after) { |
| 1334 if (!webview()) |
| 1335 return; |
| 1336 webview()->extendSelectionAndDelete(before, after); |
| 1337 } |
| 1338 |
1297 void RenderViewImpl::OnSelectRange(const gfx::Point& start, | 1339 void RenderViewImpl::OnSelectRange(const gfx::Point& start, |
1298 const gfx::Point& end) { | 1340 const gfx::Point& end) { |
1299 if (!webview()) | 1341 if (!webview()) |
1300 return; | 1342 return; |
1301 | 1343 |
1302 Send(new ViewHostMsg_SelectRange_ACK(routing_id_)); | 1344 Send(new ViewHostMsg_SelectRange_ACK(routing_id_)); |
1303 | 1345 |
1304 handling_select_range_ = true; | 1346 handling_select_range_ = true; |
1305 webview()->focusedFrame()->selectRange(start, end); | 1347 webview()->focusedFrame()->selectRange(start, end); |
1306 handling_select_range_ = false; | 1348 handling_select_range_ = false; |
(...skipping 4491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5798 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { | 5840 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { |
5799 return !!RenderThreadImpl::current()->compositor_thread(); | 5841 return !!RenderThreadImpl::current()->compositor_thread(); |
5800 } | 5842 } |
5801 | 5843 |
5802 void RenderViewImpl::OnJavaBridgeInit() { | 5844 void RenderViewImpl::OnJavaBridgeInit() { |
5803 DCHECK(!java_bridge_dispatcher_); | 5845 DCHECK(!java_bridge_dispatcher_); |
5804 #if defined(ENABLE_JAVA_BRIDGE) | 5846 #if defined(ENABLE_JAVA_BRIDGE) |
5805 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this); | 5847 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this); |
5806 #endif | 5848 #endif |
5807 } | 5849 } |
OLD | NEW |