summaryrefslogtreecommitdiffstats
path: root/ui/events/gestures
diff options
context:
space:
mode:
authortdresser <tdresser@chromium.org>2015-01-26 12:24:59 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-26 20:25:49 +0000
commitb88d572b627a99714051bf057afdb2ead4f58489 (patch)
tree388cefc08bc27337c481001510c30e83d679702e /ui/events/gestures
parent0dca04d9ff641aaba46bfb3281f3ad21e76e0c0b (diff)
downloadchromium_src-b88d572b627a99714051bf057afdb2ead4f58489.zip
chromium_src-b88d572b627a99714051bf057afdb2ead4f58489.tar.gz
chromium_src-b88d572b627a99714051bf057afdb2ead4f58489.tar.bz2
Invalid press events don't create multiple pointers with the same id.
Previously if we got an invalid event stream such as Press id 0 Press id 0 MotionEventAura would happily add the second pointer. Now we replace the first pointer with the second pointer. This work around is required due to crbug.com/373125. BUG=450880 Review URL: https://codereview.chromium.org/873283003 Cr-Commit-Position: refs/heads/master@{#313116}
Diffstat (limited to 'ui/events/gestures')
-rw-r--r--ui/events/gestures/motion_event_aura.cc15
-rw-r--r--ui/events/gestures/motion_event_aura_unittest.cc16
2 files changed, 23 insertions, 8 deletions
diff --git a/ui/events/gestures/motion_event_aura.cc b/ui/events/gestures/motion_event_aura.cc
index 2f532e7..174918f 100644
--- a/ui/events/gestures/motion_event_aura.cc
+++ b/ui/events/gestures/motion_event_aura.cc
@@ -82,12 +82,17 @@ bool MotionEventAura::OnTouch(const TouchEvent& touch) {
bool pointer_id_is_active = index != -1;
if (touch.type() == ET_TOUCH_PRESSED && pointer_id_is_active) {
- // Ignore touch press events if we already believe the pointer is down.
-
- // TODO(tdresser): this should return false (or NOTREACHED());
- // however, there is at least one case where we need to allow a
- // touch press from a currently used touch id. See
+ // TODO(tdresser): This should return false (or NOTREACHED()), and
+ // ignore the touch; however, there is at least one case where we
+ // need to allow a touch press from a currently used touch id. See
// crbug.com/446852 for details.
+
+ // Cancel the existing touch, before handling the touch press.
+ TouchEvent cancel(ET_TOUCH_CANCELLED, touch.location(), touch.touch_id(),
+ touch.time_stamp());
+ OnTouch(cancel);
+ CleanupRemovedTouchPoints(cancel);
+ DCHECK_EQ(-1, FindPointerIndexOfId(touch.touch_id()));
} else if (touch.type() != ET_TOUCH_PRESSED && !pointer_id_is_active) {
// We could have an active touch stream transfered to us, resulting in touch
// move or touch up events without associated touch down events. Ignore
diff --git a/ui/events/gestures/motion_event_aura_unittest.cc b/ui/events/gestures/motion_event_aura_unittest.cc
index 57ee6ce..8decac0 100644
--- a/ui/events/gestures/motion_event_aura_unittest.cc
+++ b/ui/events/gestures/motion_event_aura_unittest.cc
@@ -456,10 +456,20 @@ TEST(MotionEventAuraTest, Flags) {
// Once crbug.com/446852 is fixed, we should ignore redundant presses.
TEST(MotionEventAuraTest, DoesntIgnoreRedundantPresses) {
- int id = 7;
+ const int id = 7;
+ const int position_1 = 10;
+ const int position_2 = 23;
+
MotionEventAura event;
- EXPECT_TRUE(event.OnTouch(TouchWithType(ET_TOUCH_PRESSED, id)));
- EXPECT_TRUE(event.OnTouch(TouchWithType(ET_TOUCH_PRESSED, id)));
+ TouchEvent press1 = TouchWithPosition(ET_TOUCH_PRESSED, id, position_1,
+ position_1, position_1, position_1);
+ EXPECT_TRUE(event.OnTouch(press1));
+ TouchEvent press2 = TouchWithPosition(ET_TOUCH_PRESSED, id, position_2,
+ position_2, position_2, position_2);
+ EXPECT_TRUE(event.OnTouch(press2));
+
+ EXPECT_EQ(1U, event.GetPointerCount());
+ EXPECT_FLOAT_EQ(position_2, event.GetX(0));
}
TEST(MotionEventAuraTest, IgnoresEventsWithoutPress) {