| 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 #include "content/browser/renderer_host/input/touch_event_queue.h" | 5 #include "content/browser/renderer_host/input/touch_event_queue.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 | 10 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 TouchEventWithLatencyInfo coalesced_event_; | 84 TouchEventWithLatencyInfo coalesced_event_; |
| 85 | 85 |
| 86 // This is the list of the original events that were coalesced. | 86 // This is the list of the original events that were coalesced. |
| 87 WebTouchEventWithLatencyList events_; | 87 WebTouchEventWithLatencyList events_; |
| 88 | 88 |
| 89 DISALLOW_COPY_AND_ASSIGN(CoalescedWebTouchEvent); | 89 DISALLOW_COPY_AND_ASSIGN(CoalescedWebTouchEvent); |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 TouchEventQueue::TouchEventQueue(TouchEventQueueClient* client) | 92 TouchEventQueue::TouchEventQueue(TouchEventQueueClient* client) |
| 93 : client_(client), | 93 : client_(client), |
| 94 dispatching_touch_ack_(false) { | 94 dispatching_touch_ack_(false), |
| 95 no_touch_move_to_renderer_(false) { |
| 95 DCHECK(client); | 96 DCHECK(client); |
| 96 } | 97 } |
| 97 | 98 |
| 98 TouchEventQueue::~TouchEventQueue() { | 99 TouchEventQueue::~TouchEventQueue() { |
| 99 if (!touch_queue_.empty()) | 100 if (!touch_queue_.empty()) |
| 100 STLDeleteElements(&touch_queue_); | 101 STLDeleteElements(&touch_queue_); |
| 101 } | 102 } |
| 102 | 103 |
| 103 void TouchEventQueue::QueueEvent(const TouchEventWithLatencyInfo& event) { | 104 void TouchEventQueue::QueueEvent(const TouchEventWithLatencyInfo& event) { |
| 104 // If the queueing of |event| was triggered by an ack dispatch, defer | 105 // If the queueing of |event| was triggered by an ack dispatch, defer |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 client_->OnTouchEventAck((*iter), ack_result); | 199 client_->OnTouchEventAck((*iter), ack_result); |
| 199 } | 200 } |
| 200 } | 201 } |
| 201 | 202 |
| 202 bool TouchEventQueue::ShouldForwardToRenderer( | 203 bool TouchEventQueue::ShouldForwardToRenderer( |
| 203 const WebKit::WebTouchEvent& event) const { | 204 const WebKit::WebTouchEvent& event) const { |
| 204 // Touch press events should always be forwarded to the renderer. | 205 // Touch press events should always be forwarded to the renderer. |
| 205 if (event.type == WebKit::WebInputEvent::TouchStart) | 206 if (event.type == WebKit::WebInputEvent::TouchStart) |
| 206 return true; | 207 return true; |
| 207 | 208 |
| 209 if (event.type == WebKit::WebInputEvent::TouchMove && |
| 210 no_touch_move_to_renderer_) |
| 211 return false; |
| 212 |
| 208 for (unsigned int i = 0; i < event.touchesLength; ++i) { | 213 for (unsigned int i = 0; i < event.touchesLength; ++i) { |
| 209 const WebKit::WebTouchPoint& point = event.touches[i]; | 214 const WebKit::WebTouchPoint& point = event.touches[i]; |
| 210 // If a point has been stationary, then don't take it into account. | 215 // If a point has been stationary, then don't take it into account. |
| 211 if (point.state == WebKit::WebTouchPoint::StateStationary) | 216 if (point.state == WebKit::WebTouchPoint::StateStationary) |
| 212 continue; | 217 continue; |
| 213 | 218 |
| 214 if (touch_ack_states_.count(point.id) > 0) { | 219 if (touch_ack_states_.count(point.id) > 0) { |
| 215 if (touch_ack_states_.find(point.id)->second != | 220 if (touch_ack_states_.find(point.id)->second != |
| 216 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS) | 221 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS) |
| 217 return true; | 222 return true; |
| 218 } else { | 223 } else { |
| 219 // If the ACK status of a point is unknown, then the event should be | 224 // If the ACK status of a point is unknown, then the event should be |
| 220 // forwarded to the renderer. | 225 // forwarded to the renderer. |
| 221 return true; | 226 return true; |
| 222 } | 227 } |
| 223 } | 228 } |
| 224 | 229 |
| 225 return false; | 230 return false; |
| 226 } | 231 } |
| 227 | 232 |
| 228 } // namespace content | 233 } // namespace content |
| OLD | NEW |