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

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

Issue 8044004: Clean up of SelectionModel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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 103192)
+++ views/controls/textfield/native_textfield_views.cc (working copy)
@@ -225,13 +225,12 @@
selected.selection_end());
size_t selected_range_length = max_of_selected_range -
min_of_selected_range;
- if (max_of_selected_range <= drop_destination.selection_end())
- drop_destination.set_selection_end(
- drop_destination.selection_end() - selected_range_length);
- else if (min_of_selected_range <= drop_destination.selection_end())
- drop_destination.set_selection_end(min_of_selected_range);
- model_->DeleteSelectionAndInsertTextAt(text,
- drop_destination.selection_end());
+ size_t drop_destination_end = drop_destination.selection_end();
+ if (max_of_selected_range <= drop_destination_end)
+ drop_destination_end -= selected_range_length;
+ else if (min_of_selected_range <= drop_destination_end)
+ drop_destination_end = min_of_selected_range;
+ model_->DeleteSelectionAndInsertTextAt(text, drop_destination_end);
} else {
drop_destination.set_selection_start(drop_destination.selection_end());
model_->MoveCursorTo(drop_destination);
@@ -1013,10 +1012,10 @@
return;
gfx::RenderText* render_text = GetRenderText();
const gfx::SelectionModel& sel = render_text->selection_model();
- gfx::SelectionModel start_sel(sel.selection_start(), sel.selection_start(),
- sel.selection_start(), gfx::SelectionModel::LEADING);
- gfx::Rect start_cursor = render_text->GetCursorBounds(start_sel, false);
- gfx::Rect end_cursor = render_text->GetCursorBounds(sel, false);
+ gfx::SelectionModel start_sel =
+ render_text->GetSelectionModelForSelectionStart();
+ gfx::Rect start_cursor = render_text->GetCursorBounds(start_sel, true);
+ gfx::Rect end_cursor = render_text->GetCursorBounds(sel, true);
gfx::Point start(start_cursor.x(), start_cursor.bottom() - 1);
gfx::Point end(end_cursor.x(), end_cursor.bottom() - 1);
touch_selection_controller_->SelectionChanged(start, end);

Powered by Google App Engine
This is Rietveld 408576698