Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ | 5 #ifndef UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
| 6 #define UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ | 6 #define UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 // Sets the text currently displayed in the Textfield. This doesn't | 82 // Sets the text currently displayed in the Textfield. This doesn't |
| 83 // change the cursor position if the current cursor is within the | 83 // change the cursor position if the current cursor is within the |
| 84 // new text's range, or moves the cursor to the end if the cursor is | 84 // new text's range, or moves the cursor to the end if the cursor is |
| 85 // out of the new text's range. | 85 // out of the new text's range. |
| 86 void SetText(const base::string16& new_text); | 86 void SetText(const base::string16& new_text); |
| 87 | 87 |
| 88 // Appends the given string to the previously-existing text in the field. | 88 // Appends the given string to the previously-existing text in the field. |
| 89 void AppendText(const base::string16& new_text); | 89 void AppendText(const base::string16& new_text); |
| 90 | 90 |
| 91 // Inserts |new_text| at the cursor position, replacing any selected text. | 91 // Inserts |new_text| at the cursor position, replacing any selected text. |
| 92 // This method is used to handle user input via paths Textfield doesn't | |
| 93 // normally handle, so it calls UpdateAfterChange() and notifies observers of | |
| 94 // changes. | |
| 92 void InsertOrReplaceText(const base::string16& new_text); | 95 void InsertOrReplaceText(const base::string16& new_text); |
| 93 | 96 |
| 94 // Returns the text that is currently selected. Call sites should take care to | 97 // Returns the text that is currently selected. Call sites should take care to |
| 95 // not reveal the text for a password textfield. | 98 // not reveal the text for a password textfield. |
| 96 base::string16 GetSelectedText() const; | 99 base::string16 GetSelectedText() const; |
| 97 | 100 |
| 98 // Select the entire text range. If |reversed| is true, the range will end at | 101 // Select the entire text range. If |reversed| is true, the range will end at |
| 99 // the logical beginning of the text; this generally shows the leading portion | 102 // the logical beginning of the text; this generally shows the leading portion |
| 100 // of text that overflows its display area. | 103 // of text that overflows its display area. |
| 101 void SelectAll(bool reversed); | 104 void SelectAll(bool reversed); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 322 gfx::Point last_click_location() const { return last_click_location_; } | 325 gfx::Point last_click_location() const { return last_click_location_; } |
| 323 | 326 |
| 324 // Get the text from the selection clipboard. | 327 // Get the text from the selection clipboard. |
| 325 virtual base::string16 GetSelectionClipboardText() const; | 328 virtual base::string16 GetSelectionClipboardText() const; |
| 326 | 329 |
| 327 // Executes the given |command|. | 330 // Executes the given |command|. |
| 328 virtual void ExecuteTextEditCommand(ui::TextEditCommand command); | 331 virtual void ExecuteTextEditCommand(ui::TextEditCommand command); |
| 329 | 332 |
| 330 private: | 333 private: |
| 331 friend class TextfieldTestApi; | 334 friend class TextfieldTestApi; |
| 335 FRIEND_TEST_ALL_PREFIXES(TextfieldTest, CursorBlinkRestartsOnInsertOrReplace); | |
|
msw
2016/10/07 17:16:38
Please plumb the call through TextfieldTestApi ins
Elly Fong-Jones
2016/10/07 17:25:57
Done.
| |
| 332 | 336 |
| 333 // View overrides: | 337 // View overrides: |
| 334 // Declared final since overriding by subclasses would interfere with the | 338 // Declared final since overriding by subclasses would interfere with the |
| 335 // accounting related to the scheduled text edit command. Subclasses should | 339 // accounting related to the scheduled text edit command. Subclasses should |
| 336 // use TextfieldController::HandleKeyEvent, to intercept the key event. | 340 // use TextfieldController::HandleKeyEvent, to intercept the key event. |
| 337 bool OnKeyPressed(const ui::KeyEvent& event) final; | 341 bool OnKeyPressed(const ui::KeyEvent& event) final; |
| 338 bool OnKeyReleased(const ui::KeyEvent& event) final; | 342 bool OnKeyReleased(const ui::KeyEvent& event) final; |
| 339 | 343 |
| 340 // Handles a request to change the value of this text field from software | 344 // Handles a request to change the value of this text field from software |
| 341 // using an accessibility API (typically automation software, screen readers | 345 // using an accessibility API (typically automation software, screen readers |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 518 | 522 |
| 519 // Used to bind callback functions to this object. | 523 // Used to bind callback functions to this object. |
| 520 base::WeakPtrFactory<Textfield> weak_ptr_factory_; | 524 base::WeakPtrFactory<Textfield> weak_ptr_factory_; |
| 521 | 525 |
| 522 DISALLOW_COPY_AND_ASSIGN(Textfield); | 526 DISALLOW_COPY_AND_ASSIGN(Textfield); |
| 523 }; | 527 }; |
| 524 | 528 |
| 525 } // namespace views | 529 } // namespace views |
| 526 | 530 |
| 527 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ | 531 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
| OLD | NEW |