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 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
947 IPC_MESSAGE_HANDLER(ViewMsg_Cut, OnCut) | 947 IPC_MESSAGE_HANDLER(ViewMsg_Cut, OnCut) |
948 IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy) | 948 IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy) |
949 #if defined(OS_MACOSX) | 949 #if defined(OS_MACOSX) |
950 IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard) | 950 IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard) |
951 #endif | 951 #endif |
952 IPC_MESSAGE_HANDLER(ViewMsg_Paste, OnPaste) | 952 IPC_MESSAGE_HANDLER(ViewMsg_Paste, OnPaste) |
953 IPC_MESSAGE_HANDLER(ViewMsg_PasteAndMatchStyle, OnPasteAndMatchStyle) | 953 IPC_MESSAGE_HANDLER(ViewMsg_PasteAndMatchStyle, OnPasteAndMatchStyle) |
954 IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace) | 954 IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace) |
955 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete) | 955 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete) |
956 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll) | 956 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll) |
957 IPC_MESSAGE_HANDLER(ViewMsg_ReplaceAll, OnReplaceAll) | |
958 IPC_MESSAGE_HANDLER(ViewMsg_Unselect, OnUnselect) | |
959 IPC_MESSAGE_HANDLER(ViewMsg_SetEditableSelectionOffsets, | |
960 OnSetEditableSelectionOffsets) | |
961 IPC_MESSAGE_HANDLER(ViewMsg_SetCompositionFromExistingText, | |
962 OnSetCompositionFromExistingText) | |
963 IPC_MESSAGE_HANDLER(ViewMsg_ExtendSelectionAndDelete, | |
964 OnExtendSelectionAndDelete) | |
957 IPC_MESSAGE_HANDLER(ViewMsg_SelectRange, OnSelectRange) | 965 IPC_MESSAGE_HANDLER(ViewMsg_SelectRange, OnSelectRange) |
958 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) | 966 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) |
959 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand) | 967 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand) |
960 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) | 968 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) |
961 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) | 969 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) |
962 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) | 970 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) |
963 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel) | 971 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel) |
964 IPC_MESSAGE_HANDLER(ViewMsg_ZoomFactor, OnZoomFactor) | 972 IPC_MESSAGE_HANDLER(ViewMsg_ZoomFactor, OnZoomFactor) |
965 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, | 973 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, |
966 OnSetZoomLevelForLoadingURL) | 974 OnSetZoomLevelForLoadingURL) |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1371 } | 1379 } |
1372 | 1380 |
1373 void RenderViewImpl::OnSelectAll() { | 1381 void RenderViewImpl::OnSelectAll() { |
1374 if (!webview()) | 1382 if (!webview()) |
1375 return; | 1383 return; |
1376 | 1384 |
1377 webview()->focusedFrame()->executeCommand( | 1385 webview()->focusedFrame()->executeCommand( |
1378 WebString::fromUTF8("SelectAll")); | 1386 WebString::fromUTF8("SelectAll")); |
1379 } | 1387 } |
1380 | 1388 |
1389 void RenderViewImpl::OnReplaceAll(const string16& text) { | |
1390 WebKit::WebNode node = GetFocusedNode(); | |
darin (slow to review)
2012/09/04 20:12:58
nit: no need for WebKit:: before WebNode
| |
1391 if (node.isNull() || !IsEditableNode(node)) | |
1392 return; | |
1393 | |
1394 OnSelectAll(); | |
1395 OnReplace(text); | |
1396 } | |
1397 | |
1398 void RenderViewImpl::OnUnselect() { | |
1399 if (!webview()) | |
1400 return; | |
1401 | |
1402 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Unselect")); | |
1403 } | |
1404 | |
1405 void RenderViewImpl::OnSetEditableSelectionOffsets(int start, int end) { | |
1406 webview()->setEditableSelectionOffsets(start, end); | |
1407 } | |
1408 | |
1409 void RenderViewImpl::OnSetCompositionFromExistingText( | |
1410 int start, int end, | |
1411 const std::vector<WebKit::WebCompositionUnderline>& underlines) { | |
1412 if (!webview()) | |
1413 return; | |
1414 webview()->setCompositionFromExistingText(start, end, underlines); | |
1415 } | |
1416 | |
1417 void RenderViewImpl::OnExtendSelectionAndDelete(int before, int after) { | |
1418 if (!webview()) | |
1419 return; | |
1420 webview()->extendSelectionAndDelete(before, after); | |
1421 } | |
1422 | |
1381 void RenderViewImpl::OnSelectRange(const gfx::Point& start, | 1423 void RenderViewImpl::OnSelectRange(const gfx::Point& start, |
1382 const gfx::Point& end) { | 1424 const gfx::Point& end) { |
1383 if (!webview()) | 1425 if (!webview()) |
1384 return; | 1426 return; |
1385 | 1427 |
1386 Send(new ViewHostMsg_SelectRange_ACK(routing_id_)); | 1428 Send(new ViewHostMsg_SelectRange_ACK(routing_id_)); |
1387 | 1429 |
1388 handling_select_range_ = true; | 1430 handling_select_range_ = true; |
1389 webview()->focusedFrame()->selectRange(start, end); | 1431 webview()->focusedFrame()->selectRange(start, end); |
1390 handling_select_range_ = false; | 1432 handling_select_range_ = false; |
(...skipping 4659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6050 | 6092 |
6051 updating_frame_tree_ = true; | 6093 updating_frame_tree_ = true; |
6052 active_frame_id_map_.clear(); | 6094 active_frame_id_map_.clear(); |
6053 | 6095 |
6054 target_process_id_ = process_id; | 6096 target_process_id_ = process_id; |
6055 target_routing_id_ = route_id; | 6097 target_routing_id_ = route_id; |
6056 CreateFrameTree(webview()->mainFrame(), frames); | 6098 CreateFrameTree(webview()->mainFrame(), frames); |
6057 | 6099 |
6058 updating_frame_tree_ = false; | 6100 updating_frame_tree_ = false; |
6059 } | 6101 } |
OLD | NEW |