diff options
-rw-r--r-- | ui/views/ime/input_method_base.cc | 14 | ||||
-rw-r--r-- | ui/views/ime/input_method_base.h | 3 | ||||
-rw-r--r-- | ui/views/ime/input_method_bridge.cc | 9 |
3 files changed, 8 insertions, 18 deletions
diff --git a/ui/views/ime/input_method_base.cc b/ui/views/ime/input_method_base.cc index aa9e4d7..4c4298b 100644 --- a/ui/views/ime/input_method_base.cc +++ b/ui/views/ime/input_method_base.cc @@ -29,10 +29,10 @@ void InputMethodBase::Init(Widget* widget) { DCHECK(!widget_) << "The input method is already initialized."; widget_ = widget; - if (IsWidgetActive()) { - // Alert the InputMethod of the Widget's currently focused view. - OnFocus(); - } + // Alert the InputMethod of the Widget's currently focused view. + View* focused = widget->GetFocusManager()->GetFocusedView(); + if (focused) + OnWillChangeFocus(NULL, focused); widget->GetFocusManager()->AddFocusChangeListener(this); } @@ -60,12 +60,8 @@ void InputMethodBase::OnWillChangeFocus(View* focused_before, View* focused) {} void InputMethodBase::OnDidChangeFocus(View* focused_before, View* focused) {} -bool InputMethodBase::IsWidgetActive() const { - return widget_ ? widget_->IsActive() : false; -} - bool InputMethodBase::IsViewFocused(View* view) const { - return IsWidgetActive() && view && GetFocusedView() == view; + return widget_ && widget_->IsActive() && view && GetFocusedView() == view; } bool InputMethodBase::IsTextInputTypeNone() const { diff --git a/ui/views/ime/input_method_base.h b/ui/views/ime/input_method_base.h index 37e8a66..da454fb 100644 --- a/ui/views/ime/input_method_base.h +++ b/ui/views/ime/input_method_base.h @@ -45,9 +45,6 @@ class VIEWS_EXPORT InputMethodBase : public InputMethod, Widget* widget() const { return widget_; } View* GetFocusedView() const; - // Returns true only if a valid widget is attached and active. - bool IsWidgetActive() const; - // Returns true only if the View is focused and its Widget is active. bool IsViewFocused(View* view) const; diff --git a/ui/views/ime/input_method_bridge.cc b/ui/views/ime/input_method_bridge.cc index 760bd59..8165a60 100644 --- a/ui/views/ime/input_method_bridge.cc +++ b/ui/views/ime/input_method_bridge.cc @@ -33,8 +33,7 @@ InputMethodBridge::~InputMethodBridge() { void InputMethodBridge::OnFocus() { // Direct the shared IME to send TextInputClient messages to |this| object. - if (IsWidgetActive() && - (shared_input_method_ || !host_->GetTextInputClient())) + if (shared_input_method_ || !host_->GetTextInputClient()) host_->SetFocusedTextInputClient(this); // TODO(yusukes): We don't need to call OnTextInputTypeChanged() once we move @@ -55,8 +54,6 @@ void InputMethodBridge::OnBlur() { bool InputMethodBridge::OnUntranslatedIMEMessage(const base::NativeEvent& event, NativeEventResult* result) { - if (!IsWidgetActive()) - return false; return host_->OnUntranslatedIMEMessage(event, result); } @@ -85,8 +82,7 @@ void InputMethodBridge::CancelComposition(View* view) { } void InputMethodBridge::OnInputLocaleChanged() { - if (IsWidgetActive()) - host_->OnInputLocaleChanged(); + return host_->OnInputLocaleChanged(); } std::string InputMethodBridge::GetInputLocale() { @@ -256,4 +252,5 @@ ui::InputMethod* InputMethodBridge::GetHostInputMethod() const { return host_; } + } // namespace views |