| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 void InputMethodBase::DetachTextInputClient(TextInputClient* client) { | 52 void InputMethodBase::DetachTextInputClient(TextInputClient* client) { |
| 53 if (text_input_client_ != client) | 53 if (text_input_client_ != client) |
| 54 return; | 54 return; |
| 55 SetFocusedTextInputClientInternal(nullptr); | 55 SetFocusedTextInputClientInternal(nullptr); |
| 56 } | 56 } |
| 57 | 57 |
| 58 TextInputClient* InputMethodBase::GetTextInputClient() const { | 58 TextInputClient* InputMethodBase::GetTextInputClient() const { |
| 59 return text_input_client_; | 59 return text_input_client_; |
| 60 } | 60 } |
| 61 | 61 |
| 62 void InputMethodBase::set_available_bounds(gfx::Rect new_bounds) { |
| 63 available_bounds_ = new_bounds; |
| 64 if (text_input_client_) |
| 65 text_input_client_->EnsureCaretInRect(available_bounds_); |
| 66 } |
| 67 |
| 62 void InputMethodBase::OnTextInputTypeChanged(const TextInputClient* client) { | 68 void InputMethodBase::OnTextInputTypeChanged(const TextInputClient* client) { |
| 63 if (!IsTextInputClientFocused(client)) | 69 if (!IsTextInputClientFocused(client)) |
| 64 return; | 70 return; |
| 65 NotifyTextInputStateChanged(client); | 71 NotifyTextInputStateChanged(client); |
| 66 } | 72 } |
| 67 | 73 |
| 68 TextInputType InputMethodBase::GetTextInputType() const { | 74 TextInputType InputMethodBase::GetTextInputType() const { |
| 69 TextInputClient* client = GetTextInputClient(); | 75 TextInputClient* client = GetTextInputClient(); |
| 70 return client ? client->GetTextInputType() : TEXT_INPUT_TYPE_NONE; | 76 return client ? client->GetTextInputType() : TEXT_INPUT_TYPE_NONE; |
| 71 } | 77 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 140 |
| 135 void InputMethodBase::SetFocusedTextInputClientInternal( | 141 void InputMethodBase::SetFocusedTextInputClientInternal( |
| 136 TextInputClient* client) { | 142 TextInputClient* client) { |
| 137 TextInputClient* old = text_input_client_; | 143 TextInputClient* old = text_input_client_; |
| 138 if (old == client) | 144 if (old == client) |
| 139 return; | 145 return; |
| 140 OnWillChangeFocusedClient(old, client); | 146 OnWillChangeFocusedClient(old, client); |
| 141 text_input_client_ = client; // nullptr allowed. | 147 text_input_client_ = client; // nullptr allowed. |
| 142 OnDidChangeFocusedClient(old, client); | 148 OnDidChangeFocusedClient(old, client); |
| 143 NotifyTextInputStateChanged(text_input_client_); | 149 NotifyTextInputStateChanged(text_input_client_); |
| 150 |
| 151 if (available_bounds_.IsEmpty()) |
| 152 return; |
| 153 |
| 154 if (old) { |
| 155 LOG(ERROR) << "move old window"; |
| 156 old->EnsureCaretInRect(available_bounds_); |
| 157 } |
| 158 if (text_input_client_) { |
| 159 LOG(ERROR) << "set focus, available bounds: " |
| 160 << available_bounds_.ToString(); |
| 161 text_input_client_->EnsureCaretInRect(available_bounds_); |
| 162 } |
| 144 } | 163 } |
| 145 | 164 |
| 146 std::vector<gfx::Rect> InputMethodBase::GetCompositionBounds( | 165 std::vector<gfx::Rect> InputMethodBase::GetCompositionBounds( |
| 147 const TextInputClient* client) { | 166 const TextInputClient* client) { |
| 148 std::vector<gfx::Rect> bounds; | 167 std::vector<gfx::Rect> bounds; |
| 149 if (client->HasCompositionText()) { | 168 if (client->HasCompositionText()) { |
| 150 uint32_t i = 0; | 169 uint32_t i = 0; |
| 151 gfx::Rect rect; | 170 gfx::Rect rect; |
| 152 while (client->GetCompositionCharacterBounds(i++, &rect)) | 171 while (client->GetCompositionCharacterBounds(i++, &rect)) |
| 153 bounds.push_back(rect); | 172 bounds.push_back(rect); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 InputMethod* InputMethodBase::GetInputMethod() { | 229 InputMethod* InputMethodBase::GetInputMethod() { |
| 211 return this; | 230 return this; |
| 212 } | 231 } |
| 213 | 232 |
| 214 const std::vector<std::unique_ptr<ui::KeyEvent>>& | 233 const std::vector<std::unique_ptr<ui::KeyEvent>>& |
| 215 InputMethodBase::GetKeyEventsForTesting() { | 234 InputMethodBase::GetKeyEventsForTesting() { |
| 216 return key_events_for_testing_; | 235 return key_events_for_testing_; |
| 217 } | 236 } |
| 218 | 237 |
| 219 } // namespace ui | 238 } // namespace ui |
| OLD | NEW |