Commit 6ede0ad8 authored by ekaramad's avatar ekaramad Committed by Commit bot

Route Text Layout Change IPCs to the Active RenderWidgetHost

Currently, the call to
RenderWidgetHostViewAura::ChangeTextDirectionAndLayoutAlignment is only
routed to the tab's RenderWidge; which happens regardless of the
currently active widget. This CL will modify the code so that this IME
call is always routed to the active widget obtained from
TextInputManager. The CL also adds a unit test.

BUG=578168,602723

Review-Url: https://codereview.chromium.org/2161043002
Cr-Commit-Position: refs/heads/master@{#406764}
parent 15193d33
......@@ -1613,14 +1613,14 @@ void RenderWidgetHostViewAura::OnInputMethodChanged() {
bool RenderWidgetHostViewAura::ChangeTextDirectionAndLayoutAlignment(
base::i18n::TextDirection direction) {
// TODO(wjmaclean): can host_ ever be null?
if (!host_)
if (!GetTextInputManager() && !GetTextInputManager()->GetActiveWidget())
return false;
host_->UpdateTextDirection(
direction == base::i18n::RIGHT_TO_LEFT ?
blink::WebTextDirectionRightToLeft :
blink::WebTextDirectionLeftToRight);
host_->NotifyTextDirection();
GetTextInputManager()->GetActiveWidget()->UpdateTextDirection(
direction == base::i18n::RIGHT_TO_LEFT
? blink::WebTextDirectionRightToLeft
: blink::WebTextDirectionLeftToRight);
GetTextInputManager()->GetActiveWidget()->NotifyTextDirection();
return true;
}
......
......@@ -4323,9 +4323,7 @@ class InputMethodResultAuraTest : public InputMethodAuraTestBase {
DISALLOW_COPY_AND_ASSIGN(InputMethodResultAuraTest);
};
// This test verifies that ui::TextInputClient::SetCompositionText call leads to
// IPC message InputMsg_ImeSetComposition being sent to the right renderer
// process.
// This test verifies ui::TextInputClient::SetCompositionText.
TEST_F(InputMethodResultAuraTest, SetCompositionText) {
base::Closure ime_call =
base::Bind(&ui::TextInputClient::SetCompositionText,
......@@ -4337,9 +4335,7 @@ TEST_F(InputMethodResultAuraTest, SetCompositionText) {
}
}
// This test verifies that ui::TextInputClient::ConfirmCompositionText call
// leads to IPC message InputMsg_ImeConfirmComposition being sent to the right
// renderer process.
// This test is for ui::TextInputClient::ConfirmCompositionText.
TEST_F(InputMethodResultAuraTest, ConfirmCompositionText) {
base::Closure ime_call =
base::Bind(&ui::TextInputClient::ConfirmCompositionText,
......@@ -4352,9 +4348,7 @@ TEST_F(InputMethodResultAuraTest, ConfirmCompositionText) {
}
}
// This test verifies that ui::TextInputClient::ConfirmCompositionText call
// leads to IPC message InputMsg_ImeSetComposition being sent to the right
// renderer process.
// This test is for ui::TextInputClient::ConfirmCompositionText.
TEST_F(InputMethodResultAuraTest, ClearCompositionText) {
base::Closure ime_call =
base::Bind(&ui::TextInputClient::ClearCompositionText,
......@@ -4367,8 +4361,7 @@ TEST_F(InputMethodResultAuraTest, ClearCompositionText) {
}
}
// This test verifies that ui::TextInputClient::InsertText call leads to IPC
// message InputMsg_ImeSetComposition being sent to the right renderer process.
// This test is for that ui::TextInputClient::InsertText.
TEST_F(InputMethodResultAuraTest, InsertText) {
base::Closure ime_call =
base::Bind(&ui::TextInputClient::InsertText,
......@@ -4380,10 +4373,8 @@ TEST_F(InputMethodResultAuraTest, InsertText) {
}
}
// This test makes a specific 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.
// This test is for RenderWidgetHostViewAura::FinishImeCompositionSession which
// is in response to a mouse click during an ongoing composition.
TEST_F(InputMethodResultAuraTest, FinishImeCompositionSession) {
base::Closure ime_finish_session_call =
base::Bind(&RenderWidgetHostViewAura::FinishImeCompositionSession,
......@@ -4397,8 +4388,26 @@ TEST_F(InputMethodResultAuraTest, FinishImeCompositionSession) {
}
}
// This test is for ui::TextInputClient::ChangeTextDirectionAndLayoutAlignment.
TEST_F(InputMethodResultAuraTest, ChangeTextDirectionAndLayoutAlignment) {
base::Closure ime_finish_session_call = base::Bind(
base::IgnoreResult(
&RenderWidgetHostViewAura::ChangeTextDirectionAndLayoutAlignment),
base::Unretained(tab_view()), base::i18n::LEFT_TO_RIGHT);
for (auto index : active_view_sequence_) {
ActivateViewForTextInputManager(views_[index], ui::TEXT_INPUT_TYPE_TEXT);
EXPECT_TRUE(!!RunAndReturnIPCSent(ime_finish_session_call,
processes_[index],
ViewMsg_SetTextDirection::ID));
}
}
// A class of tests which verify the correctness of some tracked IME related
// state at the browser side, e.g., caret bounds.
// state at the browser side. Each test verifies the correctness tracking for
// one specific state. To do so, the views are activated in a predetermined
// sequence and each time, the IPC call for the corresponding state is simulated
// through calling the method on the view. Then the test verifies that the value
// returned by the view or ui::TextInputClient is the expected value from IPC.
class InputMethodStateAuraTest : public InputMethodAuraTestBase {
public:
InputMethodStateAuraTest() {}
......@@ -4421,10 +4430,8 @@ class InputMethodStateAuraTest : public InputMethodAuraTestBase {
DISALLOW_COPY_AND_ASSIGN(InputMethodStateAuraTest);
};
// This test activates the views on the tab according to a predefined order and
// for each tab, simulates a selection bounds changed call. Then it verifies
// that the caret bounds reported by the TextInputClient match those reported
// for the active view.
// This test is for caret bounds which are calculated based on the tracked value
// for selection bounds.
TEST_F(InputMethodStateAuraTest, GetCaretBounds) {
ViewHostMsg_SelectionBounds_Params params;
params.is_anchor_first = true;
......@@ -4450,9 +4457,7 @@ TEST_F(InputMethodStateAuraTest, GetCaretBounds) {
}
}
// This test activates child frames in a specific sequence and changes their
// composition range. Then it verifies that the ui::TextInputClient returns the
// correct character bound at the given indices.
// This test is for composition character bounds.
TEST_F(InputMethodStateAuraTest, GetCompositionCharacterBounds) {
gfx::Rect bound;
// Initially, there should be no bounds.
......
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