Modified: trunk/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp (134808 => 134809)
--- trunk/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp 2012-11-15 19:56:51 UTC (rev 134808)
+++ trunk/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp 2012-11-15 19:57:07 UTC (rev 134809)
@@ -119,9 +119,9 @@
switch (scrollStatus) {
case WebInputHandlerClient::ScrollStatusStarted: {
TRACE_EVENT_INSTANT2("cc", "WebCompositorInputHandlerImpl::handleInput wheel scroll", "deltaX", -wheelEvent.deltaX, "deltaY", -wheelEvent.deltaY);
- m_inputHandlerClient->scrollBy(WebPoint(wheelEvent.x, wheelEvent.y), IntSize(-wheelEvent.deltaX, -wheelEvent.deltaY));
+ bool didScroll = m_inputHandlerClient->scrollByIfPossible(WebPoint(wheelEvent.x, wheelEvent.y), IntSize(-wheelEvent.deltaX, -wheelEvent.deltaY));
m_inputHandlerClient->scrollEnd();
- return DidHandle;
+ return didScroll ? DidHandle : DropEvent;
}
case WebInputHandlerClient::ScrollStatusIgnored:
// FIXME: This should be DropEvent, but in cases where we fail to properly sync scrollability it's safer to send the
@@ -154,9 +154,9 @@
return DidNotHandle;
const WebGestureEvent& gestureEvent = *static_cast<const WebGestureEvent*>(&event);
- m_inputHandlerClient->scrollBy(WebPoint(gestureEvent.x, gestureEvent.y),
+ bool didScroll = m_inputHandlerClient->scrollByIfPossible(WebPoint(gestureEvent.x, gestureEvent.y),
IntSize(-gestureEvent.data.scrollUpdate.deltaX, -gestureEvent.data.scrollUpdate.deltaY));
- return DidHandle;
+ return didScroll ? DidHandle : DropEvent;
} else if (event.type == WebInputEvent::GestureScrollEnd) {
ASSERT(m_expectScrollUpdateEnd);
#ifndef NDEBUG
Modified: trunk/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp (134808 => 134809)
--- trunk/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp 2012-11-15 19:56:51 UTC (rev 134808)
+++ trunk/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp 2012-11-15 19:57:07 UTC (rev 134809)
@@ -59,7 +59,7 @@
MOCK_METHOD0(scheduleAnimation, void());
MOCK_METHOD2(scrollBegin, ScrollStatus(WebPoint, WebInputHandlerClient::ScrollInputType));
- MOCK_METHOD2(scrollBy, void(WebPoint, WebSize));
+ MOCK_METHOD2(scrollByIfPossible, bool(WebPoint, WebSize));
MOCK_METHOD0(scrollEnd, void());
private:
@@ -155,15 +155,28 @@
gesture.type = WebInputEvent::GestureScrollBegin;
m_inputHandler->handleInputEvent(gesture);
+ // The event should not be marked as handled if scrolling is not possible.
+ m_expectedDisposition = DropEvent;
VERIFY_AND_RESET_MOCKS();
gesture.type = WebInputEvent::GestureScrollUpdate;
gesture.data.scrollUpdate.deltaY = -40; // -Y means scroll down - i.e. in the +Y direction.
- EXPECT_CALL(m_mockInputHandlerClient, scrollBy(testing::_, testing::Field(&WebSize::height, testing::Gt(0))));
+ EXPECT_CALL(m_mockInputHandlerClient, scrollByIfPossible(testing::_, testing::Field(&WebSize::height, testing::Gt(0))))
+ .WillOnce(testing::Return(false));
m_inputHandler->handleInputEvent(gesture);
+ // Mark the event as handled if scroll happens.
+ m_expectedDisposition = DidHandle;
VERIFY_AND_RESET_MOCKS();
+ gesture.type = WebInputEvent::GestureScrollUpdate;
+ gesture.data.scrollUpdate.deltaY = -40; // -Y means scroll down - i.e. in the +Y direction.
+ EXPECT_CALL(m_mockInputHandlerClient, scrollByIfPossible(testing::_, testing::Field(&WebSize::height, testing::Gt(0))))
+ .WillOnce(testing::Return(true));
+ m_inputHandler->handleInputEvent(gesture);
+
+ VERIFY_AND_RESET_MOCKS();
+
gesture.type = WebInputEvent::GestureScrollEnd;
gesture.data.scrollUpdate.deltaY = 0;
EXPECT_CALL(m_mockInputHandlerClient, scrollEnd());
@@ -346,7 +359,8 @@
EXPECT_CALL(m_mockInputHandlerClient, scheduleAnimation());
EXPECT_CALL(m_mockInputHandlerClient, scrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(WebInputHandlerClient::ScrollStatusStarted));
- EXPECT_CALL(m_mockInputHandlerClient, scrollBy(testing::_, testing::Field(&WebSize::width, testing::Lt(0))));
+ EXPECT_CALL(m_mockInputHandlerClient, scrollByIfPossible(testing::_, testing::Field(&WebSize::width, testing::Lt(0))))
+ .WillOnce(testing::Return(true));
EXPECT_CALL(m_mockInputHandlerClient, scrollEnd());
m_inputHandler->animate(10.1);
@@ -358,7 +372,7 @@
EXPECT_CALL(m_mockInputHandlerClient, scheduleAnimation());
EXPECT_CALL(m_mockInputHandlerClient, scrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(WebInputHandlerClient::ScrollStatusOnMainThread));
- EXPECT_CALL(m_mockInputHandlerClient, scrollBy(testing::_, testing::_)).Times(0);
+ EXPECT_CALL(m_mockInputHandlerClient, scrollByIfPossible(testing::_, testing::_)).Times(0);
EXPECT_CALL(m_mockInputHandlerClient, scrollEnd()).Times(0);
// Expected wheel fling animation parameters:
@@ -429,7 +443,8 @@
EXPECT_CALL(m_mockInputHandlerClient, scheduleAnimation());
EXPECT_CALL(m_mockInputHandlerClient, scrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(WebInputHandlerClient::ScrollStatusStarted));
- EXPECT_CALL(m_mockInputHandlerClient, scrollBy(testing::_, testing::Field(&WebSize::width, testing::Lt(0))));
+ EXPECT_CALL(m_mockInputHandlerClient, scrollByIfPossible(testing::_, testing::Field(&WebSize::width, testing::Lt(0))))
+ .WillOnce(testing::Return(true));
EXPECT_CALL(m_mockInputHandlerClient, scrollEnd());
m_inputHandler->animate(10.1);
@@ -441,7 +456,7 @@
EXPECT_CALL(m_mockInputHandlerClient, scheduleAnimation());
EXPECT_CALL(m_mockInputHandlerClient, scrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(WebInputHandlerClient::ScrollStatusOnMainThread));
- EXPECT_CALL(m_mockInputHandlerClient, scrollBy(testing::_, testing::_)).Times(0);
+ EXPECT_CALL(m_mockInputHandlerClient, scrollByIfPossible(testing::_, testing::_)).Times(0);
EXPECT_CALL(m_mockInputHandlerClient, scrollEnd()).Times(0);
// Expected wheel fling animation parameters:
@@ -509,7 +524,8 @@
EXPECT_CALL(m_mockInputHandlerClient, scheduleAnimation());
EXPECT_CALL(m_mockInputHandlerClient, scrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(WebInputHandlerClient::ScrollStatusStarted));
- EXPECT_CALL(m_mockInputHandlerClient, scrollBy(testing::_, testing::Field(&WebSize::height, testing::Gt(0))));
+ EXPECT_CALL(m_mockInputHandlerClient, scrollByIfPossible(testing::_, testing::Field(&WebSize::height, testing::Gt(0))))
+ .WillOnce(testing::Return(true));
EXPECT_CALL(m_mockInputHandlerClient, scrollEnd());
m_inputHandler->animate(30.1);
@@ -519,7 +535,7 @@
EXPECT_CALL(m_mockInputHandlerClient, scheduleAnimation());
EXPECT_CALL(m_mockInputHandlerClient, scrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(WebInputHandlerClient::ScrollStatusOnMainThread));
- EXPECT_CALL(m_mockInputHandlerClient, scrollBy(testing::_, testing::_)).Times(0);
+ EXPECT_CALL(m_mockInputHandlerClient, scrollByIfPossible(testing::_, testing::_)).Times(0);
EXPECT_CALL(m_mockInputHandlerClient, scrollEnd()).Times(0);
// We should get parameters from the second fling, nothing from the first fling should "leak".