| 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 ee1c7c242ef3faae6f696a758241c2a3557443f8..81c3e4777755237929f7364ea5565eedb4e3ce4a 100644
|
| --- a/content/browser/renderer_host/input/touch_event_queue.cc
|
| +++ b/content/browser/renderer_host/input/touch_event_queue.cc
|
| @@ -235,12 +235,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);
|
| }
|
|
|
| @@ -326,6 +329,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
|
| @@ -345,6 +349,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
|
| @@ -368,6 +375,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_);
|
| @@ -478,6 +504,9 @@ bool TouchEventQueue::ShouldForwardToRenderer(
|
| return false;
|
| }
|
|
|
| + if (absorbing_touch_moves_ && event.type == WebInputEvent::TouchMove)
|
| + return false;
|
| +
|
| // Touch press events should always be forwarded to the renderer.
|
| if (event.type == WebInputEvent::TouchStart)
|
| return true;
|
|
|