Chromium Code Reviews| Index: ui/touch_selection/touch_selection_controller.cc |
| diff --git a/ui/touch_selection/touch_selection_controller.cc b/ui/touch_selection/touch_selection_controller.cc |
| index f5a4bda90a6d6704702a2c57a1099b78c54c544f..0f560dda907d5ae60c52b77b3870c2009527e681 100644 |
| --- a/ui/touch_selection/touch_selection_controller.cc |
| +++ b/ui/touch_selection/touch_selection_controller.cc |
| @@ -30,10 +30,12 @@ TouchHandleOrientation ToTouchHandleOrientation(SelectionBound::Type type) { |
| TouchSelectionController::TouchSelectionController( |
| TouchSelectionControllerClient* client, |
| base::TimeDelta tap_timeout, |
| - float tap_slop) |
| + float tap_slop, |
| + bool show_on_tap_for_empty_editable) |
| : client_(client), |
| tap_timeout_(tap_timeout), |
| tap_slop_(tap_slop), |
| + show_on_tap_for_empty_editable_(show_on_tap_for_empty_editable), |
| response_pending_input_event_(INPUT_EVENT_TYPE_NONE), |
| start_orientation_(TOUCH_HANDLE_ORIENTATION_UNDEFINED), |
| end_orientation_(TOUCH_HANDLE_ORIENTATION_UNDEFINED), |
| @@ -45,13 +47,12 @@ TouchSelectionController::TouchSelectionController( |
| selection_editable_(false), |
| temporarily_hidden_(false) { |
| DCHECK(client_); |
| - HideAndDisallowShowingAutomatically(); |
| } |
| TouchSelectionController::~TouchSelectionController() { |
| } |
| -void TouchSelectionController::OnSelectionBoundsChanged( |
| +void TouchSelectionController::OnSelectionBoundsUpdated( |
| const SelectionBound& start, |
| const SelectionBound& end) { |
| if (start == start_ && end_ == end) |
| @@ -213,6 +214,15 @@ bool TouchSelectionController::Animate(base::TimeTicks frame_time) { |
| return false; |
| } |
| +void TouchSelectionController::TryActivateSelection() { |
|
jdduke (slow)
2015/01/28 16:35:32
How exactly does this differ from |AllowShowingFro
mohsen
2015/02/22 23:23:09
Oh, I missed |AllowShowingFromCurrentSelection()|
|
| + if (GetStartPosition() != GetEndPosition()) { |
| + SelectionBound start = start_; |
| + SelectionBound end = end_; |
| + ShowSelectionHandlesAutomatically(); |
| + OnSelectionBoundsUpdated(start, end); |
| + } |
| +} |
| + |
| void TouchSelectionController::OnHandleDragBegin(const TouchHandle& handle) { |
| if (&handle == insertion_handle_.get()) { |
| client_->OnSelectionEvent(INSERTION_DRAG_STARTED, handle.position()); |
| @@ -251,7 +261,9 @@ void TouchSelectionController::OnHandleDragUpdate(const TouchHandle& handle, |
| } |
| void TouchSelectionController::OnHandleDragEnd(const TouchHandle& handle) { |
| - if (&handle != insertion_handle_.get()) |
| + if (&handle == insertion_handle_.get()) |
| + client_->OnSelectionEvent(INSERTION_DRAG_STOPPED, handle.position()); |
| + else |
| client_->OnSelectionEvent(SELECTION_DRAG_STOPPED, handle.position()); |
| } |
| @@ -293,7 +305,8 @@ void TouchSelectionController::ShowSelectionHandlesAutomatically() { |
| void TouchSelectionController::OnInsertionChanged() { |
| DeactivateSelection(); |
| - if (response_pending_input_event_ == TAP && selection_empty_) { |
| + if (response_pending_input_event_ == TAP && selection_empty_ && |
| + !show_on_tap_for_empty_editable_) { |
| HideAndDisallowShowingAutomatically(); |
| return; |
| } |
| @@ -316,7 +329,7 @@ void TouchSelectionController::OnInsertionChanged() { |
| void TouchSelectionController::OnSelectionChanged() { |
| DeactivateInsertion(); |
| - if (!activate_selection_automatically_) |
| + if (!activate_selection_automatically_) // XXX: needed? |
| return; |
| const bool was_active = is_selection_active_; |