| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/ime/input_method_bridge.h" | 5 #include "ui/views/ime/input_method_bridge.h" |
| 6 | 6 |
| 7 #include "ui/base/ime/input_method.h" | 7 #include "ui/base/ime/input_method.h" |
| 8 #include "ui/base/ime/input_method_observer.h" | 8 #include "ui/base/ime/input_method_observer.h" |
| 9 #include "ui/events/event.h" | 9 #include "ui/events/event.h" |
| 10 #include "ui/gfx/geometry/rect.h" | 10 #include "ui/gfx/geometry/rect.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 // this and go into |widget_|. NULL out |widget_| so we don't attempt to use | 74 // this and go into |widget_|. NULL out |widget_| so we don't attempt to use |
| 75 // it. | 75 // it. |
| 76 DetachFromWidget(); | 76 DetachFromWidget(); |
| 77 | 77 |
| 78 // Host input method might have been destroyed at this point. | 78 // Host input method might have been destroyed at this point. |
| 79 if (host_) | 79 if (host_) |
| 80 host_->DetachTextInputClient(this); | 80 host_->DetachTextInputClient(this); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void InputMethodBridge::OnFocus() { | 83 void InputMethodBridge::OnFocus() { |
| 84 DCHECK(host_); | 84 if (!host_) // |host_| could be NULL after OnInputMethodDestroyed. |
| 85 return; |
| 85 | 86 |
| 86 // Direct the shared IME to send TextInputClient messages to |this| object. | 87 // Direct the shared IME to send TextInputClient messages to |this| object. |
| 87 if (shared_input_method_ || !host_->GetTextInputClient()) | 88 if (shared_input_method_ || !host_->GetTextInputClient()) |
| 88 host_->SetFocusedTextInputClient(this); | 89 host_->SetFocusedTextInputClient(this); |
| 89 | 90 |
| 90 // TODO(yusukes): We don't need to call OnTextInputTypeChanged() once we move | 91 // TODO(yusukes): We don't need to call OnTextInputTypeChanged() once we move |
| 91 // text input type tracker code to ui::InputMethodBase. | 92 // text input type tracker code to ui::InputMethodBase. |
| 92 if (GetFocusedView()) { | 93 if (GetFocusedView()) { |
| 93 OnTextInputTypeChanged(GetFocusedView()); | 94 OnTextInputTypeChanged(GetFocusedView()); |
| 94 OnCaretBoundsChanged(GetFocusedView()); | 95 OnCaretBoundsChanged(GetFocusedView()); |
| 95 } | 96 } |
| 96 } | 97 } |
| 97 | 98 |
| 98 void InputMethodBridge::OnBlur() { | 99 void InputMethodBridge::OnBlur() { |
| 99 DCHECK(host_); | 100 if (!host_) // |host_| could be NULL after OnInputMethodDestroyed. |
| 101 return; |
| 100 | 102 |
| 101 if (HasCompositionText()) { | 103 if (HasCompositionText()) { |
| 102 ConfirmCompositionText(); | 104 ConfirmCompositionText(); |
| 103 host_->CancelComposition(this); | 105 host_->CancelComposition(this); |
| 104 } | 106 } |
| 105 | 107 |
| 106 if (host_->GetTextInputClient() == this) | 108 if (host_->GetTextInputClient() == this) |
| 107 host_->SetFocusedTextInputClient(NULL); | 109 host_->SetFocusedTextInputClient(NULL); |
| 108 } | 110 } |
| 109 | 111 |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 OnTextInputTypeChanged(focused); | 337 OnTextInputTypeChanged(focused); |
| 336 OnCaretBoundsChanged(focused); | 338 OnCaretBoundsChanged(focused); |
| 337 } | 339 } |
| 338 | 340 |
| 339 ui::InputMethod* InputMethodBridge::GetHostInputMethod() const { | 341 ui::InputMethod* InputMethodBridge::GetHostInputMethod() const { |
| 340 return host_; | 342 return host_; |
| 341 } | 343 } |
| 342 | 344 |
| 343 | 345 |
| 344 } // namespace views | 346 } // namespace views |
| OLD | NEW |