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..15511441717c8deb7d292edb0adf725d8f61b703 100644 |
--- a/content/browser/renderer_host/input/touch_event_queue.cc |
+++ b/content/browser/renderer_host/input/touch_event_queue.cc |
@@ -372,6 +372,8 @@ TouchEventQueue::TouchEventQueue(TouchEventQueueClient* client, |
drop_remaining_touches_in_sequence_(false), |
touchmove_slop_suppressor_(new TouchMoveSlopSuppressor), |
send_touch_events_async_(false), |
+ pending_uncancelable_event_ack_count_(0), |
+ sent_uncancelable_touch_move_count_(0), |
last_sent_touch_timestamp_sec_(0) { |
DCHECK(client); |
if (config.touch_ack_timeout_supported) { |
@@ -387,7 +389,6 @@ TouchEventQueue::~TouchEventQueue() { |
void TouchEventQueue::QueueEvent(const TouchEventWithLatencyInfo& event) { |
TRACE_EVENT0("input", "TouchEventQueue::QueueEvent"); |
tdresser
2015/03/25 14:16:18
Might as well leave that whitespace there.
lanwei
2015/03/26 11:54:38
Done.
|
- |
// If the queueing of |event| was triggered by an ack dispatch, defer |
// processing the event until the dispatch has finished. |
if (touch_queue_.empty() && !dispatching_touch_ack_) { |
@@ -430,7 +431,6 @@ void TouchEventQueue::ProcessTouchAck(InputEventAckState ack_result, |
return; |
touchmove_slop_suppressor_->ConfirmTouchEvent(ack_result); |
tdresser
2015/03/25 14:16:18
Might as well leave that whitespace there.
lanwei
2015/03/26 11:54:38
Done.
|
- |
if (touch_queue_.empty()) |
return; |
@@ -438,6 +438,35 @@ void TouchEventQueue::ProcessTouchAck(InputEventAckState ack_result, |
TryForwardNextEventToRenderer(); |
} |
+void TouchEventQueue::ProcessUncancelableTouchMoveAck() { |
+ TRACE_EVENT0("input", "TouchEventQueue::ProcessUncancelableTouchMoveAck"); |
+ |
+ DCHECK(!dispatching_touch_ack_); |
+ dispatching_touch_ = false; |
+ |
+ // Ignore the acks for uncancelable touchmoves when we have a touch event |
+ // rather than uncancelable touchmoves and flush pending async touchmove. |
+ if (pending_uncancelable_event_ack_count_ > 0) { |
+ --pending_uncancelable_event_ack_count_; |
+ return; |
+ } |
+ |
+ // Decrease the count once we receive the ack back from render for |
+ // uncancelable touchmoves. |
+ --sent_uncancelable_touch_move_count_; |
+ |
+ // Send the next pending async touch move once we receive the ack. |
+ if (pending_async_touchmove_) { |
+ TouchEventWithLatencyInfo touch = *pending_async_touchmove_; |
+ touch.event.cancelable = !send_touch_events_async_; |
+ pending_async_touchmove_.reset(); |
+ if (!touch.event.cancelable) |
+ ++sent_uncancelable_touch_move_count_; |
+ touch_queue_.push_front(new CoalescedWebTouchEvent(touch, true)); |
+ SendTouchEventImmediately(&touch); |
+ } |
+} |
+ |
void TouchEventQueue::TryForwardNextEventToRenderer() { |
DCHECK(!dispatching_touch_ack_); |
// If there are queued touch events, then try to forward them to the renderer |
@@ -465,7 +494,6 @@ void TouchEventQueue::ForwardNextEventToRenderer() { |
DCHECK(!empty()); |
DCHECK(!dispatching_touch_); |
TouchEventWithLatencyInfo touch = touch_queue_.front()->coalesced_event(); |
- |
if (send_touch_events_async_ && |
touch.event.type == WebInputEvent::TouchMove) { |
// Throttling touchmove's in a continuous touchmove stream while scrolling |
@@ -480,7 +508,7 @@ void TouchEventQueue::ForwardNextEventToRenderer() { |
touch.event.timeStampSeconds >= |
last_sent_touch_timestamp_sec_ + kAsyncTouchMoveIntervalSec; |
- if (!send_touchmove_now) { |
+ if (!send_touchmove_now || sent_uncancelable_touch_move_count_ > 0) { |
if (!pending_async_touchmove_) { |
pending_async_touchmove_.reset(new TouchEventWithLatencyInfo(touch)); |
} else { |
@@ -499,7 +527,6 @@ void TouchEventQueue::ForwardNextEventToRenderer() { |
} |
last_sent_touch_timestamp_sec_ = touch.event.timeStampSeconds; |
- |
// Flush any pending async touch move. If it can be combined with the current |
// (touchmove) event, great, otherwise send it immediately but separately. Its |
// ack will trigger forwarding of the original |touch| event. |
@@ -510,6 +537,10 @@ void TouchEventQueue::ForwardNextEventToRenderer() { |
touch = *pending_async_touchmove_; |
pending_async_touchmove_.reset(); |
} else { |
+ // Once we flush the pending async touch move, we ignore all the acks |
+ // from the uncancelable touch moves that we sent out and wait for acks |
+ // back. |
+ ++sent_uncancelable_touch_move_count_; |
scoped_ptr<TouchEventWithLatencyInfo> async_move = |
pending_async_touchmove_.Pass(); |
async_move->event.cancelable = false; |
@@ -528,6 +559,17 @@ void TouchEventQueue::ForwardNextEventToRenderer() { |
// 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); |
+ |
+ // We increase the count when we send out a uncancelable touch move, and we |
+ // use pending_uncancelable_event_ack_count_ to keep track the number of |
+ // acks we do not wait any more when we flush pending async touch moves. |
+ if (touch.event.type == WebInputEvent::TouchMove && !touch.event.cancelable) { |
+ ++sent_uncancelable_touch_move_count_; |
+ } else { |
+ pending_uncancelable_event_ack_count_ += |
+ sent_uncancelable_touch_move_count_; |
+ sent_uncancelable_touch_move_count_ = 0; |
+ } |
SendTouchEventImmediately(&touch); |
if (dispatching_touch_ && timeout_handler_) |
timeout_handler_->StartIfNecessary(touch); |