| 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 keyboard_bounds_ = new_bounds; |
| 68 if (text_input_client_) |
| 69 text_input_client_->EnsureCaretNotInRect(keyboard_bounds_); |
| 70 } |
| 71 |
| 66 void InputMethodBase::OnTextInputTypeChanged(const TextInputClient* client) { | 72 void InputMethodBase::OnTextInputTypeChanged(const TextInputClient* client) { |
| 67 if (!IsTextInputClientFocused(client)) | 73 if (!IsTextInputClientFocused(client)) |
| 68 return; | 74 return; |
| 69 NotifyTextInputStateChanged(client); | 75 NotifyTextInputStateChanged(client); |
| 70 } | 76 } |
| 71 | 77 |
| 72 void InputMethodBase::OnInputLocaleChanged() { | 78 void InputMethodBase::OnInputLocaleChanged() { |
| 73 } | 79 } |
| 74 | 80 |
| 75 bool InputMethodBase::IsInputLocaleCJK() const { | 81 bool InputMethodBase::IsInputLocaleCJK() const { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 151 |
| 146 void InputMethodBase::SetFocusedTextInputClientInternal( | 152 void InputMethodBase::SetFocusedTextInputClientInternal( |
| 147 TextInputClient* client) { | 153 TextInputClient* client) { |
| 148 TextInputClient* old = text_input_client_; | 154 TextInputClient* old = text_input_client_; |
| 149 if (old == client) | 155 if (old == client) |
| 150 return; | 156 return; |
| 151 OnWillChangeFocusedClient(old, client); | 157 OnWillChangeFocusedClient(old, client); |
| 152 text_input_client_ = client; // nullptr allowed. | 158 text_input_client_ = client; // nullptr allowed. |
| 153 OnDidChangeFocusedClient(old, client); | 159 OnDidChangeFocusedClient(old, client); |
| 154 NotifyTextInputStateChanged(text_input_client_); | 160 NotifyTextInputStateChanged(text_input_client_); |
| 161 |
| 162 // Move new focused window if necessary. |
| 163 if (text_input_client_) |
| 164 text_input_client_->EnsureCaretNotInRect(keyboard_bounds_); |
| 155 } | 165 } |
| 156 | 166 |
| 157 std::vector<gfx::Rect> InputMethodBase::GetCompositionBounds( | 167 std::vector<gfx::Rect> InputMethodBase::GetCompositionBounds( |
| 158 const TextInputClient* client) { | 168 const TextInputClient* client) { |
| 159 std::vector<gfx::Rect> bounds; | 169 std::vector<gfx::Rect> bounds; |
| 160 if (client->HasCompositionText()) { | 170 if (client->HasCompositionText()) { |
| 161 uint32_t i = 0; | 171 uint32_t i = 0; |
| 162 gfx::Rect rect; | 172 gfx::Rect rect; |
| 163 while (client->GetCompositionCharacterBounds(i++, &rect)) | 173 while (client->GetCompositionCharacterBounds(i++, &rect)) |
| 164 bounds.push_back(rect); | 174 bounds.push_back(rect); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 InputMethod* InputMethodBase::GetInputMethod() { | 231 InputMethod* InputMethodBase::GetInputMethod() { |
| 222 return this; | 232 return this; |
| 223 } | 233 } |
| 224 | 234 |
| 225 const std::vector<std::unique_ptr<ui::KeyEvent>>& | 235 const std::vector<std::unique_ptr<ui::KeyEvent>>& |
| 226 InputMethodBase::GetKeyEventsForTesting() { | 236 InputMethodBase::GetKeyEventsForTesting() { |
| 227 return key_events_for_testing_; | 237 return key_events_for_testing_; |
| 228 } | 238 } |
| 229 | 239 |
| 230 } // namespace ui | 240 } // namespace ui |
| OLD | NEW |