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 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 // Restore old focused window if moved. | |
| 155 if (old) { | |
|
sky
2016/08/19 00:16:40
In general chrome style is no {} around single lin
hariank
2016/08/19 00:45:38
Done.
| |
| 156 old->EnsureCaretInRect(available_bounds_); | |
|
sky
2016/08/19 00:16:40
Why do you need to notify the previous TextInputCl
hariank
2016/08/19 00:45:38
The previous TextInputClient's window should be re
sky
2016/08/19 03:47:24
That makes sense. I would never expect a function
hariank
2016/08/19 17:54:39
Ok, added an OnClientFocusLost function.
| |
| 157 } | |
| 158 // Move new focused window if necessary. | |
| 159 if (text_input_client_) { | |
| 160 text_input_client_->EnsureCaretInRect(available_bounds_); | |
| 161 } | |
| 144 } | 162 } |
| 145 | 163 |
| 146 std::vector<gfx::Rect> InputMethodBase::GetCompositionBounds( | 164 std::vector<gfx::Rect> InputMethodBase::GetCompositionBounds( |
| 147 const TextInputClient* client) { | 165 const TextInputClient* client) { |
| 148 std::vector<gfx::Rect> bounds; | 166 std::vector<gfx::Rect> bounds; |
| 149 if (client->HasCompositionText()) { | 167 if (client->HasCompositionText()) { |
| 150 uint32_t i = 0; | 168 uint32_t i = 0; |
| 151 gfx::Rect rect; | 169 gfx::Rect rect; |
| 152 while (client->GetCompositionCharacterBounds(i++, &rect)) | 170 while (client->GetCompositionCharacterBounds(i++, &rect)) |
| 153 bounds.push_back(rect); | 171 bounds.push_back(rect); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 InputMethod* InputMethodBase::GetInputMethod() { | 228 InputMethod* InputMethodBase::GetInputMethod() { |
| 211 return this; | 229 return this; |
| 212 } | 230 } |
| 213 | 231 |
| 214 const std::vector<std::unique_ptr<ui::KeyEvent>>& | 232 const std::vector<std::unique_ptr<ui::KeyEvent>>& |
| 215 InputMethodBase::GetKeyEventsForTesting() { | 233 InputMethodBase::GetKeyEventsForTesting() { |
| 216 return key_events_for_testing_; | 234 return key_events_for_testing_; |
| 217 } | 235 } |
| 218 | 236 |
| 219 } // namespace ui | 237 } // namespace ui |
| OLD | NEW |