Chromium Code Reviews| 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() { |