diff options
author | hush <hush@chromium.org> | 2015-06-23 14:22:11 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-23 21:22:52 +0000 |
commit | 1c87323ecff9e576018229327e1e80d1a33ae830 (patch) | |
tree | 0dd64170aed2010e9f7666bc7cac2186402308f7 /content/renderer/input | |
parent | 012d678acebc6af1de1866727cde85e21ca3020a (diff) | |
download | chromium_src-1c87323ecff9e576018229327e1e80d1a33ae830.zip chromium_src-1c87323ecff9e576018229327e1e80d1a33ae830.tar.gz chromium_src-1c87323ecff9e576018229327e1e80d1a33ae830.tar.bz2 |
Make it possible to synthesize a viewport scroll
When targetViewport is true, skip the hit test and always
scroll the viewport layer.
This is to support the WebView#flingScroll API, which has been
implemented to always target at viewport scroll layer.
Accompanying blink change that adds 'targetViewport':
https://codereview.chromium.org/1187633003/
BUG=493765
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1189603004
Cr-Commit-Position: refs/heads/master@{#335750}
Diffstat (limited to 'content/renderer/input')
-rw-r--r-- | content/renderer/input/input_handler_proxy.cc | 21 | ||||
-rw-r--r-- | content/renderer/input/input_handler_proxy_unittest.cc | 17 |
2 files changed, 33 insertions, 5 deletions
diff --git a/content/renderer/input/input_handler_proxy.cc b/content/renderer/input/input_handler_proxy.cc index e8e8f37..232d8b7 100644 --- a/content/renderer/input/input_handler_proxy.cc +++ b/content/renderer/input/input_handler_proxy.cc @@ -426,8 +426,14 @@ InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureScrollBegin( DCHECK(!expect_scroll_update_end_); expect_scroll_update_end_ = true; #endif - cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin( - gfx::Point(gesture_event.x, gesture_event.y), cc::InputHandler::GESTURE); + cc::InputHandler::ScrollStatus scroll_status; + if (gesture_event.data.scrollBegin.targetViewport) { + scroll_status = input_handler_->RootScrollBegin(cc::InputHandler::GESTURE); + } else { + scroll_status = input_handler_->ScrollBegin( + gfx::Point(gesture_event.x, gesture_event.y), + cc::InputHandler::GESTURE); + } UMA_HISTOGRAM_ENUMERATION("Renderer4.CompositorScrollHitTestResult", scroll_status, cc::InputHandler::ScrollStatusCount); @@ -487,9 +493,14 @@ InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureFlingStart( cc::InputHandler::ScrollStatus scroll_status; if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad) { - scroll_status = input_handler_->ScrollBegin( - gfx::Point(gesture_event.x, gesture_event.y), - cc::InputHandler::NON_BUBBLING_GESTURE); + if (gesture_event.data.flingStart.targetViewport) { + scroll_status = input_handler_->RootScrollBegin( + cc::InputHandler::NON_BUBBLING_GESTURE); + } else { + scroll_status = input_handler_->ScrollBegin( + gfx::Point(gesture_event.x, gesture_event.y), + cc::InputHandler::NON_BUBBLING_GESTURE); + } } else { if (!gesture_scroll_on_impl_thread_) scroll_status = cc::InputHandler::SCROLL_ON_MAIN_THREAD; diff --git a/content/renderer/input/input_handler_proxy_unittest.cc b/content/renderer/input/input_handler_proxy_unittest.cc index a1a55f2..0bfe1e2 100644 --- a/content/renderer/input/input_handler_proxy_unittest.cc +++ b/content/renderer/input/input_handler_proxy_unittest.cc @@ -87,6 +87,8 @@ class MockInputHandler : public cc::InputHandler { MOCK_METHOD2(ScrollBegin, ScrollStatus(const gfx::Point& viewport_point, cc::InputHandler::ScrollInputType type)); + MOCK_METHOD1(RootScrollBegin, + ScrollStatus(cc::InputHandler::ScrollInputType type)); MOCK_METHOD2(ScrollAnimated, ScrollStatus(const gfx::Point& viewport_point, const gfx::Vector2dF& scroll_delta)); @@ -395,6 +397,21 @@ TEST_F(InputHandlerProxyTest, GestureScrollIgnored) { VERIFY_AND_RESET_MOCKS(); } +TEST_F(InputHandlerProxyTest, GestureScrollBeginThatTargetViewport) { + // 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_, RootScrollBegin(testing::_)) + .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); + + gesture_.type = WebInputEvent::GestureScrollBegin; + gesture_.data.scrollBegin.targetViewport = true; + EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); + + VERIFY_AND_RESET_MOCKS(); +} + TEST_F(InputHandlerProxyTest, GesturePinch) { // We shouldn't send any events to the widget for this gesture. expected_disposition_ = InputHandlerProxy::DID_HANDLE; |