Chromium Code Reviews| 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 (FilterScrollBegin(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::FilterScrollBegin( | |
| 202 const GestureEventWithLatencyInfo& gesture_event) { | |
| 203 // If a synthetic scroll begin is encountered; it can cancel out a previous | |
|
tdresser
2016/05/02 13:27:15
; -> ,
dtapuska
2016/05/02 13:57:24
Done.
| |
| 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 if (synthetic && EventsInFlightCount() < coalesced_gesture_events_.size()) { | |
|
tdresser
2016/05/02 13:27:15
Might be worth factoring out |EventsInFlightCount(
dtapuska
2016/05/02 13:57:24
Done.
| |
| 208 GestureEventWithLatencyInfo* last_event = &coalesced_gesture_events_.back(); | |
| 209 if (last_event->event.type == WebInputEvent::GestureScrollEnd && | |
| 210 last_event->event.data.scrollEnd.synthetic) { | |
| 211 coalesced_gesture_events_.pop_back(); | |
| 212 return true; | |
| 213 } | |
| 214 } | |
| 215 return false; | |
| 216 } | |
| 217 | |
| 198 void GestureEventQueue::ProcessGestureAck(InputEventAckState ack_result, | 218 void GestureEventQueue::ProcessGestureAck(InputEventAckState ack_result, |
| 199 WebInputEvent::Type type, | 219 WebInputEvent::Type type, |
| 200 const ui::LatencyInfo& latency) { | 220 const ui::LatencyInfo& latency) { |
| 201 TRACE_EVENT0("input", "GestureEventQueue::ProcessGestureAck"); | 221 TRACE_EVENT0("input", "GestureEventQueue::ProcessGestureAck"); |
| 202 | 222 |
| 203 if (coalesced_gesture_events_.empty()) { | 223 if (coalesced_gesture_events_.empty()) { |
| 204 DLOG(ERROR) << "Received unexpected ACK for event type " << type; | 224 DLOG(ERROR) << "Received unexpected ACK for event type " << type; |
| 205 return; | 225 return; |
| 206 } | 226 } |
| 207 | 227 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 return 0; | 408 return 0; |
| 389 | 409 |
| 390 if (!ignore_next_ack_) | 410 if (!ignore_next_ack_) |
| 391 return 1; | 411 return 1; |
| 392 | 412 |
| 393 DCHECK_GT(coalesced_gesture_events_.size(), 1U); | 413 DCHECK_GT(coalesced_gesture_events_.size(), 1U); |
| 394 return 2; | 414 return 2; |
| 395 } | 415 } |
| 396 | 416 |
| 397 } // namespace content | 417 } // namespace content |
| OLD | NEW |