| 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 61166815b2b171010adafe566bca6d9063ee7bff..41fbaacf33db69b59be82cbcc6fbedc0de349592 100644
|
| --- a/content/browser/renderer_host/input/touch_event_queue.cc
|
| +++ b/content/browser/renderer_host/input/touch_event_queue.cc
|
| @@ -292,12 +292,15 @@ class CoalescedWebTouchEvent {
|
| DISALLOW_COPY_AND_ASSIGN(CoalescedWebTouchEvent);
|
| };
|
|
|
| -TouchEventQueue::TouchEventQueue(TouchEventQueueClient* client)
|
| +TouchEventQueue::TouchEventQueue(TouchEventQueueClient* client,
|
| + TouchScrollingMode mode)
|
| : client_(client),
|
| dispatching_touch_ack_(NULL),
|
| dispatching_touch_(false),
|
| touch_filtering_state_(TOUCH_FILTERING_STATE_DEFAULT),
|
| - ack_timeout_enabled_(false) {
|
| + ack_timeout_enabled_(false),
|
| + touch_scrolling_mode_(mode),
|
| + absorbing_touch_moves_(false) {
|
| DCHECK(client);
|
| }
|
|
|
| @@ -401,6 +404,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
|
| @@ -420,6 +424,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
|
| @@ -443,6 +450,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
|
| + // 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_);
|
| @@ -568,6 +594,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;
|
|
|