Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Unified Diff: ui/touch_selection/touch_selection_controller.cc

Issue 1102933003: [Contextual Search] Add support for tap on the selection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved implementation methods to match declaration order. Used INACTIVE for active_status_ state ch… Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..ad010c3807275ac0aee8b74fe7b2dc227e8c4510 100644
--- a/ui/touch_selection/touch_selection_controller.cc
+++ b/ui/touch_selection/touch_selection_controller.cc
@@ -153,11 +153,30 @@ bool TouchSelectionController::WillHandleTouchEvent(const MotionEvent& event) {
return false;
}
-void TouchSelectionController::OnLongPressEvent() {
+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::WillHandleLongPressEvent(
+ const gfx::PointF& location) {
+ if (WillHandleTapOrLongPress(location))
+ return true;
+
response_pending_input_event_ = LONG_PRESS;
ShowSelectionHandlesAutomatically();
ShowInsertionHandleAutomatically();
ForceNextUpdateIfInactive();
+ return false;
}
void TouchSelectionController::AllowShowingFromCurrentSelection() {
@@ -174,16 +193,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();
@@ -352,6 +361,22 @@ void TouchSelectionController::ShowSelectionHandlesAutomatically() {
ForceNextUpdateIfInactive();
}
+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 (active_status_ == INACTIVE &&
+ GetStartPosition() != GetEndPosition() &&
+ RectFBetweenSelectionBounds(start_, end_).Contains(location)) {
+ AllowShowingFromCurrentSelection();
+ return true;
+ }
+ return false;
+}
+
void TouchSelectionController::OnInsertionChanged() {
DeactivateSelection();
« no previous file with comments | « ui/touch_selection/touch_selection_controller.h ('k') | ui/touch_selection/touch_selection_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698