OLD | NEW |
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/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "content/browser/renderer_host/input/timeout_monitor.h" | 10 #include "content/browser/renderer_host/input/timeout_monitor.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 150 |
151 private: | 151 private: |
152 enum PendingAckState { | 152 enum PendingAckState { |
153 PENDING_ACK_NONE, | 153 PENDING_ACK_NONE, |
154 PENDING_ACK_ORIGINAL_EVENT, | 154 PENDING_ACK_ORIGINAL_EVENT, |
155 PENDING_ACK_CANCEL_EVENT, | 155 PENDING_ACK_CANCEL_EVENT, |
156 }; | 156 }; |
157 | 157 |
158 void OnTimeOut() { | 158 void OnTimeOut() { |
159 SetPendingAckState(PENDING_ACK_ORIGINAL_EVENT); | 159 SetPendingAckState(PENDING_ACK_ORIGINAL_EVENT); |
160 touch_queue_->FlushQueue(); | 160 touch_queue_->Flush(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); |
161 } | 161 } |
162 | 162 |
163 // Skip a cancel event if the timed-out event had no consumer and was the | 163 // Skip a cancel event if the timed-out event had no consumer and was the |
164 // initial event in the gesture. | 164 // initial event in the gesture. |
165 bool AckedTimeoutEventRequiresCancel(InputEventAckState ack_result) const { | 165 bool AckedTimeoutEventRequiresCancel(InputEventAckState ack_result) const { |
166 DCHECK(HasTimeoutEvent()); | 166 DCHECK(HasTimeoutEvent()); |
167 if (ack_result != INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS) | 167 if (ack_result != INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS) |
168 return true; | 168 return true; |
169 return !WebTouchEventTraits::IsTouchSequenceStart(timeout_event_.event); | 169 return !WebTouchEventTraits::IsTouchSequenceStart(timeout_event_.event); |
170 } | 170 } |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 if (!send_touch_events_async_) | 622 if (!send_touch_events_async_) |
623 needs_async_touchmove_for_outer_slop_region_ = false; | 623 needs_async_touchmove_for_outer_slop_region_ = false; |
624 } | 624 } |
625 | 625 |
626 void TouchEventQueue::OnHasTouchEventHandlers(bool has_handlers) { | 626 void TouchEventQueue::OnHasTouchEventHandlers(bool has_handlers) { |
627 DCHECK(!dispatching_touch_ack_); | 627 DCHECK(!dispatching_touch_ack_); |
628 DCHECK(!dispatching_touch_); | 628 DCHECK(!dispatching_touch_); |
629 has_handlers_ = has_handlers; | 629 has_handlers_ = has_handlers; |
630 } | 630 } |
631 | 631 |
| 632 void TouchEventQueue::Flush(InputEventAckState flush_ack) { |
| 633 DCHECK(!dispatching_touch_ack_); |
| 634 DCHECK(!dispatching_touch_); |
| 635 pending_async_touchmove_.reset(); |
| 636 drop_remaining_touches_in_sequence_ = true; |
| 637 while (!touch_queue_.empty()) |
| 638 PopTouchEventToClient(flush_ack); |
| 639 } |
| 640 |
632 bool TouchEventQueue::IsPendingAckTouchStart() const { | 641 bool TouchEventQueue::IsPendingAckTouchStart() const { |
633 DCHECK(!dispatching_touch_ack_); | 642 DCHECK(!dispatching_touch_ack_); |
634 if (touch_queue_.empty()) | 643 if (touch_queue_.empty()) |
635 return false; | 644 return false; |
636 | 645 |
637 const blink::WebTouchEvent& event = | 646 const blink::WebTouchEvent& event = |
638 touch_queue_.front()->coalesced_event().event; | 647 touch_queue_.front()->coalesced_event().event; |
639 return (event.type == WebInputEvent::TouchStart); | 648 return (event.type == WebInputEvent::TouchStart); |
640 } | 649 } |
641 | 650 |
(...skipping 12 matching lines...) Expand all Loading... |
654 | 663 |
655 bool TouchEventQueue::IsTimeoutRunningForTesting() const { | 664 bool TouchEventQueue::IsTimeoutRunningForTesting() const { |
656 return timeout_handler_ && timeout_handler_->IsTimeoutTimerRunning(); | 665 return timeout_handler_ && timeout_handler_->IsTimeoutTimerRunning(); |
657 } | 666 } |
658 | 667 |
659 const TouchEventWithLatencyInfo& | 668 const TouchEventWithLatencyInfo& |
660 TouchEventQueue::GetLatestEventForTesting() const { | 669 TouchEventQueue::GetLatestEventForTesting() const { |
661 return touch_queue_.back()->coalesced_event(); | 670 return touch_queue_.back()->coalesced_event(); |
662 } | 671 } |
663 | 672 |
664 void TouchEventQueue::FlushQueue() { | |
665 DCHECK(!dispatching_touch_ack_); | |
666 DCHECK(!dispatching_touch_); | |
667 pending_async_touchmove_.reset(); | |
668 drop_remaining_touches_in_sequence_ = true; | |
669 while (!touch_queue_.empty()) | |
670 PopTouchEventToClient(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); | |
671 } | |
672 | |
673 void TouchEventQueue::PopTouchEventToClient(InputEventAckState ack_result) { | 673 void TouchEventQueue::PopTouchEventToClient(InputEventAckState ack_result) { |
674 AckTouchEventToClient(ack_result, PopTouchEvent(), NULL); | 674 AckTouchEventToClient(ack_result, PopTouchEvent(), NULL); |
675 } | 675 } |
676 | 676 |
677 void TouchEventQueue::PopTouchEventToClient( | 677 void TouchEventQueue::PopTouchEventToClient( |
678 InputEventAckState ack_result, | 678 InputEventAckState ack_result, |
679 const LatencyInfo& renderer_latency_info) { | 679 const LatencyInfo& renderer_latency_info) { |
680 AckTouchEventToClient(ack_result, PopTouchEvent(), &renderer_latency_info); | 680 AckTouchEventToClient(ack_result, PopTouchEvent(), &renderer_latency_info); |
681 } | 681 } |
682 | 682 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 if (ack_result != INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS) | 777 if (ack_result != INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS) |
778 touch_consumer_states_.mark_bit(point.id); | 778 touch_consumer_states_.mark_bit(point.id); |
779 else | 779 else |
780 touch_consumer_states_.clear_bit(point.id); | 780 touch_consumer_states_.clear_bit(point.id); |
781 } | 781 } |
782 } | 782 } |
783 } | 783 } |
784 } | 784 } |
785 | 785 |
786 } // namespace content | 786 } // namespace content |
OLD | NEW |