Index: ui/views/controls/textfield/textfield.cc |
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc |
index 5a0cad8d9135cfa18a5c69a8b1c2d4781501fea9..ecdfb3903110ccbe0a5f2e146e1b2cba101f838a 100644 |
--- a/ui/views/controls/textfield/textfield.cc |
+++ b/ui/views/controls/textfield/textfield.cc |
@@ -1101,13 +1101,36 @@ void Textfield::MoveCaretTo(const gfx::Point& point) { |
SelectRect(point, point); |
} |
-void Textfield::GetSelectionEndPoints(gfx::Rect* p1, gfx::Rect* p2) { |
+void Textfield::GetSelectionEndPoints(ui::SelectionBound* anchor, |
+ ui::SelectionBound* focus) { |
gfx::RenderText* render_text = GetRenderText(); |
const gfx::SelectionModel& sel = render_text->selection_model(); |
gfx::SelectionModel start_sel = |
render_text->GetSelectionModelForSelectionStart(); |
- *p1 = render_text->GetCursorBounds(start_sel, true); |
- *p2 = render_text->GetCursorBounds(sel, true); |
+ gfx::Rect r1 = render_text->GetCursorBounds(start_sel, true); |
+ gfx::Rect r2 = render_text->GetCursorBounds(sel, true); |
+ |
+ anchor->edge_top = r1.origin(); |
+ anchor->edge_bottom = r1.bottom_left(); |
+ focus->edge_top = r2.origin(); |
+ focus->edge_bottom = r2.bottom_left(); |
+ |
+ // Determine the SelectionBound's type for focus and anchor. |
+ // TODO(mfomitchev): Ideally we should have different logical directions for |
+ // start and end to support proper handle direction for mixed LTR/RTL text. |
+ const bool ltr = GetTextDirection() != base::i18n::RIGHT_TO_LEFT; |
+ size_t range_start = sel.selection().start(); |
+ size_t range_end = sel.selection().end(); |
+ |
+ if (range_start == range_end) { |
+ anchor->type = focus->type = ui::SelectionBound::CENTER; |
+ } else if (ltr ^ (range_start < range_end)) { |
sky
2014/11/14 02:02:47
WHy ^ and not || ?
mfomitchev
2014/11/14 19:56:27
Any one condition is not enough.. ltr means range
sky
2014/11/14 20:30:57
Yes. I would rather have the more readable version
mfomitchev
2014/11/14 20:46:04
Ok, done. I updated render_widget_host_view_aura.c
|
+ anchor->type = ui::SelectionBound::RIGHT; |
+ focus->type = ui::SelectionBound::LEFT; |
+ } else { |
+ anchor->type = ui::SelectionBound::LEFT; |
+ focus->type = ui::SelectionBound::RIGHT; |
+ } |
} |
gfx::Rect Textfield::GetBounds() { |