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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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, | 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 | 56 // route all the following touch events directly to client, and ignore the |
| 57 // ack for the touch cancel. When Gesture{ScrollEnd,FlingStart} is received, | 57 // ack for the touch cancel. When Gesture{ScrollEnd,FlingStart} is received, |
| 58 // resume the normal flow of sending touch events to the renderer. | 58 // resume the normal flow of sending touch events to the renderer. |
| 59 void OnGestureScrollEvent(const GestureEventWithLatencyInfo& gesture_event); | 59 void OnGestureScrollEvent(const GestureEventWithLatencyInfo& gesture_event); |
| 60 | 60 |
| 61 // Empties the queue of touch events. This may result in any number of gesture | 61 // Notifies the queue whether the renderer has at least one touch handler. |
| 62 // events being sent to the renderer. | 62 void OnHasTouchEventHandlers(bool has_handlers); |
| 63 void FlushQueue(); | |
| 64 | 63 |
| 65 // Returns whether the currently pending touch event (waiting ACK) is for | 64 // Returns whether the currently pending touch event (waiting ACK) is for |
| 66 // a touch start event. | 65 // a touch start event. |
| 67 bool IsPendingAckTouchStart() const; | 66 bool IsPendingAckTouchStart() const; |
| 68 | 67 |
| 69 // Sets whether a delayed touch ack will cancel and flush the current | 68 // Sets whether a delayed touch ack will cancel and flush the current |
| 70 // touch sequence. | 69 // touch sequence. |
| 71 void SetAckTimeoutEnabled(bool enabled, size_t ack_timeout_delay_ms); | 70 void SetAckTimeoutEnabled(bool enabled, size_t ack_timeout_delay_ms); |
| 72 | 71 |
| 73 bool empty() const WARN_UNUSED_RESULT { | 72 bool empty() const WARN_UNUSED_RESULT { |
| 74 return touch_queue_.empty(); | 73 return touch_queue_.empty(); |
| 75 } | 74 } |
| 76 | 75 |
| 77 size_t size() const { | 76 size_t size() const { |
| 78 return touch_queue_.size(); | 77 return touch_queue_.size(); |
| 79 } | 78 } |
| 80 | 79 |
| 81 bool ack_timeout_enabled() const { | 80 bool ack_timeout_enabled() const { |
| 82 return ack_timeout_enabled_; | 81 return ack_timeout_enabled_; |
| 83 } | 82 } |
| 84 | 83 |
| 84 bool has_handlers() const { | |
| 85 return has_handlers_; | |
| 86 } | |
| 87 | |
| 85 private: | 88 private: |
| 86 class TouchTimeoutHandler; | 89 class TouchTimeoutHandler; |
| 87 friend class TouchTimeoutHandler; | 90 friend class TouchTimeoutHandler; |
| 88 friend class TouchEventQueueTest; | 91 friend class TouchEventQueueTest; |
| 89 | 92 |
| 90 bool HasTimeoutEvent() const; | 93 bool HasTimeoutEvent() const; |
| 91 bool IsTimeoutRunningForTesting() const; | 94 bool IsTimeoutRunningForTesting() const; |
| 92 const TouchEventWithLatencyInfo& GetLatestEventForTesting() const; | 95 const TouchEventWithLatencyInfo& GetLatestEventForTesting() const; |
| 93 | 96 |
| 97 // Empties the queue of touch events. This may result in any number of gesture | |
| 98 // events being sent to the renderer. | |
| 99 void FlushQueue(); | |
| 100 | |
| 94 // Walks the queue, checking each event for |ShouldForwardToRenderer()|. | 101 // Walks the queue, checking each event for |ShouldForwardToRenderer()|. |
| 95 // If true, forwards the touch event and stops processing further events. | 102 // If true, forwards the touch event and stops processing further events. |
| 96 // If false, acks the event with |INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS|. | 103 // If false, acks the event with |INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS|. |
| 97 void TryForwardNextEventToRenderer(); | 104 void TryForwardNextEventToRenderer(); |
| 98 | 105 |
| 99 // Pops the touch-event from the top of the queue and sends it to the | 106 // Pops the touch-event from the top of the queue and sends it to the |
| 100 // TouchEventQueueClient. This reduces the size of the queue by one. | 107 // TouchEventQueueClient. This reduces the size of the queue by one. |
| 101 void PopTouchEventToClient(InputEventAckState ack_result, | 108 void PopTouchEventToClient(InputEventAckState ack_result, |
| 102 const ui::LatencyInfo& renderer_latency_info); | 109 const ui::LatencyInfo& renderer_latency_info); |
| 103 | 110 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 119 | 126 |
| 120 // Used to defer touch forwarding when ack dispatch triggers |QueueEvent()|. | 127 // Used to defer touch forwarding when ack dispatch triggers |QueueEvent()|. |
| 121 // If not NULL, |dispatching_touch_ack_| is the touch event of which the ack | 128 // If not NULL, |dispatching_touch_ack_| is the touch event of which the ack |
| 122 // is being dispatched. | 129 // is being dispatched. |
| 123 CoalescedWebTouchEvent* dispatching_touch_ack_; | 130 CoalescedWebTouchEvent* dispatching_touch_ack_; |
| 124 | 131 |
| 125 // Used to prevent touch timeout scheduling if we receive a synchronous | 132 // Used to prevent touch timeout scheduling if we receive a synchronous |
| 126 // ack after forwarding a touch event to the client. | 133 // ack after forwarding a touch event to the client. |
| 127 bool dispatching_touch_; | 134 bool dispatching_touch_; |
| 128 | 135 |
| 136 // Whether there are any registered touch handlers. Defaults to false. | |
| 137 bool has_handlers_; | |
| 138 | |
| 129 // Don't send touch events to the renderer while scrolling. | 139 // Don't send touch events to the renderer while scrolling. |
| 130 bool no_touch_to_renderer_; | 140 bool scroll_in_progress_; |
|
tdresser
2014/01/09 21:14:32
Good rename.
| |
| 131 | 141 |
| 132 // Whether an event in the current (multi)touch sequence was consumed by the | 142 // Whether an event in the current (multi)touch sequence was consumed by the |
| 133 // renderer. The touch timeout will never be activated when this is true. | 143 // renderer. The touch timeout will never be activated when this is true. |
| 134 bool renderer_is_consuming_touch_gesture_; | 144 bool renderer_is_consuming_touch_gesture_; |
| 135 | 145 |
| 136 // Optional handler for timed-out touch event acks, disabled by default. | 146 // Optional handler for timed-out touch event acks, disabled by default. |
| 137 bool ack_timeout_enabled_; | 147 bool ack_timeout_enabled_; |
| 138 scoped_ptr<TouchTimeoutHandler> timeout_handler_; | 148 scoped_ptr<TouchTimeoutHandler> timeout_handler_; |
| 139 | 149 |
| 140 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); | 150 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); |
| 141 }; | 151 }; |
| 142 | 152 |
| 143 } // namespace content | 153 } // namespace content |
| 144 | 154 |
| 145 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ | 155 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ |
| OLD | NEW |