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

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: '' 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 93971)
+++ views/controls/textfield/native_textfield_views.cc (working copy)
@@ -197,7 +197,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);
@@ -209,11 +209,12 @@
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.cursor_pos())
+ drop_destination.set_cursor_pos(
+ drop_destination.cursor_pos() - selected_range.length());
+ else if (selected_range.GetMin() <= drop_destination.cursor_pos())
+ drop_destination.set_cursor_pos(selected_range.GetMin());
+ model_->DeleteSelectionAndInsertTextAt(text, drop_destination.cursor_pos());
} else {
model_->MoveCursorTo(drop_destination, false);
// Drop always inserts text even if the textfield is not in insert mode.
@@ -650,8 +651,7 @@
gfx::Rect NativeTextfieldViews::GetCaretBounds() {
gfx::RenderText* render_text = GetRenderText();
msw 2011/08/01 05:02:23 May as well condense these lines into: return GetR
- return render_text->GetCursorBounds(render_text->GetCursorPosition(),
- render_text->insert_mode());
+ return render_text->CursorBounds();
}
bool NativeTextfieldViews::HasCompositionText() {

Powered by Google App Engine
This is Rietveld 408576698