Commit c9440b2c authored by jdduke@chromium.org's avatar jdduke@chromium.org

Fix WebKeyboardEvent interruption of compositor scrolling

Fix an issue where keyboard events improperly reset the scroll status while
a touch scroll was active in InputHandlerProxy.

BUG=361160

Review URL: https://codereview.chromium.org/230663004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262985 0039d316-1c4b-4281-b951-d872f2087c98
parent 882ccdfa
...@@ -250,7 +250,10 @@ InputHandlerProxy::EventDisposition InputHandlerProxy::HandleInputEvent( ...@@ -250,7 +250,10 @@ InputHandlerProxy::EventDisposition InputHandlerProxy::HandleInputEvent(
} }
return DROP_EVENT; return DROP_EVENT;
} else if (WebInputEvent::isKeyboardEventType(event.type)) { } else if (WebInputEvent::isKeyboardEventType(event.type)) {
CancelCurrentFling(true); // Only call |CancelCurrentFling()| if a fling was active, as it will
// otherwise disrupt an in-progress touch scroll.
if (fling_curve_)
CancelCurrentFling(true);
} else if (event.type == WebInputEvent::MouseMove) { } else if (event.type == WebInputEvent::MouseMove) {
const WebMouseEvent& mouse_event = const WebMouseEvent& mouse_event =
*static_cast<const WebMouseEvent*>(&event); *static_cast<const WebMouseEvent*>(&event);
......
...@@ -23,6 +23,7 @@ using blink::WebFloatPoint; ...@@ -23,6 +23,7 @@ using blink::WebFloatPoint;
using blink::WebFloatSize; using blink::WebFloatSize;
using blink::WebGestureEvent; using blink::WebGestureEvent;
using blink::WebInputEvent; using blink::WebInputEvent;
using blink::WebKeyboardEvent;
using blink::WebMouseWheelEvent; using blink::WebMouseWheelEvent;
using blink::WebPoint; using blink::WebPoint;
using blink::WebSize; using blink::WebSize;
...@@ -1257,5 +1258,57 @@ TEST_F(InputHandlerProxyTest, MultiTouchPointHitTestPositive) { ...@@ -1257,5 +1258,57 @@ TEST_F(InputHandlerProxyTest, MultiTouchPointHitTestPositive) {
EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch));
} }
TEST_F(InputHandlerProxyTest, GestureFlingCancelledByKeyboardEvent) {
// We shouldn't send any events to the widget for this gesture.
expected_disposition_ = InputHandlerProxy::DID_HANDLE;
VERIFY_AND_RESET_MOCKS();
EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
gesture_.type = WebInputEvent::GestureScrollBegin;
gesture_.sourceDevice = WebGestureEvent::Touchscreen;
EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
// Keyboard events received during a scroll should have no effect.
WebKeyboardEvent key_event;
key_event.type = WebInputEvent::KeyDown;
EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE,
input_handler_->HandleInputEvent(key_event));
EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
// On the fling start, animation should be scheduled, but no scrolling occurs.
gesture_.type = WebInputEvent::GestureFlingStart;
WebFloatPoint fling_delta = WebFloatPoint(1000, 1000);
gesture_.data.flingStart.velocityX = fling_delta.x;
gesture_.data.flingStart.velocityY = fling_delta.y;
EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
.WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
// Keyboard events received during a fling should cancel the active fling.
EXPECT_CALL(mock_input_handler_, ScrollEnd());
EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE,
input_handler_->HandleInputEvent(key_event));
EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
// The call to animate should have no effect, as the fling was cancelled.
base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
input_handler_->Animate(time);
testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
// A fling cancel should be dropped, as there is nothing to cancel.
gesture_.type = WebInputEvent::GestureFlingCancel;
EXPECT_EQ(InputHandlerProxy::DROP_EVENT,
input_handler_->HandleInputEvent(gesture_));
EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
}
} // namespace } // namespace
} // namespace content } // namespace content
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