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 b766b3d1b51530ec4b49d9685cde78ebb302b525..d4eced3571c70fa537e8daad6b08be3754b23f30 100644 |
| --- a/content/browser/renderer_host/input/touch_event_queue.cc |
| +++ b/content/browser/renderer_host/input/touch_event_queue.cc |
| @@ -42,7 +42,7 @@ TouchEventWithLatencyInfo ObtainCancelEventForTouchEvent( |
| bool ShouldTouchTriggerTimeout(const WebTouchEvent& event) { |
| return (event.type == WebInputEvent::TouchStart || |
| event.type == WebInputEvent::TouchMove) && |
| - !WebInputEventTraits::IgnoresAckDisposition(event); |
| + event.cancelable; |
| } |
| // Compare all properties of touch points to determine the state. |
| @@ -82,7 +82,9 @@ class TouchEventQueue::TouchTimeoutHandler { |
| ~TouchTimeoutHandler() {} |
| void StartIfNecessary(const TouchEventWithLatencyInfo& event) { |
| - DCHECK_EQ(pending_ack_state_, PENDING_ACK_NONE); |
| + if (pending_ack_state_ != PENDING_ACK_NONE) |
| + return; |
| + |
| if (!enabled_) |
| return; |
| @@ -420,9 +422,31 @@ void TouchEventQueue::QueueEvent(const TouchEventWithLatencyInfo& event) { |
| } |
| void TouchEventQueue::ProcessTouchAck(InputEventAckState ack_result, |
| - const LatencyInfo& latency_info) { |
| + const LatencyInfo& latency_info, |
| + const uint32 unique_touch_event_id) { |
| TRACE_EVENT0("input", "TouchEventQueue::ProcessTouchAck"); |
| + // We receive an ack for async touchmove from render. |
| + if (!ack_pending_async_touchmove_.empty() && |
| + ack_pending_async_touchmove_.front() == unique_touch_event_id) { |
| + // Remove the first touchmove from the ack_pending_async_touchmove queue. |
| + ack_pending_async_touchmove_.pop_front(); |
| + // Send the next pending async touch move once we receive all acks back. |
| + if (pending_async_touchmove_ && ack_pending_async_touchmove_.empty()) { |
|
jdduke (slow)
2015/05/07 21:11:15
Let's add a DCHECK(touch_queue_.empty());
lanwei
2015/05/08 19:31:25
Done.
|
| + TouchEventWithLatencyInfo touch = *pending_async_touchmove_; |
|
jdduke (slow)
2015/05/07 21:11:15
See comment below, I think we can share some logic
|
| + |
| + // Dispatch the next pending async touch move when time expires. |
| + if (touch.event.timeStampSeconds >= |
| + last_sent_touch_timestamp_sec_ + kAsyncTouchMoveIntervalSec) { |
| + touch.event.cancelable = false; |
| + pending_async_touchmove_.reset(); |
| + touch_queue_.push_front(new CoalescedWebTouchEvent(touch, true)); |
| + SendTouchEventImmediately(&touch); |
| + } |
| + } |
| + return; |
| + } |
| + |
| DCHECK(!dispatching_touch_ack_); |
| dispatching_touch_ = false; |
| @@ -434,6 +458,9 @@ void TouchEventQueue::ProcessTouchAck(InputEventAckState ack_result, |
| if (touch_queue_.empty()) |
| return; |
| + DCHECK_EQ(touch_queue_.front()->coalesced_event().event.uniqueTouchEventId, |
| + unique_touch_event_id); |
| + |
| PopTouchEventToClient(ack_result, latency_info); |
| TryForwardNextEventToRenderer(); |
| } |
| @@ -477,8 +504,9 @@ void TouchEventQueue::ForwardNextEventToRenderer() { |
| send_touchmove_now |= pending_async_touchmove_ && |
| !pending_async_touchmove_->CanCoalesceWith(touch); |
| send_touchmove_now |= |
| - touch.event.timeStampSeconds >= |
| - last_sent_touch_timestamp_sec_ + kAsyncTouchMoveIntervalSec; |
| + ack_pending_async_touchmove_.empty() && |
| + (touch.event.timeStampSeconds >= |
| + last_sent_touch_timestamp_sec_ + kAsyncTouchMoveIntervalSec); |
| if (!send_touchmove_now) { |
| if (!pending_async_touchmove_) { |
| @@ -525,12 +553,7 @@ void TouchEventQueue::ForwardNextEventToRenderer() { |
| if (send_touch_events_async_ && touch.event.type != WebInputEvent::TouchStart) |
| touch.event.cancelable = false; |
| - // A synchronous ack will reset |dispatching_touch_|, in which case |
| - // the touch timeout should not be started. |
| - base::AutoReset<bool> dispatching_touch(&dispatching_touch_, true); |
| SendTouchEventImmediately(&touch); |
| - if (dispatching_touch_ && timeout_handler_) |
| - timeout_handler_->StartIfNecessary(touch); |
| } |
| void TouchEventQueue::OnGestureScrollEvent( |
| @@ -670,7 +693,29 @@ void TouchEventQueue::SendTouchEventImmediately( |
| else |
| last_sent_touchevent_.reset(new WebTouchEvent(touch->event)); |
| + base::AutoReset<bool> dispatching_touch(&dispatching_touch_, true); |
| + |
| client_->SendTouchEventImmediately(*touch); |
| + |
| + // A synchronous ack will reset |dispatching_touch_|, in which case the touch |
| + // timeout should not be started and the count also should not be increased. |
| + if (dispatching_touch_) { |
| + if (touch->event.type == WebInputEvent::TouchMove && |
| + !touch->event.cancelable) { |
| + // When we send out a uncancelable touch move, we increase the count and |
| + // we do not process input event ack any more, we will just ack to client |
| + // and wait for the ack from render. Also we will remove it from the front |
| + // of the queue. |
| + ack_pending_async_touchmove_.push_back(touch->event.uniqueTouchEventId); |
| + PopTouchEvent(); |
| + dispatching_touch_ = false; |
| + client_->OnTouchEventAck(*touch, INPUT_EVENT_ACK_STATE_IGNORED); |
|
jdduke (slow)
2015/05/07 21:11:15
Can we make this PopTouchEventToClient(INPUT_EVENT
lanwei
2015/05/08 19:31:25
Done.
|
| + TryForwardNextEventToRenderer(); |
|
jdduke (slow)
2015/05/07 21:11:15
Let'd add a return here.
lanwei
2015/05/08 19:31:25
Done.
|
| + } |
| + |
| + if (timeout_handler_) |
| + timeout_handler_->StartIfNecessary(*touch); |
| + } |
| } |
| TouchEventQueue::PreFilterResult |