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

Unified Diff: content/browser/renderer_host/input/touch_selection_controller.cc

Issue 467303002: [Android] Perform haptic feedback after long press when appropriate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Feedback with repeated long press Created 6 years, 4 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: content/browser/renderer_host/input/touch_selection_controller.cc
diff --git a/content/browser/renderer_host/input/touch_selection_controller.cc b/content/browser/renderer_host/input/touch_selection_controller.cc
index 8193fb180668397e589d451edf2f107e782af49a..352bf364c964b7c76fe864089b77589351364569 100644
--- a/content/browser/renderer_host/input/touch_selection_controller.cc
+++ b/content/browser/renderer_host/input/touch_selection_controller.cc
@@ -183,6 +183,8 @@ bool TouchSelectionController::Animate(base::TimeTicks frame_time) {
}
void TouchSelectionController::OnHandleDragBegin(const TouchHandle& handle) {
+ last_input_event_type_ = INPUT_EVENT_TYPE_NONE;
+
if (&handle == insertion_handle_.get()) {
client_->OnSelectionEvent(INSERTION_DRAG_STARTED, handle.position());
return;
@@ -324,8 +326,12 @@ void TouchSelectionController::ActivateSelection() {
end_selection_handle_->SetOrientation(end_orientation_);
}
- if (!is_selection_active_) {
+ // As a long press received while a selection is already active may trigger
+ // an entirely new selection, notify the client but avoid sending an
+ // intervening SELECTION_CLEARED update to avoid unnecessary state changes.
+ if (!is_selection_active_ || last_input_event_type_ == LONG_PRESS) {
cjhopman 2014/08/14 00:12:28 Maybe there's a better name for last_input_event_t
jdduke (slow) 2014/08/14 17:57:19 Yeah, I'll tweak it.
is_selection_active_ = true;
+ last_input_event_type_ = INPUT_EVENT_TYPE_NONE;
client_->OnSelectionEvent(SELECTION_SHOWN, GetStartPosition());
}
}

Powered by Google App Engine
This is Rietveld 408576698