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 3d52b4c3e423f276b65541c1491b0e260411fb86..9cdf1b8e593fd540c6745c3a8987246c2a9bba98 100644 |
--- a/ui/touch_selection/touch_selection_controller.cc |
+++ b/ui/touch_selection/touch_selection_controller.cc |
@@ -151,11 +151,26 @@ bool TouchSelectionController::WillHandleTouchEvent(const MotionEvent& event) { |
return false; |
} |
-void TouchSelectionController::OnLongPressEvent() { |
+bool TouchSelectionController::WillHandleLongPressEvent( |
+ 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 long-press 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; |
+ } |
+ } |
+ |
response_pending_input_event_ = LONG_PRESS; |
ShowSelectionHandlesAutomatically(); |
ShowInsertionHandleAutomatically(); |
ResetCachedValuesIfInactive(); |
+ return false; |
} |
void TouchSelectionController::AllowShowingFromCurrentSelection() { |
@@ -171,12 +186,24 @@ void TouchSelectionController::AllowShowingFromCurrentSelection() { |
OnInsertionChanged(); |
} |
-void TouchSelectionController::OnTapEvent() { |
+bool TouchSelectionController::WillHandleTapEvent(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 the tap 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_) { |
jdduke (slow)
2015/05/01 20:52:06
Can we split this logic out into a shared function
Donn Denman
2015/05/01 22:46:03
Done.
|
+ if (GetStartPosition() != GetEndPosition() && |
+ RectFBetweenSelectionBounds(start_, end_).Contains(location)) { |
+ AllowShowingFromCurrentSelection(); |
+ return true; |
+ } |
+ } |
response_pending_input_event_ = TAP; |
ShowInsertionHandleAutomatically(); |
if (selection_empty_ && !show_on_tap_for_empty_editable_) |
DeactivateInsertion(); |
ResetCachedValuesIfInactive(); |
+ return false; |
} |
void TouchSelectionController::HideAndDisallowShowingAutomatically() { |