Commit bbf1ae25 authored by ekaramad's avatar ekaramad Committed by Commit bot

Confirm ongoing IME composition at the right render widget in response to mouse click/tap.

After CL: https://codereview.chromium.org/2092103002/ all IME result methods are
being routed to the right RenderWidget. Similarly, when an IME session is closed
on the browser side due to a click or tap, the right widget should be notifed
by receiving an IME confirm composition with empty text. Currently, this IPC is
sent to the tab's RenderWidget regardless of what the active widget is.

This CL will route the IPC to the right widget and adds a unit test for this purpose.

BUG=578168

Review-Url: https://codereview.chromium.org/2116593002
Cr-Commit-Position: refs/heads/master@{#403273}
parent 6cee11d7
......@@ -2527,10 +2527,10 @@ bool RenderWidgetHostViewAura::NeedsMouseCapture() {
void RenderWidgetHostViewAura::FinishImeCompositionSession() {
if (!has_composition_text_)
return;
// TODO(wjmaclean): can host_ ever be null?
if (host_) {
host_->ImeConfirmComposition(base::string16(), gfx::Range::InvalidRange(),
false);
if (!!text_input_manager_ && !!text_input_manager_->GetActiveWidget()) {
text_input_manager_->GetActiveWidget()->ImeConfirmComposition(
base::string16(), gfx::Range::InvalidRange(), false);
}
ImeCancelComposition();
}
......
......@@ -352,6 +352,8 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
friend class InputMethodResultAuraTest;
friend class RenderWidgetHostViewAuraCopyRequestTest;
friend class TestInputMethodObserver;
FRIEND_TEST_ALL_PREFIXES(InputMethodResultAuraTest,
FinishImeCompositionSession);
FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest,
PopupRetainsCaptureAfterMouseRelease);
FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, SetCompositionText);
......
......@@ -4216,4 +4216,21 @@ TEST_F(InputMethodResultAuraTest, InsertText) {
}
}
// This test makes a specific child frame's view active and then forces the
// tab's view end the current IME composition session by sending out an IME
// IPC to confirm composition. The test then verifies that the message is sent
// to the active widget's process.
TEST_F(InputMethodResultAuraTest, FinishImeCompositionSession) {
base::Closure ime_finish_session_call =
base::Bind(&RenderWidgetHostViewAura::FinishImeCompositionSession,
base::Unretained(tab_view()));
for (auto index : active_view_sequence_) {
ActivateViewForTextInputManager(views_[index], ui::TEXT_INPUT_TYPE_TEXT);
SetHasCompositionTextToTrue();
EXPECT_TRUE(!!RunAndReturnIPCSent(ime_finish_session_call,
processes_[index],
InputMsg_ImeConfirmComposition::ID));
}
}
} // namespace content
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment