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 UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_SELECTION_CONTROLLER_H_ | 6 #define UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_ |
7 | 7 |
8 #include "cc/output/viewport_selection_bound.h" | 8 #include "ui/base/touch/selection_bound.h" |
9 #include "content/browser/renderer_host/input/selection_event_type.h" | |
10 #include "content/browser/renderer_host/input/touch_handle.h" | |
11 #include "content/common/content_export.h" | |
12 #include "ui/gfx/geometry/point_f.h" | 9 #include "ui/gfx/geometry/point_f.h" |
13 #include "ui/gfx/geometry/rect_f.h" | 10 #include "ui/gfx/geometry/rect_f.h" |
14 | 11 #include "ui/touch_selection/selection_event_type.h" |
15 namespace blink { | 12 #include "ui/touch_selection/touch_handle.h" |
mfomitchev
2014/12/01 21:36:24
We only need to import selection_bound.h, not all
mohsen
2014/12/02 05:17:03
We're using a lot from touch_handle.h (e.g. subcla
| |
16 class WebInputEvent; | 13 #include "ui/touch_selection/ui_touch_selection_export.h" |
17 } | |
18 | 14 |
19 namespace ui { | 15 namespace ui { |
16 | |
mfomitchev
2014/12/01 21:36:24
I think the convention is no blank line in spots l
mohsen
2014/12/02 05:17:03
Done.
| |
20 class MotionEvent; | 17 class MotionEvent; |
21 } | |
22 | |
23 namespace content { | |
24 | 18 |
25 // Interface through which |TouchSelectionController| issues selection-related | 19 // Interface through which |TouchSelectionController| issues selection-related |
26 // commands, notifications and requests. | 20 // commands, notifications and requests. |
27 class CONTENT_EXPORT TouchSelectionControllerClient { | 21 class UI_TOUCH_SELECTION_EXPORT TouchSelectionControllerClient { |
28 public: | 22 public: |
29 virtual ~TouchSelectionControllerClient() {} | 23 virtual ~TouchSelectionControllerClient() {} |
30 | 24 |
31 virtual bool SupportsAnimation() const = 0; | 25 virtual bool SupportsAnimation() const = 0; |
32 virtual void SetNeedsAnimate() = 0; | 26 virtual void SetNeedsAnimate() = 0; |
33 virtual void MoveCaret(const gfx::PointF& position) = 0; | 27 virtual void MoveCaret(const gfx::PointF& position) = 0; |
34 virtual void MoveRangeSelectionExtent(const gfx::PointF& extent) = 0; | 28 virtual void MoveRangeSelectionExtent(const gfx::PointF& extent) = 0; |
35 virtual void SelectBetweenCoordinates(const gfx::PointF& base, | 29 virtual void SelectBetweenCoordinates(const gfx::PointF& base, |
36 const gfx::PointF& extent) = 0; | 30 const gfx::PointF& extent) = 0; |
37 virtual void OnSelectionEvent(SelectionEventType event, | 31 virtual void OnSelectionEvent(SelectionEventType event, |
38 const gfx::PointF& position) = 0; | 32 const gfx::PointF& position) = 0; |
39 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() = 0; | 33 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() = 0; |
40 }; | 34 }; |
41 | 35 |
42 // Controller for manipulating text selection via touch input. | 36 // Controller for manipulating text selection via touch input. |
43 class CONTENT_EXPORT TouchSelectionController : public TouchHandleClient { | 37 class UI_TOUCH_SELECTION_EXPORT TouchSelectionController |
38 : public TouchHandleClient { | |
44 public: | 39 public: |
45 TouchSelectionController(TouchSelectionControllerClient* client, | 40 TouchSelectionController(TouchSelectionControllerClient* client, |
46 base::TimeDelta tap_timeout, | 41 base::TimeDelta tap_timeout, |
47 float tap_slop); | 42 float tap_slop); |
48 ~TouchSelectionController() override; | 43 ~TouchSelectionController() override; |
49 | 44 |
50 // To be called when the selection bounds have changed. | 45 // To be called when the selection bounds have changed. |
51 // Note that such updates will trigger handle updates only if preceded | 46 // Note that such updates will trigger handle updates only if preceded |
52 // by an appropriate call to allow automatic showing. | 47 // by an appropriate call to allow automatic showing. |
53 void OnSelectionBoundsChanged(const cc::ViewportSelectionBound& start, | 48 void OnSelectionBoundsChanged(const SelectionBound& start, |
54 const cc::ViewportSelectionBound& end); | 49 const SelectionBound& end); |
55 | 50 |
56 // Allows touch-dragging of the handle. | 51 // Allows touch-dragging of the handle. |
57 // Returns true iff the event was consumed, in which case the caller should | 52 // Returns true iff the event was consumed, in which case the caller should |
58 // cease further handling of the event. | 53 // cease further handling of the event. |
59 bool WillHandleTouchEvent(const ui::MotionEvent& event); | 54 bool WillHandleTouchEvent(const MotionEvent& event); |
60 | 55 |
61 // To be called before forwarding a tap event. This allows automatically | 56 // To be called before forwarding a tap event. This allows automatically |
62 // showing the insertion handle from subsequent bounds changes. | 57 // showing the insertion handle from subsequent bounds changes. |
63 void OnTapEvent(); | 58 void OnTapEvent(); |
64 | 59 |
65 // To be called before forwarding a longpress event. This allows automatically | 60 // To be called before forwarding a longpress event. This allows automatically |
66 // showing the selection or insertion handles from subsequent bounds changes. | 61 // showing the selection or insertion handles from subsequent bounds changes. |
67 void OnLongPressEvent(); | 62 void OnLongPressEvent(); |
68 | 63 |
69 // Allow showing the selection handles from the most recent selection bounds | 64 // Allow showing the selection handles from the most recent selection bounds |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 bool GetStartVisible() const; | 115 bool GetStartVisible() const; |
121 bool GetEndVisible() const; | 116 bool GetEndVisible() const; |
122 TouchHandle::AnimationStyle GetAnimationStyle(bool was_active) const; | 117 TouchHandle::AnimationStyle GetAnimationStyle(bool was_active) const; |
123 | 118 |
124 TouchSelectionControllerClient* const client_; | 119 TouchSelectionControllerClient* const client_; |
125 const base::TimeDelta tap_timeout_; | 120 const base::TimeDelta tap_timeout_; |
126 const float tap_slop_; | 121 const float tap_slop_; |
127 | 122 |
128 InputEventType response_pending_input_event_; | 123 InputEventType response_pending_input_event_; |
129 | 124 |
130 cc::ViewportSelectionBound start_; | 125 SelectionBound start_; |
131 cc::ViewportSelectionBound end_; | 126 SelectionBound end_; |
132 TouchHandleOrientation start_orientation_; | 127 TouchHandleOrientation start_orientation_; |
133 TouchHandleOrientation end_orientation_; | 128 TouchHandleOrientation end_orientation_; |
134 | 129 |
135 scoped_ptr<TouchHandle> insertion_handle_; | 130 scoped_ptr<TouchHandle> insertion_handle_; |
136 bool is_insertion_active_; | 131 bool is_insertion_active_; |
137 bool activate_insertion_automatically_; | 132 bool activate_insertion_automatically_; |
138 | 133 |
139 scoped_ptr<TouchHandle> start_selection_handle_; | 134 scoped_ptr<TouchHandle> start_selection_handle_; |
140 scoped_ptr<TouchHandle> end_selection_handle_; | 135 scoped_ptr<TouchHandle> end_selection_handle_; |
141 bool is_selection_active_; | 136 bool is_selection_active_; |
142 bool activate_selection_automatically_; | 137 bool activate_selection_automatically_; |
143 | 138 |
144 bool selection_empty_; | 139 bool selection_empty_; |
145 bool selection_editable_; | 140 bool selection_editable_; |
146 | 141 |
147 bool temporarily_hidden_; | 142 bool temporarily_hidden_; |
148 | 143 |
149 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController); | 144 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController); |
150 }; | 145 }; |
151 | 146 |
152 } // namespace content | 147 } // namespace ui |
153 | 148 |
154 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_SELECTION_CONTROLLER_H_ | 149 #endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_H_ |
OLD | NEW |