Chromium Code Reviews| Index: content/browser/renderer_host/touch_event_queue.cc |
| diff --git a/content/browser/renderer_host/touch_event_queue.cc b/content/browser/renderer_host/touch_event_queue.cc |
| index cdabd1570dd1076498eb71af84e0a508c0d04c6b..eab2847a61286c663d3d3717d67572c08c3a1ab7 100644 |
| --- a/content/browser/renderer_host/touch_event_queue.cc |
| +++ b/content/browser/renderer_host/touch_event_queue.cc |
| @@ -99,6 +99,7 @@ TouchEventQueue::~TouchEventQueue() { |
| } |
| void TouchEventQueue::QueueEvent(const TouchEventWithLatencyInfo& event) { |
| + latest_event_ = event; |
| if (touch_queue_.empty()) { |
| // There is no touch event in the queue. Forward it to the renderer |
| // immediately. |
| @@ -114,8 +115,10 @@ void TouchEventQueue::QueueEvent(const TouchEventWithLatencyInfo& event) { |
| // also a touch-move, then the events can be coalesced into a single event. |
| if (touch_queue_.size() > 1) { |
| CoalescedWebTouchEvent* last_event = touch_queue_.back(); |
| - if (last_event->CoalesceEventIfPossible(event)) |
| + if (last_event->CoalesceEventIfPossible(event)) { |
| + latest_event_ = last_event->coalesced_event(); |
| return; |
| + } |
| } |
| touch_queue_.push_back(new CoalescedWebTouchEvent(event)); |
| } |
| @@ -124,6 +127,10 @@ void TouchEventQueue::ProcessTouchAck(InputEventAckState ack_result) { |
| if (touch_queue_.empty()) |
| return; |
| + // If scroll update is in progress, we should have cleared the touch |
| + // event queue. |
| + DCHECK(!render_widget_host_->is_scroll_update_in_progress()); |
| + |
| // Update the ACK status for each touch point in the ACKed event. |
| const WebKit::WebTouchEvent& event = |
| touch_queue_.front()->coalesced_event().event; |
| @@ -159,6 +166,19 @@ void TouchEventQueue::ProcessTouchAck(InputEventAckState ack_result) { |
| } |
| } |
| +void TouchEventQueue::OnGestureScrollStart() { |
| + TouchEventWithLatencyInfo cancel_event = GetLatestEvent(); |
| + FlushQueue(); |
| + cancel_event.event.type = WebKit::WebInputEvent::TouchCancel; |
| + for (size_t i = 0; i < cancel_event.event.touchesLength; i++) |
| + cancel_event.event.touches[i].state = WebKit::WebTouchPoint::StateCancelled; |
| + render_widget_host_->ForwardTouchEventImmediately(cancel_event); |
| + // We only want to send the touch cancel to the renderer, but don't want |
| + // it gets processed in view. So clear the touch event queue here and the |
| + // ack for the cancel event will just be ignored. |
| + Reset(); |
| +} |
| + |
| void TouchEventQueue::FlushQueue() { |
| while (!touch_queue_.empty()) |
| PopTouchEventToView(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| @@ -174,7 +194,7 @@ size_t TouchEventQueue::GetQueueSize() const { |
| } |
| const TouchEventWithLatencyInfo& TouchEventQueue::GetLatestEvent() const { |
| - return touch_queue_.back()->coalesced_event(); |
|
sadrul
2013/06/20 08:51:27
When is touch_queue_ empty here?
Yufeng Shen (Slow to review)
2013/06/20 17:56:45
The PopTouchEventToView() below first pops the tou
|
| + return latest_event_; |
| } |
| void TouchEventQueue::PopTouchEventToView(InputEventAckState ack_result) { |