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 6c70d47d0d4b6d70c73145ac9f99939b1aaacfd9..95abfbb832641ece6e82f8e97018f346ce26455c 100644 |
--- a/ui/touch_selection/touch_selection_controller.cc |
+++ b/ui/touch_selection/touch_selection_controller.cc |
@@ -153,11 +153,48 @@ 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(); |
ForceNextUpdateIfInactive(); |
+ return false; |
+} |
+ |
+bool TouchSelectionController::WillHandleTapEvent(const gfx::PointF& location) { |
+ if (WillHandleTapOrLongPress(location)) |
+ return true; |
+ |
+ response_pending_input_event_ = TAP; |
+ if (active_status_ != SELECTION_ACTIVE) |
+ activate_selection_automatically_ = false; |
+ ShowInsertionHandleAutomatically(); |
+ if (selection_empty_ && !show_on_tap_for_empty_editable_) |
+ DeactivateInsertion(); |
+ ForceNextUpdateIfInactive(); |
+ return false; |
+} |
+ |
+bool TouchSelectionController::WillHandleTapOrLongPress( |
jdduke (slow)
2015/05/12 22:33:01
Nit: The implementation order should match the dec
Donn Denman
2015/05/12 22:52:48
Oh, didn't know that!
Done.
|
+ 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 (active_status_ != SELECTION_ACTIVE && |
Donn Denman
2015/05/12 21:42:49
Jared, please double-check this conditional -- I n
jdduke (slow)
2015/05/12 22:33:00
This can just be
if (active_status_ == INACTIVE
Donn Denman
2015/05/12 22:52:48
Done.
Noticed we don't need separate nested if's,
|
+ active_status_ != INSERTION_ACTIVE) { |
+ if (GetStartPosition() != GetEndPosition() && |
+ RectFBetweenSelectionBounds(start_, end_).Contains(location)) { |
+ AllowShowingFromCurrentSelection(); |
+ return true; |
+ } |
+ } |
+ return false; |
} |
void TouchSelectionController::AllowShowingFromCurrentSelection() { |
@@ -174,16 +211,6 @@ void TouchSelectionController::AllowShowingFromCurrentSelection() { |
} |
} |
-void TouchSelectionController::OnTapEvent() { |
- response_pending_input_event_ = TAP; |
- if (active_status_ != SELECTION_ACTIVE) |
- activate_selection_automatically_ = false; |
- ShowInsertionHandleAutomatically(); |
- if (selection_empty_ && !show_on_tap_for_empty_editable_) |
- DeactivateInsertion(); |
- ForceNextUpdateIfInactive(); |
-} |
- |
void TouchSelectionController::HideAndDisallowShowingAutomatically() { |
response_pending_input_event_ = INPUT_EVENT_TYPE_NONE; |
DeactivateInsertion(); |