Chromium Code Reviews| Index: content/renderer/render_widget.cc |
| diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc |
| index 74d2f578ca91ef885bc1aac8ba7728aed02ee742..7b3e10549169b44480786d67788595e4fad0d608 100644 |
| --- a/content/renderer/render_widget.cc |
| +++ b/content/renderer/render_widget.cc |
| @@ -486,7 +486,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_SetFocus, OnSetFocus) |
| IPC_MESSAGE_HANDLER(InputMsg_SyntheticGestureCompleted, |
| @@ -1399,13 +1401,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 |
| @@ -1418,12 +1420,27 @@ void RenderWidget::OnImeConfirmComposition(const base::string16& text, |
| return; |
| ImeEventGuard guard(this); |
| input_handler_->set_handling_input_event(true); |
| - if (text.length()) |
| - webwidget_->confirmComposition(text); |
| - else if (keep_selection) |
| - webwidget_->confirmComposition(WebWidget::KeepSelection); |
| - else |
| - webwidget_->confirmComposition(WebWidget::DoNotKeepSelection); |
| + webwidget_->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); |
| + webwidget_->finishComposingText(keep_selection |
| + ? WebWidget::KeepSelection |
| + : WebWidget::DoNotKeepSelection); |
| input_handler_->set_handling_input_event(false); |
| UpdateCompositionInfo(false /* not an immediate request */); |
| } |
| @@ -1922,7 +1939,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 (webwidget_->confirmComposition()) |
| + if (webwidget_->finishComposingText(WebWidget::KeepSelection)) |
|
aelias_OOO_until_Jul13
2016/09/07 05:02:40
Please use DoNotKeepSelection to avoid unnecessary
yabinh
2016/09/07 10:27:14
Done.
|
| Send(new InputHostMsg_ImeCancelComposition(routing_id())); |
| } |