| 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 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 static_cast<ui::KeyboardCode>(ui::VKEY_A + ch - 'a'); | 508 static_cast<ui::KeyboardCode>(ui::VKEY_A + ch - 'a'); |
| 509 SendKeyEvent(code); | 509 SendKeyEvent(code); |
| 510 } else { | 510 } else { |
| 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 the logical start of line. |
| 519 // Eg. this should move (and select) to the right end of line for RTL text. |
| 519 void SendHomeEvent(bool shift) { | 520 void SendHomeEvent(bool shift) { |
| 520 if (TestingNativeMac()) { | 521 if (TestingNativeMac()) { |
| 521 // Use Cmd+Left on native Mac. An RTL-agnostic "end" doesn't have a | 522 // [NSResponder moveToBeginningOfLine:] is the correct way to do this on |
| 522 // default key-binding on Mac. | 523 // Mac, but that doesn't have a default key binding. Since |
| 523 SendKeyEvent(ui::VKEY_LEFT, shift /* shift */, true /* command */); | 524 // views::Textfield doesn't currently support multiple lines, the same |
| 525 // effect can be achieved by Cmd+Up which maps to |
| 526 // [NSResponder moveToBeginningOfDocument:]. |
| 527 SendKeyEvent(ui::VKEY_UP, shift /* shift */, true /* command */); |
| 524 return; | 528 return; |
| 525 } | 529 } |
| 526 SendKeyEvent(ui::VKEY_HOME, shift /* shift */, false /* control */); | 530 SendKeyEvent(ui::VKEY_HOME, shift /* shift */, false /* control */); |
| 527 } | 531 } |
| 528 | 532 |
| 529 // Sends a platform-specific move (and select) to end of line. | 533 // Sends a platform-specific move (and select) to the logical end of line. |
| 530 void SendEndEvent(bool shift) { | 534 void SendEndEvent(bool shift) { |
| 531 if (TestingNativeMac()) { | 535 if (TestingNativeMac()) { |
| 532 SendKeyEvent(ui::VKEY_RIGHT, shift, true); // Cmd+Right. | 536 SendKeyEvent(ui::VKEY_DOWN, shift, true); // Cmd+Down. |
| 533 return; | 537 return; |
| 534 } | 538 } |
| 535 SendKeyEvent(ui::VKEY_END, shift, false); | 539 SendKeyEvent(ui::VKEY_END, shift, false); |
| 536 } | 540 } |
| 537 | 541 |
| 538 // Sends {delete, move, select} word {forward, backward}. | 542 // Sends {delete, move, select} word {forward, backward}. |
| 539 void SendWordEvent(ui::KeyboardCode key, bool shift) { | 543 void SendWordEvent(ui::KeyboardCode key, bool shift) { |
| 540 bool alt = false; | 544 bool alt = false; |
| 541 bool control = true; | 545 bool control = true; |
| 542 bool caps = false; | 546 bool caps = false; |
| (...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2654 | 2658 |
| 2655 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); | 2659 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); |
| 2656 ui::AXViewState state_protected; | 2660 ui::AXViewState state_protected; |
| 2657 textfield_->GetAccessibleState(&state_protected); | 2661 textfield_->GetAccessibleState(&state_protected); |
| 2658 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role); | 2662 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role); |
| 2659 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value); | 2663 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value); |
| 2660 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); | 2664 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); |
| 2661 } | 2665 } |
| 2662 | 2666 |
| 2663 } // namespace views | 2667 } // namespace views |
| OLD | NEW |