| 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 #include "ui/events/blink/web_input_event_traits.h" | 10 #include "ui/events/blink/web_input_event_traits.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 GestureEventQueue::~GestureEventQueue() { } | 80 GestureEventQueue::~GestureEventQueue() { } |
| 81 | 81 |
| 82 void GestureEventQueue::QueueEvent( | 82 void GestureEventQueue::QueueEvent( |
| 83 const GestureEventWithLatencyInfo& gesture_event) { | 83 const GestureEventWithLatencyInfo& gesture_event) { |
| 84 TRACE_EVENT0("input", "GestureEventQueue::QueueEvent"); | 84 TRACE_EVENT0("input", "GestureEventQueue::QueueEvent"); |
| 85 if (!ShouldForwardForBounceReduction(gesture_event) || | 85 if (!ShouldForwardForBounceReduction(gesture_event) || |
| 86 !ShouldForwardForGFCFiltering(gesture_event) || | 86 !ShouldForwardForGFCFiltering(gesture_event) || |
| 87 !ShouldForwardForTapSuppression(gesture_event)) { | 87 !ShouldForwardForTapSuppression(gesture_event)) { |
| 88 return; | 88 return; |
| 89 } | 89 } |
| 90 | |
| 91 QueueAndForwardIfNecessary(gesture_event); | 90 QueueAndForwardIfNecessary(gesture_event); |
| 92 } | 91 } |
| 93 | 92 |
| 94 bool GestureEventQueue::ShouldDiscardFlingCancelEvent( | 93 bool GestureEventQueue::ShouldDiscardFlingCancelEvent( |
| 95 const GestureEventWithLatencyInfo& gesture_event) const { | 94 const GestureEventWithLatencyInfo& gesture_event) const { |
| 96 if (coalesced_gesture_events_.empty() && fling_in_progress_) | 95 if (coalesced_gesture_events_.empty() && fling_in_progress_) |
| 97 return false; | 96 return false; |
| 98 GestureQueue::const_reverse_iterator it = | 97 GestureQueue::const_reverse_iterator it = |
| 99 coalesced_gesture_events_.rbegin(); | 98 coalesced_gesture_events_.rbegin(); |
| 100 while (it != coalesced_gesture_events_.rend()) { | 99 while (it != coalesced_gesture_events_.rend()) { |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 const GestureEventWithLatencyInfo& gesture_event) { | 298 const GestureEventWithLatencyInfo& gesture_event) { |
| 300 QueueAndForwardIfNecessary(gesture_event); | 299 QueueAndForwardIfNecessary(gesture_event); |
| 301 } | 300 } |
| 302 | 301 |
| 303 void GestureEventQueue::SendScrollEndingEventsNow() { | 302 void GestureEventQueue::SendScrollEndingEventsNow() { |
| 304 scrolling_in_progress_ = false; | 303 scrolling_in_progress_ = false; |
| 305 if (debouncing_deferral_queue_.empty()) | 304 if (debouncing_deferral_queue_.empty()) |
| 306 return; | 305 return; |
| 307 GestureQueue debouncing_deferral_queue; | 306 GestureQueue debouncing_deferral_queue; |
| 308 debouncing_deferral_queue.swap(debouncing_deferral_queue_); | 307 debouncing_deferral_queue.swap(debouncing_deferral_queue_); |
| 309 for (GestureQueue::const_iterator it = debouncing_deferral_queue.begin(); | 308 for (GestureQueue::iterator it = debouncing_deferral_queue.begin(); |
| 310 it != debouncing_deferral_queue.end(); it++) { | 309 it != debouncing_deferral_queue.end(); it++) { |
| 311 if (ShouldForwardForGFCFiltering(*it) && | 310 if (ShouldForwardForGFCFiltering(*it) && |
| 312 ShouldForwardForTapSuppression(*it)) { | 311 ShouldForwardForTapSuppression(*it)) { |
| 312 if (it->event.type == WebInputEvent::GestureScrollEnd && |
| 313 it < debouncing_deferral_queue.end() - 1 && |
| 314 (it + 1)->event.type == WebInputEvent::GestureFlingStart) { |
| 315 it->event.data.scrollEnd.flingMightHappenNext = true; |
| 316 } |
| 313 QueueAndForwardIfNecessary(*it); | 317 QueueAndForwardIfNecessary(*it); |
| 314 } | 318 } |
| 315 } | 319 } |
| 316 } | 320 } |
| 317 | 321 |
| 318 void GestureEventQueue::QueueScrollOrPinchAndForwardIfNecessary( | 322 void GestureEventQueue::QueueScrollOrPinchAndForwardIfNecessary( |
| 319 const GestureEventWithLatencyInfo& gesture_event) { | 323 const GestureEventWithLatencyInfo& gesture_event) { |
| 320 DCHECK_GE(coalesced_gesture_events_.size(), EventsInFlightCount()); | 324 DCHECK_GE(coalesced_gesture_events_.size(), EventsInFlightCount()); |
| 321 const size_t unsent_events_count = | 325 const size_t unsent_events_count = |
| 322 coalesced_gesture_events_.size() - EventsInFlightCount(); | 326 coalesced_gesture_events_.size() - EventsInFlightCount(); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 return 0; | 415 return 0; |
| 412 | 416 |
| 413 if (!ignore_next_ack_) | 417 if (!ignore_next_ack_) |
| 414 return 1; | 418 return 1; |
| 415 | 419 |
| 416 DCHECK_GT(coalesced_gesture_events_.size(), 1U); | 420 DCHECK_GT(coalesced_gesture_events_.size(), 1U); |
| 417 return 2; | 421 return 2; |
| 418 } | 422 } |
| 419 | 423 |
| 420 } // namespace content | 424 } // namespace content |
| OLD | NEW |