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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cstring> | 10 #include <cstring> |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 // We need to receive input method result even if the text input type is | 450 // We need to receive input method result even if the text input type is |
451 // TEXT_INPUT_TYPE_NONE, to make sure we can always send correct | 451 // TEXT_INPUT_TYPE_NONE, to make sure we can always send correct |
452 // character for each key event to the focused text input client. | 452 // character for each key event to the focused text input client. |
453 if (!GetTextInputClient()) | 453 if (!GetTextInputClient()) |
454 return; | 454 return; |
455 | 455 |
456 const base::string16 utf16_text = base::UTF8ToUTF16(text); | 456 const base::string16 utf16_text = base::UTF8ToUTF16(text); |
457 if (utf16_text.empty()) | 457 if (utf16_text.empty()) |
458 return; | 458 return; |
459 | 459 |
| 460 if (!CanComposeInline()) { |
| 461 // Hides the candidate window for preedit text. |
| 462 UpdateCompositionText(CompositionText(), 0, false); |
| 463 } |
| 464 |
460 // Append the text to the buffer, because commit signal might be fired | 465 // Append the text to the buffer, because commit signal might be fired |
461 // multiple times when processing a key event. | 466 // multiple times when processing a key event. |
462 result_text_.append(utf16_text); | 467 result_text_.append(utf16_text); |
463 | 468 |
464 // If we are not handling key event, do not bother sending text result if the | 469 // If we are not handling key event, do not bother sending text result if the |
465 // focused text input client does not support text input. | 470 // focused text input client does not support text input. |
466 if (!handling_key_event_ && !IsTextInputTypeNone()) { | 471 if (!handling_key_event_ && !IsTextInputTypeNone()) { |
467 if (!SendFakeProcessKeyEvent(true)) | 472 if (!SendFakeProcessKeyEvent(true)) |
468 GetTextInputClient()->InsertText(utf16_text); | 473 GetTextInputClient()->InsertText(utf16_text); |
469 SendFakeProcessKeyEvent(false); | 474 SendFakeProcessKeyEvent(false); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 bool InputMethodChromeOS::IsNonPasswordInputFieldFocused() { | 642 bool InputMethodChromeOS::IsNonPasswordInputFieldFocused() { |
638 TextInputType type = GetTextInputType(); | 643 TextInputType type = GetTextInputType(); |
639 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD); | 644 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD); |
640 } | 645 } |
641 | 646 |
642 bool InputMethodChromeOS::IsInputFieldFocused() { | 647 bool InputMethodChromeOS::IsInputFieldFocused() { |
643 return GetTextInputType() != TEXT_INPUT_TYPE_NONE; | 648 return GetTextInputType() != TEXT_INPUT_TYPE_NONE; |
644 } | 649 } |
645 | 650 |
646 } // namespace ui | 651 } // namespace ui |
OLD | NEW |