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

Side by Side Diff: content/browser/renderer_host/input/touch_event_queue.cc

Issue 259763010: Forward secondary touch points even if the first had no consumer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/renderer_host/input/touch_event_queue_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/input/touch_event_queue.h" 5 #include "content/browser/renderer_host/input/touch_event_queue.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 dispatching_touch_ = false; 385 dispatching_touch_ = false;
386 386
387 if (timeout_handler_ && timeout_handler_->ConfirmTouchEvent(ack_result)) 387 if (timeout_handler_ && timeout_handler_->ConfirmTouchEvent(ack_result))
388 return; 388 return;
389 389
390 touchmove_slop_suppressor_->ConfirmTouchEvent(ack_result); 390 touchmove_slop_suppressor_->ConfirmTouchEvent(ack_result);
391 391
392 if (touch_queue_.empty()) 392 if (touch_queue_.empty())
393 return; 393 return;
394 394
395 const WebTouchEvent& acked_event =
396 touch_queue_.front()->coalesced_event().event;
397
398 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED && 395 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED &&
399 touch_filtering_state_ == FORWARD_TOUCHES_UNTIL_TIMEOUT) { 396 touch_filtering_state_ == FORWARD_TOUCHES_UNTIL_TIMEOUT) {
400 touch_filtering_state_ = FORWARD_ALL_TOUCHES; 397 touch_filtering_state_ = FORWARD_ALL_TOUCHES;
401 } 398 }
402 399
403 if (ack_result == INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS &&
404 touch_filtering_state_ != DROP_ALL_TOUCHES &&
405 WebTouchEventTraits::IsTouchSequenceStart(acked_event)) {
406 touch_filtering_state_ = DROP_TOUCHES_IN_SEQUENCE;
407 }
408
409 PopTouchEventToClient(ack_result, latency_info); 400 PopTouchEventToClient(ack_result, latency_info);
410 TryForwardNextEventToRenderer(); 401 TryForwardNextEventToRenderer();
411 } 402 }
412 403
413 void TouchEventQueue::TryForwardNextEventToRenderer() { 404 void TouchEventQueue::TryForwardNextEventToRenderer() {
414 DCHECK(!dispatching_touch_ack_); 405 DCHECK(!dispatching_touch_ack_);
415 // If there are queued touch events, then try to forward them to the renderer 406 // If there are queued touch events, then try to forward them to the renderer
416 // immediately, or ACK the events back to the client if appropriate. 407 // immediately, or ACK the events back to the client if appropriate.
417 while (!touch_queue_.empty()) { 408 while (!touch_queue_.empty()) {
418 PreFilterResult filter_result = 409 PreFilterResult filter_result =
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 (pending_async_touch_move_ && 457 (pending_async_touch_move_ &&
467 !pending_async_touch_move_->CanCoalesceWith(touch)); 458 !pending_async_touch_move_->CanCoalesceWith(touch));
468 459
469 if (!send_touch_move_now) { 460 if (!send_touch_move_now) {
470 if (!pending_async_touch_move_) { 461 if (!pending_async_touch_move_) {
471 pending_async_touch_move_.reset(new TouchEventWithLatencyInfo(touch)); 462 pending_async_touch_move_.reset(new TouchEventWithLatencyInfo(touch));
472 } else { 463 } else {
473 DCHECK(pending_async_touch_move_->CanCoalesceWith(touch)); 464 DCHECK(pending_async_touch_move_->CanCoalesceWith(touch));
474 pending_async_touch_move_->CoalesceWith(touch); 465 pending_async_touch_move_->CoalesceWith(touch);
475 } 466 }
467 DCHECK_EQ(1U, size());
476 PopTouchEventToClient(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 468 PopTouchEventToClient(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
469 // It's possible (though unlikely) that ack'ing the current touch will
470 // trigger the queueing of another touch event (e.g., a touchcancel). As
471 // forwarding of the queued event will be deferred while the ack is being
472 // dispatched (see |OnTouchEvent()|), try forwarding it now.
473 TryForwardNextEventToRenderer();
477 return; 474 return;
478 } 475 }
479 } 476 }
480 477
481 last_sent_touch_timestamp_sec_ = touch.event.timeStampSeconds; 478 last_sent_touch_timestamp_sec_ = touch.event.timeStampSeconds;
482 479
483 // Flush any pending async touch move. If it can be combined with the current 480 // Flush any pending async touch move. If it can be combined with the current
484 // (touchmove) event, great, otherwise send it immediately but separately. Its 481 // (touchmove) event, great, otherwise send it immediately but separately. Its
485 // ack will trigger forwarding of the original |touch| event. 482 // ack will trigger forwarding of the original |touch| event.
486 if (pending_async_touch_move_) { 483 if (pending_async_touch_move_) {
(...skipping 27 matching lines...) Expand all
514 DCHECK(timeout_handler_); 511 DCHECK(timeout_handler_);
515 timeout_handler_->Start(touch); 512 timeout_handler_->Start(touch);
516 } 513 }
517 } 514 }
518 515
519 void TouchEventQueue::OnGestureScrollEvent( 516 void TouchEventQueue::OnGestureScrollEvent(
520 const GestureEventWithLatencyInfo& gesture_event) { 517 const GestureEventWithLatencyInfo& gesture_event) {
521 if (gesture_event.event.type != blink::WebInputEvent::GestureScrollBegin) 518 if (gesture_event.event.type != blink::WebInputEvent::GestureScrollBegin)
522 return; 519 return;
523 520
521 if (touch_filtering_state_ != DROP_ALL_TOUCHES &&
522 touch_filtering_state_ != DROP_TOUCHES_IN_SEQUENCE) {
523 // As an optimization, drop all remaining touch events in the sequence if
524 // scrolling begins while *none* of the touch points have a consumer.
525 bool no_consumers_exist = true;
526 for (TouchPointAckStates::const_iterator iter = touch_ack_states_.begin(),
jdduke (slow) 2014/04/28 18:08:15 Rick, do you think this is a worthwhile optimizati
Rick Byers 2014/04/28 21:45:22 Hmm - interesting scenario. My gut instinct is th
jdduke (slow) 2014/04/28 22:04:59 Interesting, that sounds like a reasonable use-cas
527 end = touch_ack_states_.end();
528 iter != end;
529 ++iter) {
530 if (iter->second != INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS) {
531 no_consumers_exist = false;
532 break;
533 }
534 }
535 if (no_consumers_exist) {
536 touch_filtering_state_ = DROP_TOUCHES_IN_SEQUENCE;
537 return;
538 }
539 }
540
524 if (touch_scrolling_mode_ == TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE) { 541 if (touch_scrolling_mode_ == TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE) {
525 pending_async_touch_move_.reset(); 542 pending_async_touch_move_.reset();
526 send_touch_events_async_ = true; 543 send_touch_events_async_ = true;
527 needs_async_touch_move_for_outer_slop_region_ = true; 544 needs_async_touch_move_for_outer_slop_region_ = true;
528 return; 545 return;
529 } 546 }
530 547
531 if (touch_scrolling_mode_ != TOUCH_SCROLLING_MODE_TOUCHCANCEL) 548 if (touch_scrolling_mode_ != TOUCH_SCROLLING_MODE_TOUCHCANCEL)
532 return; 549 return;
533 550
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 } else if (event.type == WebInputEvent::TouchStart) { 775 } else if (event.type == WebInputEvent::TouchStart) {
759 for (unsigned i = 0; i < event.touchesLength; ++i) { 776 for (unsigned i = 0; i < event.touchesLength; ++i) {
760 const WebTouchPoint& point = event.touches[i]; 777 const WebTouchPoint& point = event.touches[i];
761 if (point.state == WebTouchPoint::StatePressed) 778 if (point.state == WebTouchPoint::StatePressed)
762 touch_ack_states_[point.id] = ack_result; 779 touch_ack_states_[point.id] = ack_result;
763 } 780 }
764 } 781 }
765 } 782 }
766 783
767 } // namespace content 784 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/input/touch_event_queue_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698