| 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) { | 70 bool no_touch_to_renderer() const { |
| 65 no_touch_move_to_renderer_ = value; | 71 return no_touch_to_renderer_; |
| 66 } | |
| 67 bool no_touch_move_to_renderer() const { | |
| 68 return no_touch_move_to_renderer_; | |
| 69 } | 72 } |
| 70 | 73 |
| 71 private: | 74 private: |
| 72 friend class TouchEventQueueTest; | 75 friend class TouchEventQueueTest; |
| 73 | 76 |
| 74 size_t GetQueueSize() const; | 77 size_t GetQueueSize() const; |
| 75 const TouchEventWithLatencyInfo& GetLatestEvent() const; | 78 const TouchEventWithLatencyInfo& GetLatestEvent() const; |
| 76 | 79 |
| 77 // Walks the queue, checking each event for |ShouldForwardToRenderer()|. | 80 // Walks the queue, checking each event for |ShouldForwardToRenderer()|. |
| 78 // If true, forwards the touch event and stops processing further events. | 81 // If true, forwards the touch event and stops processing further events. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 90 TouchEventQueueClient* client_; | 93 TouchEventQueueClient* client_; |
| 91 | 94 |
| 92 typedef std::deque<CoalescedWebTouchEvent*> TouchQueue; | 95 typedef std::deque<CoalescedWebTouchEvent*> TouchQueue; |
| 93 TouchQueue touch_queue_; | 96 TouchQueue touch_queue_; |
| 94 | 97 |
| 95 // Maintain the ACK status for each touch point. | 98 // Maintain the ACK status for each touch point. |
| 96 typedef std::map<int, InputEventAckState> TouchPointAckStates; | 99 typedef std::map<int, InputEventAckState> TouchPointAckStates; |
| 97 TouchPointAckStates touch_ack_states_; | 100 TouchPointAckStates touch_ack_states_; |
| 98 | 101 |
| 99 // Used to defer touch forwarding when ack dispatch triggers |QueueEvent()|. | 102 // Used to defer touch forwarding when ack dispatch triggers |QueueEvent()|. |
| 100 bool dispatching_touch_ack_; | 103 // If not NULL, |dispatching_touch_ack_| is the touch event of which the ack |
| 104 // is being dispatched. |
| 105 CoalescedWebTouchEvent* dispatching_touch_ack_; |
| 101 | 106 |
| 102 // Don't send touch move events to renderer. This is enabled when the page | 107 // Don't send touch events to renderer. This is enabled when the page |
| 103 // is scrolling. This behaviour is currently enabled only on aura behind a | 108 // is scrolling. This behaviour is currently enabled only on aura behind |
| 104 // flag. | 109 // a flag. |
| 105 bool no_touch_move_to_renderer_; | 110 bool no_touch_to_renderer_; |
| 106 | 111 |
| 107 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); | 112 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); |
| 108 }; | 113 }; |
| 109 | 114 |
| 110 } // namespace content | 115 } // namespace content |
| 111 | 116 |
| 112 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ | 117 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ |
| OLD | NEW |