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..92051e5a9c442d6926892f7198400fe349d1b311 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,13 +291,16 @@ Textfield::Textfield() |
| } |
| } |
| -Textfield::~Textfield() {} |
| +Textfield::~Textfield() { |
| + if (GetInputMethod() && GetTextInputClient()) |
|
James Su
2015/06/12 07:58:50
GetTextInputClient() returns 'this', so no need to
Shu Chen
2015/06/12 08:51:31
yukawa@'s comment pointed out the derived class of
|
| + GetInputMethod()->DetachTextInputClient(GetTextInputClient()); |
|
James Su
2015/06/12 07:58:50
use 'this' directly?
Shu Chen
2015/06/12 08:51:31
Done.
|
| +} |
| void Textfield::SetReadOnly(bool read_only) { |
| // Update read-only without changing the focusable state (or active, etc.). |
| read_only_ = read_only; |
| - if (GetInputMethod()) |
| - GetInputMethod()->OnTextInputTypeChanged(this); |
| + if (GetInputMethod() && GetTextInputClient()) |
|
James Su
2015/06/12 07:58:50
ditto
Shu Chen
2015/06/12 08:51:31
Done.
|
| + GetInputMethod()->OnTextInputTypeChanged(GetTextInputClient()); |
|
James Su
2015/06/12 07:58:50
ditto
Shu Chen
2015/06/12 08:51:31
Done.
|
| SetColor(GetTextColor()); |
| UpdateBackgroundColor(); |
| } |
| @@ -306,8 +309,8 @@ void Textfield::SetTextInputType(ui::TextInputType type) { |
| GetRenderText()->SetObscured(type == ui::TEXT_INPUT_TYPE_PASSWORD); |
| text_input_type_ = type; |
| OnCaretBoundsChanged(); |
| - if (GetInputMethod()) |
| - GetInputMethod()->OnTextInputTypeChanged(this); |
| + if (GetInputMethod() && GetTextInputClient()) |
|
James Su
2015/06/12 07:58:50
ditto
Shu Chen
2015/06/12 08:51:31
Done.
|
| + GetInputMethod()->OnTextInputTypeChanged(GetTextInputClient()); |
|
James Su
2015/06/12 07:58:50
ditto
Shu Chen
2015/06/12 08:51:31
Done.
|
| SchedulePaint(); |
| } |
| @@ -979,8 +982,8 @@ void Textfield::OnVisibleBoundsChanged() { |
| void Textfield::OnEnabledChanged() { |
| View::OnEnabledChanged(); |
| - if (GetInputMethod()) |
| - GetInputMethod()->OnTextInputTypeChanged(this); |
| + if (GetInputMethod() && GetTextInputClient()) |
| + GetInputMethod()->OnTextInputTypeChanged(GetTextInputClient()); |
|
James Su
2015/06/12 07:58:50
ditto
Shu Chen
2015/06/12 08:51:31
Done.
|
| SchedulePaint(); |
| } |
| @@ -994,7 +997,8 @@ void Textfield::OnFocus() { |
| GetRenderText()->set_focused(true); |
| cursor_visible_ = true; |
| SchedulePaint(); |
| - GetInputMethod()->OnFocus(); |
| + if (GetInputMethod() && GetTextInputClient()) |
| + GetInputMethod()->SetFocusedTextInputClient(GetTextInputClient()); |
|
James Su
2015/06/12 07:58:50
ditto
Shu Chen
2015/06/12 08:51:31
Done.
|
| 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()) |
| + 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; |
| @@ -1757,8 +1747,8 @@ void Textfield::SelectThroughLastDragLocation() { |
| } |
| void Textfield::OnCaretBoundsChanged() { |
| - if (GetInputMethod()) |
| - GetInputMethod()->OnCaretBoundsChanged(this); |
| + if (GetInputMethod() && GetTextInputClient()) |
| + GetInputMethod()->OnCaretBoundsChanged(GetTextInputClient()); |
|
James Su
2015/06/12 07:58:50
ditto
Shu Chen
2015/06/12 08:51:31
Done.
|
| if (touch_selection_controller_) |
| touch_selection_controller_->SelectionChanged(); |
| } |