| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_chromeos.h" | 5 #include "ui/base/ime/input_method_chromeos.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 return; | 234 return; |
| 235 } | 235 } |
| 236 | 236 |
| 237 // Here SetSurroundingText accepts relative position of |surrounding_text|, so | 237 // Here SetSurroundingText accepts relative position of |surrounding_text|, so |
| 238 // we have to convert |selection_range| from node coordinates to | 238 // we have to convert |selection_range| from node coordinates to |
| 239 // |surrounding_text| coordinates. | 239 // |surrounding_text| coordinates. |
| 240 if (!GetEngine()) | 240 if (!GetEngine()) |
| 241 return; | 241 return; |
| 242 GetEngine()->SetSurroundingText(base::UTF16ToUTF8(surrounding_text), | 242 GetEngine()->SetSurroundingText(base::UTF16ToUTF8(surrounding_text), |
| 243 selection_range.start() - text_range.start(), | 243 selection_range.start() - text_range.start(), |
| 244 selection_range.end() - text_range.start()); | 244 selection_range.end() - text_range.start(), |
| 245 client->GetSelectionOffset()); |
| 245 } | 246 } |
| 246 | 247 |
| 247 void InputMethodChromeOS::CancelComposition(const TextInputClient* client) { | 248 void InputMethodChromeOS::CancelComposition(const TextInputClient* client) { |
| 248 if (IsNonPasswordInputFieldFocused() && IsTextInputClientFocused(client)) | 249 if (IsNonPasswordInputFieldFocused() && IsTextInputClientFocused(client)) |
| 249 ResetContext(); | 250 ResetContext(); |
| 250 } | 251 } |
| 251 | 252 |
| 252 void InputMethodChromeOS::OnInputLocaleChanged() { | 253 void InputMethodChromeOS::OnInputLocaleChanged() { |
| 253 // Not supported. | 254 // Not supported. |
| 254 } | 255 } |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 bool InputMethodChromeOS::IsNonPasswordInputFieldFocused() { | 674 bool InputMethodChromeOS::IsNonPasswordInputFieldFocused() { |
| 674 TextInputType type = GetTextInputType(); | 675 TextInputType type = GetTextInputType(); |
| 675 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD); | 676 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD); |
| 676 } | 677 } |
| 677 | 678 |
| 678 bool InputMethodChromeOS::IsInputFieldFocused() { | 679 bool InputMethodChromeOS::IsInputFieldFocused() { |
| 679 return GetTextInputType() != TEXT_INPUT_TYPE_NONE; | 680 return GetTextInputType() != TEXT_INPUT_TYPE_NONE; |
| 680 } | 681 } |
| 681 | 682 |
| 682 } // namespace ui | 683 } // namespace ui |
| OLD | NEW |