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

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

Issue 698253004: Reland: Implement Aura side of unified touch text selection for contents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Improved tap-on-selection tests Created 5 years, 9 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
106 start_orientation_ = start_selection_handle_->orientation(); 106 start_orientation_ = start_selection_handle_->orientation();
107 if (end_orientation_ == TOUCH_HANDLE_CENTER) 107 if (end_orientation_ == TOUCH_HANDLE_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_ != TOUCH_HANDLE_ORIENTATION_UNDEFINED && 113 start_orientation_ != TOUCH_HANDLE_ORIENTATION_UNDEFINED &&
114 end_orientation_ != TOUCH_HANDLE_ORIENTATION_UNDEFINED)) { 114 end_orientation_ != TOUCH_HANDLE_ORIENTATION_UNDEFINED)) {
115 OnSelectionChanged(); 115 OnSelectionChanged();
116 return; 116 return true;
117 } 117 }
118 118
119 if (start_orientation_ == TOUCH_HANDLE_CENTER && selection_editable_) { 119 if (start_orientation_ == TOUCH_HANDLE_CENTER && selection_editable_) {
120 OnInsertionChanged(); 120 OnInsertionChanged();
121 return; 121 return true;
122 } 122 }
123 123
124 HideAndDisallowShowingAutomatically(); 124 HideAndDisallowShowingAutomatically();
125 return true;
125 } 126 }
126 127
127 bool TouchSelectionController::WillHandleTouchEvent(const MotionEvent& event) { 128 bool TouchSelectionController::WillHandleTouchEvent(const MotionEvent& event) {
128 if (is_insertion_active_) { 129 if (is_insertion_active_) {
129 DCHECK(insertion_handle_); 130 DCHECK(insertion_handle_);
130 return insertion_handle_->WillHandleTouchEvent(event); 131 return insertion_handle_->WillHandleTouchEvent(event);
131 } 132 }
132 133
133 if (is_selection_active_) { 134 if (is_selection_active_) {
134 DCHECK(start_selection_handle_); 135 DCHECK(start_selection_handle_);
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 base::TimeDelta duration = base::TimeTicks::Now() - selection_start_time_; 466 base::TimeDelta duration = base::TimeTicks::Now() - selection_start_time_;
466 UMA_HISTOGRAM_CUSTOM_TIMES("Event.TouchSelection.WasDraggedDuration", 467 UMA_HISTOGRAM_CUSTOM_TIMES("Event.TouchSelection.WasDraggedDuration",
467 duration, 468 duration,
468 base::TimeDelta::FromMilliseconds(500), 469 base::TimeDelta::FromMilliseconds(500),
469 base::TimeDelta::FromSeconds(60), 470 base::TimeDelta::FromSeconds(60),
470 60); 471 60);
471 } 472 }
472 } 473 }
473 474
474 } // namespace ui 475 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698