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 fa109dedddf9bd87868d6edbe6a7a7fc1cbe9351..5da63f58d1d69c50135bfc5bb7b71004b057c28f 100644 |
| --- a/content/browser/renderer_host/input/touch_event_queue.cc |
| +++ b/content/browser/renderer_host/input/touch_event_queue.cc |
| @@ -107,7 +107,7 @@ class TouchEventQueue::TouchTimeoutHandler { |
| SetPendingAckState(PENDING_ACK_CANCEL_EVENT); |
| TouchEventWithLatencyInfo cancel_event = |
| ObtainCancelEventForTouchEvent(timeout_event_); |
| - touch_queue_->SendTouchEventImmediately(cancel_event); |
| + touch_queue_->SendTouchEventImmediately(&cancel_event); |
| } else { |
| SetPendingAckState(PENDING_ACK_NONE); |
| touch_queue_->UpdateTouchConsumerStates(timeout_event_.event, |
| @@ -525,7 +525,7 @@ void TouchEventQueue::ForwardNextEventToRenderer() { |
| pending_async_touchmove_.Pass(); |
| async_move->event.cancelable = false; |
| touch_queue_.push_front(new CoalescedWebTouchEvent(*async_move, true)); |
| - SendTouchEventImmediately(*async_move); |
| + SendTouchEventImmediately(async_move.get()); |
| return; |
| } |
| } |
| @@ -539,7 +539,7 @@ void TouchEventQueue::ForwardNextEventToRenderer() { |
| // A synchronous ack will reset |dispatching_touch_|, in which case |
| // the touch timeout should not be started. |
| base::AutoReset<bool> dispatching_touch(&dispatching_touch_, true); |
| - SendTouchEventImmediately(touch); |
| + SendTouchEventImmediately(&touch); |
| if (dispatching_touch_ && timeout_handler_) |
| timeout_handler_->StartIfNecessary(touch); |
| } |
| @@ -703,18 +703,45 @@ scoped_ptr<CoalescedWebTouchEvent> TouchEventQueue::PopTouchEvent() { |
| } |
| void TouchEventQueue::SendTouchEventImmediately( |
| - const TouchEventWithLatencyInfo& touch) { |
| + TouchEventWithLatencyInfo* touch) { |
| if (needs_async_touchmove_for_outer_slop_region_) { |
| // Any event other than a touchmove (e.g., touchcancel or secondary |
| // touchstart) after a scroll has started will interrupt the need to send a |
| // an outer slop-region exceeding touchmove. |
| - if (touch.event.type != WebInputEvent::TouchMove || |
| - OutsideApplicationSlopRegion(touch.event, |
| + if (touch->event.type != WebInputEvent::TouchMove || |
| + OutsideApplicationSlopRegion(touch->event, |
| touch_sequence_start_position_)) |
| needs_async_touchmove_for_outer_slop_region_ = false; |
| } |
| - client_->SendTouchEventImmediately(touch); |
| + // For touchmove events, compare touch points position from current event |
| + // to last sent event and update touch points state. |
| + if (touch->event.type == WebInputEvent::TouchMove) { |
| + CHECK(last_sent_touchevent_); |
| + for (unsigned int i = 0; i < last_sent_touchevent_->touchesLength; ++i) { |
| + const WebTouchPoint& last_touch_point = |
| + last_sent_touchevent_->touches[i]; |
| + // Touches with same id may not have same index in Touches array. |
| + for (unsigned int j = 0; j < touch->event.touchesLength; ++j) { |
| + const WebTouchPoint& current_touchmove_point = touch->event.touches[j]; |
| + if (last_touch_point.id == current_touchmove_point.id) { |
|
jdduke (slow)
2015/01/09 17:33:05
Style nit: With this many nested levels, let's inv
USE s.singapati at gmail.com
2015/01/12 19:30:26
Done.
|
| + if (current_touchmove_point.position.x == last_touch_point.position.x |
|
jdduke (slow)
2015/01/09 17:33:05
I think this can just be:
if (current_touchmove_p
USE s.singapati at gmail.com
2015/01/12 19:30:26
Done.
|
| + && current_touchmove_point.position.y == |
| + last_touch_point.position.y) { |
| + touch->event.touches[j].state = WebTouchPoint::StateStationary; |
| + } |
| + break; |
| + } |
| + } |
| + } |
| + } |
| + |
| + if (last_sent_touchevent_) |
| + *last_sent_touchevent_ = touch->event; |
| + else |
| + last_sent_touchevent_.reset(new WebTouchEvent(touch->event)); |
| + |
| + client_->SendTouchEventImmediately(*touch); |
| } |
| TouchEventQueue::PreFilterResult |
| @@ -729,6 +756,8 @@ TouchEventQueue::FilterBeforeForwarding(const WebTouchEvent& event) { |
| touch_consumer_states_.clear(); |
| send_touch_events_async_ = false; |
| pending_async_touchmove_.reset(); |
| + last_sent_touchevent_.reset(); |
| + |
| touch_sequence_start_position_ = gfx::PointF(event.touches[0].position); |
| drop_remaining_touches_in_sequence_ = false; |
| if (!has_handlers_) { |