Chromium Code Reviews| Index: ui/views/controls/textfield/native_textfield_views.cc |
| diff --git a/ui/views/controls/textfield/native_textfield_views.cc b/ui/views/controls/textfield/native_textfield_views.cc |
| index bb29f06ab1257eff9d1167625c2b041d14a2b634..fc69c0d5076993e0da69fbb269c870f90182efb0 100644 |
| --- a/ui/views/controls/textfield/native_textfield_views.cc |
| +++ b/ui/views/controls/textfield/native_textfield_views.cc |
| @@ -263,8 +263,12 @@ bool NativeTextfieldViews::CanDrop(const OSExchangeData& data) { |
| int NativeTextfieldViews::OnDragUpdated(const ui::DropTargetEvent& event) { |
| DCHECK(CanDrop(event.data())); |
| - bool in_selection = GetRenderText()->IsPointInSelection(event.location()); |
| + |
| + const gfx::Point& location = event.location(); |
| + bool in_selection = GetRenderText()->IsPointInSelection(location); |
| is_drop_cursor_visible_ = !in_selection; |
| + if (is_drop_cursor_visible_) |
| + drop_cursor_position_ = GetRenderText()->FindCursorPosition(location); |
|
msw
2013/04/15 17:14:04
You can optionally avoid calling both FindCursorPo
ckocagil
2013/04/15 20:41:15
Done.
|
| // TODO(msw): Pan over text when the user drags to the visible text edge. |
| OnCaretBoundsChanged(); |
| SchedulePaint(); |
| @@ -278,6 +282,11 @@ int NativeTextfieldViews::OnDragUpdated(const ui::DropTargetEvent& event) { |
| return ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_MOVE; |
| } |
| +void NativeTextfieldViews::OnDragExited() { |
| + is_drop_cursor_visible_ = false; |
| + SchedulePaint(); |
| +} |
| + |
| int NativeTextfieldViews::OnPerformDrop(const ui::DropTargetEvent& event) { |
| DCHECK(CanDrop(event.data())); |
| @@ -1081,11 +1090,15 @@ void NativeTextfieldViews::RepaintCursor() { |
| void NativeTextfieldViews::PaintTextAndCursor(gfx::Canvas* canvas) { |
| TRACE_EVENT0("views", "NativeTextfieldViews::PaintTextAndCursor"); |
| canvas->Save(); |
| - GetRenderText()->set_cursor_visible(is_drop_cursor_visible_ || |
| - (is_cursor_visible_ && !model_->HasSelection())); |
| + GetRenderText()->set_cursor_visible(!is_drop_cursor_visible_ && |
| + is_cursor_visible_ && !model_->HasSelection()); |
| // Draw the text, cursor, and selection. |
| GetRenderText()->Draw(canvas); |
| + // Draw the detached drop cursor that marks where the text will be dropped. |
| + if (is_drop_cursor_visible_) |
| + GetRenderText()->DrawCursor(canvas, drop_cursor_position_); |
| + |
| // Draw placeholder text if needed. |
| if (model_->GetText().empty() && |
| !textfield_->placeholder_text().empty()) { |