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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } | 64 } |
65 | 65 |
66 TouchSelectionController::~TouchSelectionController() { | 66 TouchSelectionController::~TouchSelectionController() { |
67 } | 67 } |
68 | 68 |
69 void TouchSelectionController::OnSelectionBoundsChanged( | 69 bool TouchSelectionController::OnSelectionBoundsUpdated( |
70 const SelectionBound& start, | 70 const SelectionBound& start, |
71 const SelectionBound& end) { | 71 const SelectionBound& end) { |
72 if (start == start_ && end_ == end) | 72 if (start == start_ && end_ == end) |
73 return; | 73 return false; |
74 | 74 |
75 start_ = start; | 75 start_ = start; |
76 end_ = end; | 76 end_ = end; |
77 start_orientation_ = ToTouchHandleOrientation(start_.type()); | 77 start_orientation_ = ToTouchHandleOrientation(start_.type()); |
78 end_orientation_ = ToTouchHandleOrientation(end_.type()); | 78 end_orientation_ = ToTouchHandleOrientation(end_.type()); |
79 | 79 |
80 if (!activate_selection_automatically_ && | 80 if (!activate_selection_automatically_ && |
81 !activate_insertion_automatically_) { | 81 !activate_insertion_automatically_) { |
82 DCHECK_EQ(INPUT_EVENT_TYPE_NONE, response_pending_input_event_); | 82 DCHECK_EQ(INPUT_EVENT_TYPE_NONE, response_pending_input_event_); |
83 return; | 83 return false; |
84 } | 84 } |
85 | 85 |
86 // Ensure that |response_pending_input_event_| is cleared after the method | 86 // Ensure that |response_pending_input_event_| is cleared after the method |
87 // completes, while also making its current value available for the duration | 87 // completes, while also making its current value available for the duration |
88 // of the call. | 88 // of the call. |
89 InputEventType causal_input_event = response_pending_input_event_; | 89 InputEventType causal_input_event = response_pending_input_event_; |
90 response_pending_input_event_ = INPUT_EVENT_TYPE_NONE; | 90 response_pending_input_event_ = INPUT_EVENT_TYPE_NONE; |
91 base::AutoReset<InputEventType> auto_reset_response_pending_input_event( | 91 base::AutoReset<InputEventType> auto_reset_response_pending_input_event( |
92 &response_pending_input_event_, causal_input_event); | 92 &response_pending_input_event_, causal_input_event); |
93 | 93 |
(...skipping 12 matching lines...) Expand all Loading... |
106 start_orientation_ = start_selection_handle_->orientation(); | 106 start_orientation_ = start_selection_handle_->orientation(); |
107 if (end_orientation_ == TouchHandleOrientation::CENTER) | 107 if (end_orientation_ == TouchHandleOrientation::CENTER) |
108 end_orientation_ = end_selection_handle_->orientation(); | 108 end_orientation_ = end_selection_handle_->orientation(); |
109 } | 109 } |
110 | 110 |
111 if (GetStartPosition() != GetEndPosition() || | 111 if (GetStartPosition() != GetEndPosition() || |
112 (is_selection_dragging && | 112 (is_selection_dragging && |
113 start_orientation_ != TouchHandleOrientation::UNDEFINED && | 113 start_orientation_ != TouchHandleOrientation::UNDEFINED && |
114 end_orientation_ != TouchHandleOrientation::UNDEFINED)) { | 114 end_orientation_ != TouchHandleOrientation::UNDEFINED)) { |
115 OnSelectionChanged(); | 115 OnSelectionChanged(); |
116 return; | 116 return true; |
117 } | 117 } |
118 | 118 |
119 if (start_orientation_ == TouchHandleOrientation::CENTER && | 119 if (start_orientation_ == TouchHandleOrientation::CENTER && |
120 selection_editable_) { | 120 selection_editable_) { |
121 OnInsertionChanged(); | 121 OnInsertionChanged(); |
122 return; | 122 return true; |
123 } | 123 } |
124 | 124 |
125 HideAndDisallowShowingAutomatically(); | 125 HideAndDisallowShowingAutomatically(); |
| 126 return true; |
126 } | 127 } |
127 | 128 |
128 bool TouchSelectionController::WillHandleTouchEvent(const MotionEvent& event) { | 129 bool TouchSelectionController::WillHandleTouchEvent(const MotionEvent& event) { |
129 if (is_insertion_active_) { | 130 if (is_insertion_active_) { |
130 DCHECK(insertion_handle_); | 131 DCHECK(insertion_handle_); |
131 return insertion_handle_->WillHandleTouchEvent(event); | 132 return insertion_handle_->WillHandleTouchEvent(event); |
132 } | 133 } |
133 | 134 |
134 if (is_selection_active_) { | 135 if (is_selection_active_) { |
135 DCHECK(start_selection_handle_); | 136 DCHECK(start_selection_handle_); |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 base::TimeDelta duration = base::TimeTicks::Now() - selection_start_time_; | 469 base::TimeDelta duration = base::TimeTicks::Now() - selection_start_time_; |
469 UMA_HISTOGRAM_CUSTOM_TIMES("Event.TouchSelection.WasDraggedDuration", | 470 UMA_HISTOGRAM_CUSTOM_TIMES("Event.TouchSelection.WasDraggedDuration", |
470 duration, | 471 duration, |
471 base::TimeDelta::FromMilliseconds(500), | 472 base::TimeDelta::FromMilliseconds(500), |
472 base::TimeDelta::FromSeconds(60), | 473 base::TimeDelta::FromSeconds(60), |
473 60); | 474 60); |
474 } | 475 } |
475 } | 476 } |
476 | 477 |
477 } // namespace ui | 478 } // namespace ui |
OLD | NEW |