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 b32537dd228fac517ef3b59f82d8e20670e9bd07..1df3039b36445b87765732bcc9b3aa42475a7a23 100644 |
| --- a/content/browser/renderer_host/input/touch_event_queue.cc |
| +++ b/content/browser/renderer_host/input/touch_event_queue.cc |
| @@ -288,12 +288,15 @@ class CoalescedWebTouchEvent { |
| }; |
| TouchEventQueue::TouchEventQueue(TouchEventQueueClient* client, |
| + TouchScrollingMode mode, |
| double touchmove_suppression_length_dips) |
| : client_(client), |
| dispatching_touch_ack_(NULL), |
| dispatching_touch_(false), |
| touch_filtering_state_(TOUCH_FILTERING_STATE_DEFAULT), |
| ack_timeout_enabled_(false), |
| + touch_scrolling_mode_(mode), |
| + absorbing_touch_moves_(false), |
| touchmove_slop_suppressor_( |
| new TouchMoveSlopSuppressor(touchmove_suppression_length_dips)) { |
| DCHECK(client); |
| @@ -398,6 +401,7 @@ void TouchEventQueue::ForwardToRenderer( |
| ack_timeout_enabled_ ? FORWARD_TOUCHES_UNTIL_TIMEOUT |
| : FORWARD_ALL_TOUCHES; |
| touch_ack_states_.clear(); |
| + absorbing_touch_moves_ = false; |
| } |
| // A synchronous ack will reset |dispatching_touch_|, in which case |
| @@ -417,6 +421,9 @@ void TouchEventQueue::OnGestureScrollEvent( |
| if (gesture_event.event.type != blink::WebInputEvent::GestureScrollBegin) |
| return; |
| + if (touch_scrolling_mode_ != TOUCH_SCROLLING_MODE_TOUCHCANCEL) |
| + return; |
| + |
| // We assume that scroll events are generated synchronously from |
| // dispatching a touch event ack. This allows us to generate a synthetic |
| // cancel event that has the same touch ids as the touch event that |
| @@ -440,6 +447,25 @@ void TouchEventQueue::OnGestureScrollEvent( |
| dispatching_touch_ack_->coalesced_event()), true)); |
| } |
| +void TouchEventQueue::OnGestureEventAck( |
| + const GestureEventWithLatencyInfo& event, |
| + InputEventAckState ack_result) { |
| + if (touch_scrolling_mode_ != TOUCH_SCROLLING_MODE_ABSORB_TOUCHMOVE) |
| + return; |
| + |
| + if (event.event.type != blink::WebInputEvent::GestureScrollUpdate) |
| + return; |
| + |
| + // Suspend sending touchmove events as long as the scroll events are handled. |
| + // Note that there's no guarantee that this ACK is for the most recent |
| + // gesture event (or even part of the current sequence). Worse case, the |
|
jdduke (slow)
2014/02/14 21:18:00
Worse -> Worst
tdresser
2014/02/14 21:24:40
Done.
|
| + // delay in updating the absorption state should onl result in minor UI |
| + // glitches. |
| + // TODO(rbyers): Define precise timing requirements and potentially implement |
| + // mitigations for races. |
| + absorbing_touch_moves_ = (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED); |
| +} |
| + |
| void TouchEventQueue::OnHasTouchEventHandlers(bool has_handlers) { |
| DCHECK(!dispatching_touch_ack_); |
| DCHECK(!dispatching_touch_); |
| @@ -549,6 +575,9 @@ TouchEventQueue::FilterBeforeForwarding(const WebTouchEvent& event) { |
| return ACK_WITH_NOT_CONSUMED; |
| } |
| + if (absorbing_touch_moves_ && event.type == WebInputEvent::TouchMove) |
| + return ACK_WITH_NOT_CONSUMED; |
| + |
| // Touch press events should always be forwarded to the renderer. |
| if (event.type == WebInputEvent::TouchStart) |
| return FORWARD_TO_RENDERER; |