Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: ui/views/controls/textfield/textfield.cc

Issue 1355753003: Allow keys with AltGr modifier to be inserted in Textfield (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added test Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/events/base_event_utils.cc ('k') | ui/views/controls/textfield/textfield_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/views/controls/textfield/textfield.h" 5 #include "ui/views/controls/textfield/textfield.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "ui/accessibility/ax_view_state.h" 10 #include "ui/accessibility/ax_view_state.h"
(...skipping 1435 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 model_->ReplaceText(new_text); 1446 model_->ReplaceText(new_text);
1447 skip_input_method_cancel_composition_ = false; 1447 skip_input_method_cancel_composition_ = false;
1448 UpdateAfterChange(true, true); 1448 UpdateAfterChange(true, true);
1449 OnAfterUserAction(); 1449 OnAfterUserAction();
1450 } 1450 }
1451 1451
1452 void Textfield::InsertChar(base::char16 ch, int flags) { 1452 void Textfield::InsertChar(base::char16 ch, int flags) {
1453 // Filter out all control characters, including tab and new line characters, 1453 // Filter out all control characters, including tab and new line characters,
1454 // and all characters with Alt modifier (and Search on ChromeOS). But allow 1454 // and all characters with Alt modifier (and Search on ChromeOS). But allow
1455 // characters with the AltGr modifier. On Windows AltGr is represented by 1455 // characters with the AltGr modifier. On Windows AltGr is represented by
1456 // Alt+Ctrl, and on Linux it's a different flag that we don't care about. 1456 // Alt+Ctrl or Right Alt, and on Linux it's a different flag that we don't
1457 const bool should_insert_char = 1457 // care about.
1458 ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) && 1458 const bool should_insert_char = ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) &&
1459 !ui::IsSystemKeyModifier(flags); 1459 !ui::IsSystemKeyModifier(flags);
1460 if (GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE || !should_insert_char) 1460 if (GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE || !should_insert_char)
1461 return; 1461 return;
1462 1462
1463 DoInsertChar(ch); 1463 DoInsertChar(ch);
1464 1464
1465 if (text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD && 1465 if (text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD &&
1466 password_reveal_duration_ != base::TimeDelta()) { 1466 password_reveal_duration_ != base::TimeDelta()) {
1467 const size_t change_offset = model_->GetCursorPosition(); 1467 const size_t change_offset = model_->GetCursorPosition();
1468 DCHECK_GT(change_offset, 0u); 1468 DCHECK_GT(change_offset, 0u);
1469 RevealPasswordChar(change_offset - 1); 1469 RevealPasswordChar(change_offset - 1);
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
1889 RequestFocus(); 1889 RequestFocus();
1890 model_->MoveCursorTo(mouse); 1890 model_->MoveCursorTo(mouse);
1891 if (!selection_clipboard_text.empty()) { 1891 if (!selection_clipboard_text.empty()) {
1892 model_->InsertText(selection_clipboard_text); 1892 model_->InsertText(selection_clipboard_text);
1893 UpdateAfterChange(true, true); 1893 UpdateAfterChange(true, true);
1894 } 1894 }
1895 OnAfterUserAction(); 1895 OnAfterUserAction();
1896 } 1896 }
1897 1897
1898 } // namespace views 1898 } // namespace views
OLDNEW
« no previous file with comments | « ui/events/base_event_utils.cc ('k') | ui/views/controls/textfield/textfield_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698