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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <deque> | 11 #include <deque> |
| 12 #include <list> | |
| 12 #include <map> | 13 #include <map> |
|
tdresser
2016/04/01 14:50:24
It looks like this include is unused. Can you remo
mustaq
2016/04/01 18:31:04
Done.
| |
| 13 | 14 |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 16 #include "content/browser/renderer_host/event_with_latency_info.h" | 17 #include "content/browser/renderer_host/event_with_latency_info.h" |
| 17 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
| 18 #include "content/common/input/input_event_ack_state.h" | 19 #include "content/common/input/input_event_ack_state.h" |
| 19 #include "third_party/WebKit/public/web/WebInputEvent.h" | 20 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 20 #include "ui/gfx/geometry/point_f.h" | 21 #include "ui/gfx/geometry/point_f.h" |
| 21 | 22 |
| 22 namespace content { | 23 namespace content { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 TouchEventQueue(TouchEventQueueClient* client, const Config& config); | 64 TouchEventQueue(TouchEventQueueClient* client, const Config& config); |
| 64 | 65 |
| 65 ~TouchEventQueue(); | 66 ~TouchEventQueue(); |
| 66 | 67 |
| 67 // Adds an event to the queue. The event may be coalesced with previously | 68 // Adds an event to the queue. The event may be coalesced with previously |
| 68 // queued events (e.g. consecutive touch-move events can be coalesced into a | 69 // queued events (e.g. consecutive touch-move events can be coalesced into a |
| 69 // single touch-move event). The event may also be immediately forwarded to | 70 // single touch-move event). The event may also be immediately forwarded to |
| 70 // the renderer (e.g. when there are no other queued touch event). | 71 // the renderer (e.g. when there are no other queued touch event). |
| 71 void QueueEvent(const TouchEventWithLatencyInfo& event); | 72 void QueueEvent(const TouchEventWithLatencyInfo& event); |
| 72 | 73 |
| 74 // Insert a TouchScrollStarted event in the queue ahead of all not-in-flight | |
| 75 // events. | |
| 76 void PrependTouchScrollNotification(); | |
| 77 | |
| 73 // Notifies the queue that a touch-event has been processed by the renderer. | 78 // Notifies the queue that a touch-event has been processed by the renderer. |
| 74 // At this point, if the ack is for async touchmove, remove the uncancelable | 79 // At this point, if the ack is for async touchmove, remove the uncancelable |
| 75 // touchmove from the front of the queue and decide if it should dispatch the | 80 // touchmove from the front of the queue and decide if it should dispatch the |
| 76 // next pending async touch move event, otherwise the queue may send one or | 81 // next pending async touch move event, otherwise the queue may send one or |
| 77 // more gesture events and/or additional queued touch-events to the renderer. | 82 // more gesture events and/or additional queued touch-events to the renderer. |
| 78 void ProcessTouchAck(InputEventAckState ack_result, | 83 void ProcessTouchAck(InputEventAckState ack_result, |
| 79 const ui::LatencyInfo& latency_info, | 84 const ui::LatencyInfo& latency_info, |
| 80 const uint32_t unique_touch_event_id); | 85 const uint32_t unique_touch_event_id); |
| 81 | 86 |
| 82 // When GestureScrollBegin is received, we send a touch cancel to renderer, | 87 // When GestureScrollBegin is received, we send a touch cancel to renderer, |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 102 void SetAckTimeoutEnabled(bool enabled); | 107 void SetAckTimeoutEnabled(bool enabled); |
| 103 | 108 |
| 104 // Sets whether the current site has a mobile friendly viewport. This | 109 // Sets whether the current site has a mobile friendly viewport. This |
| 105 // determines which ack timeout delay will be used for *future* touch events. | 110 // determines which ack timeout delay will be used for *future* touch events. |
| 106 // The default assumption is that the site is *not* mobile-optimized. | 111 // The default assumption is that the site is *not* mobile-optimized. |
| 107 void SetIsMobileOptimizedSite(bool mobile_optimized_site); | 112 void SetIsMobileOptimizedSite(bool mobile_optimized_site); |
| 108 | 113 |
| 109 // Whether ack timeout behavior is supported and enabled for the current site. | 114 // Whether ack timeout behavior is supported and enabled for the current site. |
| 110 bool IsAckTimeoutEnabled() const; | 115 bool IsAckTimeoutEnabled() const; |
| 111 | 116 |
| 112 bool IsForwardingTouches(); | |
| 113 | |
| 114 bool empty() const WARN_UNUSED_RESULT { | 117 bool empty() const WARN_UNUSED_RESULT { |
| 115 return touch_queue_.empty(); | 118 return touch_queue_.empty(); |
| 116 } | 119 } |
| 117 | 120 |
| 118 size_t size() const { | 121 size_t size() const { |
| 119 return touch_queue_.size(); | 122 return touch_queue_.size(); |
| 120 } | 123 } |
| 121 | 124 |
| 122 bool has_handlers() const { return has_handlers_; } | 125 bool has_handlers() const { return has_handlers_; } |
| 123 | 126 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 148 void ForwardNextEventToRenderer(); | 151 void ForwardNextEventToRenderer(); |
| 149 | 152 |
| 150 // Pops the touch-event from the head of the queue and acks it to the client. | 153 // Pops the touch-event from the head of the queue and acks it to the client. |
| 151 void PopTouchEventToClient(InputEventAckState ack_result); | 154 void PopTouchEventToClient(InputEventAckState ack_result); |
| 152 | 155 |
| 153 // Pops the touch-event from the top of the queue and acks it to the client, | 156 // Pops the touch-event from the top of the queue and acks it to the client, |
| 154 // updating the event with |renderer_latency_info|. | 157 // updating the event with |renderer_latency_info|. |
| 155 void PopTouchEventToClient(InputEventAckState ack_result, | 158 void PopTouchEventToClient(InputEventAckState ack_result, |
| 156 const ui::LatencyInfo& renderer_latency_info); | 159 const ui::LatencyInfo& renderer_latency_info); |
| 157 | 160 |
| 158 // Ack all coalesced events in |acked_event| to the client with |ack_result|, | 161 // Ack all coalesced events at the head of the queue to the client with |
| 159 // updating the acked events with |optional_latency_info| if it exists. | 162 // |ack_result|, updating the acked events with |optional_latency_info| if it |
| 163 // exists, and popping the head of the queue. | |
| 160 void AckTouchEventToClient(InputEventAckState ack_result, | 164 void AckTouchEventToClient(InputEventAckState ack_result, |
| 161 scoped_ptr<CoalescedWebTouchEvent> acked_event, | |
| 162 const ui::LatencyInfo* optional_latency_info); | 165 const ui::LatencyInfo* optional_latency_info); |
| 163 | 166 |
| 164 // Safely pop the head of the queue. | |
| 165 scoped_ptr<CoalescedWebTouchEvent> PopTouchEvent(); | |
| 166 | |
| 167 // Dispatch |touch| to the client. Before dispatching, updates pointer | 167 // Dispatch |touch| to the client. Before dispatching, updates pointer |
| 168 // states in touchmove events for pointers that have not changed position. | 168 // states in touchmove events for pointers that have not changed position. |
| 169 void SendTouchEventImmediately(TouchEventWithLatencyInfo* touch); | 169 void SendTouchEventImmediately(TouchEventWithLatencyInfo* touch); |
| 170 | 170 |
| 171 enum PreFilterResult { | 171 enum PreFilterResult { |
| 172 ACK_WITH_NO_CONSUMER_EXISTS, | 172 ACK_WITH_NO_CONSUMER_EXISTS, |
| 173 ACK_WITH_NOT_CONSUMED, | 173 ACK_WITH_NOT_CONSUMED, |
| 174 FORWARD_TO_RENDERER, | 174 FORWARD_TO_RENDERER, |
| 175 }; | 175 }; |
| 176 // Filter touches prior to forwarding to the renderer, e.g., if the renderer | 176 // Filter touches prior to forwarding to the renderer, e.g., if the renderer |
| 177 // has no touch handler. | 177 // has no touch handler. |
| 178 PreFilterResult FilterBeforeForwarding(const blink::WebTouchEvent& event); | 178 PreFilterResult FilterBeforeForwarding(const blink::WebTouchEvent& event); |
| 179 void ForwardToRenderer(const TouchEventWithLatencyInfo& event); | 179 void ForwardToRenderer(const TouchEventWithLatencyInfo& event); |
| 180 void UpdateTouchConsumerStates(const blink::WebTouchEvent& event, | 180 void UpdateTouchConsumerStates(const blink::WebTouchEvent& event, |
| 181 InputEventAckState ack_result); | 181 InputEventAckState ack_result); |
| 182 void FlushPendingAsyncTouchmove(); | 182 void FlushPendingAsyncTouchmove(); |
| 183 | 183 |
| 184 // Handles touch event forwarding and ack'ed event dispatch. | 184 // Handles touch event forwarding and ack'ed event dispatch. |
| 185 TouchEventQueueClient* client_; | 185 TouchEventQueueClient* client_; |
| 186 | 186 |
| 187 typedef std::deque<CoalescedWebTouchEvent*> TouchQueue; | 187 typedef std::list<CoalescedWebTouchEvent*> TouchQueue; |
| 188 TouchQueue touch_queue_; | 188 TouchQueue touch_queue_; |
| 189 | 189 |
| 190 // Position of the first touch in the most recent sequence forwarded to the | 190 // Position of the first touch in the most recent sequence forwarded to the |
| 191 // client. | 191 // client. |
| 192 gfx::PointF touch_sequence_start_position_; | 192 gfx::PointF touch_sequence_start_position_; |
| 193 | 193 |
| 194 // Used to defer touch forwarding when ack dispatch triggers |QueueEvent()|. | 194 // Used to defer touch forwarding when ack dispatch triggers |QueueEvent()|. |
| 195 // True within the scope of |AckTouchEventToClient()|. | 195 // True within the scope of |AckTouchEventToClient()|. |
| 196 bool dispatching_touch_ack_; | 196 bool dispatching_touch_ack_; |
| 197 | 197 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 242 | 242 |
| 243 // Event is saved to compare pointer positions for new touchmove events. | 243 // Event is saved to compare pointer positions for new touchmove events. |
| 244 scoped_ptr<blink::WebTouchEvent> last_sent_touchevent_; | 244 scoped_ptr<blink::WebTouchEvent> last_sent_touchevent_; |
| 245 | 245 |
| 246 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); | 246 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); |
| 247 }; | 247 }; |
| 248 | 248 |
| 249 } // namespace content | 249 } // namespace content |
| 250 | 250 |
| 251 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ | 251 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ |
| OLD | NEW |