| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 client_->OnTouchEventAck((*iter), ack_result); | 206 client_->OnTouchEventAck((*iter), ack_result); |
| 206 } | 207 } |
| 207 } | 208 } |
| 208 | 209 |
| 209 bool TouchEventQueue::ShouldForwardToRenderer( | 210 bool TouchEventQueue::ShouldForwardToRenderer( |
| 210 const WebKit::WebTouchEvent& event) const { | 211 const WebKit::WebTouchEvent& event) const { |
| 211 // Touch press events should always be forwarded to the renderer. | 212 // Touch press events should always be forwarded to the renderer. |
| 212 if (event.type == WebKit::WebInputEvent::TouchStart) | 213 if (event.type == WebKit::WebInputEvent::TouchStart) |
| 213 return true; | 214 return true; |
| 214 | 215 |
| 216 if (event.type == WebKit::WebInputEvent::TouchMove && |
| 217 no_touch_move_to_renderer_) |
| 218 return false; |
| 219 |
| 215 for (unsigned int i = 0; i < event.touchesLength; ++i) { | 220 for (unsigned int i = 0; i < event.touchesLength; ++i) { |
| 216 const WebKit::WebTouchPoint& point = event.touches[i]; | 221 const WebKit::WebTouchPoint& point = event.touches[i]; |
| 217 // If a point has been stationary, then don't take it into account. | 222 // If a point has been stationary, then don't take it into account. |
| 218 if (point.state == WebKit::WebTouchPoint::StateStationary) | 223 if (point.state == WebKit::WebTouchPoint::StateStationary) |
| 219 continue; | 224 continue; |
| 220 | 225 |
| 221 if (touch_ack_states_.count(point.id) > 0) { | 226 if (touch_ack_states_.count(point.id) > 0) { |
| 222 if (touch_ack_states_.find(point.id)->second != | 227 if (touch_ack_states_.find(point.id)->second != |
| 223 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS) | 228 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS) |
| 224 return true; | 229 return true; |
| 225 } else { | 230 } else { |
| 226 // If the ACK status of a point is unknown, then the event should be | 231 // If the ACK status of a point is unknown, then the event should be |
| 227 // forwarded to the renderer. | 232 // forwarded to the renderer. |
| 228 return true; | 233 return true; |
| 229 } | 234 } |
| 230 } | 235 } |
| 231 | 236 |
| 232 return false; | 237 return false; |
| 233 } | 238 } |
| 234 | 239 |
| 235 } // namespace content | 240 } // namespace content |
| OLD | NEW |