Chromium Code Reviews| 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/base/ime/input_method_base.h" | 5 #include "ui/base/ime/input_method_base.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 void InputMethodBase::DetachTextInputClient(TextInputClient* client) { | 56 void InputMethodBase::DetachTextInputClient(TextInputClient* client) { |
| 57 if (text_input_client_ != client) | 57 if (text_input_client_ != client) |
| 58 return; | 58 return; |
| 59 SetFocusedTextInputClientInternal(nullptr); | 59 SetFocusedTextInputClientInternal(nullptr); |
| 60 } | 60 } |
| 61 | 61 |
| 62 TextInputClient* InputMethodBase::GetTextInputClient() const { | 62 TextInputClient* InputMethodBase::GetTextInputClient() const { |
| 63 return text_input_client_; | 63 return text_input_client_; |
| 64 } | 64 } |
| 65 | 65 |
| 66 void InputMethodBase::SetOnScreenKeyboardBounds(const gfx::Rect& new_bounds) { | |
| 67 LOG(ERROR) << "Called SetOnScreenKeyboardBounds: " << new_bounds.ToString(); | |
|
oshima
2017/01/18 02:37:19
nit: remove debug log
yhanada
2017/01/30 13:02:47
Done.
| |
| 68 keyboard_bounds_ = new_bounds; | |
| 69 if (text_input_client_) | |
| 70 text_input_client_->EnsureCaretNotInRect(keyboard_bounds_); | |
| 71 } | |
| 72 | |
| 66 void InputMethodBase::OnTextInputTypeChanged(const TextInputClient* client) { | 73 void InputMethodBase::OnTextInputTypeChanged(const TextInputClient* client) { |
| 67 if (!IsTextInputClientFocused(client)) | 74 if (!IsTextInputClientFocused(client)) |
| 68 return; | 75 return; |
| 69 NotifyTextInputStateChanged(client); | 76 NotifyTextInputStateChanged(client); |
| 70 } | 77 } |
| 71 | 78 |
| 72 void InputMethodBase::OnInputLocaleChanged() { | 79 void InputMethodBase::OnInputLocaleChanged() { |
| 73 } | 80 } |
| 74 | 81 |
| 75 bool InputMethodBase::IsInputLocaleCJK() const { | 82 bool InputMethodBase::IsInputLocaleCJK() const { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 | 146 |
| 140 void InputMethodBase::NotifyTextInputCaretBoundsChanged( | 147 void InputMethodBase::NotifyTextInputCaretBoundsChanged( |
| 141 const TextInputClient* client) { | 148 const TextInputClient* client) { |
| 142 for (InputMethodObserver& observer : observer_list_) | 149 for (InputMethodObserver& observer : observer_list_) |
| 143 observer.OnCaretBoundsChanged(client); | 150 observer.OnCaretBoundsChanged(client); |
| 144 } | 151 } |
| 145 | 152 |
| 146 void InputMethodBase::SetFocusedTextInputClientInternal( | 153 void InputMethodBase::SetFocusedTextInputClientInternal( |
| 147 TextInputClient* client) { | 154 TextInputClient* client) { |
| 148 TextInputClient* old = text_input_client_; | 155 TextInputClient* old = text_input_client_; |
| 156 LOG(ERROR) << "Called SetFocusedTextInputClientInternal: old = " << old | |
| 157 << ", new = " << client; | |
|
oshima
2017/01/18 02:37:19
nit: debug log
yhanada
2017/01/30 13:02:47
Done.
| |
| 158 | |
| 149 if (old == client) | 159 if (old == client) |
| 150 return; | 160 return; |
| 151 OnWillChangeFocusedClient(old, client); | 161 OnWillChangeFocusedClient(old, client); |
| 152 text_input_client_ = client; // nullptr allowed. | 162 text_input_client_ = client; // nullptr allowed. |
| 153 OnDidChangeFocusedClient(old, client); | 163 OnDidChangeFocusedClient(old, client); |
| 154 NotifyTextInputStateChanged(text_input_client_); | 164 NotifyTextInputStateChanged(text_input_client_); |
| 165 | |
| 166 // Restore old focused window if moved. | |
| 167 if (old) | |
| 168 old->OnClientFocusLost(); | |
| 169 // Move new focused window if necessary. | |
| 170 if (text_input_client_) | |
| 171 text_input_client_->EnsureCaretNotInRect(keyboard_bounds_); | |
| 155 } | 172 } |
| 156 | 173 |
| 157 std::vector<gfx::Rect> InputMethodBase::GetCompositionBounds( | 174 std::vector<gfx::Rect> InputMethodBase::GetCompositionBounds( |
| 158 const TextInputClient* client) { | 175 const TextInputClient* client) { |
| 159 std::vector<gfx::Rect> bounds; | 176 std::vector<gfx::Rect> bounds; |
| 160 if (client->HasCompositionText()) { | 177 if (client->HasCompositionText()) { |
| 161 uint32_t i = 0; | 178 uint32_t i = 0; |
| 162 gfx::Rect rect; | 179 gfx::Rect rect; |
| 163 while (client->GetCompositionCharacterBounds(i++, &rect)) | 180 while (client->GetCompositionCharacterBounds(i++, &rect)) |
| 164 bounds.push_back(rect); | 181 bounds.push_back(rect); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 InputMethod* InputMethodBase::GetInputMethod() { | 238 InputMethod* InputMethodBase::GetInputMethod() { |
| 222 return this; | 239 return this; |
| 223 } | 240 } |
| 224 | 241 |
| 225 const std::vector<std::unique_ptr<ui::KeyEvent>>& | 242 const std::vector<std::unique_ptr<ui::KeyEvent>>& |
| 226 InputMethodBase::GetKeyEventsForTesting() { | 243 InputMethodBase::GetKeyEventsForTesting() { |
| 227 return key_events_for_testing_; | 244 return key_events_for_testing_; |
| 228 } | 245 } |
| 229 | 246 |
| 230 } // namespace ui | 247 } // namespace ui |
| OLD | NEW |