Commit 97c66c78 authored by Kevin McNee's avatar Kevin McNee Committed by Commit Bot

Clear touchscreen gesture target at the end of a gesture

We currently leave the last touchscreen gesture target in
|touchscreen_gesture_target_| and only overwrite it upon the next
touchscreen gesture. This is a problem if the user switches from using a
touchscreen to another input device, since the scroll bubbling logic
will believe that there is an ongoing touchscreen gesture and drop any
attempts to bubble scroll to this target.

We now clear the target at the end of a touchscreen gesture (more
specifically, after dispatching a gesture event which indicates the lift
of the last finger).

Bug: 865151
Change-Id: I8fddc1ac9c36ebf9b84a59b1304784188c46f142
Reviewed-on: https://chromium-review.googlesource.com/c/1351744Reviewed-by: default avatarKen Buchanan <kenrb@chromium.org>
Commit-Queue: Kevin McNee <mcnee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#613124}
parent 11942ab7
...@@ -1333,11 +1333,8 @@ void RenderWidgetHostInputEventRouter::DispatchTouchscreenGestureEvent( ...@@ -1333,11 +1333,8 @@ void RenderWidgetHostInputEventRouter::DispatchTouchscreenGestureEvent(
gesture_target_it == touchscreen_gesture_target_map_.end(); gesture_target_it == touchscreen_gesture_target_map_.end();
// We use GestureTapDown to detect the start of a gesture sequence since // We use GestureTapDown to detect the start of a gesture sequence since
// there is no WebGestureEvent equivalent for ET_GESTURE_BEGIN. Note that // there is no WebGestureEvent equivalent for ET_GESTURE_BEGIN.
// this means the GestureFlingCancel that always comes between const bool is_gesture_start =
// ET_GESTURE_BEGIN and GestureTapDown is sent to the previous target, in
// case it is still in a fling.
bool is_gesture_start =
gesture_event.GetType() == blink::WebInputEvent::kGestureTapDown; gesture_event.GetType() == blink::WebInputEvent::kGestureTapDown;
if (gesture_event.unique_touch_event_id == 0) { if (gesture_event.unique_touch_event_id == 0) {
...@@ -1431,6 +1428,19 @@ void RenderWidgetHostInputEventRouter::DispatchTouchscreenGestureEvent( ...@@ -1431,6 +1428,19 @@ void RenderWidgetHostInputEventRouter::DispatchTouchscreenGestureEvent(
if (gesture_event.GetType() == blink::WebInputEvent::kGestureFlingStart) if (gesture_event.GetType() == blink::WebInputEvent::kGestureFlingStart)
last_fling_start_target_ = touchscreen_gesture_target_.target; last_fling_start_target_ = touchscreen_gesture_target_.target;
// If we have one of the following events, then the user has lifted their
// last finger.
const bool is_gesture_end =
gesture_event.GetType() == blink::WebInputEvent::kGestureTap ||
gesture_event.GetType() == blink::WebInputEvent::kGestureLongTap ||
gesture_event.GetType() == blink::WebInputEvent::kGestureDoubleTap ||
gesture_event.GetType() == blink::WebInputEvent::kGestureTwoFingerTap ||
gesture_event.GetType() == blink::WebInputEvent::kGestureScrollEnd ||
gesture_event.GetType() == blink::WebInputEvent::kGestureFlingStart;
if (is_gesture_end)
touchscreen_gesture_target_.target = nullptr;
} }
void RenderWidgetHostInputEventRouter::RouteTouchscreenGestureEvent( void RenderWidgetHostInputEventRouter::RouteTouchscreenGestureEvent(
......
...@@ -3835,7 +3835,6 @@ void SendGestureTapSequenceWithExpectedTarget( ...@@ -3835,7 +3835,6 @@ void SendGestureTapSequenceWithExpectedTarget(
RenderWidgetHostViewBase* root_view, RenderWidgetHostViewBase* root_view,
const gfx::Point& gesture_point, const gfx::Point& gesture_point,
RenderWidgetHostViewBase*& router_gesture_target, RenderWidgetHostViewBase*& router_gesture_target,
const RenderWidgetHostViewBase* old_expected_target,
const RenderWidgetHostViewBase* expected_target, const RenderWidgetHostViewBase* expected_target,
const uint32_t unique_touch_event_id) { const uint32_t unique_touch_event_id) {
auto* root_view_aura = static_cast<RenderWidgetHostViewAura*>(root_view); auto* root_view_aura = static_cast<RenderWidgetHostViewAura*>(root_view);
...@@ -3848,12 +3847,6 @@ void SendGestureTapSequenceWithExpectedTarget( ...@@ -3848,12 +3847,6 @@ void SendGestureTapSequenceWithExpectedTarget(
gesture_begin_details, unique_touch_event_id); gesture_begin_details, unique_touch_event_id);
UpdateEventRootLocation(&gesture_begin_event, root_view_aura); UpdateEventRootLocation(&gesture_begin_event, root_view_aura);
root_view_aura->OnGestureEvent(&gesture_begin_event); root_view_aura->OnGestureEvent(&gesture_begin_event);
// We expect to still have the old gesture target in place for the
// GestureFlingCancel that will be inserted before GestureTapDown.
// Note: the GestureFlingCancel is inserted by RenderWidgetHostViewAura::
// OnGestureEvent() when it sees ui::ET_GESTURE_TAP_DOWN, so we don't
// explicitly add it here.
EXPECT_EQ(old_expected_target, router_gesture_target);
ui::GestureEventDetails gesture_tap_down_details(ui::ET_GESTURE_TAP_DOWN); ui::GestureEventDetails gesture_tap_down_details(ui::ET_GESTURE_TAP_DOWN);
gesture_tap_down_details.set_device_type( gesture_tap_down_details.set_device_type(
...@@ -3884,7 +3877,7 @@ void SendGestureTapSequenceWithExpectedTarget( ...@@ -3884,7 +3877,7 @@ void SendGestureTapSequenceWithExpectedTarget(
unique_touch_event_id); unique_touch_event_id);
UpdateEventRootLocation(&gesture_tap_event, root_view_aura); UpdateEventRootLocation(&gesture_tap_event, root_view_aura);
root_view_aura->OnGestureEvent(&gesture_tap_event); root_view_aura->OnGestureEvent(&gesture_tap_event);
EXPECT_EQ(expected_target, router_gesture_target); EXPECT_EQ(nullptr, router_gesture_target);
ui::GestureEventDetails gesture_end_details(ui::ET_GESTURE_END); ui::GestureEventDetails gesture_end_details(ui::ET_GESTURE_END);
gesture_end_details.set_device_type( gesture_end_details.set_device_type(
...@@ -3894,7 +3887,7 @@ void SendGestureTapSequenceWithExpectedTarget( ...@@ -3894,7 +3887,7 @@ void SendGestureTapSequenceWithExpectedTarget(
unique_touch_event_id); unique_touch_event_id);
UpdateEventRootLocation(&gesture_end_event, root_view_aura); UpdateEventRootLocation(&gesture_end_event, root_view_aura);
root_view_aura->OnGestureEvent(&gesture_end_event); root_view_aura->OnGestureEvent(&gesture_end_event);
EXPECT_EQ(expected_target, router_gesture_target); EXPECT_EQ(nullptr, router_gesture_target);
} }
void SendTouchpadPinchSequenceWithExpectedTarget( void SendTouchpadPinchSequenceWithExpectedTarget(
...@@ -4070,28 +4063,22 @@ IN_PROC_BROWSER_TEST_P(SitePerProcessHitTestBrowserTest, ...@@ -4070,28 +4063,22 @@ IN_PROC_BROWSER_TEST_P(SitePerProcessHitTestBrowserTest,
// main frame. // main frame.
SendGestureTapSequenceWithExpectedTarget( SendGestureTapSequenceWithExpectedTarget(
rwhv_parent, main_frame_point, router->touchscreen_gesture_target_.target, rwhv_parent, main_frame_point, router->touchscreen_gesture_target_.target,
nullptr, rwhv_parent, firstId); rwhv_parent, firstId);
EXPECT_EQ(2u, router->touchscreen_gesture_target_map_.size()); EXPECT_EQ(2u, router->touchscreen_gesture_target_map_.size());
// Note: rwhv_parent is the target used for GestureFlingCancel sent by
// RenderWidgetHostViewAura::OnGestureEvent() at the start of the next gesture
// sequence; the sequence itself goes to rwhv_child.
EXPECT_EQ(rwhv_parent, router->touchscreen_gesture_target_.target);
// The second touch sequence should generate a GestureTapDown, sent to the // The second touch sequence should generate a GestureTapDown, sent to the
// child frame. // child frame.
SendGestureTapSequenceWithExpectedTarget( SendGestureTapSequenceWithExpectedTarget(
rwhv_parent, child_center, router->touchscreen_gesture_target_.target, rwhv_parent, child_center, router->touchscreen_gesture_target_.target,
rwhv_parent, rwhv_child, secondId); rwhv_child, secondId);
EXPECT_EQ(1u, router->touchscreen_gesture_target_map_.size()); EXPECT_EQ(1u, router->touchscreen_gesture_target_map_.size());
EXPECT_EQ(rwhv_child, router->touchscreen_gesture_target_.target);
// The third touch sequence should generate a GestureTapDown, sent to the // The third touch sequence should generate a GestureTapDown, sent to the
// main frame. // main frame.
SendGestureTapSequenceWithExpectedTarget( SendGestureTapSequenceWithExpectedTarget(
rwhv_parent, main_frame_point, router->touchscreen_gesture_target_.target, rwhv_parent, main_frame_point, router->touchscreen_gesture_target_.target,
rwhv_child, rwhv_parent, thirdId); rwhv_parent, thirdId);
EXPECT_EQ(0u, router->touchscreen_gesture_target_map_.size()); EXPECT_EQ(0u, router->touchscreen_gesture_target_map_.size());
EXPECT_EQ(rwhv_parent, router->touchscreen_gesture_target_.target);
} }
// TODO: Flaking test crbug.com/802827 // TODO: Flaking test crbug.com/802827
...@@ -4166,20 +4153,15 @@ IN_PROC_BROWSER_TEST_P( ...@@ -4166,20 +4153,15 @@ IN_PROC_BROWSER_TEST_P(
// main frame. // main frame.
SendGestureTapSequenceWithExpectedTarget( SendGestureTapSequenceWithExpectedTarget(
rwhv_parent, main_frame_point, router->touchscreen_gesture_target_.target, rwhv_parent, main_frame_point, router->touchscreen_gesture_target_.target,
nullptr, rwhv_parent, firstId); rwhv_parent, firstId);
EXPECT_EQ(1u, router->touchscreen_gesture_target_map_.size()); EXPECT_EQ(1u, router->touchscreen_gesture_target_map_.size());
// Note: rwhv_parent is the target used for GestureFlingCancel sent by
// RenderWidgetHostViewAura::OnGestureEvent() at the start of the next gesture
// sequence; the sequence itself goes to rwhv_child.
EXPECT_EQ(rwhv_parent, router->touchscreen_gesture_target_.target);
// The third touch sequence should generate a GestureTapDown, sent to the // The third touch sequence should generate a GestureTapDown, sent to the
// main frame. // main frame.
SendGestureTapSequenceWithExpectedTarget( SendGestureTapSequenceWithExpectedTarget(
rwhv_parent, main_frame_point, router->touchscreen_gesture_target_.target, rwhv_parent, main_frame_point, router->touchscreen_gesture_target_.target,
rwhv_parent, rwhv_parent, thirdId); rwhv_parent, thirdId);
EXPECT_EQ(0u, router->touchscreen_gesture_target_map_.size()); EXPECT_EQ(0u, router->touchscreen_gesture_target_map_.size());
EXPECT_EQ(rwhv_parent, router->touchscreen_gesture_target_.target);
} }
#endif // defined(USE_AURA) || defined(OS_ANDROID) #endif // defined(USE_AURA) || defined(OS_ANDROID)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment