OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/views/controls/textfield/native_textfield_views.h" | 5 #include "ui/views/controls/textfield/native_textfield_views.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 skip_input_method_cancel_composition_ = true; | 902 skip_input_method_cancel_composition_ = true; |
903 if (GetRenderText()->insert_mode()) | 903 if (GetRenderText()->insert_mode()) |
904 model_->InsertText(GetTextForDisplay(text)); | 904 model_->InsertText(GetTextForDisplay(text)); |
905 else | 905 else |
906 model_->ReplaceText(GetTextForDisplay(text)); | 906 model_->ReplaceText(GetTextForDisplay(text)); |
907 skip_input_method_cancel_composition_ = false; | 907 skip_input_method_cancel_composition_ = false; |
908 UpdateAfterChange(true, true); | 908 UpdateAfterChange(true, true); |
909 OnAfterUserAction(); | 909 OnAfterUserAction(); |
910 } | 910 } |
911 | 911 |
912 void NativeTextfieldViews::InsertChar(char16 ch, int flags) { | 912 void NativeTextfieldViews::InsertChar(base::char16 ch, int flags) { |
913 if (GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE || | 913 if (GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE || |
914 !ShouldInsertChar(ch, flags)) { | 914 !ShouldInsertChar(ch, flags)) { |
915 return; | 915 return; |
916 } | 916 } |
917 | 917 |
918 OnBeforeUserAction(); | 918 OnBeforeUserAction(); |
919 skip_input_method_cancel_composition_ = true; | 919 skip_input_method_cancel_composition_ = true; |
920 if (GetRenderText()->insert_mode()) | 920 if (GetRenderText()->insert_mode()) |
921 model_->InsertChar(ch); | 921 model_->InsertChar(ch); |
922 else | 922 else |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1477 } | 1477 } |
1478 | 1478 |
1479 bool NativeTextfieldViews::ImeEditingAllowed() const { | 1479 bool NativeTextfieldViews::ImeEditingAllowed() const { |
1480 // We don't allow the input method to retrieve or delete content from a | 1480 // We don't allow the input method to retrieve or delete content from a |
1481 // password field. | 1481 // password field. |
1482 ui::TextInputType t = GetTextInputType(); | 1482 ui::TextInputType t = GetTextInputType(); |
1483 return (t != ui::TEXT_INPUT_TYPE_NONE && t != ui::TEXT_INPUT_TYPE_PASSWORD); | 1483 return (t != ui::TEXT_INPUT_TYPE_NONE && t != ui::TEXT_INPUT_TYPE_PASSWORD); |
1484 } | 1484 } |
1485 | 1485 |
1486 // static | 1486 // static |
1487 bool NativeTextfieldViews::ShouldInsertChar(char16 ch, int flags) { | 1487 bool NativeTextfieldViews::ShouldInsertChar(base::char16 ch, int flags) { |
1488 // Filter out all control characters, including tab and new line characters, | 1488 // Filter out all control characters, including tab and new line characters, |
1489 // and all characters with Alt modifier. But we need to allow characters with | 1489 // and all characters with Alt modifier. But we need to allow characters with |
1490 // AltGr modifier. | 1490 // AltGr modifier. |
1491 // On Windows AltGr is represented by Alt+Ctrl, and on Linux it's a different | 1491 // On Windows AltGr is represented by Alt+Ctrl, and on Linux it's a different |
1492 // flag that we don't care about. | 1492 // flag that we don't care about. |
1493 return ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) && | 1493 return ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) && |
1494 (flags & ~(ui::EF_SHIFT_DOWN | ui::EF_CAPS_LOCK_DOWN)) != ui::EF_ALT_DOWN; | 1494 (flags & ~(ui::EF_SHIFT_DOWN | ui::EF_CAPS_LOCK_DOWN)) != ui::EF_ALT_DOWN; |
1495 } | 1495 } |
1496 | 1496 |
1497 void NativeTextfieldViews::CreateTouchSelectionControllerAndNotifyIt() { | 1497 void NativeTextfieldViews::CreateTouchSelectionControllerAndNotifyIt() { |
(...skipping 21 matching lines...) Expand all Loading... |
1519 if (index != -1) { | 1519 if (index != -1) { |
1520 obscured_reveal_timer_.Start( | 1520 obscured_reveal_timer_.Start( |
1521 FROM_HERE, | 1521 FROM_HERE, |
1522 duration, | 1522 duration, |
1523 base::Bind(&NativeTextfieldViews::RevealObscuredChar, | 1523 base::Bind(&NativeTextfieldViews::RevealObscuredChar, |
1524 base::Unretained(this), -1, base::TimeDelta())); | 1524 base::Unretained(this), -1, base::TimeDelta())); |
1525 } | 1525 } |
1526 } | 1526 } |
1527 | 1527 |
1528 } // namespace views | 1528 } // namespace views |
OLD | NEW |