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

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

Issue 1221083008: [NOT FOR COMMIT] Ignore inserting characters of Keys with modifiers on CrOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the double keydowns. 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
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 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after
1442 if (GetRenderText()->insert_mode()) 1442 if (GetRenderText()->insert_mode())
1443 model_->InsertText(new_text); 1443 model_->InsertText(new_text);
1444 else 1444 else
1445 model_->ReplaceText(new_text); 1445 model_->ReplaceText(new_text);
1446 skip_input_method_cancel_composition_ = false; 1446 skip_input_method_cancel_composition_ = false;
1447 UpdateAfterChange(true, true); 1447 UpdateAfterChange(true, true);
1448 OnAfterUserAction(); 1448 OnAfterUserAction();
1449 } 1449 }
1450 1450
1451 void Textfield::InsertChar(base::char16 ch, int flags) { 1451 void Textfield::InsertChar(base::char16 ch, int flags) {
1452 #if defined(OS_CHROMEOS)
1452 const int kControlModifierMask = ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN | 1453 const int kControlModifierMask = ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN |
1453 ui::EF_COMMAND_DOWN | ui::EF_ALTGR_DOWN | 1454 ui::EF_COMMAND_DOWN;
1454 ui::EF_MOD3_DOWN; 1455 #else
1456 const int kControlModifierMask = ui::EF_ALT_DOWN;
1457 #endif // defined(OS_CHROMEOS)
1455 1458
1456 // Filter out all control characters, including tab and new line characters, 1459 // Filter out all control characters, including tab and new line characters,
1457 // and all characters with Alt modifier. But allow characters with the AltGr 1460 // and all characters with Alt (also Ctrl and Search on CrOs) modifiers. But
1458 // modifier. On Windows AltGr is represented by Alt+Ctrl, and on Linux it's a 1461 // allow characters with the AltGr modifier. On Windows AltGr is represented
1459 // different flag that we don't care about. 1462 // by Alt+Ctrl, and on Linux it's a different flag that we don't care about.
1460 const bool should_insert_char = 1463 const bool should_insert_char = ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) &&
1461 ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) && 1464 (flags & kControlModifierMask) == 0;
1462 (flags & kControlModifierMask) != ui::EF_ALT_DOWN;
1463 if (GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE || !should_insert_char) 1465 if (GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE || !should_insert_char)
1464 return; 1466 return;
1465 1467
1466 DoInsertChar(ch); 1468 DoInsertChar(ch);
1467 1469
1468 if (text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD && 1470 if (text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD &&
1469 password_reveal_duration_ != base::TimeDelta()) { 1471 password_reveal_duration_ != base::TimeDelta()) {
1470 const size_t change_offset = model_->GetCursorPosition(); 1472 const size_t change_offset = model_->GetCursorPosition();
1471 DCHECK_GT(change_offset, 0u); 1473 DCHECK_GT(change_offset, 0u);
1472 RevealPasswordChar(change_offset - 1); 1474 RevealPasswordChar(change_offset - 1);
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 RequestFocus(); 1894 RequestFocus();
1893 model_->MoveCursorTo(mouse); 1895 model_->MoveCursorTo(mouse);
1894 if (!selection_clipboard_text.empty()) { 1896 if (!selection_clipboard_text.empty()) {
1895 model_->InsertText(selection_clipboard_text); 1897 model_->InsertText(selection_clipboard_text);
1896 UpdateAfterChange(true, true); 1898 UpdateAfterChange(true, true);
1897 } 1899 }
1898 OnAfterUserAction(); 1900 OnAfterUserAction();
1899 } 1901 }
1900 1902
1901 } // namespace views 1903 } // namespace views
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.cc ('k') | ui/views/controls/textfield/textfield_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698