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 7ec25d1d442e6d13bbdcb9c7990f4e61120e039d..73e295949caec72a57650452701514c38c0931d4 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. |
- bool WillHandleLongPressEvent(const gfx::PointF& location); |
+ bool WillHandleLongPressEvent(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. |
@@ -109,18 +114,26 @@ class UI_TOUCH_SELECTION_EXPORT TouchSelectionController |
ActiveStatus active_status() const { return active_status_; } |
private: |
+ friend class TouchSelectionControllerTestApi; |
+ |
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(); |
@@ -135,6 +148,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; |
@@ -145,7 +162,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. |
@@ -176,6 +193,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. |