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..f85aeb4756994c2b5030a206115c6d38be88ea01 100644 |
--- a/content/browser/renderer_host/input/touch_event_queue.cc |
+++ b/content/browser/renderer_host/input/touch_event_queue.cc |
@@ -41,8 +41,7 @@ TouchEventWithLatencyInfo ObtainCancelEventForTouchEvent( |
bool ShouldTouchTriggerTimeout(const WebTouchEvent& event) { |
return (event.type == WebInputEvent::TouchStart || |
- event.type == WebInputEvent::TouchMove) && |
- !WebInputEventTraits::IgnoresAckDisposition(event); |
+ event.type == WebInputEvent::TouchMove) && event.cancelable; |
} |
// Compare all properties of touch points to determine the state. |
@@ -438,6 +437,31 @@ void TouchEventQueue::ProcessTouchAck(InputEventAckState ack_result, |
TryForwardNextEventToRenderer(); |
} |
+void TouchEventQueue::ProcessUncancelableTouchMoveAck() { |
+ TRACE_EVENT0("input", "TouchEventQueue::ProcessUncancelableTouchMoveAck"); |
+ |
+ DCHECK(!dispatching_touch_ack_); |
+ dispatching_touch_ = false; |
+ |
+ // Remove it from the queue once we receive the ack back from render for |
+ // uncancelable touchmoves. |
+ DCHECK(!ack_pending_async_touchmove_.empty()); |
+ ack_pending_async_touchmove_.pop_back(); |
+ |
+ // Send the next pending async touch move once we receive the ack. |
+ 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(); |
+ SendTouchEventImmediately(&touch); |
+ } |
+ } |
+} |
+ |
void TouchEventQueue::TryForwardNextEventToRenderer() { |
DCHECK(!dispatching_touch_ack_); |
// If there are queued touch events, then try to forward them to the renderer |
@@ -479,6 +503,7 @@ void TouchEventQueue::ForwardNextEventToRenderer() { |
send_touchmove_now |= |
touch.event.timeStampSeconds >= |
last_sent_touch_timestamp_sec_ + kAsyncTouchMoveIntervalSec; |
+ send_touchmove_now &= ack_pending_async_touchmove_.empty(); |
jdduke (slow)
2015/04/15 17:14:53
So, I think we have to send the touchmove if we ca
lanwei
2015/04/17 20:49:00
Done.
|
if (!send_touchmove_now) { |
if (!pending_async_touchmove_) { |
@@ -513,7 +538,6 @@ void TouchEventQueue::ForwardNextEventToRenderer() { |
scoped_ptr<TouchEventWithLatencyInfo> async_move = |
pending_async_touchmove_.Pass(); |
async_move->event.cancelable = false; |
- touch_queue_.push_front(new CoalescedWebTouchEvent(*async_move, true)); |
SendTouchEventImmediately(async_move.get()); |
return; |
} |
@@ -525,6 +549,11 @@ void TouchEventQueue::ForwardNextEventToRenderer() { |
if (send_touch_events_async_ && touch.event.type != WebInputEvent::TouchStart) |
touch.event.cancelable = false; |
+ // For the async touchmove, when we dispatch it, we will remove it from the |
+ // front of the queue and keep it in a separate queue. |
+ if (touch.event.type == WebInputEvent::TouchMove && !touch.event.cancelable) { |
+ PopTouchEvent(); |
jdduke (slow)
2015/04/15 17:14:53
Why can't we move this code next to the other asyn
lanwei
2015/04/17 20:49:00
When pending_async_touchmove_ is not null and we h
|
+ } |
// 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); |
@@ -671,6 +700,16 @@ void TouchEventQueue::SendTouchEventImmediately( |
last_sent_touchevent_.reset(new WebTouchEvent(touch->event)); |
client_->SendTouchEventImmediately(*touch); |
+ |
+ if (touch->event.type == WebInputEvent::TouchMove && |
jdduke (slow)
2015/04/15 17:14:53
I think we may need a guard here in the event that
lanwei
2015/04/17 20:49:00
Done.
|
+ !touch->event.cancelable) { |
+ // We push it into the queue when we send out a uncancelable touch move. |
+ // For the async touchmove, we do not process input event ack any more, we |
+ // will ack to client and wait for the ack from render. |
+ ack_pending_async_touchmove_.push_front(*touch); |
jdduke (slow)
2015/04/15 17:14:53
A count should be sufficient.
lanwei
2015/04/17 20:49:00
Done.
|
+ client_->OnTouchEventAck(*touch, INPUT_EVENT_ACK_STATE_IGNORED); |
+ TryForwardNextEventToRenderer(); |
+ } |
} |
TouchEventQueue::PreFilterResult |