OLD | NEW |
---|---|
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 Loading... | |
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 // If a scroll happens after a long-press on an empty area, the long-press | |
mfomitchev
2016/01/04 18:58:44
Can we rephrase to be a bit more explicit, e.g.:
I
mohsen
2016/01/04 19:23:05
Done.
| |
236 // will not change the selection, however the scroll will move the selection. | |
237 // In this case we might think incorrectly that the selection change was due | |
mfomitchev
2016/01/04 18:58:44
Can we replace "might" with "will" here?
Also, per
mohsen
2016/01/04 19:23:05
Done.
| |
238 // to long-press and will activate touch selection and start long-press drag | |
239 // gesture. To prevent this, we need to reset the state of touch selection | |
240 // controller and long-press drag selector. | |
241 // TODO(mohsen): Remove this workaround when we have enough information about | |
242 // the cause of a selection change (see https://crbug.com/571897). | |
243 longpress_drag_selector_.OnScrollBeginEvent(); | |
244 response_pending_input_event_ = INPUT_EVENT_TYPE_NONE; | |
245 if (active_status_ == INACTIVE) { | |
246 activate_insertion_automatically_ = false; | |
247 activate_selection_automatically_ = false; | |
248 } | |
249 } | |
250 | |
234 void TouchSelectionController::AllowShowingFromCurrentSelection() { | 251 void TouchSelectionController::AllowShowingFromCurrentSelection() { |
235 if (active_status_ != INACTIVE) | 252 if (active_status_ != INACTIVE) |
236 return; | 253 return; |
237 | 254 |
238 activate_selection_automatically_ = true; | 255 activate_selection_automatically_ = true; |
239 activate_insertion_automatically_ = true; | 256 activate_insertion_automatically_ = true; |
240 if (GetStartPosition() != GetEndPosition()) { | 257 if (GetStartPosition() != GetEndPosition()) { |
241 OnSelectionChanged(); | 258 OnSelectionChanged(); |
242 } else if (start_orientation_ == TouchHandleOrientation::CENTER && | 259 } else if (start_orientation_ == TouchHandleOrientation::CENTER && |
243 selection_editable_) { | 260 selection_editable_) { |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
661 base::TimeDelta duration = base::TimeTicks::Now() - selection_start_time_; | 678 base::TimeDelta duration = base::TimeTicks::Now() - selection_start_time_; |
662 UMA_HISTOGRAM_CUSTOM_TIMES("Event.TouchSelection.WasDraggedDuration", | 679 UMA_HISTOGRAM_CUSTOM_TIMES("Event.TouchSelection.WasDraggedDuration", |
663 duration, | 680 duration, |
664 base::TimeDelta::FromMilliseconds(500), | 681 base::TimeDelta::FromMilliseconds(500), |
665 base::TimeDelta::FromSeconds(60), | 682 base::TimeDelta::FromSeconds(60), |
666 60); | 683 60); |
667 } | 684 } |
668 } | 685 } |
669 | 686 |
670 } // namespace ui | 687 } // namespace ui |
OLD | NEW |