Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Removes the |system_toplevel_window_focused| flag in ui::InputMethodB…
Browse files Browse the repository at this point in the history
…ase.

BUG=569339,505231,520213
TEST=Keyboard typing can work well on Win/Linux/CrOS.

Review URL: https://codereview.chromium.org/1620633002

Cr-Commit-Position: refs/heads/master@{#370944}
(cherry picked from commit c191a57)

Review URL: https://codereview.chromium.org/1648213002 .

Cr-Commit-Position: refs/branch-heads/2623@{#189}
Cr-Branched-From: 92d7753-refs/heads/master@{#369907}
  • Loading branch information
shuchen-google committed Jan 29, 2016
1 parent 3096d15 commit f0b1c3c
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 57 deletions.
1 change: 0 additions & 1 deletion ui/base/ime/input_method_auralinux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ bool InputMethodAuraLinux::OnUntranslatedIMEMessage(

void InputMethodAuraLinux::DispatchKeyEvent(ui::KeyEvent* event) {
DCHECK(event->type() == ET_KEY_PRESSED || event->type() == ET_KEY_RELEASED);
DCHECK(system_toplevel_window_focused());

// If no text input client, do nothing.
if (!GetTextInputClient()) {
Expand Down
13 changes: 4 additions & 9 deletions ui/base/ime/input_method_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ namespace ui {

InputMethodBase::InputMethodBase()
: delegate_(NULL),
text_input_client_(NULL),
system_toplevel_window_focused_(false) {
text_input_client_(NULL) {
}

InputMethodBase::~InputMethodBase() {
Expand All @@ -30,13 +29,9 @@ void InputMethodBase::SetDelegate(internal::InputMethodDelegate* delegate) {
delegate_ = delegate;
}

void InputMethodBase::OnFocus() {
system_toplevel_window_focused_ = true;
}
void InputMethodBase::OnFocus() {}

void InputMethodBase::OnBlur() {
system_toplevel_window_focused_ = false;
}
void InputMethodBase::OnBlur() {}

void InputMethodBase::SetFocusedTextInputClient(TextInputClient* client) {
SetFocusedTextInputClientInternal(client);
Expand All @@ -49,7 +44,7 @@ void InputMethodBase::DetachTextInputClient(TextInputClient* client) {
}

TextInputClient* InputMethodBase::GetTextInputClient() const {
return system_toplevel_window_focused_ ? text_input_client_ : NULL;
return text_input_client_;
}

void InputMethodBase::OnTextInputTypeChanged(const TextInputClient* client) {
Expand Down
9 changes: 0 additions & 9 deletions ui/base/ime/input_method_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ class UI_BASE_IME_EXPORT InputMethodBase

// Overriden from InputMethod.
void SetDelegate(internal::InputMethodDelegate* delegate) override;
// If a derived class overrides OnFocus()/OnBlur(), it should call parent's
// implementation first, to make sure |system_toplevel_window_focused_| flag
// can be updated correctly.
void OnFocus() override;
void OnBlur() override;
void SetFocusedTextInputClient(TextInputClient* client) override;
Expand Down Expand Up @@ -87,10 +84,6 @@ class UI_BASE_IME_EXPORT InputMethodBase
// |client| which is the text input client with focus.
void NotifyTextInputCaretBoundsChanged(const TextInputClient* client);

bool system_toplevel_window_focused() const {
return system_toplevel_window_focused_;
}

private:
void SetFocusedTextInputClientInternal(TextInputClient* client);

Expand All @@ -99,8 +92,6 @@ class UI_BASE_IME_EXPORT InputMethodBase

base::ObserverList<InputMethodObserver> observer_list_;

bool system_toplevel_window_focused_;

DISALLOW_COPY_AND_ASSIGN(InputMethodBase);
};

Expand Down
3 changes: 0 additions & 3 deletions ui/base/ime/input_method_chromeos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ void InputMethodChromeOS::ProcessKeyEventDone(ui::KeyEvent* event,
void InputMethodChromeOS::DispatchKeyEvent(ui::KeyEvent* event) {
DCHECK(event->IsKeyEvent());
DCHECK(!(event->flags() & ui::EF_IS_SYNTHESIZED));
DCHECK(system_toplevel_window_focused());

// For linux_chromeos, the ime keyboard cannot track the caps lock state by
// itself, so need to call SetCapsLockEnabled() method to reflect the caps
Expand Down Expand Up @@ -301,8 +300,6 @@ void InputMethodChromeOS::ResetContext() {
if (!IsNonPasswordInputFieldFocused() || !GetTextInputClient())
return;

DCHECK(system_toplevel_window_focused());

composition_.Clear();
result_text_.clear();
composing_text_ = false;
Expand Down
26 changes: 0 additions & 26 deletions ui/base/ime/input_method_chromeos_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -390,32 +390,6 @@ TEST_F(InputMethodChromeOSTest, GetInputTextType_WithoutFocusedClient) {
EXPECT_EQ(TEXT_INPUT_TYPE_PASSWORD, ime_->GetTextInputType());
}

TEST_F(InputMethodChromeOSTest, GetInputTextType_WithoutFocusedWindow) {
ime_->OnFocus();
EXPECT_EQ(TEXT_INPUT_TYPE_NONE, ime_->GetTextInputType());
ime_->OnBlur();
input_type_ = TEXT_INPUT_TYPE_PASSWORD;
ime_->OnTextInputTypeChanged(this);
// The OnTextInputTypeChanged() call above should be ignored since the top-
// level window which the ime_ is attached to is not currently focused.
EXPECT_EQ(TEXT_INPUT_TYPE_NONE, ime_->GetTextInputType());

ime_->OnFocus();
ime_->OnTextInputTypeChanged(this);
EXPECT_EQ(TEXT_INPUT_TYPE_PASSWORD, ime_->GetTextInputType());
}

TEST_F(InputMethodChromeOSTest, GetInputTextType_WithoutFocusedWindow2) {
EXPECT_EQ(TEXT_INPUT_TYPE_NONE, ime_->GetTextInputType());
input_type_ = TEXT_INPUT_TYPE_PASSWORD;
ime_->OnTextInputTypeChanged(this);
EXPECT_EQ(TEXT_INPUT_TYPE_NONE, ime_->GetTextInputType());

ime_->OnFocus();
ime_->OnTextInputTypeChanged(this);
EXPECT_EQ(TEXT_INPUT_TYPE_PASSWORD, ime_->GetTextInputType());
}

// Confirm that IBusClient::FocusIn is called on "connected" if input_type_ is
// TEXT.
TEST_F(InputMethodChromeOSTest, FocusIn_Text) {
Expand Down
16 changes: 7 additions & 9 deletions ui/base/ime/input_method_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -297,15 +297,13 @@ LRESULT InputMethodWin::OnImeSetContext(HWND window_handle,
BOOL* handled) {
if (!!wparam) {
imm32_manager_.CreateImeWindow(window_handle);
if (system_toplevel_window_focused()) {
// Delay initialize the tsf to avoid perf regression.
// Loading tsf dll causes some time, so doing it in UpdateIMEState() will
// slow down the browser window creation.
// See crbug.com/509984.
tsf_inputscope::InitializeTsfForInputScopes();
tsf_inputscope::SetInputScopeForTsfUnawareWindow(
toplevel_window_handle_, GetTextInputType(), GetTextInputMode());
}
// Delay initialize the tsf to avoid perf regression.
// Loading tsf dll causes some time, so doing it in UpdateIMEState() will
// slow down the browser window creation.
// See crbug.com/509984.
tsf_inputscope::InitializeTsfForInputScopes();
tsf_inputscope::SetInputScopeForTsfUnawareWindow(
toplevel_window_handle_, GetTextInputType(), GetTextInputMode());
}

OnInputMethodChanged();
Expand Down

0 comments on commit f0b1c3c

Please sign in to comment.