Chromium Code Reviews| Index: ui/gfx/render_text.cc |
| =================================================================== |
| --- ui/gfx/render_text.cc (revision 97029) |
| +++ ui/gfx/render_text.cc (working copy) |
| @@ -199,8 +199,7 @@ |
| // Cancelling a selection moves to the edge of the selection. |
| if (break_type != LINE_BREAK && !EmptySelection() && !select) { |
| // Use the selection start if it is left of the selection end. |
| - SelectionModel selection_start(GetSelectionStart(), GetSelectionStart(), |
| - SelectionModel::LEADING); |
| + SelectionModel selection_start = GetSelectionModelForSelectionStart(); |
| if (GetCursorBounds(selection_start, false).x() < |
| GetCursorBounds(position, false).x()) |
| position = selection_start; |
| @@ -221,8 +220,7 @@ |
| // Cancelling a selection moves to the edge of the selection. |
| if (break_type != LINE_BREAK && !EmptySelection() && !select) { |
| // Use the selection start if it is right of the selection end. |
| - SelectionModel selection_start(GetSelectionStart(), GetSelectionStart(), |
| - SelectionModel::LEADING); |
| + SelectionModel selection_start = GetSelectionModelForSelectionStart(); |
| if (GetCursorBounds(selection_start, false).x() > |
| GetCursorBounds(position, false).x()) |
| position = selection_start; |
| @@ -608,4 +606,16 @@ |
| cursor_bounds_.Offset(delta_offset, 0); |
| } |
| +SelectionModel RenderText::GetSelectionModelForSelectionStart() { |
| + if (GetSelectionStart() < GetCursorPosition()) { |
| + return SelectionModel(GetSelectionStart(), |
| + GetSelectionStart(), |
| + SelectionModel::LEADING); |
| + } else { |
|
oshima
2011/08/19 18:44:07
no need for else. (It's chromium style)
Alternativ
xji
2011/08/20 00:53:05
removed else.
|
| + return SelectionModel(GetSelectionStart(), |
| + GetIndexOfPreviousGrapheme(GetSelectionStart()), |
| + SelectionModel::TRAILING); |
| + } |
| +} |
| + |
| } // namespace gfx |