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

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

Issue 1087893003: Support longpress drag selection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review Created 5 years, 7 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 29 matching lines...) Expand all
40 40
41 } // namespace 41 } // namespace
42 42
43 TouchSelectionController::TouchSelectionController( 43 TouchSelectionController::TouchSelectionController(
44 TouchSelectionControllerClient* client, 44 TouchSelectionControllerClient* client,
45 base::TimeDelta tap_timeout, 45 base::TimeDelta tap_timeout,
46 float tap_slop, 46 float tap_slop,
47 bool show_on_tap_for_empty_editable) 47 bool show_on_tap_for_empty_editable)
48 : client_(client), 48 : client_(client),
49 tap_timeout_(tap_timeout), 49 tap_timeout_(tap_timeout),
50 tap_slop_(tap_slop), 50 tap_slop_squared_(static_cast<double>(tap_slop) * tap_slop),
51 force_next_update_(false), 51 force_next_update_(false),
52 show_on_tap_for_empty_editable_(show_on_tap_for_empty_editable), 52 show_on_tap_for_empty_editable_(show_on_tap_for_empty_editable),
53 response_pending_input_event_(INPUT_EVENT_TYPE_NONE), 53 response_pending_input_event_(INPUT_EVENT_TYPE_NONE),
54 start_orientation_(TouchHandleOrientation::UNDEFINED), 54 start_orientation_(TouchHandleOrientation::UNDEFINED),
55 end_orientation_(TouchHandleOrientation::UNDEFINED), 55 end_orientation_(TouchHandleOrientation::UNDEFINED),
56 active_status_(INACTIVE), 56 active_status_(INACTIVE),
57 activate_insertion_automatically_(false), 57 activate_insertion_automatically_(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 longpress_drag_selector_(this),
62 selection_handle_dragged_(false) { 63 selection_handle_dragged_(false) {
63 DCHECK(client_); 64 DCHECK(client_);
64 } 65 }
65 66
66 TouchSelectionController::~TouchSelectionController() { 67 TouchSelectionController::~TouchSelectionController() {
67 } 68 }
68 69
69 void TouchSelectionController::OnSelectionBoundsChanged( 70 void TouchSelectionController::OnSelectionBoundsChanged(
70 const SelectionBound& start, 71 const SelectionBound& start,
71 const SelectionBound& end) { 72 const SelectionBound& end) {
(...skipping 15 matching lines...) Expand all
87 88
88 // Ensure that |response_pending_input_event_| is cleared after the method 89 // Ensure that |response_pending_input_event_| is cleared after the method
89 // completes, while also making its current value available for the duration 90 // completes, while also making its current value available for the duration
90 // of the call. 91 // of the call.
91 InputEventType causal_input_event = response_pending_input_event_; 92 InputEventType causal_input_event = response_pending_input_event_;
92 response_pending_input_event_ = INPUT_EVENT_TYPE_NONE; 93 response_pending_input_event_ = INPUT_EVENT_TYPE_NONE;
93 base::AutoReset<InputEventType> auto_reset_response_pending_input_event( 94 base::AutoReset<InputEventType> auto_reset_response_pending_input_event(
94 &response_pending_input_event_, causal_input_event); 95 &response_pending_input_event_, causal_input_event);
95 96
96 const bool is_selection_dragging = active_status_ == SELECTION_ACTIVE && 97 const bool is_selection_dragging = active_status_ == SELECTION_ACTIVE &&
97 (start_selection_handle_->is_dragging() || 98 (start_selection_handle_->IsActive() ||
98 end_selection_handle_->is_dragging()); 99 end_selection_handle_->IsActive());
99 100
100 // It's possible that the bounds temporarily overlap while a selection handle 101 // It's possible that the bounds temporarily overlap while a selection handle
101 // is being dragged, incorrectly reporting a CENTER orientation. 102 // is being dragged, incorrectly reporting a CENTER orientation.
102 // TODO(jdduke): This safeguard is racy, as it's possible the delayed response 103 // TODO(jdduke): This safeguard is racy, as it's possible the delayed response
103 // from handle positioning occurs *after* the handle dragging has ceased. 104 // from handle positioning occurs *after* the handle dragging has ceased.
104 // Instead, prevent selection -> insertion transitions without an intervening 105 // Instead, prevent selection -> insertion transitions without an intervening
105 // action or selection clearing of some sort, crbug.com/392696. 106 // action or selection clearing of some sort, crbug.com/392696.
106 if (is_selection_dragging) { 107 if (is_selection_dragging) {
107 if (start_orientation_ == TouchHandleOrientation::CENTER) 108 if (start_orientation_ == TouchHandleOrientation::CENTER)
108 start_orientation_ = start_selection_handle_->orientation(); 109 start_orientation_ = start_selection_handle_->orientation();
(...skipping 12 matching lines...) Expand all
121 if (start_orientation_ == TouchHandleOrientation::CENTER && 122 if (start_orientation_ == TouchHandleOrientation::CENTER &&
122 selection_editable_) { 123 selection_editable_) {
123 OnInsertionChanged(); 124 OnInsertionChanged();
124 return; 125 return;
125 } 126 }
126 127
127 HideAndDisallowShowingAutomatically(); 128 HideAndDisallowShowingAutomatically();
128 } 129 }
129 130
130 bool TouchSelectionController::WillHandleTouchEvent(const MotionEvent& event) { 131 bool TouchSelectionController::WillHandleTouchEvent(const MotionEvent& event) {
132 if (longpress_drag_selector_.WillHandleTouchEvent(event))
133 return true;
134
131 if (active_status_ == INSERTION_ACTIVE) { 135 if (active_status_ == INSERTION_ACTIVE) {
132 DCHECK(insertion_handle_); 136 DCHECK(insertion_handle_);
133 return insertion_handle_->WillHandleTouchEvent(event); 137 return insertion_handle_->WillHandleTouchEvent(event);
134 } 138 }
135 139
136 if (active_status_ == SELECTION_ACTIVE) { 140 if (active_status_ == SELECTION_ACTIVE) {
137 DCHECK(start_selection_handle_); 141 DCHECK(start_selection_handle_);
138 DCHECK(end_selection_handle_); 142 DCHECK(end_selection_handle_);
139 if (start_selection_handle_->is_dragging()) 143 if (start_selection_handle_->IsActive())
140 return start_selection_handle_->WillHandleTouchEvent(event); 144 return start_selection_handle_->WillHandleTouchEvent(event);
141 145
142 if (end_selection_handle_->is_dragging()) 146 if (end_selection_handle_->IsActive())
143 return end_selection_handle_->WillHandleTouchEvent(event); 147 return end_selection_handle_->WillHandleTouchEvent(event);
144 148
145 const gfx::PointF event_pos(event.GetX(), event.GetY()); 149 const gfx::PointF event_pos(event.GetX(), event.GetY());
146 if ((event_pos - GetStartPosition()).LengthSquared() <= 150 if ((event_pos - GetStartPosition()).LengthSquared() <=
147 (event_pos - GetEndPosition()).LengthSquared()) { 151 (event_pos - GetEndPosition()).LengthSquared()) {
148 return start_selection_handle_->WillHandleTouchEvent(event); 152 return start_selection_handle_->WillHandleTouchEvent(event);
149 } 153 }
150 return end_selection_handle_->WillHandleTouchEvent(event); 154 return end_selection_handle_->WillHandleTouchEvent(event);
151 } 155 }
152 156
153 return false; 157 return false;
154 } 158 }
155 159
156 bool TouchSelectionController::WillHandleTapEvent(const gfx::PointF& location) { 160 bool TouchSelectionController::WillHandleTapEvent(const gfx::PointF& location) {
157 if (WillHandleTapOrLongPress(location)) 161 if (WillHandleTapOrLongPress(location))
158 return true; 162 return true;
159 163
160 response_pending_input_event_ = TAP; 164 response_pending_input_event_ = TAP;
161 if (active_status_ != SELECTION_ACTIVE) 165 if (active_status_ != SELECTION_ACTIVE)
162 activate_selection_automatically_ = false; 166 activate_selection_automatically_ = false;
163 ShowInsertionHandleAutomatically(); 167 ShowInsertionHandleAutomatically();
164 if (selection_empty_ && !show_on_tap_for_empty_editable_) 168 if (selection_empty_ && !show_on_tap_for_empty_editable_)
165 DeactivateInsertion(); 169 DeactivateInsertion();
166 ForceNextUpdateIfInactive(); 170 ForceNextUpdateIfInactive();
167 return false; 171 return false;
168 } 172 }
169 173
170 bool TouchSelectionController::WillHandleLongPressEvent( 174 bool TouchSelectionController::WillHandleLongPressEvent(
175 base::TimeTicks event_time,
171 const gfx::PointF& location) { 176 const gfx::PointF& location) {
172 if (WillHandleTapOrLongPress(location)) 177 if (WillHandleTapOrLongPress(location))
173 return true; 178 return true;
174 179
180 longpress_drag_selector_.OnLongPressEvent(event_time, location);
175 response_pending_input_event_ = LONG_PRESS; 181 response_pending_input_event_ = LONG_PRESS;
176 ShowSelectionHandlesAutomatically(); 182 ShowSelectionHandlesAutomatically();
177 ShowInsertionHandleAutomatically(); 183 ShowInsertionHandleAutomatically();
178 ForceNextUpdateIfInactive(); 184 ForceNextUpdateIfInactive();
179 return false; 185 return false;
180 } 186 }
181 187
182 void TouchSelectionController::AllowShowingFromCurrentSelection() { 188 void TouchSelectionController::AllowShowingFromCurrentSelection() {
183 if (active_status_ != INACTIVE) 189 if (active_status_ != INACTIVE)
184 return; 190 return;
(...skipping 13 matching lines...) Expand all
198 DeactivateInsertion(); 204 DeactivateInsertion();
199 DeactivateSelection(); 205 DeactivateSelection();
200 activate_insertion_automatically_ = false; 206 activate_insertion_automatically_ = false;
201 activate_selection_automatically_ = false; 207 activate_selection_automatically_ = false;
202 } 208 }
203 209
204 void TouchSelectionController::SetTemporarilyHidden(bool hidden) { 210 void TouchSelectionController::SetTemporarilyHidden(bool hidden) {
205 if (temporarily_hidden_ == hidden) 211 if (temporarily_hidden_ == hidden)
206 return; 212 return;
207 temporarily_hidden_ = hidden; 213 temporarily_hidden_ = hidden;
208 214 RefreshHandleVisibility();
209 TouchHandle::AnimationStyle animation_style = GetAnimationStyle(true);
210 if (active_status_ == SELECTION_ACTIVE) {
211 start_selection_handle_->SetVisible(GetStartVisible(), animation_style);
212 end_selection_handle_->SetVisible(GetEndVisible(), animation_style);
213 } else if (active_status_ == INSERTION_ACTIVE) {
214 insertion_handle_->SetVisible(GetStartVisible(), animation_style);
215 }
216 } 215 }
217 216
218 void TouchSelectionController::OnSelectionEditable(bool editable) { 217 void TouchSelectionController::OnSelectionEditable(bool editable) {
219 if (selection_editable_ == editable) 218 if (selection_editable_ == editable)
220 return; 219 return;
221 selection_editable_ = editable; 220 selection_editable_ = editable;
222 ForceNextUpdateIfInactive(); 221 ForceNextUpdateIfInactive();
223 if (!selection_editable_) 222 if (!selection_editable_)
224 DeactivateInsertion(); 223 DeactivateInsertion();
225 } 224 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 } 275 }
277 276
278 const gfx::PointF& TouchSelectionController::GetStartPosition() const { 277 const gfx::PointF& TouchSelectionController::GetStartPosition() const {
279 return start_.edge_bottom(); 278 return start_.edge_bottom();
280 } 279 }
281 280
282 const gfx::PointF& TouchSelectionController::GetEndPosition() const { 281 const gfx::PointF& TouchSelectionController::GetEndPosition() const {
283 return end_.edge_bottom(); 282 return end_.edge_bottom();
284 } 283 }
285 284
286 void TouchSelectionController::OnHandleDragBegin(const TouchHandle& handle) { 285 void TouchSelectionController::OnDragBegin(
287 if (&handle == insertion_handle_.get()) { 286 const TouchSelectionDraggable& draggable,
287 const gfx::PointF& drag_position) {
288 if (&draggable == insertion_handle_.get()) {
289 DCHECK_EQ(active_status_, INSERTION_ACTIVE);
288 client_->OnSelectionEvent(INSERTION_DRAG_STARTED); 290 client_->OnSelectionEvent(INSERTION_DRAG_STARTED);
291 drag_line_offset_ = GetStartLineOffset();
289 return; 292 return;
290 } 293 }
291 294
292 gfx::PointF base, extent; 295 DCHECK_EQ(active_status_, SELECTION_ACTIVE);
293 if (&handle == start_selection_handle_.get()) { 296
294 base = end_selection_handle_->position() + GetEndLineOffset(); 297 bool extend_selection_start = false;
295 extent = start_selection_handle_->position() + GetStartLineOffset(); 298 if (&draggable == start_selection_handle_.get()) {
299 extend_selection_start = true;
300 } else if (&draggable == end_selection_handle_.get()) {
301 extend_selection_start = false;
296 } else { 302 } else {
297 base = start_selection_handle_->position() + GetStartLineOffset(); 303 DCHECK_EQ(&draggable, &longpress_drag_selector_);
298 extent = end_selection_handle_->position() + GetEndLineOffset(); 304 extend_selection_start =
305 (drag_position - GetStartPosition()).LengthSquared() <
306 (drag_position - GetEndPosition()).LengthSquared();
299 } 307 }
308
309 gfx::PointF base = GetStartPosition() + GetStartLineOffset();
310 gfx::PointF extent = GetEndPosition() + GetEndLineOffset();
311 if (extend_selection_start) {
312 std::swap(base, extent);
313 drag_line_offset_ = GetStartLineOffset();
314 } else {
315 drag_line_offset_ = GetEndLineOffset();
316 }
317
300 selection_handle_dragged_ = true; 318 selection_handle_dragged_ = true;
301 319
302 // When moving the handle we want to move only the extent point. Before doing 320 // When moving the handle we want to move only the extent point. Before doing
303 // so we must make sure that the base point is set correctly. 321 // so we must make sure that the base point is set correctly.
304 client_->SelectBetweenCoordinates(base, extent); 322 client_->SelectBetweenCoordinates(base, extent);
305 client_->OnSelectionEvent(SELECTION_DRAG_STARTED); 323 client_->OnSelectionEvent(SELECTION_DRAG_STARTED);
306 } 324 }
307 325
308 void TouchSelectionController::OnHandleDragUpdate(const TouchHandle& handle, 326 void TouchSelectionController::OnDragUpdate(
309 const gfx::PointF& position) { 327 const TouchSelectionDraggable& draggable,
328 const gfx::PointF& drag_position) {
310 // As the position corresponds to the bottom left point of the selection 329 // As the position corresponds to the bottom left point of the selection
311 // bound, offset it by half the corresponding line height. 330 // bound, offset it by half the corresponding line height.
312 gfx::Vector2dF line_offset = &handle == start_selection_handle_.get() 331 gfx::PointF line_position = drag_position + drag_line_offset_;
313 ? GetStartLineOffset() 332 if (&draggable == insertion_handle_.get())
314 : GetEndLineOffset();
315 gfx::PointF line_position = position + line_offset;
316 if (&handle == insertion_handle_.get())
317 client_->MoveCaret(line_position); 333 client_->MoveCaret(line_position);
318 else 334 else
319 client_->MoveRangeSelectionExtent(line_position); 335 client_->MoveRangeSelectionExtent(line_position);
320 } 336 }
321 337
322 void TouchSelectionController::OnHandleDragEnd(const TouchHandle& handle) { 338 void TouchSelectionController::OnDragEnd(
323 if (&handle == insertion_handle_.get()) 339 const TouchSelectionDraggable& draggable) {
340 if (&draggable == insertion_handle_.get())
324 client_->OnSelectionEvent(INSERTION_DRAG_STOPPED); 341 client_->OnSelectionEvent(INSERTION_DRAG_STOPPED);
325 else 342 else
326 client_->OnSelectionEvent(SELECTION_DRAG_STOPPED); 343 client_->OnSelectionEvent(SELECTION_DRAG_STOPPED);
327 } 344 }
328 345
346 bool TouchSelectionController::IsWithinTapSlop(
347 const gfx::Vector2dF& delta) const {
348 return delta.LengthSquared() < tap_slop_squared_;
349 }
350
329 void TouchSelectionController::OnHandleTapped(const TouchHandle& handle) { 351 void TouchSelectionController::OnHandleTapped(const TouchHandle& handle) {
330 if (insertion_handle_ && &handle == insertion_handle_.get()) 352 if (insertion_handle_ && &handle == insertion_handle_.get())
331 client_->OnSelectionEvent(INSERTION_TAPPED); 353 client_->OnSelectionEvent(INSERTION_TAPPED);
332 } 354 }
333 355
334 void TouchSelectionController::SetNeedsAnimate() { 356 void TouchSelectionController::SetNeedsAnimate() {
335 client_->SetNeedsAnimate(); 357 client_->SetNeedsAnimate();
336 } 358 }
337 359
338 scoped_ptr<TouchHandleDrawable> TouchSelectionController::CreateDrawable() { 360 scoped_ptr<TouchHandleDrawable> TouchSelectionController::CreateDrawable() {
339 return client_->CreateDrawable(); 361 return client_->CreateDrawable();
340 } 362 }
341 363
342 base::TimeDelta TouchSelectionController::GetTapTimeout() const { 364 base::TimeDelta TouchSelectionController::GetTapTimeout() const {
343 return tap_timeout_; 365 return tap_timeout_;
344 } 366 }
345 367
346 float TouchSelectionController::GetTapSlop() const { 368 void TouchSelectionController::OnLongPressDragActiveStateChanged() {
347 return tap_slop_; 369 // The handles should remain hidden for the duration of a longpress drag,
370 // including the time between a longpress and the start of drag motion.
371 RefreshHandleVisibility();
372 }
373
374 gfx::PointF TouchSelectionController::GetSelectionStart() const {
375 return GetStartPosition();
376 }
377
378 gfx::PointF TouchSelectionController::GetSelectionEnd() const {
379 return GetEndPosition();
348 } 380 }
349 381
350 void TouchSelectionController::ShowInsertionHandleAutomatically() { 382 void TouchSelectionController::ShowInsertionHandleAutomatically() {
351 if (activate_insertion_automatically_) 383 if (activate_insertion_automatically_)
352 return; 384 return;
353 activate_insertion_automatically_ = true; 385 activate_insertion_automatically_ = true;
354 ForceNextUpdateIfInactive(); 386 ForceNextUpdateIfInactive();
355 } 387 }
356 388
357 void TouchSelectionController::ShowSelectionHandlesAutomatically() { 389 void TouchSelectionController::ShowSelectionHandlesAutomatically() {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 if (active_status_ == INACTIVE || 499 if (active_status_ == INACTIVE ||
468 response_pending_input_event_ == LONG_PRESS) { 500 response_pending_input_event_ == LONG_PRESS) {
469 if (active_status_ == SELECTION_ACTIVE) { 501 if (active_status_ == SELECTION_ACTIVE) {
470 // The active selection session finishes with the start of the new one. 502 // The active selection session finishes with the start of the new one.
471 LogSelectionEnd(); 503 LogSelectionEnd();
472 } 504 }
473 active_status_ = SELECTION_ACTIVE; 505 active_status_ = SELECTION_ACTIVE;
474 selection_handle_dragged_ = false; 506 selection_handle_dragged_ = false;
475 selection_start_time_ = base::TimeTicks::Now(); 507 selection_start_time_ = base::TimeTicks::Now();
476 response_pending_input_event_ = INPUT_EVENT_TYPE_NONE; 508 response_pending_input_event_ = INPUT_EVENT_TYPE_NONE;
509 longpress_drag_selector_.OnSelectionActivated();
477 client_->OnSelectionEvent(SELECTION_SHOWN); 510 client_->OnSelectionEvent(SELECTION_SHOWN);
478 } 511 }
479 } 512 }
480 513
481 void TouchSelectionController::DeactivateSelection() { 514 void TouchSelectionController::DeactivateSelection() {
482 if (active_status_ != SELECTION_ACTIVE) 515 if (active_status_ != SELECTION_ACTIVE)
483 return; 516 return;
484 DCHECK(start_selection_handle_); 517 DCHECK(start_selection_handle_);
485 DCHECK(end_selection_handle_); 518 DCHECK(end_selection_handle_);
486 LogSelectionEnd(); 519 LogSelectionEnd();
520 longpress_drag_selector_.OnSelectionDeactivated();
487 start_selection_handle_->SetEnabled(false); 521 start_selection_handle_->SetEnabled(false);
488 end_selection_handle_->SetEnabled(false); 522 end_selection_handle_->SetEnabled(false);
489 active_status_ = INACTIVE; 523 active_status_ = INACTIVE;
490 client_->OnSelectionEvent(SELECTION_CLEARED); 524 client_->OnSelectionEvent(SELECTION_CLEARED);
491 } 525 }
492 526
493 void TouchSelectionController::ForceNextUpdateIfInactive() { 527 void TouchSelectionController::ForceNextUpdateIfInactive() {
494 if (active_status_ == INACTIVE) 528 if (active_status_ == INACTIVE)
495 force_next_update_ = true; 529 force_next_update_ = true;
496 } 530 }
497 531
532 void TouchSelectionController::RefreshHandleVisibility() {
533 TouchHandle::AnimationStyle animation_style = GetAnimationStyle(true);
534 if (active_status_ == SELECTION_ACTIVE) {
535 start_selection_handle_->SetVisible(GetStartVisible(), animation_style);
536 end_selection_handle_->SetVisible(GetEndVisible(), animation_style);
537 }
538 if (active_status_ == INSERTION_ACTIVE)
539 insertion_handle_->SetVisible(GetStartVisible(), animation_style);
540 }
541
498 gfx::Vector2dF TouchSelectionController::GetStartLineOffset() const { 542 gfx::Vector2dF TouchSelectionController::GetStartLineOffset() const {
499 return ComputeLineOffsetFromBottom(start_); 543 return ComputeLineOffsetFromBottom(start_);
500 } 544 }
501 545
502 gfx::Vector2dF TouchSelectionController::GetEndLineOffset() const { 546 gfx::Vector2dF TouchSelectionController::GetEndLineOffset() const {
503 return ComputeLineOffsetFromBottom(end_); 547 return ComputeLineOffsetFromBottom(end_);
504 } 548 }
505 549
506 bool TouchSelectionController::GetStartVisible() const { 550 bool TouchSelectionController::GetStartVisible() const {
507 return start_.visible() && !temporarily_hidden_; 551 if (!start_.visible())
552 return false;
553
554 return !temporarily_hidden_ && !longpress_drag_selector_.IsActive();
508 } 555 }
509 556
510 bool TouchSelectionController::GetEndVisible() const { 557 bool TouchSelectionController::GetEndVisible() const {
511 return end_.visible() && !temporarily_hidden_; 558 if (!end_.visible())
559 return false;
560
561 return !temporarily_hidden_ && !longpress_drag_selector_.IsActive();
512 } 562 }
513 563
514 TouchHandle::AnimationStyle TouchSelectionController::GetAnimationStyle( 564 TouchHandle::AnimationStyle TouchSelectionController::GetAnimationStyle(
515 bool was_active) const { 565 bool was_active) const {
516 return was_active && client_->SupportsAnimation() 566 return was_active && client_->SupportsAnimation()
517 ? TouchHandle::ANIMATION_SMOOTH 567 ? TouchHandle::ANIMATION_SMOOTH
518 : TouchHandle::ANIMATION_NONE; 568 : TouchHandle::ANIMATION_NONE;
519 } 569 }
520 570
521 void TouchSelectionController::LogSelectionEnd() { 571 void TouchSelectionController::LogSelectionEnd() {
522 // TODO(mfomitchev): Once we are able to tell the difference between 572 // TODO(mfomitchev): Once we are able to tell the difference between
523 // 'successful' and 'unsuccessful' selections - log 573 // 'successful' and 'unsuccessful' selections - log
524 // Event.TouchSelection.Duration instead and get rid of 574 // Event.TouchSelection.Duration instead and get rid of
525 // Event.TouchSelectionD.WasDraggeduration. 575 // Event.TouchSelectionD.WasDraggeduration.
526 if (selection_handle_dragged_) { 576 if (selection_handle_dragged_) {
527 base::TimeDelta duration = base::TimeTicks::Now() - selection_start_time_; 577 base::TimeDelta duration = base::TimeTicks::Now() - selection_start_time_;
528 UMA_HISTOGRAM_CUSTOM_TIMES("Event.TouchSelection.WasDraggedDuration", 578 UMA_HISTOGRAM_CUSTOM_TIMES("Event.TouchSelection.WasDraggedDuration",
529 duration, 579 duration,
530 base::TimeDelta::FromMilliseconds(500), 580 base::TimeDelta::FromMilliseconds(500),
531 base::TimeDelta::FromSeconds(60), 581 base::TimeDelta::FromSeconds(60),
532 60); 582 60);
533 } 583 }
534 } 584 }
535 585
536 } // namespace ui 586 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698