Chromium Code Reviews| Index: ui/touch_selection/touch_selection_controller.h |
| diff --git a/ui/touch_selection/touch_selection_controller.h b/ui/touch_selection/touch_selection_controller.h |
| index 4f6a57832a20fafd5e17ce8fc7c0f37937025563..370bfe7214294c2427f6b0d7aca2f010c30f59eb 100644 |
| --- a/ui/touch_selection/touch_selection_controller.h |
| +++ b/ui/touch_selection/touch_selection_controller.h |
| @@ -5,9 +5,12 @@ |
| #ifndef UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_ |
| #define UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_ |
| +#include "base/time/time.h" |
| #include "ui/base/touch/selection_bound.h" |
| #include "ui/gfx/geometry/point_f.h" |
| #include "ui/gfx/geometry/rect_f.h" |
| +#include "ui/gfx/geometry/vector2d_f.h" |
| +#include "ui/touch_selection/longpress_drag_selector.h" |
| #include "ui/touch_selection/selection_event_type.h" |
| #include "ui/touch_selection/touch_handle.h" |
| #include "ui/touch_selection/touch_handle_orientation.h" |
| @@ -34,7 +37,8 @@ class UI_TOUCH_SELECTION_EXPORT TouchSelectionControllerClient { |
| // Controller for manipulating text selection via touch input. |
| class UI_TOUCH_SELECTION_EXPORT TouchSelectionController |
| - : public TouchHandleClient { |
| + : public TouchHandleClient, |
| + public LongPressDragSelectorClient { |
| public: |
| enum ActiveStatus { |
| INACTIVE, |
| @@ -65,7 +69,8 @@ class UI_TOUCH_SELECTION_EXPORT TouchSelectionController |
| // To be called before forwarding a longpress event. This allows automatically |
| // showing the selection or insertion handles from subsequent bounds changes. |
| - void OnLongPressEvent(); |
| + void OnLongPressEvent(base::TimeTicks event_time, |
| + const gfx::PointF& location); |
| // Allow showing the selection handles from the most recent selection bounds |
| // update (if valid), or a future valid bounds update. |
| @@ -103,6 +108,11 @@ class UI_TOUCH_SELECTION_EXPORT TouchSelectionController |
| const gfx::PointF& GetStartPosition() const; |
| const gfx::PointF& GetEndPosition() const; |
| + // Whether the specified touch handle is visible, both as indicated by the |
| + // renderer and for any temporary visibility overrides. |
| + bool GetStartVisibleForTesting() const; |
|
mfomitchev
2015/05/13 20:52:25
How about creating TouchSelectionControllerTestApi
jdduke (slow)
2015/05/14 18:29:26
Sure.
|
| + bool GetEndVisibleForTesting() const; |
| + |
| const SelectionBound& start() const { return start_; } |
| const SelectionBound& end() const { return end_; } |
| @@ -112,15 +122,21 @@ class UI_TOUCH_SELECTION_EXPORT TouchSelectionController |
| enum InputEventType { TAP, LONG_PRESS, INPUT_EVENT_TYPE_NONE }; |
| // TouchHandleClient implementation. |
| - void OnHandleDragBegin(const TouchHandle& handle) override; |
| - void OnHandleDragUpdate(const TouchHandle& handle, |
| - const gfx::PointF& new_position) override; |
| - void OnHandleDragEnd(const TouchHandle& handle) override; |
| + void OnDragBegin(const TouchSelectionDraggable& draggable, |
| + const gfx::PointF& drag_position) override; |
| + void OnDragUpdate(const TouchSelectionDraggable& draggable, |
| + const gfx::PointF& drag_position) override; |
| + void OnDragEnd(const TouchSelectionDraggable& draggable) override; |
| + bool IsWithinTapSlop(const gfx::Vector2dF& delta) const override; |
| void OnHandleTapped(const TouchHandle& handle) override; |
| void SetNeedsAnimate() override; |
| scoped_ptr<TouchHandleDrawable> CreateDrawable() override; |
| base::TimeDelta GetTapTimeout() const override; |
| - float GetTapSlop() const override; |
| + |
| + // LongPressDragSelectorClient implementation. |
| + void OnLongPressDragActiveStateChanged() override; |
| + gfx::PointF GetSelectionStart() const override; |
| + gfx::PointF GetSelectionEnd() const override; |
| void ShowInsertionHandleAutomatically(); |
| void ShowSelectionHandlesAutomatically(); |
| @@ -134,6 +150,10 @@ class UI_TOUCH_SELECTION_EXPORT TouchSelectionController |
| void DeactivateSelection(); |
| void ForceNextUpdateIfInactive(); |
| + bool WillHandleTouchEventForLongPressDrag(const MotionEvent& event); |
| + void SetTemporarilyHiddenForLongPressDrag(bool hidden); |
| + void RefreshHandleVisibility(); |
| + |
| gfx::Vector2dF GetStartLineOffset() const; |
| gfx::Vector2dF GetEndLineOffset() const; |
| bool GetStartVisible() const; |
| @@ -144,7 +164,7 @@ class UI_TOUCH_SELECTION_EXPORT TouchSelectionController |
| TouchSelectionControllerClient* const client_; |
| const base::TimeDelta tap_timeout_; |
| - const float tap_slop_; |
| + const double tap_slop_squared_; |
| // Whether to force an update on the next selection event even if the |
| // cached selection matches the new selection. |
| @@ -175,6 +195,14 @@ class UI_TOUCH_SELECTION_EXPORT TouchSelectionController |
| bool temporarily_hidden_; |
| + // Offset from the start of a drag sequence to a reasonable position on the |
| + // corresponding line of text. This helps ensure that the initial selection |
| + // induced by the drag doesn't "jump" between lines. |
| + gfx::Vector2dF drag_line_offset_; |
| + |
| + // Longpress drag allows direct manipulation of longpress-initiated selection. |
| + LongPressDragSelector longpress_drag_selector_; |
| + |
| base::TimeTicks selection_start_time_; |
| // Whether a selection handle was dragged during the current 'selection |
| // session' - i.e. since the current selection has been activated. |