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

Unified Diff: content/renderer/render_widget.cc

Issue 2339793002: Handle newCursorPosition correctly for Android's commitText() (Closed)
Patch Set: Fix compile error (rebased on r418371) Created 4 years, 3 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
« no previous file with comments | « content/renderer/render_widget.h ('k') | third_party/WebKit/Source/core/editing/InputMethodController.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_widget.cc
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index c2ebe6f3fddb47a8626dc355b5622348d5ba3f53..d4097830ae789584c4dbbaf26709ef67d0019a18 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -485,7 +485,9 @@ bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange,
OnCursorVisibilityChange)
IPC_MESSAGE_HANDLER(InputMsg_ImeSetComposition, OnImeSetComposition)
- IPC_MESSAGE_HANDLER(InputMsg_ImeConfirmComposition, OnImeConfirmComposition)
+ IPC_MESSAGE_HANDLER(InputMsg_ImeCommitText, OnImeCommitText)
+ IPC_MESSAGE_HANDLER(InputMsg_ImeFinishComposingText,
+ OnImeFinishComposingText)
IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost)
IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent,
OnSetEditCommandsForNextKeyEvent)
@@ -1409,13 +1411,13 @@ void RenderWidget::OnImeSetComposition(
UpdateCompositionInfo(false /* not an immediate request */);
}
-void RenderWidget::OnImeConfirmComposition(const base::string16& text,
- const gfx::Range& replacement_range,
- bool keep_selection) {
+void RenderWidget::OnImeCommitText(const base::string16& text,
+ const gfx::Range& replacement_range,
+ int relative_cursor_pos) {
#if defined(ENABLE_PLUGINS)
if (focused_pepper_plugin_) {
- focused_pepper_plugin_->render_frame()->OnImeConfirmComposition(
- text, replacement_range, keep_selection);
+ focused_pepper_plugin_->render_frame()->OnImeCommitText(
+ text, replacement_range, relative_cursor_pos);
return;
}
#endif
@@ -1428,12 +1430,27 @@ void RenderWidget::OnImeConfirmComposition(const base::string16& text,
return;
ImeEventGuard guard(this);
input_handler_->set_handling_input_event(true);
- if (text.length())
- GetWebWidget()->confirmComposition(text);
- else if (keep_selection)
- GetWebWidget()->confirmComposition(WebWidget::KeepSelection);
- else
- GetWebWidget()->confirmComposition(WebWidget::DoNotKeepSelection);
+ GetWebWidget()->commitText(text, relative_cursor_pos);
+ input_handler_->set_handling_input_event(false);
+ UpdateCompositionInfo(false /* not an immediate request */);
+}
+
+void RenderWidget::OnImeFinishComposingText(bool keep_selection) {
+#if defined(ENABLE_PLUGINS)
+ if (focused_pepper_plugin_) {
+ focused_pepper_plugin_->render_frame()->OnImeFinishComposingText(
+ keep_selection);
+ return;
+ }
+#endif
+
+ if (!ShouldHandleImeEvent())
+ return;
+ ImeEventGuard guard(this);
+ input_handler_->set_handling_input_event(true);
+ GetWebWidget()->finishComposingText(keep_selection
+ ? WebWidget::KeepSelection
+ : WebWidget::DoNotKeepSelection);
input_handler_->set_handling_input_event(false);
UpdateCompositionInfo(false /* not an immediate request */);
}
@@ -1963,7 +1980,7 @@ void RenderWidget::resetInputMethod() {
if (text_input_info_.type != blink::WebTextInputTypeNone) {
// If a composition text exists, then we need to let the browser process
// to cancel the input method's ongoing composition session.
- if (GetWebWidget()->confirmComposition())
+ if (GetWebWidget()->finishComposingText(WebWidget::DoNotKeepSelection))
Send(new InputHostMsg_ImeCancelComposition(routing_id()));
}
« no previous file with comments | « content/renderer/render_widget.h ('k') | third_party/WebKit/Source/core/editing/InputMethodController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698