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

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

Issue 1325333002: Ignore inserting character with Search as a modifier on ChromeOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: kpschoedel's comments 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"
11 #include "ui/base/clipboard/scoped_clipboard_writer.h" 11 #include "ui/base/clipboard/scoped_clipboard_writer.h"
12 #include "ui/base/cursor/cursor.h" 12 #include "ui/base/cursor/cursor.h"
13 #include "ui/base/dragdrop/drag_drop_types.h" 13 #include "ui/base/dragdrop/drag_drop_types.h"
14 #include "ui/base/dragdrop/drag_utils.h" 14 #include "ui/base/dragdrop/drag_utils.h"
15 #include "ui/base/ime/input_method.h" 15 #include "ui/base/ime/input_method.h"
16 #include "ui/base/touch/selection_bound.h" 16 #include "ui/base/touch/selection_bound.h"
17 #include "ui/base/ui_base_switches_util.h" 17 #include "ui/base/ui_base_switches_util.h"
18 #include "ui/compositor/canvas_painter.h" 18 #include "ui/compositor/canvas_painter.h"
19 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 19 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
20 #include "ui/events/base_event_utils.h"
20 #include "ui/events/event.h" 21 #include "ui/events/event.h"
21 #include "ui/events/keycodes/keyboard_codes.h" 22 #include "ui/events/keycodes/keyboard_codes.h"
22 #include "ui/gfx/canvas.h" 23 #include "ui/gfx/canvas.h"
23 #include "ui/gfx/display.h" 24 #include "ui/gfx/display.h"
24 #include "ui/gfx/geometry/insets.h" 25 #include "ui/gfx/geometry/insets.h"
25 #include "ui/gfx/screen.h" 26 #include "ui/gfx/screen.h"
26 #include "ui/native_theme/native_theme.h" 27 #include "ui/native_theme/native_theme.h"
27 #include "ui/strings/grit/ui_strings.h" 28 #include "ui/strings/grit/ui_strings.h"
28 #include "ui/views/background.h" 29 #include "ui/views/background.h"
29 #include "ui/views/controls/focusable_border.h" 30 #include "ui/views/controls/focusable_border.h"
(...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after
1442 if (GetRenderText()->insert_mode()) 1443 if (GetRenderText()->insert_mode())
1443 model_->InsertText(new_text); 1444 model_->InsertText(new_text);
1444 else 1445 else
1445 model_->ReplaceText(new_text); 1446 model_->ReplaceText(new_text);
1446 skip_input_method_cancel_composition_ = false; 1447 skip_input_method_cancel_composition_ = false;
1447 UpdateAfterChange(true, true); 1448 UpdateAfterChange(true, true);
1448 OnAfterUserAction(); 1449 OnAfterUserAction();
1449 } 1450 }
1450 1451
1451 void Textfield::InsertChar(base::char16 ch, int flags) { 1452 void Textfield::InsertChar(base::char16 ch, int flags) {
1452 const int kControlModifierMask = ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN |
1453 ui::EF_COMMAND_DOWN | ui::EF_ALTGR_DOWN |
1454 ui::EF_MOD3_DOWN;
1455
1456 // Filter out all control characters, including tab and new line characters, 1453 // Filter out all control characters, including tab and new line characters,
1457 // and all characters with Alt modifier. But allow characters with the AltGr 1454 // and all characters with Alt modifier (and Search on ChromeOS). But allow
1458 // modifier. On Windows AltGr is represented by Alt+Ctrl, and on Linux it's a 1455 // characters with the AltGr modifier. On Windows AltGr is represented by
1459 // different flag that we don't care about. 1456 // Alt+Ctrl, and on Linux it's a different flag that we don't care about.
1460 const bool should_insert_char = 1457 const bool should_insert_char =
1461 ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) && 1458 ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) &&
1462 (flags & kControlModifierMask) != ui::EF_ALT_DOWN; 1459 !ui::IsSystemKeyModifier(flags);
1463 if (GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE || !should_insert_char) 1460 if (GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE || !should_insert_char)
1464 return; 1461 return;
1465 1462
1466 DoInsertChar(ch); 1463 DoInsertChar(ch);
1467 1464
1468 if (text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD && 1465 if (text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD &&
1469 password_reveal_duration_ != base::TimeDelta()) { 1466 password_reveal_duration_ != base::TimeDelta()) {
1470 const size_t change_offset = model_->GetCursorPosition(); 1467 const size_t change_offset = model_->GetCursorPosition();
1471 DCHECK_GT(change_offset, 0u); 1468 DCHECK_GT(change_offset, 0u);
1472 RevealPasswordChar(change_offset - 1); 1469 RevealPasswordChar(change_offset - 1);
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 RequestFocus(); 1889 RequestFocus();
1893 model_->MoveCursorTo(mouse); 1890 model_->MoveCursorTo(mouse);
1894 if (!selection_clipboard_text.empty()) { 1891 if (!selection_clipboard_text.empty()) {
1895 model_->InsertText(selection_clipboard_text); 1892 model_->InsertText(selection_clipboard_text);
1896 UpdateAfterChange(true, true); 1893 UpdateAfterChange(true, true);
1897 } 1894 }
1898 OnAfterUserAction(); 1895 OnAfterUserAction();
1899 } 1896 }
1900 1897
1901 } // 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