| 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 #include "base/metrics/user_metrics.h" | 10 #include "base/metrics/user_metrics.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 NOTREACHED() << "Invalid selection bound type: " << type; | 39 NOTREACHED() << "Invalid selection bound type: " << type; |
| 40 return TouchHandleOrientation::UNDEFINED; | 40 return TouchHandleOrientation::UNDEFINED; |
| 41 } | 41 } |
| 42 | 42 |
| 43 } // namespace | 43 } // namespace |
| 44 | 44 |
| 45 TouchSelectionController::Config::Config() | 45 TouchSelectionController::Config::Config() |
| 46 : max_tap_duration(base::TimeDelta::FromMilliseconds(300)), | 46 : max_tap_duration(base::TimeDelta::FromMilliseconds(300)), |
| 47 tap_slop(8), | 47 tap_slop(8), |
| 48 enable_adaptive_handle_orientation(false), | 48 enable_adaptive_handle_orientation(false), |
| 49 enable_longpress_drag_selection(false), | 49 enable_longpress_drag_selection(false) {} |
| 50 show_on_tap_for_empty_editable(false) {} | |
| 51 | 50 |
| 52 TouchSelectionController::Config::~Config() { | 51 TouchSelectionController::Config::~Config() { |
| 53 } | 52 } |
| 54 | 53 |
| 55 TouchSelectionController::TouchSelectionController( | 54 TouchSelectionController::TouchSelectionController( |
| 56 TouchSelectionControllerClient* client, | 55 TouchSelectionControllerClient* client, |
| 57 const Config& config) | 56 const Config& config) |
| 58 : client_(client), | 57 : client_(client), |
| 59 config_(config), | 58 config_(config), |
| 60 force_next_update_(false), | 59 force_next_update_(false), |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 215 |
| 217 if (tap_count > 1) { | 216 if (tap_count > 1) { |
| 218 response_pending_input_event_ = REPEATED_TAP; | 217 response_pending_input_event_ = REPEATED_TAP; |
| 219 ShowSelectionHandlesAutomatically(); | 218 ShowSelectionHandlesAutomatically(); |
| 220 } else { | 219 } else { |
| 221 response_pending_input_event_ = TAP; | 220 response_pending_input_event_ = TAP; |
| 222 if (active_status_ != SELECTION_ACTIVE) | 221 if (active_status_ != SELECTION_ACTIVE) |
| 223 activate_selection_automatically_ = false; | 222 activate_selection_automatically_ = false; |
| 224 } | 223 } |
| 225 ShowInsertionHandleAutomatically(); | 224 ShowInsertionHandleAutomatically(); |
| 226 if (selection_empty_ && !config_.show_on_tap_for_empty_editable) | 225 if (selection_empty_) |
| 227 DeactivateInsertion(); | 226 DeactivateInsertion(); |
| 228 ForceNextUpdateIfInactive(); | 227 ForceNextUpdateIfInactive(); |
| 229 return false; | 228 return false; |
| 230 } | 229 } |
| 231 | 230 |
| 232 bool TouchSelectionController::WillHandleLongPressEvent( | 231 bool TouchSelectionController::WillHandleLongPressEvent( |
| 233 base::TimeTicks event_time, | 232 base::TimeTicks event_time, |
| 234 const gfx::PointF& location) { | 233 const gfx::PointF& location) { |
| 235 if (WillHandleTapOrLongPress(location)) | 234 if (WillHandleTapOrLongPress(location)) |
| 236 return true; | 235 return true; |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 return true; | 489 return true; |
| 491 } | 490 } |
| 492 return false; | 491 return false; |
| 493 } | 492 } |
| 494 | 493 |
| 495 void TouchSelectionController::OnInsertionChanged() { | 494 void TouchSelectionController::OnInsertionChanged() { |
| 496 DeactivateSelection(); | 495 DeactivateSelection(); |
| 497 | 496 |
| 498 if ((response_pending_input_event_ == TAP || | 497 if ((response_pending_input_event_ == TAP || |
| 499 response_pending_input_event_ == REPEATED_TAP) && | 498 response_pending_input_event_ == REPEATED_TAP) && |
| 500 selection_empty_ && !config_.show_on_tap_for_empty_editable) { | 499 selection_empty_) { |
| 501 HideAndDisallowShowingAutomatically(); | 500 HideAndDisallowShowingAutomatically(); |
| 502 return; | 501 return; |
| 503 } | 502 } |
| 504 | 503 |
| 505 if (!activate_insertion_automatically_) | 504 if (!activate_insertion_automatically_) |
| 506 return; | 505 return; |
| 507 | 506 |
| 508 const bool activated = ActivateInsertionIfNecessary(); | 507 const bool activated = ActivateInsertionIfNecessary(); |
| 509 | 508 |
| 510 const TouchHandle::AnimationStyle animation = GetAnimationStyle(!activated); | 509 const TouchHandle::AnimationStyle animation = GetAnimationStyle(!activated); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 base::TimeDelta duration = base::TimeTicks::Now() - selection_start_time_; | 694 base::TimeDelta duration = base::TimeTicks::Now() - selection_start_time_; |
| 696 UMA_HISTOGRAM_CUSTOM_TIMES("Event.TouchSelection.WasDraggedDuration", | 695 UMA_HISTOGRAM_CUSTOM_TIMES("Event.TouchSelection.WasDraggedDuration", |
| 697 duration, | 696 duration, |
| 698 base::TimeDelta::FromMilliseconds(500), | 697 base::TimeDelta::FromMilliseconds(500), |
| 699 base::TimeDelta::FromSeconds(60), | 698 base::TimeDelta::FromSeconds(60), |
| 700 60); | 699 60); |
| 701 } | 700 } |
| 702 } | 701 } |
| 703 | 702 |
| 704 } // namespace ui | 703 } // namespace ui |
| OLD | NEW |