| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/gesture_event_queue.h" | 5 #include "content/browser/renderer_host/input/gesture_event_queue.h" |
| 6 | 6 |
| 7 #include "base/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
| 8 #include "content/browser/renderer_host/input/touchpad_tap_suppression_controlle
r.h" | 8 #include "content/browser/renderer_host/input/touchpad_tap_suppression_controlle
r.h" |
| 9 #include "content/browser/renderer_host/input/touchscreen_tap_suppression_contro
ller.h" | 9 #include "content/browser/renderer_host/input/touchscreen_tap_suppression_contro
ller.h" |
| 10 | 10 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 case WebInputEvent::GestureFlingCancel: | 179 case WebInputEvent::GestureFlingCancel: |
| 180 fling_in_progress_ = false; | 180 fling_in_progress_ = false; |
| 181 break; | 181 break; |
| 182 case WebInputEvent::GestureFlingStart: | 182 case WebInputEvent::GestureFlingStart: |
| 183 fling_in_progress_ = true; | 183 fling_in_progress_ = true; |
| 184 break; | 184 break; |
| 185 case WebInputEvent::GesturePinchUpdate: | 185 case WebInputEvent::GesturePinchUpdate: |
| 186 case WebInputEvent::GestureScrollUpdate: | 186 case WebInputEvent::GestureScrollUpdate: |
| 187 QueueScrollOrPinchAndForwardIfNecessary(gesture_event); | 187 QueueScrollOrPinchAndForwardIfNecessary(gesture_event); |
| 188 return; | 188 return; |
| 189 case WebInputEvent::GestureScrollBegin: |
| 190 if (OnScrollBegin(gesture_event)) |
| 191 return; |
| 189 default: | 192 default: |
| 190 break; | 193 break; |
| 191 } | 194 } |
| 192 | 195 |
| 193 coalesced_gesture_events_.push_back(gesture_event); | 196 coalesced_gesture_events_.push_back(gesture_event); |
| 194 if (coalesced_gesture_events_.size() == 1) | 197 if (coalesced_gesture_events_.size() == 1) |
| 195 client_->SendGestureEventImmediately(gesture_event); | 198 client_->SendGestureEventImmediately(gesture_event); |
| 196 } | 199 } |
| 197 | 200 |
| 201 bool GestureEventQueue::OnScrollBegin( |
| 202 const GestureEventWithLatencyInfo& gesture_event) { |
| 203 // If a synthetic scroll begin is encountered, it can cancel out a previous |
| 204 // synthetic scroll end. This allows a later gesture scroll update to coalesce |
| 205 // with the previous one. crbug.com/607340. |
| 206 bool synthetic = gesture_event.event.data.scrollBegin.synthetic; |
| 207 bool have_unsent_events = |
| 208 EventsInFlightCount() < coalesced_gesture_events_.size(); |
| 209 if (synthetic && have_unsent_events) { |
| 210 GestureEventWithLatencyInfo* last_event = &coalesced_gesture_events_.back(); |
| 211 if (last_event->event.type == WebInputEvent::GestureScrollEnd && |
| 212 last_event->event.data.scrollEnd.synthetic) { |
| 213 coalesced_gesture_events_.pop_back(); |
| 214 return true; |
| 215 } |
| 216 } |
| 217 return false; |
| 218 } |
| 219 |
| 198 void GestureEventQueue::ProcessGestureAck(InputEventAckState ack_result, | 220 void GestureEventQueue::ProcessGestureAck(InputEventAckState ack_result, |
| 199 WebInputEvent::Type type, | 221 WebInputEvent::Type type, |
| 200 const ui::LatencyInfo& latency) { | 222 const ui::LatencyInfo& latency) { |
| 201 TRACE_EVENT0("input", "GestureEventQueue::ProcessGestureAck"); | 223 TRACE_EVENT0("input", "GestureEventQueue::ProcessGestureAck"); |
| 202 | 224 |
| 203 if (coalesced_gesture_events_.empty()) { | 225 if (coalesced_gesture_events_.empty()) { |
| 204 DLOG(ERROR) << "Received unexpected ACK for event type " << type; | 226 DLOG(ERROR) << "Received unexpected ACK for event type " << type; |
| 205 return; | 227 return; |
| 206 } | 228 } |
| 207 | 229 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 return 0; | 410 return 0; |
| 389 | 411 |
| 390 if (!ignore_next_ack_) | 412 if (!ignore_next_ack_) |
| 391 return 1; | 413 return 1; |
| 392 | 414 |
| 393 DCHECK_GT(coalesced_gesture_events_.size(), 1U); | 415 DCHECK_GT(coalesced_gesture_events_.size(), 1U); |
| 394 return 2; | 416 return 2; |
| 395 } | 417 } |
| 396 | 418 |
| 397 } // namespace content | 419 } // namespace content |
| OLD | NEW |