Title: [134809] trunk/Source
Revision
134809
Author
[email protected]
Date
2012-11-15 11:57:07 -0800 (Thu, 15 Nov 2012)

Log Message

[chromium] Do not mark an event (mouse wheel, scroll update) as handled if nothing was scrolled.
https://bugs.webkit.org/show_bug.cgi?id=102246

Patch by Sadrul Habib Chowdhury <[email protected]> on 2012-11-15
Reviewed by James Robinson.

* src/WebCompositorInputHandlerImpl.cpp:
(WebKit::WebCompositorInputHandlerImpl::handleInputEventInternal):
* tests/WebCompositorInputHandlerImplTest.cpp:
(MockWebInputHandlerClient):
(WebKit::TEST_F):

Modified Paths

Diff

Modified: trunk/Source/Platform/chromium/public/WebInputHandlerClient.h (134808 => 134809)


--- trunk/Source/Platform/chromium/public/WebInputHandlerClient.h	2012-11-15 19:56:51 UTC (rev 134808)
+++ trunk/Source/Platform/chromium/public/WebInputHandlerClient.h	2012-11-15 19:57:07 UTC (rev 134809)
@@ -51,9 +51,10 @@
 
     // Scroll the selected layer starting at the given window coordinate. If
     // there is no room to move the layer in the requested direction, its first
-    // ancestor layer that can be scrolled will be moved instead. Should only be
-    // called if scrollBegin() returned ScrollStarted.
-    virtual void scrollBy(WebPoint, WebSize) = 0;
+    // ancestor layer that can be scrolled will be moved instead. If there is no
+    // such layer to be moved, this returns false. Returns true otherwise.
+    // Should only be called if scrollBegin() returned ScrollStarted.
+    virtual bool scrollByIfPossible(WebPoint, WebSize) = 0;
 
     // Stop scrolling the selected layer. Should only be called if scrollBegin()
     // returned ScrollStarted.

Modified: trunk/Source/WebKit/chromium/ChangeLog (134808 => 134809)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-11-15 19:56:51 UTC (rev 134808)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-11-15 19:57:07 UTC (rev 134809)
@@ -1,3 +1,16 @@
+2012-11-15  Sadrul Habib Chowdhury  <[email protected]>
+
+        [chromium] Do not mark an event (mouse wheel, scroll update) as handled if nothing was scrolled.
+        https://bugs.webkit.org/show_bug.cgi?id=102246
+
+        Reviewed by James Robinson.
+
+        * src/WebCompositorInputHandlerImpl.cpp:
+        (WebKit::WebCompositorInputHandlerImpl::handleInputEventInternal):
+        * tests/WebCompositorInputHandlerImplTest.cpp:
+        (MockWebInputHandlerClient):
+        (WebKit::TEST_F):
+
 2012-11-15  Tommy Widenflycht  <[email protected]>
 
         MediaStream API: Update RTCPeerConnection states to match the latest editors draft

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".
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to