Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Unified Diff: content/browser/renderer_host/input/touch_event_queue.cc

Issue 788923002: Touch Events - changedTouches list includes non-changed touch points on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor change to comments Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 c22cbc51f38e296809ac32f8f160864d6c63392b..6a9bbe2667e13668287e5f9147e99dc8e347148d 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,
@@ -515,7 +515,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;
}
}
@@ -529,7 +529,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);
}
@@ -693,18 +693,44 @@ 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 (current_touchmove_point.id != last_touch_point.id)
+ continue;
+
+ if (current_touchmove_point.position == last_touch_point.position)
jdduke (slow) 2015/01/27 17:29:54 Yeah, for correctness, I think we'll need to compa
USE s.singapati at gmail.com 2015/01/28 16:09:52 Done.
+ 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
@@ -719,6 +745,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_) {

Powered by Google App Engine
This is Rietveld 408576698