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

Unified Diff: ui/views/controls/textfield/textfield.cc

Issue 927743002: Focus and trail cursor on Views Textfield selection clipboard paste. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use SetClipboardText on other platforms too. Created 5 years, 10 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
Index: ui/views/controls/textfield/textfield.cc
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc
index ca39c99c49aac957362be449e6fbe36647eb69a9..ccbc10f950c67919d7ca8606bfe4be1a29f7f8b5 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -1858,23 +1858,17 @@ void Textfield::PasteSelectionClipboard(const ui::MouseEvent& event) {
DCHECK(event.IsOnlyMiddleMouseButton());
DCHECK(!read_only());
base::string16 selection_clipboard_text = GetSelectionClipboardText();
+ OnBeforeUserAction();
+ const gfx::SelectionModel mouse =
+ GetRenderText()->FindCursorPosition(event.location());
+ if (!HasFocus())
+ RequestFocus();
+ model_->MoveCursorTo(mouse);
if (!selection_clipboard_text.empty()) {
- OnBeforeUserAction();
- gfx::Range range = GetSelectionModel().selection();
- gfx::LogicalCursorDirection affinity = GetSelectionModel().caret_affinity();
- const gfx::SelectionModel mouse =
- GetRenderText()->FindCursorPosition(event.location());
- model_->MoveCursorTo(mouse);
model_->InsertText(selection_clipboard_text);
- // Update the new selection range as needed.
- if (range.GetMin() >= mouse.caret_pos()) {
- const size_t length = selection_clipboard_text.length();
- range = gfx::Range(range.start() + length, range.end() + length);
- }
- model_->MoveCursorTo(gfx::SelectionModel(range, affinity));
UpdateAfterChange(true, true);
- OnAfterUserAction();
}
+ OnAfterUserAction();
}
} // namespace views
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc ('k') | ui/views/controls/textfield/textfield_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698