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..37088da86c43fe02187b692cd7c8897c540f5969 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()) { |
+ TouchEventWithLatencyInfo touch = *pending_async_touchmove_; |
+ |
+ // 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,10 @@ void TouchEventQueue::ProcessTouchAck(InputEventAckState ack_result, |
if (touch_queue_.empty()) |
return; |
+ if (touch_queue_.front()->coalesced_event().event.uniqueTouchEventId != |
jdduke (slow)
2015/05/01 19:11:09
This should probably be a DCHECK_EQ instead of an
lanwei
2015/05/07 04:11:37
Done.
|
+ unique_touch_event_id) |
+ return; |
+ |
PopTouchEventToClient(ack_result, latency_info); |
TryForwardNextEventToRenderer(); |
} |
@@ -477,8 +505,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 +554,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 +694,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); |
+ TryForwardNextEventToRenderer(); |
+ } |
+ |
+ if (timeout_handler_) |
+ timeout_handler_->StartIfNecessary(*touch); |
+ } |
} |
TouchEventQueue::PreFilterResult |