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

Side by Side Diff: ui/touch_selection/touch_selection_controller.cc

Issue 1537493006: Allow scrolling a page with selection after long-press on whitespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated comments Created 4 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/touch_selection/touch_selection_controller.h" 5 #include "ui/touch_selection/touch_selection_controller.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 10
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 return true; 224 return true;
225 225
226 longpress_drag_selector_.OnLongPressEvent(event_time, location); 226 longpress_drag_selector_.OnLongPressEvent(event_time, location);
227 response_pending_input_event_ = LONG_PRESS; 227 response_pending_input_event_ = LONG_PRESS;
228 ShowSelectionHandlesAutomatically(); 228 ShowSelectionHandlesAutomatically();
229 ShowInsertionHandleAutomatically(); 229 ShowInsertionHandleAutomatically();
230 ForceNextUpdateIfInactive(); 230 ForceNextUpdateIfInactive();
231 return false; 231 return false;
232 } 232 }
233 233
234 void TouchSelectionController::OnScrollBeginEvent() {
235 // When there is an active selection, if the user performs a long-press that
236 // does not trigger a new selection (e.g. a long-press on an empty area) and
237 // then scrolls, the scroll will move the selection. In this case we will
238 // think incorrectly that the selection change was due to the long-press and
239 // will activate touch selection and start long-press drag gesture (see
240 // ActivateInsertionIfNecessary()). To prevent this, we need to reset the
241 // state of touch selection controller and long-press drag selector.
242 // TODO(mohsen): Remove this workaround when we have enough information about
243 // the cause of a selection change (see https://crbug.com/571897).
244 longpress_drag_selector_.OnScrollBeginEvent();
245 response_pending_input_event_ = INPUT_EVENT_TYPE_NONE;
246 if (active_status_ == INACTIVE) {
247 activate_insertion_automatically_ = false;
248 activate_selection_automatically_ = false;
249 }
250 }
251
234 void TouchSelectionController::AllowShowingFromCurrentSelection() { 252 void TouchSelectionController::AllowShowingFromCurrentSelection() {
235 if (active_status_ != INACTIVE) 253 if (active_status_ != INACTIVE)
236 return; 254 return;
237 255
238 activate_selection_automatically_ = true; 256 activate_selection_automatically_ = true;
239 activate_insertion_automatically_ = true; 257 activate_insertion_automatically_ = true;
240 if (GetStartPosition() != GetEndPosition()) { 258 if (GetStartPosition() != GetEndPosition()) {
241 OnSelectionChanged(); 259 OnSelectionChanged();
242 } else if (start_orientation_ == TouchHandleOrientation::CENTER && 260 } else if (start_orientation_ == TouchHandleOrientation::CENTER &&
243 selection_editable_) { 261 selection_editable_) {
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 base::TimeDelta duration = base::TimeTicks::Now() - selection_start_time_; 679 base::TimeDelta duration = base::TimeTicks::Now() - selection_start_time_;
662 UMA_HISTOGRAM_CUSTOM_TIMES("Event.TouchSelection.WasDraggedDuration", 680 UMA_HISTOGRAM_CUSTOM_TIMES("Event.TouchSelection.WasDraggedDuration",
663 duration, 681 duration,
664 base::TimeDelta::FromMilliseconds(500), 682 base::TimeDelta::FromMilliseconds(500),
665 base::TimeDelta::FromSeconds(60), 683 base::TimeDelta::FromSeconds(60),
666 60); 684 60);
667 } 685 }
668 } 686 }
669 687
670 } // namespace ui 688 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698