Chromium Code Reviews| Index: ui/views/controls/textfield/textfield.cc |
| diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc |
| index cc2d492a3cb2e1d43c7e4830fd0561637ddc5922..2aa4fe6d8cd06acb845c7dbbff272103a3a18068 100644 |
| --- a/ui/views/controls/textfield/textfield.cc |
| +++ b/ui/views/controls/textfield/textfield.cc |
| @@ -12,6 +12,7 @@ |
| #include "ui/base/cursor/cursor.h" |
| #include "ui/base/dragdrop/drag_drop_types.h" |
| #include "ui/base/dragdrop/drag_utils.h" |
| +#include "ui/base/ime/input_method.h" |
| #include "ui/base/touch/selection_bound.h" |
| #include "ui/base/ui_base_switches_util.h" |
| #include "ui/compositor/canvas_painter.h" |
| @@ -31,7 +32,6 @@ |
| #include "ui/views/controls/native/native_view_host.h" |
| #include "ui/views/controls/textfield/textfield_controller.h" |
| #include "ui/views/drag_utils.h" |
| -#include "ui/views/ime/input_method.h" |
| #include "ui/views/metrics.h" |
| #include "ui/views/native_cursor.h" |
| #include "ui/views/painter.h" |
| @@ -291,7 +291,10 @@ Textfield::Textfield() |
| } |
| } |
| -Textfield::~Textfield() {} |
| +Textfield::~Textfield() { |
| + if (GetInputMethod()) |
|
yukawa
2015/06/11 21:48:42
Why do we test GetTextInputClient() in Combobox::~
Shu Chen
2015/06/12 03:34:38
You're right. I've updated the code to check GetTe
yukawa
2015/06/12 05:20:45
Hmm, if the derived class of TextField calls |GetI
Shu Chen
2015/06/12 05:32:54
I think the derived class of TextField overrides G
|
| + GetInputMethod()->DetachTextInputClient(GetTextInputClient()); |
| +} |
| void Textfield::SetReadOnly(bool read_only) { |
| // Update read-only without changing the focusable state (or active, etc.). |
| @@ -994,7 +997,8 @@ void Textfield::OnFocus() { |
| GetRenderText()->set_focused(true); |
| cursor_visible_ = true; |
| SchedulePaint(); |
| - GetInputMethod()->OnFocus(); |
| + if (GetInputMethod()) |
|
yukawa
2015/06/11 21:48:42
ditto.
Shu Chen
2015/06/12 03:34:38
Done.
|
| + GetInputMethod()->SetFocusedTextInputClient(this); |
| OnCaretBoundsChanged(); |
| const size_t caret_blink_ms = Textfield::GetCaretBlinkMs(); |
| @@ -1010,7 +1014,8 @@ void Textfield::OnFocus() { |
| void Textfield::OnBlur() { |
| GetRenderText()->set_focused(false); |
| - GetInputMethod()->OnBlur(); |
| + if (GetInputMethod()) |
|
yukawa
2015/06/11 21:48:42
ditto.
Shu Chen
2015/06/12 03:34:38
Done.
|
| + GetInputMethod()->DetachTextInputClient(this); |
| cursor_repaint_timer_.Stop(); |
| if (cursor_visible_) { |
| cursor_visible_ = false; |
| @@ -1459,21 +1464,6 @@ void Textfield::InsertChar(base::char16 ch, int flags) { |
| } |
| } |
| -gfx::NativeWindow Textfield::GetAttachedWindow() const { |
| - // Imagine the following hierarchy. |
| - // [NativeWidget A] - FocusManager |
| - // [View] |
| - // [NativeWidget B] |
| - // [View] |
| - // [View X] |
| - // An important thing is that [NativeWidget A] owns Win32 input focus even |
| - // when [View X] is logically focused by FocusManager. As a result, an Win32 |
| - // IME may want to interact with the native view of [NativeWidget A] rather |
| - // than that of [NativeWidget B]. This is why we need to call |
| - // GetTopLevelWidget() here. |
| - return GetWidget()->GetTopLevelWidget()->GetNativeWindow(); |
| -} |
| - |
| ui::TextInputType Textfield::GetTextInputType() const { |
| if (read_only() || !enabled()) |
| return ui::TEXT_INPUT_TYPE_NONE; |