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

Unified Diff: ui/views/controls/textfield/textfield.cc

Issue 2505943002: MacViews: Fix accelerator handling while Omnibox is in focus. (Closed)
Patch Set: Fixed TextfieldTest.*, disable ViewTest.ActivateAcceleratorOnMac on non-MacViews. Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/textfield/textfield.cc
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc
index 4b0bef22f724ba3c3d7bd4defe8aab6874b4560c..c7bf227dc62dbc7589b1025d17202f1d565080f6 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -92,7 +92,11 @@ ui::TextEditCommand GetCommandForKeyEvent(const ui::KeyEvent& event) {
return ui::TextEditCommand::INVALID_COMMAND;
const bool shift = event.IsShiftDown();
+#if defined(OS_MACOSX)
+ const bool control = event.IsCommandDown();
themblsha 2016/11/22 14:33:48 Fixes TextfieldTest.CutCopyPaste. "Ensure [Ctrl]+[
tapted 2016/11/23 02:09:30 This doesn't look right -- E.g. -[BridgedContentVi
themblsha 2016/11/23 15:16:39 Just EventGenerator::WINDOW is not enough, but in
+#else
const bool control = event.IsControlDown();
+#endif
const bool alt = event.IsAltDown() || event.IsAltGrDown();
switch (event.key_code()) {
case ui::VKEY_Z:
@@ -1264,6 +1268,14 @@ void Textfield::InsertText(const base::string16& new_text) {
}
void Textfield::InsertChar(const ui::KeyEvent& event) {
+#if defined(OS_MACOSX)
+ // MockInputMethod::DispatchKeyEvent() will try to incorrectly call
+ // TestTextfield::InsertChar(), even though when Command is pressed text input
+ // shouldn't work at all.
+ if (event.IsCommandDown())
+ return;
+#endif
themblsha 2016/11/22 14:33:48 Fixes TextfieldTest.KeysWithModifiersTest. MockInp
tapted 2016/11/23 02:09:30 This test already behaves correctly on CrOS. I thi
themblsha 2016/11/23 15:16:39 Whoa, this really fixes it. Thanks!
+
if (read_only()) {
OnEditFailed();
return;

Powered by Google App Engine
This is Rietveld 408576698