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..97fc9ec7e502ec94604b3d782ce83d49a697497a 100644 |
--- a/content/browser/renderer_host/input/touch_event_queue.cc |
+++ b/content/browser/renderer_host/input/touch_event_queue.cc |
@@ -107,7 +107,8 @@ class TouchEventQueue::TouchTimeoutHandler { |
SetPendingAckState(PENDING_ACK_CANCEL_EVENT); |
TouchEventWithLatencyInfo cancel_event = |
ObtainCancelEventForTouchEvent(timeout_event_); |
- touch_queue_->SendTouchEventImmediately(cancel_event); |
+ touch_queue_->UpdateTouchesStateIfNeededAndSendTouchEvent( |
+ cancel_event); |
} else { |
SetPendingAckState(PENDING_ACK_NONE); |
touch_queue_->UpdateTouchConsumerStates(timeout_event_.event, |
@@ -525,7 +526,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); |
+ UpdateTouchesStateIfNeededAndSendTouchEvent(*async_move); |
return; |
} |
} |
@@ -539,7 +540,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); |
+ UpdateTouchesStateIfNeededAndSendTouchEvent(touch); |
if (dispatching_touch_ && timeout_handler_) |
timeout_handler_->StartIfNecessary(touch); |
} |
@@ -702,6 +703,41 @@ scoped_ptr<CoalescedWebTouchEvent> TouchEventQueue::PopTouchEvent() { |
return event.Pass(); |
} |
+void TouchEventQueue::UpdateTouchesStateIfNeededAndSendTouchEvent( |
+ TouchEventWithLatencyInfo& touch) { |
jdduke (slow)
2014/12/09 20:30:25
This logic can probably be folded into SendTouchEv
USE s.singapati at gmail.com
2014/12/13 07:46:05
Done.
|
+ if (touch.event.type == WebInputEvent::TouchMove) { |
+ if (last_sent_touchmove_) { |
+ WebTouchEvent last_touchmove_event = last_sent_touchmove_->event; |
+ // compare touch points position from current event to last sent event |
+ // and update touch points state. touchesLength & order of touches |
+ // (point ids) should be same in consecutive TouchMoves |
+ for (unsigned int i = 0; i < last_touchmove_event.touchesLength; ++i) { |
+ const WebTouchPoint& last_touchmove_point = |
+ last_touchmove_event.touches[i]; |
+ WebTouchPoint& current_touchmove_point = touch.event.touches[i]; |
+ |
+ // current touches state would have been set to "StateMoved" |
+ // in web_input_event_util. This check may not be needed!? |
+ if (current_touchmove_point.state == WebTouchPoint::StateMoved |
jdduke (slow)
2014/12/09 20:30:25
I don't think there are any guarantees that pointe
USE s.singapati at gmail.com
2014/12/13 07:46:05
Done. Form testing it is found that most of the ti
|
+ && last_touchmove_point.id == current_touchmove_point.id) { |
+ |
+ if (fabs(current_touchmove_point.position.x - |
+ last_touchmove_point.position.x) < 0.000001 |
+ && fabs(current_touchmove_point.position.y - |
+ last_touchmove_point.position.y) < 0.000001) |
+ current_touchmove_point.state = WebTouchPoint::StateStationary; |
+ } |
+ } |
+ } |
+ last_sent_touchmove_.reset(new TouchEventWithLatencyInfo(touch)); |
jdduke (slow)
2014/12/09 20:30:25
Do we need to store the LatencyInfo? I think we ca
USE s.singapati at gmail.com
2014/12/13 07:46:05
Done.
|
+ } else { |
+ if (last_sent_touchmove_) |
+ last_sent_touchmove_.reset(); |
+ } |
+ |
+ SendTouchEventImmediately(touch); |
+} |
+ |
void TouchEventQueue::SendTouchEventImmediately( |
const TouchEventWithLatencyInfo& touch) { |
if (needs_async_touchmove_for_outer_slop_region_) { |
@@ -729,6 +765,8 @@ TouchEventQueue::FilterBeforeForwarding(const WebTouchEvent& event) { |
touch_consumer_states_.clear(); |
send_touch_events_async_ = false; |
pending_async_touchmove_.reset(); |
+ last_sent_touchmove_.reset(); |
+ |
touch_sequence_start_position_ = gfx::PointF(event.touches[0].position); |
drop_remaining_touches_in_sequence_ = false; |
if (!has_handlers_) { |