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 29068794dbb3af6d1e21b7a28e38b2caa80d3674..4407fb14f51df4316aed264d88a22001e7a1bc53 100644 |
| --- a/ui/touch_selection/touch_selection_controller.cc |
| +++ b/ui/touch_selection/touch_selection_controller.cc |
| @@ -151,11 +151,46 @@ bool TouchSelectionController::WillHandleTouchEvent(const MotionEvent& event) { |
| return false; |
| } |
| -void TouchSelectionController::OnLongPressEvent() { |
| +bool TouchSelectionController::WillHandleLongPressEvent( |
| + const gfx::PointF& location) { |
| + if (WillHandleTapOrLongPress(location)) |
| + return true; |
| + |
| response_pending_input_event_ = LONG_PRESS; |
| ShowSelectionHandlesAutomatically(); |
| ShowInsertionHandleAutomatically(); |
| ResetCachedValuesIfInactive(); |
| + return false; |
| +} |
| + |
| +bool TouchSelectionController::WillHandleTapEvent(const gfx::PointF& location) { |
| + if (WillHandleTapOrLongPress(location)) |
| + return true; |
| + |
| + response_pending_input_event_ = TAP; |
| + activate_selection_automatically_ = false; |
|
jdduke (slow)
2015/05/08 22:05:52
This will need to be rebased.
Donn Denman
2015/05/11 21:23:39
Done.
|
| + ShowInsertionHandleAutomatically(); |
| + if (selection_empty_ && !show_on_tap_for_empty_editable_) |
| + DeactivateInsertion(); |
| + ResetCachedValuesIfInactive(); |
| + return false; |
| +} |
| + |
| +bool TouchSelectionController::WillHandleTapOrLongPress( |
| + const gfx::PointF& location) { |
| + // If there is an active selection that was not triggered by a user gesture, |
| + // allow showing the handles for that selection if a gesture occurs within |
| + // the selection rect. Note that this hit test is at best a crude |
| + // approximation, and may swallow taps that actually fall outside the |
| + // real selection. |
| + if (!is_selection_active_ && !is_insertion_active_) { |
| + if (GetStartPosition() != GetEndPosition() && |
| + RectFBetweenSelectionBounds(start_, end_).Contains(location)) { |
| + AllowShowingFromCurrentSelection(); |
| + return true; |
| + } |
| + } |
| + return false; |
| } |
| void TouchSelectionController::AllowShowingFromCurrentSelection() { |
| @@ -171,15 +206,6 @@ void TouchSelectionController::AllowShowingFromCurrentSelection() { |
| OnInsertionChanged(); |
| } |
| -void TouchSelectionController::OnTapEvent() { |
| - response_pending_input_event_ = TAP; |
| - activate_selection_automatically_ = false; |
| - ShowInsertionHandleAutomatically(); |
| - if (selection_empty_ && !show_on_tap_for_empty_editable_) |
| - DeactivateInsertion(); |
| - ResetCachedValuesIfInactive(); |
| -} |
| - |
| void TouchSelectionController::HideAndDisallowShowingAutomatically() { |
| response_pending_input_event_ = INPUT_EVENT_TYPE_NONE; |
| DeactivateInsertion(); |