OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/ime/input_method_base.h" | 5 #include "views/ime/input_method_base.h" |
6 #include "views/ime/input_method_manager.h" | |
6 #include "views/view.h" | 7 #include "views/view.h" |
7 #include "views/widget/widget.h" | 8 #include "views/widget/widget.h" |
8 | 9 |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
10 | 11 |
11 namespace views { | 12 namespace views { |
12 | 13 |
13 InputMethodBase::InputMethodBase() | 14 InputMethodBase::InputMethodBase() |
14 : delegate_(NULL), | 15 : delegate_(NULL), |
15 widget_(NULL), | 16 widget_(NULL), |
(...skipping 24 matching lines...) Expand all Loading... | |
40 | 41 |
41 widget_ = widget; | 42 widget_ = widget; |
42 View* focused = widget->GetFocusManager()->GetFocusedView(); | 43 View* focused = widget->GetFocusManager()->GetFocusedView(); |
43 if (focused) | 44 if (focused) |
44 FocusWillChange(NULL, focused); | 45 FocusWillChange(NULL, focused); |
45 widget->GetFocusManager()->AddFocusChangeListener(this); | 46 widget->GetFocusManager()->AddFocusChangeListener(this); |
46 } | 47 } |
47 | 48 |
48 void InputMethodBase::OnFocus() { | 49 void InputMethodBase::OnFocus() { |
49 widget_focused_ = true; | 50 widget_focused_ = true; |
51 InputMethodManager *manager = InputMethodManager::GetInstance(); | |
52 manager->OnTextInputTypeChanged(GetTextInputType(), widget_); | |
James Su
2011/07/07 02:03:03
nit:
1. how about to combine these two lines? The
Peng
2011/07/07 17:56:54
Done.
James Su
2011/07/08 02:15:04
If it's necessary then it's better to state it in
| |
50 } | 53 } |
51 | 54 |
52 void InputMethodBase::OnBlur() { | 55 void InputMethodBase::OnBlur() { |
53 widget_focused_ = false; | 56 widget_focused_ = false; |
57 InputMethodManager *manager = InputMethodManager::GetInstance(); | |
58 manager->OnTextInputTypeChanged(GetTextInputType(), widget_); | |
James Su
2011/07/07 02:03:03
ditto
Peng
2011/07/07 17:56:54
Done.
| |
59 } | |
60 | |
61 void InputMethodBase::OnTextInputTypeChanged(View* view) { | |
62 if (IsViewFocused(view)) { | |
63 InputMethodManager *manager = InputMethodManager::GetInstance(); | |
64 manager->OnTextInputTypeChanged(GetTextInputType(), widget_); | |
James Su
2011/07/07 02:03:03
ditto
Peng
2011/07/07 17:56:54
Done.
| |
65 } | |
54 } | 66 } |
55 | 67 |
56 TextInputClient* InputMethodBase::GetTextInputClient() const { | 68 TextInputClient* InputMethodBase::GetTextInputClient() const { |
57 return (widget_focused_ && focused_view_) ? | 69 return (widget_focused_ && focused_view_) ? |
58 focused_view_->GetTextInputClient() : NULL; | 70 focused_view_->GetTextInputClient() : NULL; |
59 } | 71 } |
60 | 72 |
61 ui::TextInputType InputMethodBase::GetTextInputType() const { | 73 ui::TextInputType InputMethodBase::GetTextInputType() const { |
62 TextInputClient* client = GetTextInputClient(); | 74 TextInputClient* client = GetTextInputClient(); |
63 return client ? client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE; | 75 return client ? client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 // Widget. | 113 // Widget. |
102 if (focused_view_->GetWidget() != widget_) | 114 if (focused_view_->GetWidget() != widget_) |
103 return Widget::ConvertRect(focused_view_->GetWidget(), widget_, rect); | 115 return Widget::ConvertRect(focused_view_->GetWidget(), widget_, rect); |
104 return true; | 116 return true; |
105 } | 117 } |
106 | 118 |
107 void InputMethodBase::FocusedViewWillChange() { | 119 void InputMethodBase::FocusedViewWillChange() { |
108 } | 120 } |
109 | 121 |
110 void InputMethodBase::FocusedViewDidChange() { | 122 void InputMethodBase::FocusedViewDidChange() { |
123 if (widget_focused_) { | |
124 InputMethodManager *manager = InputMethodManager::GetInstance(); | |
125 manager->OnTextInputTypeChanged(GetTextInputType(), widget_); | |
126 } | |
James Su
2011/07/07 02:03:03
move these code into FocusWillChange(). It may not
Peng
2011/07/07 17:56:54
Done.
| |
111 } | 127 } |
112 | 128 |
113 } // namespace views | 129 } // namespace views |
OLD | NEW |