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 0a7b1d4fd9e713f5e52d9fae6d5befe2f9bffe8f..81fc917328d94a2a36c4e20ed5289b9b89b3a9f7 100644 |
| --- a/content/browser/renderer_host/input/touch_event_queue.cc |
| +++ b/content/browser/renderer_host/input/touch_event_queue.cc |
| @@ -101,6 +101,7 @@ TouchEventQueue::~TouchEventQueue() { |
| } |
| void TouchEventQueue::QueueEvent(const TouchEventWithLatencyInfo& event) { |
| + latest_event_ = event; |
| // 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_) { |
| @@ -118,8 +119,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)); |
| } |
| @@ -164,18 +167,34 @@ void TouchEventQueue::ProcessTouchAck(InputEventAckState ack_result) { |
| } |
| } |
| +void TouchEventQueue::OnGestureScrollEnd() { |
| + TouchEventWithLatencyInfo end_event = GetLatestEvent(); |
| + FlushQueue(); |
| + end_event.event.type = WebKit::WebInputEvent::TouchEnd; |
| + for (unsigned i = 0; i < end_event.event.touchesLength; ++i) |
| + end_event.event.touches[i].state = WebKit::WebTouchPoint::StateReleased; |
| + end_event.latency = ui::LatencyInfo(); |
| + client_->SendTouchEventImmediately(end_event); |
| + ClearQueue(); |
| +} |
| + |
| void TouchEventQueue::FlushQueue() { |
| DCHECK(!dispatching_touch_ack_); |
| while (!touch_queue_.empty()) |
| PopTouchEventWithAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| } |
| +void TouchEventQueue::ClearQueue() { |
| + if (!touch_queue_.empty()) |
| + STLDeleteElements(&touch_queue_); |
| +} |
| + |
| size_t TouchEventQueue::GetQueueSize() const { |
| return touch_queue_.size(); |
| } |
| const TouchEventWithLatencyInfo& TouchEventQueue::GetLatestEvent() const { |
| - return touch_queue_.back()->coalesced_event(); |
| + return latest_event_; |
|
sadrul
2013/08/06 19:34:19
Why is this necessary?
|
| } |
| void TouchEventQueue::PopTouchEventWithAck(InputEventAckState ack_result) { |