[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 1 | // Copyright 2011 The Chromium Authors. All rights reserved. |
[email protected] | 0fb2500 | 2012-10-12 07:20:02 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 4 | |
[email protected] | 3052b10f | 2013-03-18 07:41:21 | [diff] [blame] | 5 | #ifndef CC_INPUT_INPUT_HANDLER_H_ |
| 6 | #define CC_INPUT_INPUT_HANDLER_H_ |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 7 | |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 8 | #include <memory> |
| 9 | |
[email protected] | 1b0df50 | 2013-06-27 23:39:58 | [diff] [blame] | 10 | #include "base/time/time.h" |
chrishtr | ac41ff9 | 2017-03-17 05:07:30 | [diff] [blame] | 11 | #include "cc/cc_export.h" |
dtapuska | f206a40d | 2016-02-05 21:36:02 | [diff] [blame] | 12 | #include "cc/input/event_listener_properties.h" |
danakj | 3590476 | 2016-01-21 20:49:40 | [diff] [blame] | 13 | #include "cc/input/main_thread_scrolling_reason.h" |
Sandra Sun | 2288e853 | 2017-11-30 22:50:16 | [diff] [blame] | 14 | #include "cc/input/overscroll_behavior.h" |
majidvp | 944a8cd | 2016-01-12 21:05:18 | [diff] [blame] | 15 | #include "cc/input/scroll_state.h" |
[email protected] | c28df4c1 | 2013-05-22 17:36:49 | [diff] [blame] | 16 | #include "cc/input/scrollbar.h" |
Hayley Ferr | 2b14e2a6c | 2017-07-04 17:34:43 | [diff] [blame] | 17 | #include "cc/input/touch_action.h" |
Xida Chen | af5964b3 | 2019-07-18 19:44:22 | [diff] [blame] | 18 | #include "cc/paint/element_id.h" |
jamesr | f313a21 | 2015-03-16 21:27:37 | [diff] [blame] | 19 | #include "cc/trees/swap_promise_monitor.h" |
Ella Ge | 7393cf9 | 2019-07-09 21:52:59 | [diff] [blame] | 20 | #include "components/viz/common/frame_sinks/begin_frame_args.h" |
Daniel Libby | e15b80b | 2019-05-24 17:18:24 | [diff] [blame] | 21 | #include "ui/events/types/scroll_types.h" |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 22 | |
[email protected] | d455d55 | 2012-11-02 00:19:06 | [diff] [blame] | 23 | namespace gfx { |
| 24 | class Point; |
danakj | 0481b57 | 2015-09-10 01:18:01 | [diff] [blame] | 25 | class ScrollOffset; |
danakj | ddaec91 | 2015-09-25 19:38:40 | [diff] [blame] | 26 | class SizeF; |
[email protected] | 240376c | 2013-03-07 04:12:34 | [diff] [blame] | 27 | class Vector2dF; |
Kaan Alsan | 8e49b3c3 | 2019-10-30 20:04:42 | [diff] [blame] | 28 | } // namespace gfx |
[email protected] | d455d55 | 2012-11-02 00:19:06 | [diff] [blame] | 29 | |
miletus | 45effdc4 | 2015-08-05 00:29:18 | [diff] [blame] | 30 | namespace ui { |
| 31 | class LatencyInfo; |
Kaan Alsan | 8e49b3c3 | 2019-10-30 20:04:42 | [diff] [blame] | 32 | } // namespace ui |
[email protected] | b76329d | 2013-06-11 04:15:08 | [diff] [blame] | 33 | |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 34 | namespace cc { |
| 35 | |
ccameron | 4163cc35 | 2014-11-13 19:06:36 | [diff] [blame] | 36 | class ScrollElasticityHelper; |
[email protected] | 1960a71 | 2013-04-30 17:06:47 | [diff] [blame] | 37 | |
Rahul Arakeri | 5935a30 | 2019-04-18 00:04:44 | [diff] [blame] | 38 | enum PointerResultType { kUnhandled = 0, kScrollbarScroll }; |
| 39 | |
| 40 | struct CC_EXPORT InputHandlerPointerResult { |
| 41 | InputHandlerPointerResult(); |
| 42 | // Tells what type of processing occurred in the input handler as a result of |
| 43 | // the pointer event. |
| 44 | PointerResultType type; |
| 45 | |
Rahul Arakeri | 193a7ef | 2019-05-07 08:09:53 | [diff] [blame] | 46 | // Tells what scroll_units should be used. |
Mohsen Izadi | ffcbc61f1 | 2020-02-09 06:31:27 | [diff] [blame] | 47 | ui::ScrollGranularity scroll_units; |
Rahul Arakeri | 193a7ef | 2019-05-07 08:09:53 | [diff] [blame] | 48 | |
Rahul Arakeri | 5935a30 | 2019-04-18 00:04:44 | [diff] [blame] | 49 | // If the input handler processed the event as a scrollbar scroll, it will |
| 50 | // return a gfx::ScrollOffset that produces the necessary scroll. However, |
| 51 | // it is still the client's responsibility to generate the gesture scrolls |
| 52 | // instead of the input handler performing it as a part of handling the |
| 53 | // pointer event (due to the latency attribution that happens at the |
| 54 | // InputHandlerProxy level). |
| 55 | gfx::ScrollOffset scroll_offset; |
Rahul Arakeri | c024599d | 2019-08-21 23:37:24 | [diff] [blame] | 56 | |
| 57 | // Used to determine which scroll_node needs to be scrolled. The primary |
| 58 | // purpose of this is to avoid hit testing for gestures that already know |
| 59 | // which scroller to target. |
| 60 | ElementId target_scroller; |
Rahul Arakeri | 5935a30 | 2019-04-18 00:04:44 | [diff] [blame] | 61 | }; |
| 62 | |
ccameron | 36d091f | 2014-11-07 03:18:50 | [diff] [blame] | 63 | struct CC_EXPORT InputHandlerScrollResult { |
| 64 | InputHandlerScrollResult(); |
David Bokan | 8429933 | 2020-01-09 22:23:21 | [diff] [blame] | 65 | // Did any layer scroll as a result this ScrollUpdate call? |
ccameron | 36d091f | 2014-11-07 03:18:50 | [diff] [blame] | 66 | bool did_scroll; |
David Bokan | 8429933 | 2020-01-09 22:23:21 | [diff] [blame] | 67 | // Was any of the scroll delta argument to this ScrollUpdate call not used? |
ccameron | 36d091f | 2014-11-07 03:18:50 | [diff] [blame] | 68 | bool did_overscroll_root; |
David Bokan | 8429933 | 2020-01-09 22:23:21 | [diff] [blame] | 69 | // The total overscroll that has been accumulated by all ScrollUpdate calls |
| 70 | // that have had overscroll since the last ScrollBegin call. This resets upon |
| 71 | // a ScrollUpdate with no overscroll. |
ccameron | 36d091f | 2014-11-07 03:18:50 | [diff] [blame] | 72 | gfx::Vector2dF accumulated_root_overscroll; |
David Bokan | 8429933 | 2020-01-09 22:23:21 | [diff] [blame] | 73 | // The amount of the scroll delta argument to this ScrollUpdate call that was |
| 74 | // not used for scrolling. |
ccameron | 36d091f | 2014-11-07 03:18:50 | [diff] [blame] | 75 | gfx::Vector2dF unused_scroll_delta; |
sunyunjia | bbea8a9 | 2017-08-31 11:18:54 | [diff] [blame] | 76 | // How the browser should handle the overscroll navigation based on the css |
| 77 | // property scroll-boundary-behavior. |
Sandra Sun | 2288e853 | 2017-11-30 22:50:16 | [diff] [blame] | 78 | OverscrollBehavior overscroll_behavior; |
Sandra Sun | 6141310 | 2018-04-09 22:24:43 | [diff] [blame] | 79 | // The current offset of the currently scrolling node. It is in DIP or |
Sandra Sun | 5b21b4e | 2018-05-17 23:28:36 | [diff] [blame] | 80 | // physical pixels depending on the use-zoom-for-dsf flag. If the currently |
| 81 | // scrolling node is the viewport, this would be the sum of the scroll offsets |
| 82 | // of the inner and outer node, representing the visual scroll offset. |
| 83 | gfx::Vector2dF current_visual_offset; |
ccameron | 36d091f | 2014-11-07 03:18:50 | [diff] [blame] | 84 | }; |
| 85 | |
[email protected] | 200a9c06 | 2013-05-20 04:34:37 | [diff] [blame] | 86 | class CC_EXPORT InputHandlerClient { |
| 87 | public: |
Vladimir Levin | f06d1cd7 | 2019-03-13 18:24:10 | [diff] [blame] | 88 | InputHandlerClient(const InputHandlerClient&) = delete; |
| 89 | virtual ~InputHandlerClient() = default; |
| 90 | |
| 91 | InputHandlerClient& operator=(const InputHandlerClient&) = delete; |
[email protected] | 200a9c06 | 2013-05-20 04:34:37 | [diff] [blame] | 92 | |
| 93 | virtual void WillShutdown() = 0; |
| 94 | virtual void Animate(base::TimeTicks time) = 0; |
ccameron | a8a42b2 | 2014-12-23 03:24:08 | [diff] [blame] | 95 | virtual void ReconcileElasticOverscrollAndRootScroll() = 0; |
danakj | dd74e51 | 2015-09-21 23:07:59 | [diff] [blame] | 96 | virtual void UpdateRootLayerStateForSynchronousInputHandler( |
| 97 | const gfx::ScrollOffset& total_scroll_offset, |
| 98 | const gfx::ScrollOffset& max_scroll_offset, |
| 99 | const gfx::SizeF& scrollable_size, |
| 100 | float page_scale_factor, |
| 101 | float min_page_scale_factor, |
| 102 | float max_page_scale_factor) = 0; |
Ella Ge | 7393cf9 | 2019-07-09 21:52:59 | [diff] [blame] | 103 | virtual void DeliverInputForBeginFrame(const viz::BeginFrameArgs& args) = 0; |
| 104 | virtual void DeliverInputForHighLatencyMode() = 0; |
[email protected] | 200a9c06 | 2013-05-20 04:34:37 | [diff] [blame] | 105 | |
| 106 | protected: |
Vladimir Levin | f06d1cd7 | 2019-03-13 18:24:10 | [diff] [blame] | 107 | InputHandlerClient() = default; |
[email protected] | 200a9c06 | 2013-05-20 04:34:37 | [diff] [blame] | 108 | }; |
| 109 | |
[email protected] | 5ff3c978 | 2013-04-29 17:35:12 | [diff] [blame] | 110 | // The InputHandler is a way for the embedders to interact with the impl thread |
| 111 | // side of the compositor implementation. There is one InputHandler per |
| 112 | // LayerTreeHost. To use the input handler, implement the InputHanderClient |
| 113 | // interface and bind it to the handler on the compositor thread. |
| 114 | class CC_EXPORT InputHandler { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 115 | public: |
[email protected] | 05ba53c | 2014-04-16 21:22:51 | [diff] [blame] | 116 | // Note these are used in a histogram. Do not reorder or delete existing |
| 117 | // entries. |
tdresser | 81e84c67 | 2016-01-18 23:21:22 | [diff] [blame] | 118 | enum ScrollThread { |
ericrk | 7c03099 | 2015-02-20 01:39:38 | [diff] [blame] | 119 | SCROLL_ON_MAIN_THREAD = 0, |
tdresser | 81e84c67 | 2016-01-18 23:21:22 | [diff] [blame] | 120 | SCROLL_ON_IMPL_THREAD, |
ericrk | 7c03099 | 2015-02-20 01:39:38 | [diff] [blame] | 121 | SCROLL_IGNORED, |
| 122 | SCROLL_UNKNOWN, |
danakj | 3590476 | 2016-01-21 20:49:40 | [diff] [blame] | 123 | LAST_SCROLL_STATUS = SCROLL_UNKNOWN |
tdresser | 81e84c67 | 2016-01-18 23:21:22 | [diff] [blame] | 124 | }; |
| 125 | |
Vladimir Levin | f06d1cd7 | 2019-03-13 18:24:10 | [diff] [blame] | 126 | InputHandler(const InputHandler&) = delete; |
| 127 | InputHandler& operator=(const InputHandler&) = delete; |
| 128 | |
tdresser | 81e84c67 | 2016-01-18 23:21:22 | [diff] [blame] | 129 | struct ScrollStatus { |
| 130 | ScrollStatus() |
| 131 | : thread(SCROLL_ON_IMPL_THREAD), |
danakj | 3590476 | 2016-01-21 20:49:40 | [diff] [blame] | 132 | main_thread_scrolling_reasons( |
Sahel Sharify | dbafed5 | 2017-08-03 16:59:12 | [diff] [blame] | 133 | MainThreadScrollingReason::kNotScrollingOnMain), |
| 134 | bubble(false) {} |
danakj | 3590476 | 2016-01-21 20:49:40 | [diff] [blame] | 135 | ScrollStatus(ScrollThread thread, uint32_t main_thread_scrolling_reasons) |
tdresser | 81e84c67 | 2016-01-18 23:21:22 | [diff] [blame] | 136 | : thread(thread), |
| 137 | main_thread_scrolling_reasons(main_thread_scrolling_reasons) {} |
| 138 | ScrollThread thread; |
danakj | 3590476 | 2016-01-21 20:49:40 | [diff] [blame] | 139 | uint32_t main_thread_scrolling_reasons; |
Sahel Sharify | dbafed5 | 2017-08-03 16:59:12 | [diff] [blame] | 140 | bool bubble; |
tdresser | 81e84c67 | 2016-01-18 23:21:22 | [diff] [blame] | 141 | }; |
| 142 | |
Rahul Arakeri | 5935a30 | 2019-04-18 00:04:44 | [diff] [blame] | 143 | enum ScrollInputType { |
| 144 | TOUCHSCREEN, |
| 145 | WHEEL, |
| 146 | AUTOSCROLL, |
| 147 | SCROLLBAR, |
| 148 | SCROLL_INPUT_UNKNOWN |
| 149 | }; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 150 | |
Dave Tapuska | 75fe739 | 2017-06-05 14:01:26 | [diff] [blame] | 151 | enum class TouchStartOrMoveEventListenerType { |
lanwei | 53c1236 | 2016-11-29 06:51:17 | [diff] [blame] | 152 | NO_HANDLER, |
| 153 | HANDLER, |
| 154 | HANDLER_ON_SCROLLING_LAYER |
| 155 | }; |
| 156 | |
[email protected] | 200a9c06 | 2013-05-20 04:34:37 | [diff] [blame] | 157 | // Binds a client to this handler to receive notifications. Only one client |
| 158 | // can be bound to an InputHandler. The client must live at least until the |
| 159 | // handler calls WillShutdown() on the client. |
Sahel Sharify | e6d81f47 | 2018-07-11 20:40:26 | [diff] [blame] | 160 | virtual void BindToClient(InputHandlerClient* client) = 0; |
[email protected] | 200a9c06 | 2013-05-20 04:34:37 | [diff] [blame] | 161 | |
David Bokan | 8429933 | 2020-01-09 22:23:21 | [diff] [blame] | 162 | // Selects a ScrollNode to be "latched" for scrolling using the |
| 163 | // |scroll_state| start position. The selected node remains latched until the |
| 164 | // gesture is ended by a call to ScrollEnd. Returns SCROLL_STARTED if a node |
| 165 | // at the coordinates can be scrolled and was latched, SCROLL_ON_MAIN_THREAD |
| 166 | // if the scroll event should instead be delegated to the main thread, or |
| 167 | // SCROLL_IGNORED if there is nothing to be scrolled at the given |
| 168 | // coordinates. |
majidvp | 944a8cd | 2016-01-12 21:05:18 | [diff] [blame] | 169 | virtual ScrollStatus ScrollBegin(ScrollState* scroll_state, |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 170 | ScrollInputType type) = 0; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 171 | |
hush | 1c87323 | 2015-06-23 21:22:11 | [diff] [blame] | 172 | // Similar to ScrollBegin, except the hit test is skipped and scroll always |
| 173 | // targets at the root layer. |
majidvp | 944a8cd | 2016-01-12 21:05:18 | [diff] [blame] | 174 | virtual ScrollStatus RootScrollBegin(ScrollState* scroll_state, |
| 175 | ScrollInputType type) = 0; |
dtapuska | 1827dd2 | 2016-03-11 15:24:59 | [diff] [blame] | 176 | |
majidvp | 944a8cd | 2016-01-12 21:05:18 | [diff] [blame] | 177 | // Scroll the layer selected by |ScrollBegin| by given |scroll_state| delta. |
| 178 | // Internally, the delta is transformed to local layer's coordinate space for |
David Bokan | 8429933 | 2020-01-09 22:23:21 | [diff] [blame] | 179 | // scrolls gestures that are direct manipulation (e.g. touch). If the |
| 180 | // viewport is latched, and it can no longer scroll, the root overscroll |
majidvp | 944a8cd | 2016-01-12 21:05:18 | [diff] [blame] | 181 | // accumulated within this ScrollBegin() scope is reported in the return |
| 182 | // value's |accumulated_overscroll| field. Should only be called if |
| 183 | // ScrollBegin() returned SCROLL_STARTED. |
David Bokan | 8429933 | 2020-01-09 22:23:21 | [diff] [blame] | 184 | // |delayed_by| is the delay from the event that caused the scroll. This is |
| 185 | // taken into account when determining the duration of the animation if one |
| 186 | // is created. |
| 187 | virtual InputHandlerScrollResult ScrollUpdate(ScrollState* scroll_state, |
David Bokan | 8429933 | 2020-01-09 22:23:21 | [diff] [blame] | 188 | base::TimeDelta delayed_by) = 0; |
| 189 | |
| 190 | // Stop scrolling the selected layer. Should only be called if ScrollBegin() |
| 191 | // returned SCROLL_STARTED. Snap to a snap position if |should_snap| is true. |
| 192 | virtual void ScrollEnd(bool should_snap) = 0; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 193 | |
Rahul Arakeri | 193a7ef | 2019-05-07 08:09:53 | [diff] [blame] | 194 | virtual InputHandlerPointerResult MouseMoveAt( |
| 195 | const gfx::Point& mouse_position) = 0; |
Rahul Arakeri | cfc807f | 2019-11-13 08:57:33 | [diff] [blame] | 196 | // TODO(arakeri): Pass in the modifier instead of a bool once the refactor |
| 197 | // (crbug.com/1022097) is done. For details, see crbug.com/1016955. |
Rahul Arakeri | 605a066 | 2019-09-25 16:22:36 | [diff] [blame] | 198 | virtual InputHandlerPointerResult MouseDown(const gfx::PointF& mouse_position, |
| 199 | bool shift_modifier) = 0; |
Rahul Arakeri | 5935a30 | 2019-04-18 00:04:44 | [diff] [blame] | 200 | virtual InputHandlerPointerResult MouseUp( |
| 201 | const gfx::PointF& mouse_position) = 0; |
chaopeng | fff2d5a | 2016-10-13 15:42:01 | [diff] [blame] | 202 | virtual void MouseLeave() = 0; |
[email protected] | bf1cfd9a | 2013-09-26 05:43:02 | [diff] [blame] | 203 | |
danakj | dd74e51 | 2015-09-21 23:07:59 | [diff] [blame] | 204 | // Requests a callback to UpdateRootLayerStateForSynchronousInputHandler() |
| 205 | // giving the current root scroll and page scale information. |
| 206 | virtual void RequestUpdateForSynchronousInputHandler() = 0; |
[email protected] | 1960a71 | 2013-04-30 17:06:47 | [diff] [blame] | 207 | |
danakj | dd74e51 | 2015-09-21 23:07:59 | [diff] [blame] | 208 | // Called when the root scroll offset has been changed in the synchronous |
David Bokan | 0a3aa0d5 | 2019-07-03 18:43:02 | [diff] [blame] | 209 | // input handler by the application (outside of input event handling). Offset |
| 210 | // is expected in "content/page coordinates". |
danakj | dd74e51 | 2015-09-21 23:07:59 | [diff] [blame] | 211 | virtual void SetSynchronousInputHandlerRootScrollOffset( |
David Bokan | 0a3aa0d5 | 2019-07-03 18:43:02 | [diff] [blame] | 212 | const gfx::ScrollOffset& root_content_offset) = 0; |
[email protected] | 1960a71 | 2013-04-30 17:06:47 | [diff] [blame] | 213 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 214 | virtual void PinchGestureBegin() = 0; |
[email protected] | 47a723f | 2014-03-05 12:42:49 | [diff] [blame] | 215 | virtual void PinchGestureUpdate(float magnify_delta, |
| 216 | const gfx::Point& anchor) = 0; |
Sean O'Brien | 09fb8b7 | 2017-11-30 20:45:47 | [diff] [blame] | 217 | virtual void PinchGestureEnd(const gfx::Point& anchor, bool snap_to_min) = 0; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 218 | |
[email protected] | 5ff3c978 | 2013-04-29 17:35:12 | [diff] [blame] | 219 | // Request another callback to InputHandlerClient::Animate(). |
hush | b0ee8dc | 2015-06-10 00:48:57 | [diff] [blame] | 220 | virtual void SetNeedsAnimateInput() = 0; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 221 | |
bokan | e248130 | 2016-10-03 23:01:07 | [diff] [blame] | 222 | // Returns true if there is an active scroll on the viewport. |
| 223 | virtual bool IsCurrentlyScrollingViewport() const = 0; |
danakj | e9f830c | 2015-09-09 21:36:16 | [diff] [blame] | 224 | |
[email protected] | edcc1a1 | 2014-05-06 01:26:39 | [diff] [blame] | 225 | // Whether the layer under |viewport_point| is the currently scrolling layer. |
Philip Rogers | 315062e | 2019-06-06 19:33:48 | [diff] [blame] | 226 | virtual bool IsCurrentlyScrollingLayerAt( |
| 227 | const gfx::Point& viewport_point) const = 0; |
[email protected] | edcc1a1 | 2014-05-06 01:26:39 | [diff] [blame] | 228 | |
dtapuska | f206a40d | 2016-02-05 21:36:02 | [diff] [blame] | 229 | virtual EventListenerProperties GetEventListenerProperties( |
| 230 | EventListenerClass event_class) const = 0; |
rbyers | 18779d82 | 2015-02-05 06:22:06 | [diff] [blame] | 231 | |
sunxd | 3e3a37a7 | 2018-07-06 22:58:43 | [diff] [blame] | 232 | // Returns true if |viewport_point| hits a wheel event handler region that |
| 233 | // could block scrolling. |
sunxd | 9f98e81 | 2018-08-16 15:34:49 | [diff] [blame] | 234 | virtual bool HasBlockingWheelEventHandlerAt( |
sunxd | 3e3a37a7 | 2018-07-06 22:58:43 | [diff] [blame] | 235 | const gfx::Point& viewport_point) const = 0; |
| 236 | |
Dave Tapuska | 75fe739 | 2017-06-05 14:01:26 | [diff] [blame] | 237 | // It returns the type of a touch start or move event listener at |
| 238 | // |viewport_point|. Whether the page should be given the opportunity to |
| 239 | // suppress scrolling by consuming touch events that started at |
| 240 | // |viewport_point|, and whether |viewport_point| is on the currently |
| 241 | // scrolling layer. |
Hayley Ferr | 2b14e2a6c | 2017-07-04 17:34:43 | [diff] [blame] | 242 | // |out_touch_action| is assigned the whitelisted touch action for the |
| 243 | // |viewport_point|. In the case there are no touch handlers or touch action |
Henrique Ferreiro | 00e24f1 | 2019-12-17 01:14:48 | [diff] [blame] | 244 | // regions, |out_touch_action| is assigned TouchAction::kAuto since the |
| 245 | // default touch action is auto. |
Dave Tapuska | 75fe739 | 2017-06-05 14:01:26 | [diff] [blame] | 246 | virtual TouchStartOrMoveEventListenerType |
Hayley Ferr | 2b14e2a6c | 2017-07-04 17:34:43 | [diff] [blame] | 247 | EventListenerTypeForTouchStartOrMoveAt(const gfx::Point& viewport_point, |
| 248 | TouchAction* out_touch_action) = 0; |
[email protected] | 2f1acc26 | 2012-11-16 21:42:22 | [diff] [blame] | 249 | |
[email protected] | 6be422b | 2013-12-08 06:47:31 | [diff] [blame] | 250 | // Calling CreateLatencyInfoSwapPromiseMonitor() to get a scoped |
| 251 | // LatencyInfoSwapPromiseMonitor. During the life time of the |
| 252 | // LatencyInfoSwapPromiseMonitor, if SetNeedsRedraw() or SetNeedsRedrawRect() |
| 253 | // is called on LayerTreeHostImpl, the original latency info will be turned |
| 254 | // into a LatencyInfoSwapPromise. |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 255 | virtual std::unique_ptr<SwapPromiseMonitor> |
| 256 | CreateLatencyInfoSwapPromiseMonitor(ui::LatencyInfo* latency) = 0; |
[email protected] | b76329d | 2013-06-11 04:15:08 | [diff] [blame] | 257 | |
ccameron | 4163cc35 | 2014-11-13 19:06:36 | [diff] [blame] | 258 | virtual ScrollElasticityHelper* CreateScrollElasticityHelper() = 0; |
| 259 | |
tapted | 4b70c52 | 2016-08-13 09:09:32 | [diff] [blame] | 260 | // Called by the single-threaded UI Compositor to get or set the scroll offset |
Robert Flack | b62bd42 | 2018-07-25 14:54:42 | [diff] [blame] | 261 | // on the impl side. Returns false if |element_id| isn't in the active tree. |
| 262 | virtual bool GetScrollOffsetForLayer(ElementId element_id, |
tapted | 4b70c52 | 2016-08-13 09:09:32 | [diff] [blame] | 263 | gfx::ScrollOffset* offset) = 0; |
Robert Flack | b62bd42 | 2018-07-25 14:54:42 | [diff] [blame] | 264 | virtual bool ScrollLayerTo(ElementId element_id, |
| 265 | const gfx::ScrollOffset& offset) = 0; |
tapted | 4b70c52 | 2016-08-13 09:09:32 | [diff] [blame] | 266 | |
sahel | fad903f | 2017-03-31 21:00:41 | [diff] [blame] | 267 | virtual bool ScrollingShouldSwitchtoMainThread() = 0; |
| 268 | |
Sandra Sun | eb85637d | 2018-03-22 22:35:16 | [diff] [blame] | 269 | // Sets the initial and target offset for scroll snapping for the currently |
Kaan Alsan | 9a3cb835 | 2019-12-18 14:30:32 | [diff] [blame] | 270 | // scrolling node and the given natural displacement. Also sets the target |
| 271 | // element of the snap's scrolling animation. |
Sandra Sun | 6141310 | 2018-04-09 22:24:43 | [diff] [blame] | 272 | // |natural_displacement_in_viewport| is the estimated total scrolling for |
| 273 | // the active scroll sequence. |
Sandra Sun | eb85637d | 2018-03-22 22:35:16 | [diff] [blame] | 274 | // Returns false if their is no position to snap to. |
Kaan Alsan | 9a3cb835 | 2019-12-18 14:30:32 | [diff] [blame] | 275 | virtual bool GetSnapFlingInfoAndSetAnimatingSnapTarget( |
Sandra Sun | 6141310 | 2018-04-09 22:24:43 | [diff] [blame] | 276 | const gfx::Vector2dF& natural_displacement_in_viewport, |
| 277 | gfx::Vector2dF* initial_offset, |
Kaan Alsan | 8e49b3c3 | 2019-10-30 20:04:42 | [diff] [blame] | 278 | gfx::Vector2dF* target_offset) = 0; |
Sandra Sun | eb85637d | 2018-03-22 22:35:16 | [diff] [blame] | 279 | |
Kaan Alsan | 9a3cb835 | 2019-12-18 14:30:32 | [diff] [blame] | 280 | // |did_finish| is true if the animation reached its target position (i.e. |
| 281 | // it wasn't aborted). |
| 282 | virtual void ScrollEndForSnapFling(bool did_finish) = 0; |
| 283 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 284 | protected: |
Vladimir Levin | f06d1cd7 | 2019-03-13 18:24:10 | [diff] [blame] | 285 | InputHandler() = default; |
| 286 | virtual ~InputHandler() = default; |
[email protected] | 5ff3c978 | 2013-04-29 17:35:12 | [diff] [blame] | 287 | }; |
| 288 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 289 | } // namespace cc |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 290 | |
[email protected] | 3052b10f | 2013-03-18 07:41:21 | [diff] [blame] | 291 | #endif // CC_INPUT_INPUT_HANDLER_H_ |