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 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 void OnGestureScrollEvent(const GestureEventWithLatencyInfo& gesture_event); | |
| 56 | |
| 55 // Empties the queue of touch events. This may result in any number of gesture | 57 // Empties the queue of touch events. This may result in any number of gesture | 
| 56 // events being sent to the renderer. | 58 // events being sent to the renderer. | 
| 57 void FlushQueue(); | 59 void FlushQueue(); | 
| 58 | 60 | 
| 59 // Returns whether the event-queue is empty. | 61 // Returns whether the event-queue is empty. | 
| 60 bool empty() const WARN_UNUSED_RESULT { | 62 bool empty() const WARN_UNUSED_RESULT { | 
| 61 return touch_queue_.empty(); | 63 return touch_queue_.empty(); | 
| 62 } | 64 } | 
| 63 | 65 | 
| 64 void set_no_touch_move_to_renderer(bool value) { | |
| 65 no_touch_move_to_renderer_ = value; | |
| 66 } | |
| 67 | |
| 68 private: | 66 private: | 
| 69 friend class MockRenderWidgetHost; | 67 friend class MockRenderWidgetHost; | 
| 70 friend class ImmediateInputRouterTest; | 68 friend class ImmediateInputRouterTest; | 
| 71 | 69 | 
| 72 CONTENT_EXPORT size_t GetQueueSize() const; | 70 CONTENT_EXPORT size_t GetQueueSize() const; | 
| 73 CONTENT_EXPORT const TouchEventWithLatencyInfo& GetLatestEvent() const; | 71 CONTENT_EXPORT const TouchEventWithLatencyInfo& GetLatestEvent() const; | 
| 74 | 72 | 
| 75 // Pops the touch-event from the top of the queue and sends it to the | 73 // Pops the touch-event from the top of the queue and sends it to the | 
| 76 // TouchEventQueueClient. This reduces the size of the queue by one. | 74 // TouchEventQueueClient. This reduces the size of the queue by one. | 
| 77 void PopTouchEventToClient(InputEventAckState ack_result, | 75 void PopTouchEventToClient(InputEventAckState ack_result, | 
| 78 const ui::LatencyInfo& renderer_latency_info); | 76 const ui::LatencyInfo& renderer_latency_info); | 
| 79 | 77 | 
| 80 bool ShouldForwardToRenderer(const WebKit::WebTouchEvent& event) const; | 78 bool ShouldForwardToRenderer(const WebKit::WebTouchEvent& event) const; | 
| 81 | 79 | 
| 82 // Handles touch event forwarding and ack'ed event dispatch. | 80 // Handles touch event forwarding and ack'ed event dispatch. | 
| 83 TouchEventQueueClient* client_; | 81 TouchEventQueueClient* client_; | 
| 84 | 82 | 
| 85 typedef std::deque<CoalescedWebTouchEvent*> TouchQueue; | 83 typedef std::deque<CoalescedWebTouchEvent*> TouchQueue; | 
| 86 TouchQueue touch_queue_; | 84 TouchQueue touch_queue_; | 
| 87 | 85 | 
| 88 // Maintain the ACK status for each touch point. | 86 // Maintain the ACK status for each touch point. | 
| 89 typedef std::map<int, InputEventAckState> TouchPointAckStates; | 87 typedef std::map<int, InputEventAckState> TouchPointAckStates; | 
| 90 TouchPointAckStates touch_ack_states_; | 88 TouchPointAckStates touch_ack_states_; | 
| 91 | 89 | 
| 92 // Used to defer touch forwarding when ack dispatch triggers |QueueEvent()|. | 90 // Used to defer touch forwarding when ack dispatch triggers |QueueEvent()|. | 
| 93 bool dispatching_touch_ack_; | 91 bool dispatching_touch_ack_; | 
| 94 | 92 | 
| 95 // Don't send touch move events to renderer. This is enabled when the page | 93 // Don't send touch events to renderer. This is enabled when the page | 
| 96 // is scrolling. This behaviour is currently enabled only on aura behind a | 94 // is scrolling. This behaviour is currently enabled only on aura behind | 
| 97 // flag. | 95 // a flag. | 
| 98 bool no_touch_move_to_renderer_; | 96 bool no_touch_to_renderer_; | 
| 97 | |
| 98 // Latest event that is queued. | |
| 99 TouchEventWithLatencyInfo latest_event_; | |
| 
 
sadrul
2013/09/23 16:17:33
Why do you need this?
 
 | |
| 100 | |
| 101 // When scroll begins, we send the |synthesized_cancel_event_| to renderer | |
| 102 // and when it is acked back we drop it before forwarding it to view. | |
| 103 CoalescedWebTouchEvent* synthesized_cancel_event_; | |
| 
 
sadrul
2013/09/23 16:17:33
We shouldn't hold onto a raw pointer like this. Ad
 
 | |
| 99 | 104 | 
| 100 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); | 105 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); | 
| 101 }; | 106 }; | 
| 102 | 107 | 
| 103 } // namespace content | 108 } // namespace content | 
| 104 | 109 | 
| 105 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ | 110 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ | 
| OLD | NEW |