diff --git a/ui/aura/gestures/gesture_recognizer_unittest.cc b/ui/aura/gestures/gesture_recognizer_unittest.cc index fed5ea462eef8..951aa443f5de4 100644 --- a/ui/aura/gestures/gesture_recognizer_unittest.cc +++ b/ui/aura/gestures/gesture_recognizer_unittest.cc @@ -2554,7 +2554,7 @@ TEST_F(GestureRecognizerTest, PressDoesNotCrash) { // there is at least one case where we need to allow a touch press // from a currently used touch id. See crbug.com/373125 for details. EXPECT_TRUE(delegate->begin()); - EXPECT_FALSE(delegate->tap_down()); + EXPECT_TRUE(delegate->tap_down()); EXPECT_TRUE(delegate->tap_cancel()); EXPECT_FALSE(delegate->scroll_begin()); } diff --git a/ui/events/gestures/motion_event_aura.cc b/ui/events/gestures/motion_event_aura.cc index 1f4d2855b2fc0..e8fcf263a677b 100644 --- a/ui/events/gestures/motion_event_aura.cc +++ b/ui/events/gestures/motion_event_aura.cc @@ -74,12 +74,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 b1ce027836533..2a95b080bb208 100644 --- a/ui/events/gestures/motion_event_aura_unittest.cc +++ b/ui/events/gestures/motion_event_aura_unittest.cc @@ -426,10 +426,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) {