Chromium Code Reviews| Index: content/browser/renderer_host/input/touch_event_queue.cc |
| diff --git a/content/browser/renderer_host/input/touch_event_queue.cc b/content/browser/renderer_host/input/touch_event_queue.cc |
| index b0646ebdff63fe82ef2154076f3e3823eab4c65e..b8937156a191bd0d7f9fd6931e3b4dca5775356b 100644 |
| --- a/content/browser/renderer_host/input/touch_event_queue.cc |
| +++ b/content/browser/renderer_host/input/touch_event_queue.cc |
| @@ -392,20 +392,11 @@ void TouchEventQueue::ProcessTouchAck(InputEventAckState ack_result, |
| if (touch_queue_.empty()) |
| return; |
| - const WebTouchEvent& acked_event = |
| - touch_queue_.front()->coalesced_event().event; |
| - |
| if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED && |
| touch_filtering_state_ == FORWARD_TOUCHES_UNTIL_TIMEOUT) { |
| touch_filtering_state_ = FORWARD_ALL_TOUCHES; |
| } |
| - if (ack_result == INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS && |
| - touch_filtering_state_ != DROP_ALL_TOUCHES && |
| - WebTouchEventTraits::IsTouchSequenceStart(acked_event)) { |
| - touch_filtering_state_ = DROP_TOUCHES_IN_SEQUENCE; |
| - } |
| - |
| PopTouchEventToClient(ack_result, latency_info); |
| TryForwardNextEventToRenderer(); |
| } |
| @@ -473,7 +464,13 @@ void TouchEventQueue::ForwardNextEventToRenderer() { |
| DCHECK(pending_async_touch_move_->CanCoalesceWith(touch)); |
| pending_async_touch_move_->CoalesceWith(touch); |
| } |
| + DCHECK_EQ(1U, size()); |
| PopTouchEventToClient(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| + // It's possible (though unlikely) that ack'ing the current touch will |
| + // trigger the queueing of another touch event (e.g., a touchcancel). As |
| + // forwarding of the queued event will be deferred while the ack is being |
| + // dispatched (see |OnTouchEvent()|), try forwarding it now. |
| + TryForwardNextEventToRenderer(); |
| return; |
| } |
| } |
| @@ -521,6 +518,26 @@ void TouchEventQueue::OnGestureScrollEvent( |
| if (gesture_event.event.type != blink::WebInputEvent::GestureScrollBegin) |
| return; |
| + if (touch_filtering_state_ != DROP_ALL_TOUCHES && |
| + touch_filtering_state_ != DROP_TOUCHES_IN_SEQUENCE) { |
| + // As an optimization, drop all remaining touch events in the sequence if |
| + // scrolling begins while *none* of the touch points have a consumer. |
| + bool no_consumers_exist = true; |
| + for (TouchPointAckStates::const_iterator iter = touch_ack_states_.begin(), |
|
jdduke (slow)
2014/04/28 18:08:15
Rick, do you think this is a worthwhile optimizati
Rick Byers
2014/04/28 21:45:22
Hmm - interesting scenario. My gut instinct is th
jdduke (slow)
2014/04/28 22:04:59
Interesting, that sounds like a reasonable use-cas
|
| + end = touch_ack_states_.end(); |
| + iter != end; |
| + ++iter) { |
| + if (iter->second != INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS) { |
| + no_consumers_exist = false; |
| + break; |
| + } |
| + } |
| + if (no_consumers_exist) { |
| + touch_filtering_state_ = DROP_TOUCHES_IN_SEQUENCE; |
| + return; |
| + } |
| + } |
| + |
| if (touch_scrolling_mode_ == TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE) { |
| pending_async_touch_move_.reset(); |
| send_touch_events_async_ = true; |