Commit 49dd36b4 authored by Xida Chen's avatar Xida Chen Committed by Commit Bot

Fix the case where scrolling_touch_action_ has no value

It seems that TouchActionFilter::scrolling_touch_action_ could have no
value in various cases:
1. Start a fling with a touchpad and then do fling boosting with a touch
screen.
2. We could have TapDown targeting an iframe and GestureScrollBegin
targeting the main frame.

This CL does the temporary fix to ensure that the scrolling_touch_action_
always have value. A proper fix with tests will come later.

This CL also fixes the case when we try to access the allowed_touch_action_
which could have no value.

TBR=creis@chromium.org

Bug: 850979
Change-Id: I8dc52a396970d20a7037fa64dc239a25def4fac1
Reviewed-on: https://chromium-review.googlesource.com/1099193Reviewed-by: default avatarXida Chen <xidachen@chromium.org>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Commit-Queue: Xida Chen <xidachen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#566947}
parent decb450f
......@@ -225,7 +225,8 @@ void InputRouterImpl::SetForceEnableZoom(bool enabled) {
}
base::Optional<cc::TouchAction> InputRouterImpl::AllowedTouchAction() {
return touch_action_filter_.allowed_touch_action();
return touch_action_filter_.allowed_touch_action().value_or(
cc::kTouchActionAuto);
}
void InputRouterImpl::BindHost(mojom::WidgetInputHandlerHostRequest request,
......
......@@ -52,6 +52,9 @@ FilterGestureEventResult TouchActionFilter::FilterGestureEvent(
DCHECK(!suppress_manipulation_events_);
DCHECK(!touchscreen_scroll_in_progress_);
touchscreen_scroll_in_progress_ = true;
// TODO(https://crbug.com/851644): Make sure the value is properly set.
if (!scrolling_touch_action_.has_value())
SetTouchAction(cc::kTouchActionAuto);
suppress_manipulation_events_ =
ShouldSuppressManipulation(*gesture_event);
return suppress_manipulation_events_
......@@ -115,6 +118,9 @@ FilterGestureEventResult TouchActionFilter::FilterGestureEvent(
// If double tap is disabled, there's no reason for the tap delay.
case WebInputEvent::kGestureTapUnconfirmed: {
DCHECK_EQ(1, gesture_event->data.tap.tap_count);
// TODO(https://crbug.com/851644): Make sure the value is properly set.
if (!scrolling_touch_action_.has_value())
SetTouchAction(cc::kTouchActionAuto);
allow_current_double_tap_event_ = (scrolling_touch_action_.value() &
cc::kTouchActionDoubleTapZoom) != 0;
if (!allow_current_double_tap_event_) {
......
......@@ -2729,9 +2729,9 @@ IN_PROC_BROWSER_TEST_P(SitePerProcessHitTestBrowserTest,
// will trigger kTouchActionNone being sent back to the browser.
RenderWidgetHostImpl* child_render_widget_host =
root->child_at(0)->current_frame_host()->GetRenderWidgetHost();
EXPECT_EQ(false, child_render_widget_host->input_router()
->AllowedTouchAction()
.has_value());
EXPECT_EQ(true, child_render_widget_host->input_router()
->AllowedTouchAction()
.has_value());
InputEventAckWaiter waiter(child_render_widget_host,
blink::WebInputEvent::kTouchStart);
......@@ -2806,7 +2806,7 @@ IN_PROC_BROWSER_TEST_P(SitePerProcessHitTestBrowserTest,
RenderWidgetHostImpl* render_widget_host =
root->current_frame_host()->GetRenderWidgetHost();
EXPECT_EQ(
false,
true,
render_widget_host->input_router()->AllowedTouchAction().has_value());
// Simulate touch event to sub-frame.
......
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