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

Unified Diff: content/renderer/render_widget.cc

Issue 2466283002: [WIP Approach 2] Straighten up input method reactivation
Patch Set: Created 4 years, 1 month 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/input/MouseEventManager.cpp » ('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 691874df188fe501dbde7e77046dfae03c0d1974..0479705c6c34f8de5aba11ebf21f66e23644eebb 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -221,6 +221,7 @@ RenderWidget::RenderWidget(CompositorDependencies* compositor_deps,
display_mode_(blink::WebDisplayModeUndefined),
ime_event_guard_(nullptr),
ime_in_batch_edit_(false),
+ ime_ignore_until_acked_(false),
closing_(false),
host_closing_(false),
is_swapped_out_(swapped_out),
@@ -895,10 +896,24 @@ void RenderWidget::SetInputHandler(RenderWidgetInputHandler* input_handler) {
DCHECK(!input_handler_);
}
+void RenderWidget::CancelComposition() {
+ ime_ignore_until_acked_ = true;
+ UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME);
+ Send(new InputHostMsg_ImeCancelComposition(routing_id()));
+}
+
+void RenderWidget::OnFocusedNodeChanged(bool is_editable,
+ const gfx::Rect& node_bounds) {
+ ime_ignore_until_acked_ = true;
+ UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME);
+ Send(new ViewHostMsg_FocusedNodeChanged(
+ routing_id(), is_editable, node_bounds));
+}
+
void RenderWidget::UpdateTextInputState(ShowIme show_ime,
ChangeSource change_source) {
TRACE_EVENT0("renderer", "RenderWidget::UpdateTextInputState");
- if (ime_event_guard_) {
+ if (!ime_ignore_until_acked_ && ime_event_guard_) {
// show_ime should still be effective even if it was set inside the IME
// event guard.
if (show_ime == ShowIme::IF_NEEDED) {
@@ -925,7 +940,7 @@ void RenderWidget::UpdateTextInputState(ShowIme show_ime,
(IsUsingImeThread() && 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)
+ can_compose_inline_ != new_can_compose_inline) || ime_ignore_until_acked_
#if defined(OS_ANDROID)
|| text_field_is_dirty_
#endif
@@ -948,8 +963,12 @@ void RenderWidget::UpdateTextInputState(ShowIme show_ime,
params.is_non_ime_change =
(change_source == ChangeSource::FROM_NON_IME) || text_field_is_dirty_;
params.batch_edit = ime_in_batch_edit_;
- if (params.is_non_ime_change)
+ if (ime_ignore_until_acked_ ||
+ (!IsUsingImeThread() && params.is_non_ime_change)) {
+ params.requires_ack = true;
OnImeEventSentForAck(new_info);
+ ime_ignore_until_acked_ = false;
+ }
text_field_is_dirty_ = false;
#endif
Send(new ViewHostMsg_TextInputStateChanged(routing_id(), params));
@@ -1402,7 +1421,7 @@ void RenderWidget::OnImeSetComposition(
// If we failed to set the composition text, then we need to let the browser
// process to cancel the input method's ongoing composition session, to make
// sure we are in a consistent state.
- Send(new InputHostMsg_ImeCancelComposition(routing_id()));
+ CancelComposition();
}
UpdateCompositionInfo(false /* not an immediate request */);
}
@@ -1635,8 +1654,6 @@ bool RenderWidget::ShouldHandleImeEvent() {
#if defined(OS_ANDROID)
if (!GetWebWidget())
return false;
- if (IsUsingImeThread())
- 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
@@ -1759,11 +1776,9 @@ void RenderWidget::OnImeEventGuardFinish(ImeEventGuard* guard) {
// are ignored. These must explicitly be updated once finished handling the
// ime event.
UpdateSelectionBounds();
-#if defined(OS_ANDROID)
UpdateTextInputState(
guard->show_ime() ? ShowIme::IF_NEEDED : ShowIme::HIDE_IME,
guard->from_ime() ? ChangeSource::FROM_IME : ChangeSource::FROM_NON_IME);
-#endif
}
void RenderWidget::GetSelectionBounds(gfx::Rect* focus, gfx::Rect* anchor) {
@@ -1953,8 +1968,9 @@ void RenderWidget::resetInputMethod() {
if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE) {
// If a composition text exists, then we need to let the browser process
// to cancel the input method's ongoing composition session.
- if (GetWebWidget()->finishComposingText(WebWidget::DoNotKeepSelection))
- Send(new InputHostMsg_ImeCancelComposition(routing_id()));
+ if (GetWebWidget()->finishComposingText(WebWidget::DoNotKeepSelection)) {
+ CancelComposition();
+ }
}
UpdateCompositionInfo(false /* not an immediate request */);
« no previous file with comments | « content/renderer/render_widget.h ('k') | third_party/WebKit/Source/core/input/MouseEventManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698