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 "content/browser/renderer_host/input/selection_event_type.h" | 8 #include "content/browser/renderer_host/input/selection_event_type.h" |
9 #include "content/browser/renderer_host/input/touch_handle.h" | 9 #include "content/browser/renderer_host/input/touch_handle.h" |
10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 bool start_visible, | 51 bool start_visible, |
52 const gfx::RectF& end_rect, | 52 const gfx::RectF& end_rect, |
53 TouchHandleOrientation end_orientation, | 53 TouchHandleOrientation end_orientation, |
54 bool end_visible); | 54 bool end_visible); |
55 | 55 |
56 // Allows touch-dragging of the handle. | 56 // Allows touch-dragging of the handle. |
57 // Returns true iff the event was consumed, in which case the caller should | 57 // Returns true iff the event was consumed, in which case the caller should |
58 // cease further handling of the event. | 58 // cease further handling of the event. |
59 bool WillHandleTouchEvent(const ui::MotionEvent& event); | 59 bool WillHandleTouchEvent(const ui::MotionEvent& event); |
60 | 60 |
61 // Allow the insertion or selection handles to be shown from the data | 61 // To be called before forwarding a tap event. This allows automatically |
62 // in |OnSelectionBoundsChanged()|. | 62 // showing the insertion handle from subsequent bounds changes. |
63 void ShowInsertionHandleAutomatically(); | 63 void OnTapEvent(); |
64 void ShowSelectionHandlesAutomatically(); | 64 |
| 65 // To be called before forwarding a longpress event. This allows automatically |
| 66 // showing the selection or insertion handles from subsequent bounds changes. |
| 67 void OnLongPressEvent(); |
65 | 68 |
66 // Hide the handles and suppress bounds updates until the next explicit | 69 // Hide the handles and suppress bounds updates until the next explicit |
67 // showing allowance. | 70 // showing allowance. |
68 void HideAndDisallowAutomaticShowing(); | 71 void HideAndDisallowShowingAutomatically(); |
69 | 72 |
70 // Override the handle visibility according to |hidden|. | 73 // Override the handle visibility according to |hidden|. |
71 void SetTemporarilyHidden(bool hidden); | 74 void SetTemporarilyHidden(bool hidden); |
72 | 75 |
73 // To be called when the editability of the focused region changes. | 76 // To be called when the editability of the focused region changes. |
74 void OnSelectionEditable(bool editable); | 77 void OnSelectionEditable(bool editable); |
75 | 78 |
| 79 // To be called when the contents of the focused region changes. |
| 80 void OnSelectionEmpty(bool empty); |
| 81 |
76 // Ticks an active animation, as requested to the client by |SetNeedsAnimate|. | 82 // Ticks an active animation, as requested to the client by |SetNeedsAnimate|. |
77 // Returns true if an animation is active and requires further ticking. | 83 // Returns true if an animation is active and requires further ticking. |
78 bool Animate(base::TimeTicks animate_time); | 84 bool Animate(base::TimeTicks animate_time); |
79 | 85 |
80 private: | 86 private: |
| 87 enum InputEventType { TAP, LONG_PRESS, INPUT_EVENT_TYPE_NONE }; |
| 88 |
81 // TouchHandleClient implementation. | 89 // TouchHandleClient implementation. |
82 virtual void OnHandleDragBegin(const TouchHandle& handle) OVERRIDE; | 90 virtual void OnHandleDragBegin(const TouchHandle& handle) OVERRIDE; |
83 virtual void OnHandleDragUpdate(const TouchHandle& handle, | 91 virtual void OnHandleDragUpdate(const TouchHandle& handle, |
84 const gfx::PointF& new_position) OVERRIDE; | 92 const gfx::PointF& new_position) OVERRIDE; |
85 virtual void OnHandleDragEnd(const TouchHandle& handle) OVERRIDE; | 93 virtual void OnHandleDragEnd(const TouchHandle& handle) OVERRIDE; |
86 virtual void OnHandleTapped(const TouchHandle& handle) OVERRIDE; | 94 virtual void OnHandleTapped(const TouchHandle& handle) OVERRIDE; |
87 virtual void SetNeedsAnimate() OVERRIDE; | 95 virtual void SetNeedsAnimate() OVERRIDE; |
88 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() OVERRIDE; | 96 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() OVERRIDE; |
89 | 97 |
| 98 void ShowInsertionHandleAutomatically(); |
| 99 void ShowSelectionHandlesAutomatically(); |
| 100 |
90 void OnInsertionChanged(); | 101 void OnInsertionChanged(); |
91 void OnSelectionChanged(); | 102 void OnSelectionChanged(); |
92 | 103 |
93 void ActivateInsertion(); | 104 void ActivateInsertion(); |
94 void DeactivateInsertion(); | 105 void DeactivateInsertion(); |
95 void ActivateSelection(); | 106 void ActivateSelection(); |
96 void DeactivateSelection(); | 107 void DeactivateSelection(); |
97 void ResetCachedValues(); | 108 void ResetCachedValues(); |
98 | 109 |
99 gfx::PointF GetStartPosition() const; | 110 gfx::PointF GetStartPosition() const; |
100 gfx::PointF GetEndPosition() const; | 111 gfx::PointF GetEndPosition() const; |
101 float GetStartLineHeight() const; | 112 float GetStartLineHeight() const; |
102 float GetEndLineHeight() const; | 113 float GetEndLineHeight() const; |
103 bool GetStartVisible() const; | 114 bool GetStartVisible() const; |
104 bool GetEndVisible() const; | 115 bool GetEndVisible() const; |
105 TouchHandle::AnimationStyle GetAnimationStyle(bool was_active) const; | 116 TouchHandle::AnimationStyle GetAnimationStyle(bool was_active) const; |
106 | 117 |
107 TouchSelectionControllerClient* const client_; | 118 TouchSelectionControllerClient* const client_; |
108 | 119 |
| 120 InputEventType last_input_event_type_; |
| 121 |
109 gfx::RectF start_rect_; | 122 gfx::RectF start_rect_; |
110 TouchHandleOrientation start_orientation_; | 123 TouchHandleOrientation start_orientation_; |
111 bool start_visible_; | 124 bool start_visible_; |
112 gfx::RectF end_rect_; | 125 gfx::RectF end_rect_; |
113 TouchHandleOrientation end_orientation_; | 126 TouchHandleOrientation end_orientation_; |
114 bool end_visible_; | 127 bool end_visible_; |
115 | 128 |
116 scoped_ptr<TouchHandle> insertion_handle_; | 129 scoped_ptr<TouchHandle> insertion_handle_; |
117 bool is_insertion_active_; | 130 bool is_insertion_active_; |
118 bool activate_insertion_automatically_; | 131 bool activate_insertion_automatically_; |
119 | 132 |
120 scoped_ptr<TouchHandle> start_selection_handle_; | 133 scoped_ptr<TouchHandle> start_selection_handle_; |
121 scoped_ptr<TouchHandle> end_selection_handle_; | 134 scoped_ptr<TouchHandle> end_selection_handle_; |
122 gfx::PointF fixed_handle_position_; | 135 gfx::PointF fixed_handle_position_; |
123 bool is_selection_active_; | 136 bool is_selection_active_; |
124 bool activate_selection_automatically_; | 137 bool activate_selection_automatically_; |
125 | 138 |
| 139 bool selection_empty_; |
126 bool selection_editable_; | 140 bool selection_editable_; |
127 bool selection_editable_for_last_update_; | 141 bool selection_editable_for_last_update_; |
128 | 142 |
129 bool temporarily_hidden_; | 143 bool temporarily_hidden_; |
130 | 144 |
131 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController); | 145 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController); |
132 }; | 146 }; |
133 | 147 |
134 } // namespace content | 148 } // namespace content |
135 | 149 |
136 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_SELECTION_CONTROLLER_H_ | 150 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_SELECTION_CONTROLLER_H_ |
OLD | NEW |