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

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

Issue 10836053: Add IPCs/methods for additional IME actions. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 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
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 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 IPC_MESSAGE_HANDLER(ViewMsg_Cut, OnCut) 860 IPC_MESSAGE_HANDLER(ViewMsg_Cut, OnCut)
861 IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy) 861 IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy)
862 #if defined(OS_MACOSX) 862 #if defined(OS_MACOSX)
863 IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard) 863 IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard)
864 #endif 864 #endif
865 IPC_MESSAGE_HANDLER(ViewMsg_Paste, OnPaste) 865 IPC_MESSAGE_HANDLER(ViewMsg_Paste, OnPaste)
866 IPC_MESSAGE_HANDLER(ViewMsg_PasteAndMatchStyle, OnPasteAndMatchStyle) 866 IPC_MESSAGE_HANDLER(ViewMsg_PasteAndMatchStyle, OnPasteAndMatchStyle)
867 IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace) 867 IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace)
868 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete) 868 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete)
869 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll) 869 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll)
870 IPC_MESSAGE_HANDLER(ViewMsg_ReplaceAll, OnReplaceAll)
871 IPC_MESSAGE_HANDLER(ViewMsg_Unselect, OnUnselect)
872 IPC_MESSAGE_HANDLER(ViewMsg_SetEditableSelectionOffsets,
873 OnSetEditableSelectionOffsets)
874 IPC_MESSAGE_HANDLER(ViewMsg_SetComposingRegion,
875 OnSetComposingRegion)
876 IPC_MESSAGE_HANDLER(ViewMsg_DeleteSurroundingText,
877 OnDeleteSurroundingText)
870 IPC_MESSAGE_HANDLER(ViewMsg_SelectRange, OnSelectRange) 878 IPC_MESSAGE_HANDLER(ViewMsg_SelectRange, OnSelectRange)
871 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) 879 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt)
872 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand) 880 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand)
873 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) 881 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind)
874 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) 882 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding)
875 IPC_MESSAGE_HANDLER(ViewMsg_FindReplyACK, OnFindReplyAck) 883 IPC_MESSAGE_HANDLER(ViewMsg_FindReplyACK, OnFindReplyAck)
876 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) 884 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom)
877 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel) 885 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel)
878 IPC_MESSAGE_HANDLER(ViewMsg_ZoomFactor, OnZoomFactor) 886 IPC_MESSAGE_HANDLER(ViewMsg_ZoomFactor, OnZoomFactor)
879 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, 887 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL,
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 } 1281 }
1274 1282
1275 void RenderViewImpl::OnSelectAll() { 1283 void RenderViewImpl::OnSelectAll() {
1276 if (!webview()) 1284 if (!webview())
1277 return; 1285 return;
1278 1286
1279 webview()->focusedFrame()->executeCommand( 1287 webview()->focusedFrame()->executeCommand(
1280 WebString::fromUTF8("SelectAll")); 1288 WebString::fromUTF8("SelectAll"));
1281 } 1289 }
1282 1290
1291 void RenderViewImpl::OnReplaceAll(const string16& text) {
1292 WebKit::WebNode node = GetFocusedNode();
1293 if (node.isNull() || !IsEditableNode(node))
1294 return;
1295
1296 OnSelectAll();
1297 OnReplace(text);
1298 }
1299
1300 void RenderViewImpl::OnUnselect() {
1301 if (!webview())
1302 return;
1303
1304 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Unselect"));
1305 }
1306
1307 void RenderViewImpl::OnSetEditableSelectionOffsets(int start, int end) {
1308 webview()->setEditableSelectionOffsets(start, end);
1309 }
1310
1311 void RenderViewImpl::OnSetComposingRegion(int start, int end,
bulach 2012/08/01 20:09:45 nit: params on the next line
olilan 2012/08/21 14:36:15 Done.
1312 const std::vector<WebKit::WebCompositionUnderline>& underlines) {
1313 if (!webview() || !webview()->focusedFrame())
1314 return;
1315 WebKit::WebTextInputInfo info;
1316 if (end > start) {
1317 // WebCore's Editor does not provide a way to set a composition without
1318 // inserting the composing text. So, we select, then save and then delete
1319 // the required composing text, then reinsert it as a new composition.
1320 info = webview()->textInputInfo();
1321 if (info.type == WebKit::WebTextInputTypeNone)
1322 return;
1323 if (info.compositionStart < info.compositionEnd)
1324 webview()->confirmComposition("");
1325 webview()->setEditableSelectionOffsets(start, end);
1326 WebString text = webview()->focusedFrame()->selectionAsText();
1327 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Delete"));
1328 OnImeSetComposition(text, underlines, 0, text.length());
1329 // Set the selection back to what it was.
1330 webview()->setEditableSelectionOffsets(info.selectionStart,
rniwa-cr 2012/08/02 17:11:54 We should just add a new method to Editor that doe
olilan 2012/08/21 14:36:15 Replaced by a call to new WebKit method setComposi
1331 info.selectionEnd);
1332 } else {
1333 // Clear the existing composition.
1334 webview()->confirmComposition("");
1335 }
1336 }
1337
1338 void RenderViewImpl::OnDeleteSurroundingText(int before, int after) {
1339 if (!webview() || !webview()->focusedFrame())
1340 return;
1341 for (int i = 0; i < before; ++i)
1342 webview()->focusedFrame()->executeCommand(
darin (slow to review) 2012/08/02 06:25:13 can't executing this command have side-effects? f
olilan 2012/08/02 09:55:44 Yes, agreed this implementation is not ideal. At t
rniwa-cr 2012/08/02 17:11:54 First off, we should move all of this to Source/We
olilan 2012/08/03 15:55:08 Thanks. One question: is there a way to delete a R
rniwa-cr 2012/08/03 20:00:07 There isn't if it needs to be in the undo stack.
olilan 2012/08/21 14:36:15 Implementation replaced by call to new WebKit meth
1343 WebString::fromUTF8("DeleteBackward"));
1344 for (int i = 0; i < after; ++i)
1345 webview()->focusedFrame()->executeCommand(
1346 WebString::fromUTF8("DeleteForward"));
1347 }
1348
1283 void RenderViewImpl::OnSelectRange(const gfx::Point& start, 1349 void RenderViewImpl::OnSelectRange(const gfx::Point& start,
1284 const gfx::Point& end) { 1350 const gfx::Point& end) {
1285 if (!webview()) 1351 if (!webview())
1286 return; 1352 return;
1287 1353
1288 handling_select_range_ = true; 1354 handling_select_range_ = true;
1289 webview()->focusedFrame()->selectRange(start, end); 1355 webview()->focusedFrame()->selectRange(start, end);
1290 handling_select_range_ = false; 1356 handling_select_range_ = false;
1291 } 1357 }
1292 1358
(...skipping 4443 matching lines...) Expand 10 before | Expand all | Expand 10 after
5736 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { 5802 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const {
5737 return !!RenderThreadImpl::current()->compositor_thread(); 5803 return !!RenderThreadImpl::current()->compositor_thread();
5738 } 5804 }
5739 5805
5740 void RenderViewImpl::OnJavaBridgeInit() { 5806 void RenderViewImpl::OnJavaBridgeInit() {
5741 DCHECK(!java_bridge_dispatcher_); 5807 DCHECK(!java_bridge_dispatcher_);
5742 #if defined(ENABLE_JAVA_BRIDGE) 5808 #if defined(ENABLE_JAVA_BRIDGE)
5743 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this); 5809 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this);
5744 #endif 5810 #endif
5745 } 5811 }
OLDNEW
« content/renderer/render_view_impl.h ('K') | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698