Chromium Code Reviews| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 // queued events (e.g. consecutive touch-move events can be coalesced into a | 44 // queued events (e.g. consecutive touch-move events can be coalesced into a |
| 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 | 53 |
| 54 // When scroll starts, we stop forwarding touch events to renderer. When | |
| 55 // scroll ends, we flush the queue and send touch end to renderer to release | |
| 56 // all existing touches. And we don't want to process the touch end in view, | |
| 57 // so we also clear the queue to not process the ack to the touch end. | |
|
sadrul
2013/08/06 19:34:19
I think with this patchset, the sequence of events
| |
| 58 void OnGestureScrollEnd(); | |
| 59 | |
| 60 void ClearQueue(); | |
| 61 | |
| 54 // Empties the queue of touch events. This may result in any number of gesture | 62 // Empties the queue of touch events. This may result in any number of gesture |
| 55 // events being sent to the renderer. | 63 // events being sent to the renderer. |
| 56 void FlushQueue(); | 64 void FlushQueue(); |
| 57 | 65 |
| 58 // Returns whether the event-queue is empty. | 66 // Returns whether the event-queue is empty. |
| 59 bool empty() const WARN_UNUSED_RESULT { | 67 bool empty() const WARN_UNUSED_RESULT { |
| 60 return touch_queue_.empty(); | 68 return touch_queue_.empty(); |
| 61 } | 69 } |
| 62 | 70 |
| 63 private: | 71 private: |
| 64 friend class MockRenderWidgetHost; | 72 friend class MockRenderWidgetHost; |
| 65 | 73 |
| 66 CONTENT_EXPORT size_t GetQueueSize() const; | 74 CONTENT_EXPORT size_t GetQueueSize() const; |
| 67 CONTENT_EXPORT const TouchEventWithLatencyInfo& GetLatestEvent() const; | 75 CONTENT_EXPORT const TouchEventWithLatencyInfo& GetLatestEvent() const; |
| 68 | 76 |
| 69 // Pops the touch-event from the top of the queue and sends it to the | 77 // Pops the touch-event from the top of the queue and sends it to the |
| 70 // TouchEventQueueClient. This reduces the size of the queue by one. | 78 // TouchEventQueueClient. This reduces the size of the queue by one. |
| 71 void PopTouchEventWithAck(InputEventAckState ack_result); | 79 void PopTouchEventWithAck(InputEventAckState ack_result); |
| 72 | 80 |
| 73 bool ShouldForwardToRenderer(const WebKit::WebTouchEvent& event) const; | 81 bool ShouldForwardToRenderer(const WebKit::WebTouchEvent& event) const; |
| 74 | 82 |
| 75 // Handles touch event forwarding and ack'ed event dispatch. | 83 // Handles touch event forwarding and ack'ed event dispatch. |
| 76 TouchEventQueueClient* client_; | 84 TouchEventQueueClient* client_; |
| 77 | 85 |
| 78 typedef std::deque<CoalescedWebTouchEvent*> TouchQueue; | 86 typedef std::deque<CoalescedWebTouchEvent*> TouchQueue; |
| 79 TouchQueue touch_queue_; | 87 TouchQueue touch_queue_; |
| 80 | 88 |
| 89 TouchEventWithLatencyInfo latest_event_; | |
| 90 | |
| 81 // Maintain the ACK status for each touch point. | 91 // Maintain the ACK status for each touch point. |
| 82 typedef std::map<int, InputEventAckState> TouchPointAckStates; | 92 typedef std::map<int, InputEventAckState> TouchPointAckStates; |
| 83 TouchPointAckStates touch_ack_states_; | 93 TouchPointAckStates touch_ack_states_; |
| 84 | 94 |
| 85 // Used to defer touch forwarding when ack dispatch triggers |QueueEvent()|. | 95 // Used to defer touch forwarding when ack dispatch triggers |QueueEvent()|. |
| 86 bool dispatching_touch_ack_; | 96 bool dispatching_touch_ack_; |
| 87 | 97 |
| 88 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); | 98 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); |
| 89 }; | 99 }; |
| 90 | 100 |
| 91 } // namespace content | 101 } // namespace content |
| 92 | 102 |
| 93 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ | 103 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ |
| OLD | NEW |