Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 511 // For unicode characters, assume they come from IME rather than the | 511 // For unicode characters, assume they come from IME rather than the |
| 512 // keyboard. So they are dispatched directly to the input method. | 512 // keyboard. So they are dispatched directly to the input method. |
| 513 ui::KeyEvent event(ch, ui::VKEY_UNKNOWN, ui::EF_NONE); | 513 ui::KeyEvent event(ch, ui::VKEY_UNKNOWN, ui::EF_NONE); |
| 514 input_method_->DispatchKeyEvent(&event); | 514 input_method_->DispatchKeyEvent(&event); |
| 515 } | 515 } |
| 516 } | 516 } |
| 517 | 517 |
| 518 // Sends a platform-specific move (and select) to start of line. | 518 // Sends a platform-specific move (and select) to start of line. |
| 519 void SendHomeEvent(bool shift) { | 519 void SendHomeEvent(bool shift) { |
| 520 if (TestingNativeMac()) { | 520 if (TestingNativeMac()) { |
| 521 // Use Cmd+Left on native Mac. An RTL-agnostic "end" doesn't have a | 521 // Move to beginning of line doesn't have a default key binding on Mac. |
|
tapted
2016/06/08 04:16:45
This is now different to "SendHomeEvent". If the p
karandeepb
2016/06/08 04:56:05
How is it different to SendHomeEvent? Based on the
tapted
2016/06/08 05:59:03
It sends Up. It's sorta coincidence that that goes
karandeepb
2016/06/08 08:04:56
Added a comment to SendHomeEvent/SendEndEvent sayi
| |
| 522 // default key-binding on Mac. | 522 // Since textfields don't support multiple lines, use Cmd+Up instead, |
| 523 SendKeyEvent(ui::VKEY_LEFT, shift /* shift */, true /* command */); | 523 // which moves to the beginning of document. |
| 524 SendKeyEvent(ui::VKEY_UP, shift /* shift */, true /* command */); | |
| 524 return; | 525 return; |
| 525 } | 526 } |
| 526 SendKeyEvent(ui::VKEY_HOME, shift /* shift */, false /* control */); | 527 SendKeyEvent(ui::VKEY_HOME, shift /* shift */, false /* control */); |
| 527 } | 528 } |
| 528 | 529 |
| 529 // Sends a platform-specific move (and select) to end of line. | 530 // Sends a platform-specific move (and select) to end of line. |
| 530 void SendEndEvent(bool shift) { | 531 void SendEndEvent(bool shift) { |
| 531 if (TestingNativeMac()) { | 532 if (TestingNativeMac()) { |
| 532 SendKeyEvent(ui::VKEY_RIGHT, shift, true); // Cmd+Right. | 533 SendKeyEvent(ui::VKEY_DOWN, shift, true); // Cmd+Down. |
| 533 return; | 534 return; |
| 534 } | 535 } |
| 535 SendKeyEvent(ui::VKEY_END, shift, false); | 536 SendKeyEvent(ui::VKEY_END, shift, false); |
| 536 } | 537 } |
| 537 | 538 |
| 538 // Sends {delete, move, select} word {forward, backward}. | 539 // Sends {delete, move, select} word {forward, backward}. |
| 539 void SendWordEvent(ui::KeyboardCode key, bool shift) { | 540 void SendWordEvent(ui::KeyboardCode key, bool shift) { |
| 540 bool alt = false; | 541 bool alt = false; |
| 541 bool control = true; | 542 bool control = true; |
| 542 bool caps = false; | 543 bool caps = false; |
| (...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2654 | 2655 |
| 2655 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); | 2656 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); |
| 2656 ui::AXViewState state_protected; | 2657 ui::AXViewState state_protected; |
| 2657 textfield_->GetAccessibleState(&state_protected); | 2658 textfield_->GetAccessibleState(&state_protected); |
| 2658 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role); | 2659 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role); |
| 2659 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value); | 2660 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value); |
| 2660 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); | 2661 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); |
| 2661 } | 2662 } |
| 2662 | 2663 |
| 2663 } // namespace views | 2664 } // namespace views |
| OLD | NEW |