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

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: Leave the test disabled... 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..b71994d54bba9fa897ec66c1e8a6926c96ed7ffc 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -1860,18 +1860,12 @@ void Textfield::PasteSelectionClipboard(const ui::MouseEvent& event) {
base::string16 selection_clipboard_text = GetSelectionClipboardText();
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());
+ if (!HasFocus())
+ RequestFocus();
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();
}
« no previous file with comments | « no previous file | ui/views/controls/textfield/textfield_unittest.cc » ('j') | ui/views/controls/textfield/textfield_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698