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

Unified Diff: ui/views/controls/textfield/textfield_model.h

Issue 2119813002: views::Textfield: Implement yank editing command. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review. Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/textfield/textfield.cc ('k') | ui/views/controls/textfield/textfield_model.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/textfield/textfield_model.h
diff --git a/ui/views/controls/textfield/textfield_model.h b/ui/views/controls/textfield/textfield_model.h
index df3e9754e2d52c1e51949b542cf3d2552c56dfc4..88a07b17e8ea8129a250da96f292d447dd4d4f2e 100644
--- a/ui/views/controls/textfield/textfield_model.h
+++ b/ui/views/controls/textfield/textfield_model.h
@@ -37,6 +37,10 @@ enum MergeType {
} // namespace internal
+namespace test {
+class BridgedNativeWidgetTest;
+} // namsespace test
+
// A model that represents text content for a views::Textfield.
// It supports editing, selection and cursor manipulation.
class VIEWS_EXPORT TextfieldModel {
@@ -95,15 +99,17 @@ class VIEWS_EXPORT TextfieldModel {
// Deletes the first character after the current cursor position (as if, the
// the user has pressed delete key in the textfield). Returns true if
- // the deletion is successful.
+ // the deletion is successful. If |add_to_kill_buffer| is true, the deleted
+ // text is copied to the kill buffer.
// If there is composition text, it'll be deleted instead.
- bool Delete();
+ bool Delete(bool add_to_kill_buffer = false);
// Deletes the first character before the current cursor position (as if, the
// the user has pressed backspace key in the textfield). Returns true if
- // the removal is successful.
+ // the removal is successful. If |add_to_kill_buffer| is true, the deleted
+ // text is copied to the kill buffer.
// If there is composition text, it'll be deleted instead.
- bool Backspace();
+ bool Backspace(bool add_to_kill_buffer = false);
// Cursor related methods.
@@ -182,6 +188,10 @@ class VIEWS_EXPORT TextfieldModel {
// changed.
bool Transpose();
+ // Pastes text from the kill buffer at the current cursor position. Returns
+ // true if the text has changed after yanking.
+ bool Yank();
+
// Tells if any text is selected, even if the selection is in composition
// text.
bool HasSelection() const;
@@ -225,6 +235,9 @@ class VIEWS_EXPORT TextfieldModel {
private:
friend class internal::Edit;
+ friend class test::BridgedNativeWidgetTest;
+ friend class TextfieldModelTest;
+ friend class TextfieldTest;
FRIEND_TEST_ALL_PREFIXES(TextfieldModelTest, UndoRedo_BasicTest);
FRIEND_TEST_ALL_PREFIXES(TextfieldModelTest, UndoRedo_CutCopyPasteTest);
@@ -269,6 +282,9 @@ class VIEWS_EXPORT TextfieldModel {
void ClearComposition();
+ // Clears the kill buffer. Used to clear global state between tests.
+ static void ClearKillBuffer();
+
// The TextfieldModel::Delegate instance should be provided by the owner.
Delegate* delegate_;
« no previous file with comments | « ui/views/controls/textfield/textfield.cc ('k') | ui/views/controls/textfield/textfield_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698