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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
« content/renderer/render_view_impl.h ('K') | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_view_impl.cc
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 22a3a8831d6481beb49639f065e827e457edb2bc..2f587951f07708ad2ef9c280abd96a4ec2cc6eb6 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -867,6 +867,14 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace)
IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete)
IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll)
+ IPC_MESSAGE_HANDLER(ViewMsg_ReplaceAll, OnReplaceAll)
+ IPC_MESSAGE_HANDLER(ViewMsg_Unselect, OnUnselect)
+ IPC_MESSAGE_HANDLER(ViewMsg_SetEditableSelectionOffsets,
+ OnSetEditableSelectionOffsets)
+ IPC_MESSAGE_HANDLER(ViewMsg_SetComposingRegion,
+ OnSetComposingRegion)
+ IPC_MESSAGE_HANDLER(ViewMsg_DeleteSurroundingText,
+ OnDeleteSurroundingText)
IPC_MESSAGE_HANDLER(ViewMsg_SelectRange, OnSelectRange)
IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt)
IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand)
@@ -1280,6 +1288,64 @@ void RenderViewImpl::OnSelectAll() {
WebString::fromUTF8("SelectAll"));
}
+void RenderViewImpl::OnReplaceAll(const string16& text) {
+ WebKit::WebNode node = GetFocusedNode();
+ if (node.isNull() || !IsEditableNode(node))
+ return;
+
+ OnSelectAll();
+ OnReplace(text);
+}
+
+void RenderViewImpl::OnUnselect() {
+ if (!webview())
+ return;
+
+ webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Unselect"));
+}
+
+void RenderViewImpl::OnSetEditableSelectionOffsets(int start, int end) {
+ webview()->setEditableSelectionOffsets(start, end);
+}
+
+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.
+ const std::vector<WebKit::WebCompositionUnderline>& underlines) {
+ if (!webview() || !webview()->focusedFrame())
+ return;
+ WebKit::WebTextInputInfo info;
+ if (end > start) {
+ // WebCore's Editor does not provide a way to set a composition without
+ // inserting the composing text. So, we select, then save and then delete
+ // the required composing text, then reinsert it as a new composition.
+ info = webview()->textInputInfo();
+ if (info.type == WebKit::WebTextInputTypeNone)
+ return;
+ if (info.compositionStart < info.compositionEnd)
+ webview()->confirmComposition("");
+ webview()->setEditableSelectionOffsets(start, end);
+ WebString text = webview()->focusedFrame()->selectionAsText();
+ webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Delete"));
+ OnImeSetComposition(text, underlines, 0, text.length());
+ // Set the selection back to what it was.
+ 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
+ info.selectionEnd);
+ } else {
+ // Clear the existing composition.
+ webview()->confirmComposition("");
+ }
+}
+
+void RenderViewImpl::OnDeleteSurroundingText(int before, int after) {
+ if (!webview() || !webview()->focusedFrame())
+ return;
+ for (int i = 0; i < before; ++i)
+ 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
+ WebString::fromUTF8("DeleteBackward"));
+ for (int i = 0; i < after; ++i)
+ webview()->focusedFrame()->executeCommand(
+ WebString::fromUTF8("DeleteForward"));
+}
+
void RenderViewImpl::OnSelectRange(const gfx::Point& start,
const gfx::Point& end) {
if (!webview())
« 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