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..65a2e6e7ae34cf256eda010270d7ef24c9060efd 100644 |
| --- a/ui/views/controls/textfield/native_textfield_views.cc |
| +++ b/ui/views/controls/textfield/native_textfield_views.cc |
| @@ -263,7 +263,14 @@ 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 ui::Range& selection = GetRenderText()->selection(); |
| + drop_cursor_position_ = GetRenderText()->FindCursorPosition(event.location()); |
| + bool in_selection = !selection.is_empty() && |
| + GetRenderText()->RangeContainsCaret( |
| + selection, |
| + drop_cursor_position_.caret_pos(), |
| + drop_cursor_position_.caret_affinity()); |
| is_drop_cursor_visible_ = !in_selection; |
| // TODO(msw): Pan over text when the user drags to the visible text edge. |
| OnCaretBoundsChanged(); |
| @@ -278,9 +285,16 @@ 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())); |
| + is_drop_cursor_visible_ = false; |
|
ckocagil
2013/04/16 19:20:25
Added to fix a condition where OnDragDone isn't ca
|
| + |
| TextfieldController* controller = textfield_->GetController(); |
| if (controller) { |
| int drag_operation = controller->OnDrop(event.data()); |
| @@ -1081,11 +1095,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()) { |