Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1152)

Unified Diff: content/browser/renderer_host/input/touch_event_queue.cc

Issue 997283002: Coalesce async touch move events until the ack back from render (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..cff5ef5e50c6d29df9dca2743ec2fdfeb6c3e8bb 100644
--- a/content/browser/renderer_host/input/touch_event_queue.cc
+++ b/content/browser/renderer_host/input/touch_event_queue.cc
@@ -372,6 +372,7 @@ TouchEventQueue::TouchEventQueue(TouchEventQueueClient* client,
drop_remaining_touches_in_sequence_(false),
touchmove_slop_suppressor_(new TouchMoveSlopSuppressor),
send_touch_events_async_(false),
+ uncancelable_touch_moves_pending_ack_count_(0),
last_sent_touch_timestamp_sec_(0) {
DCHECK(client);
if (config.touch_ack_timeout_supported) {
@@ -438,6 +439,32 @@ void TouchEventQueue::ProcessTouchAck(InputEventAckState ack_result,
TryForwardNextEventToRenderer();
}
+void TouchEventQueue::ProcessUncancelableTouchMoveAck() {
+ TRACE_EVENT0("input", "TouchEventQueue::ProcessUncancelableTouchMoveAck");
+
+ DCHECK(!dispatching_touch_ack_);
+ dispatching_touch_ = false;
+
+ // Decrease the count once we receive the ack back from render for
+ // uncancelable touchmoves.
+ --uncancelable_touch_moves_pending_ack_count_;
+
+ // Send the next pending async touch move once we receive the ack.
+ if (pending_async_touchmove_ &&
+ uncancelable_touch_moves_pending_ack_count_ == 0) {
+ 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 = !send_touch_events_async_;
tdresser 2015/03/31 14:44:07 send_touch_events_async_ should never be false her
lanwei 2015/04/01 13:14:21 You are right, it will always be async, I thought
+ pending_async_touchmove_.reset();
+ 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
@@ -480,7 +507,8 @@ void TouchEventQueue::ForwardNextEventToRenderer() {
touch.event.timeStampSeconds >=
last_sent_touch_timestamp_sec_ + kAsyncTouchMoveIntervalSec;
- if (!send_touchmove_now) {
+ if (!send_touchmove_now ||
+ uncancelable_touch_moves_pending_ack_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.
@@ -648,6 +675,10 @@ void TouchEventQueue::SendTouchEventImmediately(
// to last sent event and update touch points state.
if (touch->event.type == WebInputEvent::TouchMove) {
CHECK(last_sent_touchevent_);
+ // We increase the count when we send out a uncancelable touch move.
+ if (!touch->event.cancelable)
+ ++uncancelable_touch_moves_pending_ack_count_;
+
for (unsigned int i = 0; i < last_sent_touchevent_->touchesLength; ++i) {
const WebTouchPoint& last_touch_point =
last_sent_touchevent_->touches[i];

Powered by Google App Engine
This is Rietveld 408576698