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

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

Issue 7461102: modification to RenderText for inheritance/SelectionModel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync and change non-const reference to pointer Created 9 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
Index: views/controls/textfield/native_textfield_views.cc
===================================================================
--- views/controls/textfield/native_textfield_views.cc (revision 95171)
+++ views/controls/textfield/native_textfield_views.cc (working copy)
@@ -198,7 +198,7 @@
skip_input_method_cancel_composition_ = true;
// TODO(msw): Remove final reference to FindCursorPosition.
- size_t drop_destination =
+ gfx::SelectionModel drop_destination =
GetRenderText()->FindCursorPosition(event.location());
string16 text;
event.data().GetString(&text);
@@ -210,13 +210,16 @@
ui::Range selected_range;
model_->GetSelectedRange(&selected_range);
// Adjust the drop destination if it is on or after the current selection.
- if (selected_range.GetMax() <= drop_destination)
- drop_destination -= selected_range.length();
- else if (selected_range.GetMin() <= drop_destination)
- drop_destination = selected_range.GetMin();
- model_->DeleteSelectionAndInsertTextAt(text, drop_destination);
+ if (selected_range.GetMax() <= drop_destination.selection_end())
+ drop_destination.set_selection_end(
+ drop_destination.selection_end() - selected_range.length());
+ else if (selected_range.GetMin() <= drop_destination.selection_end())
+ drop_destination.set_selection_end(selected_range.GetMin());
+ model_->DeleteSelectionAndInsertTextAt(text,
+ drop_destination.selection_end());
} else {
- model_->MoveCursorTo(drop_destination, false);
+ drop_destination.SetSelectionEmpty();
+ model_->MoveCursorTo(&drop_destination);
// Drop always inserts text even if the textfield is not in insert mode.
model_->InsertText(text);
}
@@ -656,9 +659,7 @@
}
gfx::Rect NativeTextfieldViews::GetCaretBounds() {
- gfx::RenderText* render_text = GetRenderText();
- return render_text->GetCursorBounds(render_text->GetCursorPosition(),
- render_text->insert_mode());
+ return GetRenderText()->CursorBounds();
}
bool NativeTextfieldViews::HasCompositionText() {

Powered by Google App Engine
This is Rietveld 408576698