Chromium Code Reviews| 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 66023b1e9cbdb980d194f2a7d20814d2154bea27..c1b81df3d52dfb6108418e11be7ed75f0aa087fa 100644 |
| --- a/content/browser/renderer_host/input/touch_event_queue.cc |
| +++ b/content/browser/renderer_host/input/touch_event_queue.cc |
| @@ -28,8 +28,7 @@ namespace { |
| const double kAsyncTouchMoveIntervalSec = .2; |
| // A sanity check on touches received to ensure that touch movement outside |
| -// the platform slop region will cause scrolling, as indicated by the event's |
| -// |causesScrollingIfUncanceled| bit. |
| +// the platform slop region will cause scrolling. |
| const double kMaxConceivablePlatformSlopRegionLengthDipsSquared = 60. * 60.; |
| TouchEventWithLatencyInfo ObtainCancelEventForTouchEvent( |
| @@ -460,8 +459,9 @@ void TouchEventQueue::QueueEvent(const TouchEventWithLatencyInfo& event) { |
| TRACE_EVENT0("input", "TouchEventQueue::QueueEvent"); |
| // 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_) { |
| + // processing the event until the dispatch has finished. The touch queue is |
| + // non-empty in this case. |
| + if (touch_queue_.empty()) { |
| // Optimization of the case without touch handlers. Removing this path |
| // yields identical results, but this avoids unnecessary allocations. |
| PreFilterResult filter_result = FilterBeforeForwarding(event.event); |
| @@ -491,6 +491,24 @@ void TouchEventQueue::QueueEvent(const TouchEventWithLatencyInfo& event) { |
| touch_queue_.push_back(new CoalescedWebTouchEvent(event, false)); |
| } |
| +void TouchEventQueue::PrependTouchScrollNotification() { |
| + TRACE_EVENT0("input", "TouchEventQueue::PrependTouchScrollNotification"); |
| + |
| + TouchEventWithLatencyInfo touch; |
| + touch.event.type = WebInputEvent::TouchScrollStarted; |
| + touch.event.uniqueTouchEventId = 0; |
| + |
| + if (touch_queue_.empty()) { |
| + touch_queue_.push_back(new CoalescedWebTouchEvent(touch, false)); |
| + ForwardNextEventToRenderer(); |
| + } else { |
| + // Leave the head of the queue untouched since it is an in-flight event. |
| + auto it = touch_queue_.begin(); |
| + touch_queue_.insert(++it, new CoalescedWebTouchEvent(touch, false)); |
| + } |
| +} |
| + |
| + |
| void TouchEventQueue::ProcessTouchAck(InputEventAckState ack_result, |
| const LatencyInfo& latency_info, |
| const uint32_t unique_touch_event_id) { |
| @@ -719,34 +737,36 @@ void TouchEventQueue::FlushQueue() { |
| } |
| void TouchEventQueue::PopTouchEventToClient(InputEventAckState ack_result) { |
| - AckTouchEventToClient(ack_result, PopTouchEvent(), nullptr); |
| + AckTouchEventToClient(ack_result, nullptr); |
| } |
| void TouchEventQueue::PopTouchEventToClient( |
| InputEventAckState ack_result, |
| const LatencyInfo& renderer_latency_info) { |
| - AckTouchEventToClient(ack_result, PopTouchEvent(), &renderer_latency_info); |
| + AckTouchEventToClient(ack_result, &renderer_latency_info); |
| } |
| void TouchEventQueue::AckTouchEventToClient( |
| InputEventAckState ack_result, |
| - scoped_ptr<CoalescedWebTouchEvent> acked_event, |
| const ui::LatencyInfo* optional_latency_info) { |
| - DCHECK(acked_event); |
| DCHECK(!dispatching_touch_ack_); |
| + DCHECK(!touch_queue_.empty()); |
| + scoped_ptr<CoalescedWebTouchEvent> acked_event(touch_queue_.front()); |
| + DCHECK(acked_event); |
| + |
| UpdateTouchConsumerStates(acked_event->coalesced_event().event, ack_result); |
| // Note that acking the touch-event may result in multiple gestures being sent |
| // to the renderer, or touch-events being queued. |
| base::AutoReset<bool> dispatching_touch_ack(&dispatching_touch_ack_, true); |
| - acked_event->DispatchAckToClient(ack_result, optional_latency_info, client_); |
| -} |
| -scoped_ptr<CoalescedWebTouchEvent> TouchEventQueue::PopTouchEvent() { |
| - DCHECK(!touch_queue_.empty()); |
| - scoped_ptr<CoalescedWebTouchEvent> event(touch_queue_.front()); |
| + // Skip ack for TouchScrollStarted since it was synthesized within the queue. |
| + if (acked_event->coalesced_event().event.type != |
| + WebInputEvent::TouchScrollStarted) |
|
tdresser
2016/04/01 19:03:20
Multiline bodies require {}
mustaq
2016/04/01 21:49:52
Done.
|
| + acked_event->DispatchAckToClient(ack_result, optional_latency_info, |
| + client_); |
| + |
| touch_queue_.pop_front(); |
| - return event; |
| } |
| void TouchEventQueue::SendTouchEventImmediately( |
| @@ -772,10 +792,12 @@ void TouchEventQueue::SendTouchEventImmediately( |
| } |
| } |
| - if (last_sent_touchevent_) |
| - *last_sent_touchevent_ = touch->event; |
| - else |
| - last_sent_touchevent_.reset(new WebTouchEvent(touch->event)); |
| + if (touch->event.type != WebInputEvent::TouchScrollStarted) { |
| + if (last_sent_touchevent_) |
| + *last_sent_touchevent_ = touch->event; |
| + else |
| + last_sent_touchevent_.reset(new WebTouchEvent(touch->event)); |
| + } |
| base::AutoReset<bool> dispatching_touch(&dispatching_touch_, true); |
| @@ -805,6 +827,9 @@ void TouchEventQueue::SendTouchEventImmediately( |
| TouchEventQueue::PreFilterResult |
| TouchEventQueue::FilterBeforeForwarding(const WebTouchEvent& event) { |
| + if (event.type == WebInputEvent::TouchScrollStarted) |
| + return FORWARD_TO_RENDERER; |
| + |
| if (WebTouchEventTraits::IsTouchSequenceStart(event)) { |
| has_handler_for_current_sequence_ = false; |
| send_touch_events_async_ = false; |