| Index: content/renderer/render_widget.cc
|
| diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
|
| index b0a74d63d62d6cdd93e6baf4bb4c405049701049..d87ebf134d63e695c21d8cee610c6b4db9f1e91e 100644
|
| --- a/content/renderer/render_widget.cc
|
| +++ b/content/renderer/render_widget.cc
|
| @@ -714,6 +714,8 @@ bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
|
| IPC_MESSAGE_HANDLER(ViewMsg_SetSurfaceIdNamespace, OnSetSurfaceIdNamespace)
|
| #if defined(OS_ANDROID)
|
| IPC_MESSAGE_HANDLER(InputMsg_ImeEventAck, OnImeEventAck)
|
| + IPC_MESSAGE_HANDLER(InputMsg_RequestTextInputStateUpdate,
|
| + OnRequestTextInputStateUpdate)
|
| IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded)
|
| #endif
|
| IPC_MESSAGE_HANDLER(ViewMsg_HandleCompositorProto, OnHandleCompositorProto)
|
| @@ -1298,9 +1300,16 @@ void RenderWidget::UpdateTextInputState(ShowIme show_ime,
|
|
|
| bool new_can_compose_inline = CanComposeInline();
|
|
|
| + bool use_ime_thread = true;
|
| +#if defined(OS_ANDROID)
|
| + use_ime_thread = base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kUseImeThread);
|
| +#endif
|
| +
|
| // Only sends text input params if they are changed or if the ime should be
|
| // shown.
|
| if (show_ime == ShowIme::IF_NEEDED ||
|
| + (use_ime_thread && change_source == ChangeSource::FROM_IME) ||
|
| (text_input_type_ != new_type || text_input_mode_ != new_mode ||
|
| text_input_info_ != new_info ||
|
| can_compose_inline_ != new_can_compose_inline)
|
| @@ -1808,12 +1817,21 @@ void RenderWidget::OnImeEventAck() {
|
| DCHECK_GE(text_input_info_history_.size(), 1u);
|
| text_input_info_history_.pop_front();
|
| }
|
| +
|
| +void RenderWidget::OnRequestTextInputStateUpdate() {
|
| + DCHECK(!ime_event_guard_);
|
| + UpdateSelectionBounds();
|
| + UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_IME);
|
| +}
|
| #endif
|
|
|
| bool RenderWidget::ShouldHandleImeEvent() {
|
| #if defined(OS_ANDROID)
|
| if (!webwidget_)
|
| return false;
|
| + if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kUseImeThread))
|
| + return true;
|
|
|
| // We cannot handle IME events if there is any chance that the event we are
|
| // receiving here from the browser is based on the state that is different
|
| @@ -1906,6 +1924,18 @@ void RenderWidget::set_next_paint_is_repaint_ack() {
|
| next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK;
|
| }
|
|
|
| +bool RenderWidget::IsFromImeDefault() {
|
| +#if defined(OS_ANDROID)
|
| + // When ChromiumInputConnection is used, we want to make sure that FROM_IME
|
| + // is set only for OnRequestTextInputStateUpdate() so that we can distinguish
|
| + // it from other updates so that we can wait for it safely.
|
| + return !base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kUseImeThread);
|
| +#else
|
| + return false;
|
| +#endif
|
| +}
|
| +
|
| void RenderWidget::OnImeEventGuardStart(ImeEventGuard* guard) {
|
| if (!ime_event_guard_)
|
| ime_event_guard_ = guard;
|
| @@ -1916,7 +1946,7 @@ void RenderWidget::OnImeEventGuardFinish(ImeEventGuard* guard) {
|
| #if defined(OS_ANDROID)
|
| // In case a from-IME event (e.g. touch) ends up in not-from-IME event
|
| // (e.g. long press gesture), we want to treat it as not-from-IME event
|
| - // so that AdapterInputConnection can make changes to its Editable model.
|
| + // so that ReplicaInputConnection can make changes to its Editable model.
|
| // Therefore, we want to mark this text state update as 'from IME' only
|
| // when all the nested events are all originating from IME.
|
| ime_event_guard_->set_from_ime(
|
| @@ -2202,7 +2232,9 @@ void RenderWidget::setTouchAction(
|
|
|
| void RenderWidget::didUpdateTextOfFocusedElementByNonUserInput() {
|
| #if defined(OS_ANDROID)
|
| - text_field_is_dirty_ = true;
|
| + if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kUseImeThread))
|
| + text_field_is_dirty_ = true;
|
| #endif
|
| }
|
|
|
|
|