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

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

Issue 2201853002: Blink handle selection handle visibility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: default handle visibility should be false Created 4 years, 4 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 #ifndef UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_ 5 #ifndef UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_
6 #define UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_ 6 #define UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "ui/gfx/geometry/point_f.h" 10 #include "ui/gfx/geometry/point_f.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 99
100 // To be called before forwarding a longpress event. This allows automatically 100 // To be called before forwarding a longpress event. This allows automatically
101 // showing the selection or insertion handles from subsequent bounds changes. 101 // showing the selection or insertion handles from subsequent bounds changes.
102 bool WillHandleLongPressEvent(base::TimeTicks event_time, 102 bool WillHandleLongPressEvent(base::TimeTicks event_time,
103 const gfx::PointF& location); 103 const gfx::PointF& location);
104 104
105 // To be called before forwarding a gesture scroll begin event to prevent 105 // To be called before forwarding a gesture scroll begin event to prevent
106 // long-press drag. 106 // long-press drag.
107 void OnScrollBeginEvent(); 107 void OnScrollBeginEvent();
108 108
109 // Allow showing the selection handles from the most recent selection bounds
110 // update (if valid), or a future valid bounds update.
111 void AllowShowingFromCurrentSelection();
112
113 // Hide the handles and suppress bounds updates until the next explicit 109 // Hide the handles and suppress bounds updates until the next explicit
114 // showing allowance. 110 // showing allowance.
115 void HideAndDisallowShowingAutomatically(); 111 void HideAndDisallowShowingAutomatically();
116 112
117 // Override the handle visibility according to |hidden|. 113 // Override the handle visibility according to |hidden|.
118 void SetTemporarilyHidden(bool hidden); 114 void SetTemporarilyHidden(bool hidden);
119 115
120 // To be called when the editability of the focused region changes. 116 // To be called when the editability of the focused region changes.
121 void OnSelectionEditable(bool editable); 117 void OnSelectionEditable(bool editable);
122 118
(...skipping 17 matching lines...) Expand all
140 // Returns the focal point of the start and end bounds, as defined by 136 // Returns the focal point of the start and end bounds, as defined by
141 // their bottom coordinate. 137 // their bottom coordinate.
142 const gfx::PointF& GetStartPosition() const; 138 const gfx::PointF& GetStartPosition() const;
143 const gfx::PointF& GetEndPosition() const; 139 const gfx::PointF& GetEndPosition() const;
144 140
145 const gfx::SelectionBound& start() const { return start_; } 141 const gfx::SelectionBound& start() const { return start_; }
146 const gfx::SelectionBound& end() const { return end_; } 142 const gfx::SelectionBound& end() const { return end_; }
147 143
148 ActiveStatus active_status() const { return active_status_; } 144 ActiveStatus active_status() const { return active_status_; }
149 145
150 bool insertion_active_or_requested() const {
151 return activate_insertion_automatically_;
152 }
153
154 private: 146 private:
155 friend class TouchSelectionControllerTestApi; 147 friend class TouchSelectionControllerTestApi;
156 148
157 enum InputEventType { TAP, REPEATED_TAP, LONG_PRESS, INPUT_EVENT_TYPE_NONE }; 149 enum InputEventType { TAP, REPEATED_TAP, LONG_PRESS, INPUT_EVENT_TYPE_NONE };
158 150
159 // TouchHandleClient implementation. 151 // TouchHandleClient implementation.
160 void OnDragBegin(const TouchSelectionDraggable& draggable, 152 void OnDragBegin(const TouchSelectionDraggable& draggable,
161 const gfx::PointF& drag_position) override; 153 const gfx::PointF& drag_position) override;
162 void OnDragUpdate(const TouchSelectionDraggable& draggable, 154 void OnDragUpdate(const TouchSelectionDraggable& draggable,
163 const gfx::PointF& drag_position) override; 155 const gfx::PointF& drag_position) override;
164 void OnDragEnd(const TouchSelectionDraggable& draggable) override; 156 void OnDragEnd(const TouchSelectionDraggable& draggable) override;
165 bool IsWithinTapSlop(const gfx::Vector2dF& delta) const override; 157 bool IsWithinTapSlop(const gfx::Vector2dF& delta) const override;
166 void OnHandleTapped(const TouchHandle& handle) override; 158 void OnHandleTapped(const TouchHandle& handle) override;
167 void SetNeedsAnimate() override; 159 void SetNeedsAnimate() override;
168 std::unique_ptr<TouchHandleDrawable> CreateDrawable() override; 160 std::unique_ptr<TouchHandleDrawable> CreateDrawable() override;
169 base::TimeDelta GetMaxTapDuration() const override; 161 base::TimeDelta GetMaxTapDuration() const override;
170 bool IsAdaptiveHandleOrientationEnabled() const override; 162 bool IsAdaptiveHandleOrientationEnabled() const override;
171 163
172 // LongPressDragSelectorClient implementation. 164 // LongPressDragSelectorClient implementation.
173 void OnLongPressDragActiveStateChanged() override; 165 void OnLongPressDragActiveStateChanged() override;
174 gfx::PointF GetSelectionStart() const override; 166 gfx::PointF GetSelectionStart() const override;
175 gfx::PointF GetSelectionEnd() const override; 167 gfx::PointF GetSelectionEnd() const override;
176 168
177 void ShowInsertionHandleAutomatically();
178 void ShowSelectionHandlesAutomatically();
179 bool WillHandleTapOrLongPress(const gfx::PointF& location); 169 bool WillHandleTapOrLongPress(const gfx::PointF& location);
180 170
181 void OnInsertionChanged(); 171 void OnInsertionChanged();
182 void OnSelectionChanged(); 172 void OnSelectionChanged();
183 173
184 // Returns true if insertion mode was newly (re)activated. 174 // Returns true if insertion mode was newly (re)activated.
185 bool ActivateInsertionIfNecessary(); 175 bool ActivateInsertionIfNecessary();
186 void DeactivateInsertion(); 176 void DeactivateInsertion();
187 // Returns true if selection mode was newly (re)activated. 177 // Returns true if selection mode was newly (re)activated.
188 bool ActivateSelectionIfNecessary(); 178 bool ActivateSelectionIfNecessary();
(...skipping 23 matching lines...) Expand all
212 InputEventType response_pending_input_event_; 202 InputEventType response_pending_input_event_;
213 203
214 gfx::SelectionBound start_; 204 gfx::SelectionBound start_;
215 gfx::SelectionBound end_; 205 gfx::SelectionBound end_;
216 TouchHandleOrientation start_orientation_; 206 TouchHandleOrientation start_orientation_;
217 TouchHandleOrientation end_orientation_; 207 TouchHandleOrientation end_orientation_;
218 208
219 ActiveStatus active_status_; 209 ActiveStatus active_status_;
220 210
221 std::unique_ptr<TouchHandle> insertion_handle_; 211 std::unique_ptr<TouchHandle> insertion_handle_;
222 bool activate_insertion_automatically_;
223 212
224 std::unique_ptr<TouchHandle> start_selection_handle_; 213 std::unique_ptr<TouchHandle> start_selection_handle_;
225 std::unique_ptr<TouchHandle> end_selection_handle_; 214 std::unique_ptr<TouchHandle> end_selection_handle_;
226 bool activate_selection_automatically_;
227 215
228 bool selection_empty_; 216 bool selection_empty_;
229 bool selection_editable_; 217 bool selection_editable_;
230 218
231 bool temporarily_hidden_; 219 bool temporarily_hidden_;
232 220
233 // Whether to use the start bound (if false, the end bound) for computing the 221 // Whether to use the start bound (if false, the end bound) for computing the
234 // appropriate text line offset when performing a selection drag. This helps 222 // appropriate text line offset when performing a selection drag. This helps
235 // ensure that the initial selection induced by the drag doesn't "jump" 223 // ensure that the initial selection induced by the drag doesn't "jump"
236 // between lines. 224 // between lines.
237 bool anchor_drag_to_selection_start_; 225 bool anchor_drag_to_selection_start_;
238 226
239 // Longpress drag allows direct manipulation of longpress-initiated selection. 227 // Longpress drag allows direct manipulation of longpress-initiated selection.
240 LongPressDragSelector longpress_drag_selector_; 228 LongPressDragSelector longpress_drag_selector_;
241 229
242 gfx::RectF viewport_rect_; 230 gfx::RectF viewport_rect_;
243 231
244 base::TimeTicks selection_start_time_; 232 base::TimeTicks selection_start_time_;
245 // Whether a selection handle was dragged during the current 'selection 233 // Whether a selection handle was dragged during the current 'selection
246 // session' - i.e. since the current selection has been activated. 234 // session' - i.e. since the current selection has been activated.
247 bool selection_handle_dragged_; 235 bool selection_handle_dragged_;
248 236
249 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController); 237 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController);
250 }; 238 };
251 239
252 } // namespace ui 240 } // namespace ui
253 241
254 #endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_ 242 #endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698