OLD | NEW |
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 CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_SELECTION_CONTROLLER_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_SELECTION_CONTROLLER_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_SELECTION_CONTROLLER_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_SELECTION_CONTROLLER_H_ |
7 | 7 |
8 #include "cc/output/viewport_selection_bound.h" | 8 #include "cc/output/viewport_selection_bound.h" |
9 #include "content/browser/renderer_host/input/selection_event_type.h" | 9 #include "content/browser/renderer_host/input/selection_event_type.h" |
10 #include "content/browser/renderer_host/input/touch_handle.h" | 10 #include "content/browser/renderer_host/input/touch_handle.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 virtual void SelectBetweenCoordinates(const gfx::PointF& start, | 34 virtual void SelectBetweenCoordinates(const gfx::PointF& start, |
35 const gfx::PointF& end) = 0; | 35 const gfx::PointF& end) = 0; |
36 virtual void OnSelectionEvent(SelectionEventType event, | 36 virtual void OnSelectionEvent(SelectionEventType event, |
37 const gfx::PointF& position) = 0; | 37 const gfx::PointF& position) = 0; |
38 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() = 0; | 38 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() = 0; |
39 }; | 39 }; |
40 | 40 |
41 // Controller for manipulating text selection via touch input. | 41 // Controller for manipulating text selection via touch input. |
42 class CONTENT_EXPORT TouchSelectionController : public TouchHandleClient { | 42 class CONTENT_EXPORT TouchSelectionController : public TouchHandleClient { |
43 public: | 43 public: |
44 explicit TouchSelectionController(TouchSelectionControllerClient* client); | 44 TouchSelectionController(TouchSelectionControllerClient* client, |
| 45 base::TimeDelta tap_timeout, |
| 46 float tap_slop); |
45 virtual ~TouchSelectionController(); | 47 virtual ~TouchSelectionController(); |
46 | 48 |
47 // To be called when the selection bounds have changed. | 49 // To be called when the selection bounds have changed. |
48 // Note that such updates will trigger handle updates only if preceded | 50 // Note that such updates will trigger handle updates only if preceded |
49 // by an appropriate call to allow automatic showing. | 51 // by an appropriate call to allow automatic showing. |
50 void OnSelectionBoundsChanged(const cc::ViewportSelectionBound& start, | 52 void OnSelectionBoundsChanged(const cc::ViewportSelectionBound& start, |
51 const cc::ViewportSelectionBound& end); | 53 const cc::ViewportSelectionBound& end); |
52 | 54 |
53 // Allows touch-dragging of the handle. | 55 // Allows touch-dragging of the handle. |
54 // Returns true iff the event was consumed, in which case the caller should | 56 // Returns true iff the event was consumed, in which case the caller should |
(...skipping 29 matching lines...) Expand all Loading... |
84 enum InputEventType { TAP, LONG_PRESS, INPUT_EVENT_TYPE_NONE }; | 86 enum InputEventType { TAP, LONG_PRESS, INPUT_EVENT_TYPE_NONE }; |
85 | 87 |
86 // TouchHandleClient implementation. | 88 // TouchHandleClient implementation. |
87 virtual void OnHandleDragBegin(const TouchHandle& handle) OVERRIDE; | 89 virtual void OnHandleDragBegin(const TouchHandle& handle) OVERRIDE; |
88 virtual void OnHandleDragUpdate(const TouchHandle& handle, | 90 virtual void OnHandleDragUpdate(const TouchHandle& handle, |
89 const gfx::PointF& new_position) OVERRIDE; | 91 const gfx::PointF& new_position) OVERRIDE; |
90 virtual void OnHandleDragEnd(const TouchHandle& handle) OVERRIDE; | 92 virtual void OnHandleDragEnd(const TouchHandle& handle) OVERRIDE; |
91 virtual void OnHandleTapped(const TouchHandle& handle) OVERRIDE; | 93 virtual void OnHandleTapped(const TouchHandle& handle) OVERRIDE; |
92 virtual void SetNeedsAnimate() OVERRIDE; | 94 virtual void SetNeedsAnimate() OVERRIDE; |
93 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() OVERRIDE; | 95 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() OVERRIDE; |
| 96 virtual base::TimeDelta GetTapTimeout() const OVERRIDE; |
| 97 virtual float GetTapSlop() const OVERRIDE; |
94 | 98 |
95 void ShowInsertionHandleAutomatically(); | 99 void ShowInsertionHandleAutomatically(); |
96 void ShowSelectionHandlesAutomatically(); | 100 void ShowSelectionHandlesAutomatically(); |
97 | 101 |
98 void OnInsertionChanged(); | 102 void OnInsertionChanged(); |
99 void OnSelectionChanged(); | 103 void OnSelectionChanged(); |
100 | 104 |
101 void ActivateInsertion(); | 105 void ActivateInsertion(); |
102 void DeactivateInsertion(); | 106 void DeactivateInsertion(); |
103 void ActivateSelection(); | 107 void ActivateSelection(); |
104 void DeactivateSelection(); | 108 void DeactivateSelection(); |
105 void ResetCachedValuesIfInactive(); | 109 void ResetCachedValuesIfInactive(); |
106 | 110 |
107 const gfx::PointF& GetStartPosition() const; | 111 const gfx::PointF& GetStartPosition() const; |
108 const gfx::PointF& GetEndPosition() const; | 112 const gfx::PointF& GetEndPosition() const; |
109 gfx::Vector2dF GetStartLineOffset() const; | 113 gfx::Vector2dF GetStartLineOffset() const; |
110 gfx::Vector2dF GetEndLineOffset() const; | 114 gfx::Vector2dF GetEndLineOffset() const; |
111 bool GetStartVisible() const; | 115 bool GetStartVisible() const; |
112 bool GetEndVisible() const; | 116 bool GetEndVisible() const; |
113 TouchHandle::AnimationStyle GetAnimationStyle(bool was_active) const; | 117 TouchHandle::AnimationStyle GetAnimationStyle(bool was_active) const; |
114 | 118 |
115 TouchSelectionControllerClient* const client_; | 119 TouchSelectionControllerClient* const client_; |
| 120 const base::TimeDelta tap_timeout_; |
| 121 const float tap_slop_; |
116 | 122 |
117 InputEventType response_pending_input_event_; | 123 InputEventType response_pending_input_event_; |
118 | 124 |
119 cc::ViewportSelectionBound start_; | 125 cc::ViewportSelectionBound start_; |
120 cc::ViewportSelectionBound end_; | 126 cc::ViewportSelectionBound end_; |
121 TouchHandleOrientation start_orientation_; | 127 TouchHandleOrientation start_orientation_; |
122 TouchHandleOrientation end_orientation_; | 128 TouchHandleOrientation end_orientation_; |
123 | 129 |
124 scoped_ptr<TouchHandle> insertion_handle_; | 130 scoped_ptr<TouchHandle> insertion_handle_; |
125 bool is_insertion_active_; | 131 bool is_insertion_active_; |
126 bool activate_insertion_automatically_; | 132 bool activate_insertion_automatically_; |
127 | 133 |
128 scoped_ptr<TouchHandle> start_selection_handle_; | 134 scoped_ptr<TouchHandle> start_selection_handle_; |
129 scoped_ptr<TouchHandle> end_selection_handle_; | 135 scoped_ptr<TouchHandle> end_selection_handle_; |
130 gfx::PointF fixed_handle_position_; | 136 gfx::PointF fixed_handle_position_; |
131 bool is_selection_active_; | 137 bool is_selection_active_; |
132 bool activate_selection_automatically_; | 138 bool activate_selection_automatically_; |
133 | 139 |
134 bool selection_empty_; | 140 bool selection_empty_; |
135 bool selection_editable_; | 141 bool selection_editable_; |
136 | 142 |
137 bool temporarily_hidden_; | 143 bool temporarily_hidden_; |
138 | 144 |
139 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController); | 145 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController); |
140 }; | 146 }; |
141 | 147 |
142 } // namespace content | 148 } // namespace content |
143 | 149 |
144 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_SELECTION_CONTROLLER_H_ | 150 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_SELECTION_CONTROLLER_H_ |
OLD | NEW |