| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 end_orientation_(TOUCH_HANDLE_ORIENTATION_UNDEFINED), | 54 end_orientation_(TOUCH_HANDLE_ORIENTATION_UNDEFINED), |
| 55 is_insertion_active_(false), | 55 is_insertion_active_(false), |
| 56 activate_insertion_automatically_(false), | 56 activate_insertion_automatically_(false), |
| 57 is_selection_active_(false), | 57 is_selection_active_(false), |
| 58 activate_selection_automatically_(false), | 58 activate_selection_automatically_(false), |
| 59 selection_empty_(false), | 59 selection_empty_(false), |
| 60 selection_editable_(false), | 60 selection_editable_(false), |
| 61 temporarily_hidden_(false), | 61 temporarily_hidden_(false), |
| 62 selection_handle_dragged_(false) { | 62 selection_handle_dragged_(false) { |
| 63 DCHECK(client_); | 63 DCHECK(client_); |
| 64 HideAndDisallowShowingAutomatically(); | |
| 65 } | 64 } |
| 66 | 65 |
| 67 TouchSelectionController::~TouchSelectionController() { | 66 TouchSelectionController::~TouchSelectionController() { |
| 68 } | 67 } |
| 69 | 68 |
| 70 void TouchSelectionController::OnSelectionBoundsChanged( | 69 void TouchSelectionController::OnSelectionBoundsChanged( |
| 71 const SelectionBound& start, | 70 const SelectionBound& start, |
| 72 const SelectionBound& end) { | 71 const SelectionBound& end) { |
| 73 if (start == start_ && end_ == end) | 72 if (start == start_ && end_ == end) |
| 74 return; | 73 return; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 : GetEndLineOffset(); | 260 : GetEndLineOffset(); |
| 262 gfx::PointF line_position = position + line_offset; | 261 gfx::PointF line_position = position + line_offset; |
| 263 if (&handle == insertion_handle_.get()) { | 262 if (&handle == insertion_handle_.get()) { |
| 264 client_->MoveCaret(line_position); | 263 client_->MoveCaret(line_position); |
| 265 } else { | 264 } else { |
| 266 client_->MoveRangeSelectionExtent(line_position); | 265 client_->MoveRangeSelectionExtent(line_position); |
| 267 } | 266 } |
| 268 } | 267 } |
| 269 | 268 |
| 270 void TouchSelectionController::OnHandleDragEnd(const TouchHandle& handle) { | 269 void TouchSelectionController::OnHandleDragEnd(const TouchHandle& handle) { |
| 271 if (&handle != insertion_handle_.get()) | 270 if (&handle == insertion_handle_.get()) |
| 271 client_->OnSelectionEvent(INSERTION_DRAG_STOPPED, handle.position()); |
| 272 else |
| 272 client_->OnSelectionEvent(SELECTION_DRAG_STOPPED, handle.position()); | 273 client_->OnSelectionEvent(SELECTION_DRAG_STOPPED, handle.position()); |
| 273 } | 274 } |
| 274 | 275 |
| 275 void TouchSelectionController::OnHandleTapped(const TouchHandle& handle) { | 276 void TouchSelectionController::OnHandleTapped(const TouchHandle& handle) { |
| 276 if (insertion_handle_ && &handle == insertion_handle_.get()) | 277 if (insertion_handle_ && &handle == insertion_handle_.get()) |
| 277 client_->OnSelectionEvent(INSERTION_TAPPED, handle.position()); | 278 client_->OnSelectionEvent(INSERTION_TAPPED, handle.position()); |
| 278 } | 279 } |
| 279 | 280 |
| 280 void TouchSelectionController::SetNeedsAnimate() { | 281 void TouchSelectionController::SetNeedsAnimate() { |
| 281 client_->SetNeedsAnimate(); | 282 client_->SetNeedsAnimate(); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 base::TimeDelta duration = base::TimeTicks::Now() - selection_start_time_; | 465 base::TimeDelta duration = base::TimeTicks::Now() - selection_start_time_; |
| 465 UMA_HISTOGRAM_CUSTOM_TIMES("Event.TouchSelection.WasDraggedDuration", | 466 UMA_HISTOGRAM_CUSTOM_TIMES("Event.TouchSelection.WasDraggedDuration", |
| 466 duration, | 467 duration, |
| 467 base::TimeDelta::FromMilliseconds(500), | 468 base::TimeDelta::FromMilliseconds(500), |
| 468 base::TimeDelta::FromSeconds(60), | 469 base::TimeDelta::FromSeconds(60), |
| 469 60); | 470 60); |
| 470 } | 471 } |
| 471 } | 472 } |
| 472 | 473 |
| 473 } // namespace ui | 474 } // namespace ui |
| OLD | NEW |