| Index: ui/views/controls/textfield/textfield.cc
|
| diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc
|
| index 19e5c2ca689acbd6ab7cc7c045d7ef6bdd536c3e..c2d134d076a3127d4027144df4c808a873c33dde 100644
|
| --- a/ui/views/controls/textfield/textfield.cc
|
| +++ b/ui/views/controls/textfield/textfield.cc
|
| @@ -1488,6 +1488,8 @@ bool Textfield::IsTextEditCommandEnabled(ui::TextEditCommand command) const {
|
| return editable && !result.empty();
|
| case ui::TextEditCommand::SELECT_ALL:
|
| return !text().empty();
|
| + case ui::TextEditCommand::YANK:
|
| + return editable;
|
| case ui::TextEditCommand::MOVE_DOWN:
|
| case ui::TextEditCommand::MOVE_DOWN_AND_MODIFY_SELECTION:
|
| case ui::TextEditCommand::MOVE_PAGE_DOWN:
|
| @@ -1538,21 +1540,24 @@ base::string16 Textfield::GetSelectionClipboardText() const {
|
| void Textfield::ExecuteTextEditCommand(ui::TextEditCommand command) {
|
| DestroyTouchSelection();
|
|
|
| + bool add_to_kill_buffer = false;
|
| +
|
| // Some codepaths may bypass GetCommandForKeyEvent, so any selection-dependent
|
| // modifications of the command should happen here.
|
| - if (HasSelection()) {
|
| - switch (command) {
|
| - case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_LINE:
|
| - case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_PARAGRAPH:
|
| - case ui::TextEditCommand::DELETE_TO_END_OF_LINE:
|
| - case ui::TextEditCommand::DELETE_TO_END_OF_PARAGRAPH:
|
| - case ui::TextEditCommand::DELETE_WORD_BACKWARD:
|
| - case ui::TextEditCommand::DELETE_WORD_FORWARD:
|
| + switch (command) {
|
| + case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_LINE:
|
| + case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_PARAGRAPH:
|
| + case ui::TextEditCommand::DELETE_TO_END_OF_LINE:
|
| + case ui::TextEditCommand::DELETE_TO_END_OF_PARAGRAPH:
|
| + add_to_kill_buffer = true;
|
| + // Fall through.
|
| + case ui::TextEditCommand::DELETE_WORD_BACKWARD:
|
| + case ui::TextEditCommand::DELETE_WORD_FORWARD:
|
| + if (HasSelection())
|
| command = ui::TextEditCommand::DELETE_FORWARD;
|
| - break;
|
| - default:
|
| - break;
|
| - }
|
| + break;
|
| + default:
|
| + break;
|
| }
|
|
|
| // We only execute the commands enabled in Textfield::IsTextEditCommandEnabled
|
| @@ -1570,28 +1575,28 @@ void Textfield::ExecuteTextEditCommand(ui::TextEditCommand command) {
|
| OnBeforeUserAction();
|
| switch (command) {
|
| case ui::TextEditCommand::DELETE_BACKWARD:
|
| - text_changed = cursor_changed = model_->Backspace();
|
| + text_changed = cursor_changed = model_->Backspace(add_to_kill_buffer);
|
| break;
|
| case ui::TextEditCommand::DELETE_FORWARD:
|
| - text_changed = cursor_changed = model_->Delete();
|
| + text_changed = cursor_changed = model_->Delete(add_to_kill_buffer);
|
| break;
|
| case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_LINE:
|
| case ui::TextEditCommand::DELETE_TO_BEGINNING_OF_PARAGRAPH:
|
| model_->MoveCursor(gfx::LINE_BREAK, begin, true);
|
| - text_changed = cursor_changed = model_->Backspace();
|
| + text_changed = cursor_changed = model_->Backspace(add_to_kill_buffer);
|
| break;
|
| case ui::TextEditCommand::DELETE_TO_END_OF_LINE:
|
| case ui::TextEditCommand::DELETE_TO_END_OF_PARAGRAPH:
|
| model_->MoveCursor(gfx::LINE_BREAK, end, true);
|
| - text_changed = cursor_changed = model_->Delete();
|
| + text_changed = cursor_changed = model_->Delete(add_to_kill_buffer);
|
| break;
|
| case ui::TextEditCommand::DELETE_WORD_BACKWARD:
|
| model_->MoveCursor(gfx::WORD_BREAK, begin, true);
|
| - text_changed = cursor_changed = model_->Backspace();
|
| + text_changed = cursor_changed = model_->Backspace(add_to_kill_buffer);
|
| break;
|
| case ui::TextEditCommand::DELETE_WORD_FORWARD:
|
| model_->MoveCursor(gfx::WORD_BREAK, end, true);
|
| - text_changed = cursor_changed = model_->Delete();
|
| + text_changed = cursor_changed = model_->Delete(add_to_kill_buffer);
|
| break;
|
| case ui::TextEditCommand::MOVE_BACKWARD:
|
| model_->MoveCursor(gfx::CHARACTER_BREAK, begin, false);
|
| @@ -1681,6 +1686,9 @@ void Textfield::ExecuteTextEditCommand(ui::TextEditCommand command) {
|
| case ui::TextEditCommand::SELECT_ALL:
|
| SelectAll(false);
|
| break;
|
| + case ui::TextEditCommand::YANK:
|
| + text_changed = cursor_changed = model_->Yank();
|
| + break;
|
| case ui::TextEditCommand::MOVE_DOWN:
|
| case ui::TextEditCommand::MOVE_DOWN_AND_MODIFY_SELECTION:
|
| case ui::TextEditCommand::MOVE_PAGE_DOWN:
|
|
|