| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_EVENT_QUEUE_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // single touch-move event). The event may also be immediately forwarded to | 45 // single touch-move event). The event may also be immediately forwarded to |
| 46 // the renderer (e.g. when there are no other queued touch event). | 46 // the renderer (e.g. when there are no other queued touch event). |
| 47 void QueueEvent(const TouchEventWithLatencyInfo& event); | 47 void QueueEvent(const TouchEventWithLatencyInfo& event); |
| 48 | 48 |
| 49 // Notifies the queue that a touch-event has been processed by the renderer. | 49 // Notifies the queue that a touch-event has been processed by the renderer. |
| 50 // At this point, the queue may send one or more gesture events and/or | 50 // At this point, the queue may send one or more gesture events and/or |
| 51 // additional queued touch-events to the renderer. | 51 // additional queued touch-events to the renderer. |
| 52 void ProcessTouchAck(InputEventAckState ack_result, | 52 void ProcessTouchAck(InputEventAckState ack_result, |
| 53 const ui::LatencyInfo& latency_info); | 53 const ui::LatencyInfo& latency_info); |
| 54 | 54 |
| 55 // When GestureScrollBegin is received, we send a touch cancel to renderer, |
| 56 // route all the following touch events directly to client, and ignore the |
| 57 // ack for the touch cancel. When GestureScrollEnd/GestureFlingStart is |
| 58 // received, we resume the normal flow of sending touch events to renderer. |
| 59 void OnGestureScrollEvent(const GestureEventWithLatencyInfo& gesture_event); |
| 60 |
| 55 // Empties the queue of touch events. This may result in any number of gesture | 61 // Empties the queue of touch events. This may result in any number of gesture |
| 56 // events being sent to the renderer. | 62 // events being sent to the renderer. |
| 57 void FlushQueue(); | 63 void FlushQueue(); |
| 58 | 64 |
| 59 // Returns whether the event-queue is empty. | 65 // Returns whether the event-queue is empty. |
| 60 bool empty() const WARN_UNUSED_RESULT { | 66 bool empty() const WARN_UNUSED_RESULT { |
| 61 return touch_queue_.empty(); | 67 return touch_queue_.empty(); |
| 62 } | 68 } |
| 63 | 69 |
| 64 void set_no_touch_move_to_renderer(bool value) { | |
| 65 no_touch_move_to_renderer_ = value; | |
| 66 } | |
| 67 | |
| 68 private: | 70 private: |
| 69 friend class MockRenderWidgetHost; | 71 friend class MockRenderWidgetHost; |
| 70 friend class ImmediateInputRouterTest; | 72 friend class ImmediateInputRouterTest; |
| 71 | 73 |
| 72 CONTENT_EXPORT size_t GetQueueSize() const; | 74 CONTENT_EXPORT size_t GetQueueSize() const; |
| 73 CONTENT_EXPORT const TouchEventWithLatencyInfo& GetLatestEvent() const; | 75 CONTENT_EXPORT const TouchEventWithLatencyInfo& GetLatestEvent() const; |
| 74 | 76 |
| 75 // Walks the queue, checking each event for |ShouldForwardToRenderer()|. | 77 // Walks the queue, checking each event for |ShouldForwardToRenderer()|. |
| 76 // If true, forwards the touch event and stops processing further events. | 78 // If true, forwards the touch event and stops processing further events. |
| 77 // If false, acks the event with |INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS|. | 79 // If false, acks the event with |INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS|. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 88 TouchEventQueueClient* client_; | 90 TouchEventQueueClient* client_; |
| 89 | 91 |
| 90 typedef std::deque<CoalescedWebTouchEvent*> TouchQueue; | 92 typedef std::deque<CoalescedWebTouchEvent*> TouchQueue; |
| 91 TouchQueue touch_queue_; | 93 TouchQueue touch_queue_; |
| 92 | 94 |
| 93 // Maintain the ACK status for each touch point. | 95 // Maintain the ACK status for each touch point. |
| 94 typedef std::map<int, InputEventAckState> TouchPointAckStates; | 96 typedef std::map<int, InputEventAckState> TouchPointAckStates; |
| 95 TouchPointAckStates touch_ack_states_; | 97 TouchPointAckStates touch_ack_states_; |
| 96 | 98 |
| 97 // Used to defer touch forwarding when ack dispatch triggers |QueueEvent()|. | 99 // Used to defer touch forwarding when ack dispatch triggers |QueueEvent()|. |
| 98 bool dispatching_touch_ack_; | 100 // If not NULL, |dispatching_touch_ack_| is the touch event of which the ack |
| 101 // is being dispatched. |
| 102 CoalescedWebTouchEvent* dispatching_touch_ack_; |
| 99 | 103 |
| 100 // Don't send touch move events to renderer. This is enabled when the page | 104 // Don't send touch events to renderer. This is enabled when the page |
| 101 // is scrolling. This behaviour is currently enabled only on aura behind a | 105 // is scrolling. This behaviour is currently enabled only on aura behind |
| 102 // flag. | 106 // a flag. |
| 103 bool no_touch_move_to_renderer_; | 107 bool no_touch_to_renderer_; |
| 104 | 108 |
| 105 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); | 109 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); |
| 106 }; | 110 }; |
| 107 | 111 |
| 108 } // namespace content | 112 } // namespace content |
| 109 | 113 |
| 110 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ | 114 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ |
| OLD | NEW |