Source/WebKit/chromium: Use new type-specific WebGestureEvent fields
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Sep 2012 04:46:39 +0000 (04:46 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Sep 2012 04:46:39 +0000 (04:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=95573

Patch by Rick Byers <rbyers@chromium.org> on 2012-09-05
Reviewed by James Robinson.

Chromium has been updated to store gesture-type specific details in the
new WebGestureEvent fields (crrev.com/152508, crrev.com/154815 and
crrev.com/154959), so we can now rely on them.

* src/WebCompositorInputHandlerImpl.cpp:
Update the compositor scroll, pinch and fling handling to use these new fields.
(WebKit::WebCompositorInputHandlerImpl::handleInputEventInternal):
(WebKit::WebCompositorInputHandlerImpl::handleGestureFling):
* src/WebInputEventConversion.cpp:
Update PlatformGestureEvent/WebGestureEvent conversion to use the new
fields, storing into the existing overloaded PlatformGestureEvent
fields (which will be cleaned up in my next CL).
(WebKit::PlatformGestureEventBuilder::PlatformGestureEventBuilder):
(WebKit::WebGestureEventBuilder::WebGestureEventBuilder):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::handleGestureEvent):
Update fling scrolling implementation for correct location of velocity.
* tests/WebCompositorInputHandlerImplTest.cpp:
(WebKit::TEST_F):
Update tests to use the new fields.

Tools: Update chromium DumpRenderTree for new WebGestureEvent fields
https://bugs.webkit.org/show_bug.cgi?id=95573

Patch by Rick Byers <rbyers@chromium.org> on 2012-09-05
Reviewed by James Robinson.

Update EventSender to write gesture details into the appropriate
type-specific WebGestureEvent fields.
* DumpRenderTree/chromium/TestRunner/EventSender.cpp:
(EventSender::gestureEvent):
(EventSender::gestureFlingStart):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@127689 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp
Source/WebKit/chromium/src/WebInputEventConversion.cpp
Source/WebKit/chromium/src/WebViewImpl.cpp
Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp
Tools/ChangeLog
Tools/DumpRenderTree/chromium/TestRunner/EventSender.cpp

index a35e34e..b392eeb 100644 (file)
@@ -1,3 +1,32 @@
+2012-09-05  Rick Byers  <rbyers@chromium.org>
+
+        Use new type-specific WebGestureEvent fields
+        https://bugs.webkit.org/show_bug.cgi?id=95573
+
+        Reviewed by James Robinson.
+
+        Chromium has been updated to store gesture-type specific details in the
+        new WebGestureEvent fields (crrev.com/152508, crrev.com/154815 and
+        crrev.com/154959), so we can now rely on them.
+
+        * src/WebCompositorInputHandlerImpl.cpp:
+        Update the compositor scroll, pinch and fling handling to use these new fields.
+        (WebKit::WebCompositorInputHandlerImpl::handleInputEventInternal):
+        (WebKit::WebCompositorInputHandlerImpl::handleGestureFling):
+        * src/WebInputEventConversion.cpp:
+        Update PlatformGestureEvent/WebGestureEvent conversion to use the new
+        fields, storing into the existing overloaded PlatformGestureEvent
+        fields (which will be cleaned up in my next CL).
+        (WebKit::PlatformGestureEventBuilder::PlatformGestureEventBuilder):
+        (WebKit::WebGestureEventBuilder::WebGestureEventBuilder):
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::handleGestureEvent):
+        Update fling scrolling implementation for correct location of velocity.
+        * tests/WebCompositorInputHandlerImplTest.cpp:
+        (WebKit::TEST_F):
+        Update tests to use the new fields.
+
+
 2012-09-05  James Robinson  <jamesr@chromium.org>
 
         [chromium] Test WebSolidColorLayer in WebLayerTest.Client unit test
index 8084d71..1e50385 100644 (file)
@@ -216,7 +216,8 @@ WebCompositorInputHandlerImpl::EventDisposition WebCompositorInputHandlerImpl::h
             return DidNotHandle;
 
         const WebGestureEvent& gestureEvent = *static_cast<const WebGestureEvent*>(&event);
-        m_inputHandlerClient->scrollBy(IntPoint(gestureEvent.x, gestureEvent.y), IntSize(-gestureEvent.deltaX, -gestureEvent.deltaY));
+        m_inputHandlerClient->scrollBy(IntPoint(gestureEvent.x, gestureEvent.y),
+            IntSize(-gestureEvent.data.scrollUpdate.deltaX, -gestureEvent.data.scrollUpdate.deltaY));
         return DidHandle;
     } else if (event.type == WebInputEvent::GestureScrollEnd) {
         ASSERT(m_expectScrollUpdateEnd);
@@ -246,7 +247,7 @@ WebCompositorInputHandlerImpl::EventDisposition WebCompositorInputHandlerImpl::h
     } else if (event.type == WebInputEvent::GesturePinchUpdate) {
         ASSERT(m_expectPinchUpdateEnd);
         const WebGestureEvent& gestureEvent = *static_cast<const WebGestureEvent*>(&event);
-        m_inputHandlerClient->pinchGestureUpdate(gestureEvent.deltaX, IntPoint(gestureEvent.x, gestureEvent.y));
+        m_inputHandlerClient->pinchGestureUpdate(gestureEvent.data.pinchUpdate.scale, IntPoint(gestureEvent.x, gestureEvent.y));
         return DidHandle;
     } else if (event.type == WebInputEvent::GestureFlingStart) {
         const WebGestureEvent& gestureEvent = *static_cast<const WebGestureEvent*>(&event);
@@ -267,9 +268,9 @@ WebCompositorInputHandlerImpl::EventDisposition WebCompositorInputHandlerImpl::h
     switch (scrollStatus) {
     case CCInputHandlerClient::ScrollStarted: {
         TRACE_EVENT_INSTANT0("cc", "WebCompositorInputHandlerImpl::handleGestureFling::started");
-        OwnPtr<PlatformGestureCurve> flingCurve = TouchpadFlingPlatformGestureCurve::create(FloatPoint(gestureEvent.deltaX, gestureEvent.deltaY));
+        OwnPtr<PlatformGestureCurve> flingCurve = TouchpadFlingPlatformGestureCurve::create(FloatPoint(gestureEvent.data.flingStart.velocityX, gestureEvent.data.flingStart.velocityY));
         m_wheelFlingAnimation = CCActiveGestureAnimation::create(PlatformGestureToCCGestureAdapter::create(flingCurve.release()), this);
-        m_wheelFlingParameters.delta = WebFloatPoint(gestureEvent.deltaX, gestureEvent.deltaY);
+        m_wheelFlingParameters.delta = WebFloatPoint(gestureEvent.data.flingStart.velocityX, gestureEvent.data.flingStart.velocityY);
         m_wheelFlingParameters.point = WebPoint(gestureEvent.x, gestureEvent.y);
         m_wheelFlingParameters.globalPoint = WebPoint(gestureEvent.globalX, gestureEvent.globalY);
         m_wheelFlingParameters.modifiers = gestureEvent.modifiers;
index 0391c28..bb6b573 100644 (file)
@@ -149,10 +149,14 @@ PlatformGestureEventBuilder::PlatformGestureEventBuilder(Widget* widget, const W
         break;
     case WebInputEvent::GestureScrollUpdate:
         m_type = PlatformEvent::GestureScrollUpdate;
+        m_deltaX = e.data.scrollUpdate.deltaX;
+        m_deltaY = e.data.scrollUpdate.deltaY;
         break;
     case WebInputEvent::GestureTap:
         m_type = PlatformEvent::GestureTap;
-        m_area = IntSize(e.boundingBox.width, e.boundingBox.height);
+        m_area = IntSize(e.data.tap.width, e.data.tap.height);
+        // FIXME: PlatformGestureEvent deltaX is overloaded - wkb.ug/93123
+        m_deltaX = static_cast<int>(e.data.tap.tapCount);
         break;
     case WebInputEvent::GestureTapDown:
         m_type = PlatformEvent::GestureTapDown;
@@ -165,7 +169,7 @@ PlatformGestureEventBuilder::PlatformGestureEventBuilder(Widget* widget, const W
         break;
     case WebInputEvent::GestureLongPress:
         m_type = PlatformEvent::GestureLongPress;
-        m_area = IntSize(e.boundingBox.width, e.boundingBox.height);
+        m_area = IntSize(e.data.longPress.width, e.data.longPress.height);
         break;
     case WebInputEvent::GesturePinchBegin:
         m_type = PlatformEvent::GesturePinchBegin;
@@ -175,14 +179,14 @@ PlatformGestureEventBuilder::PlatformGestureEventBuilder(Widget* widget, const W
         break;
     case WebInputEvent::GesturePinchUpdate:
         m_type = PlatformEvent::GesturePinchUpdate;
+        // FIXME: PlatformGestureEvent deltaX is overloaded - wkb.ug/93123
+        m_deltaX = e.data.pinchUpdate.scale;
         break;
     default:
         ASSERT_NOT_REACHED();
     }
     m_position = widget->convertFromContainingWindow(IntPoint(e.x, e.y));
     m_globalPosition = IntPoint(e.globalX, e.globalY);
-    m_deltaX = e.deltaX;
-    m_deltaY = e.deltaY;
     m_timestamp = e.timeStampSeconds;
 
     m_modifiers = 0;
@@ -526,8 +530,11 @@ WebGestureEventBuilder::WebGestureEventBuilder(const Widget* widget, const Gestu
         type = GestureScrollBegin;
     else if (event.type() == eventNames().gesturescrollendEvent)
         type = GestureScrollEnd;
-    else if (event.type() == eventNames().gesturescrollupdateEvent)
+    else if (event.type() == eventNames().gesturescrollupdateEvent) {
         type = GestureScrollUpdate;
+        data.scrollUpdate.deltaX = event.deltaX();
+        data.scrollUpdate.deltaY = event.deltaY();
+    }
 
     timeStampSeconds = event.timeStamp() / millisPerSecond;
     modifiers = getWebInputModifiers(event);
@@ -536,9 +543,6 @@ WebGestureEventBuilder::WebGestureEventBuilder(const Widget* widget, const Gestu
     globalY = event.screenY();
     x = event.absoluteLocation().x() - widget->location().x();
     y = event.absoluteLocation().y() - widget->location().y();
-
-    deltaX = event.deltaX();
-    deltaY = event.deltaY();
 }
 #endif // ENABLE(GESTURE_EVENTS)
 
index 3c9d89c..4fb451a 100644 (file)
@@ -693,7 +693,7 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
         m_lastWheelGlobalPosition = WebPoint(event.globalX, event.globalY);
         m_flingModifier = event.modifiers;
         // FIXME: Make the curve parametrizable from the browser.
-        m_gestureAnimation = ActivePlatformGestureAnimation::create(TouchpadFlingPlatformGestureCurve::create(FloatPoint(event.deltaX, event.deltaY)), this);
+        m_gestureAnimation = ActivePlatformGestureAnimation::create(TouchpadFlingPlatformGestureCurve::create(FloatPoint(event.data.flingStart.velocityX, event.data.flingStart.velocityY)), this);
         scheduleAnimation();
         return true;
     }
index 8313b0f..82e3b54 100644 (file)
@@ -200,14 +200,14 @@ TEST_F(WebCompositorInputHandlerImplTest, gestureScrollStarted)
     VERIFY_AND_RESET_MOCKS();
 
     gesture.type = WebInputEvent::GestureScrollUpdate;
-    gesture.deltaY = -40; // -Y means scroll down - i.e. in the +Y direction.
+    gesture.data.scrollUpdate.deltaY = -40; // -Y means scroll down - i.e. in the +Y direction.
     EXPECT_CALL(m_mockCCInputHandlerClient, scrollBy(testing::_, testing::Property(&WebCore::IntSize::height, testing::Gt(0))));
     m_inputHandler->handleInputEvent(gesture);
 
     VERIFY_AND_RESET_MOCKS();
 
     gesture.type = WebInputEvent::GestureScrollEnd;
-    gesture.deltaY = 0;
+    gesture.data.scrollUpdate.deltaY = 0;
     EXPECT_CALL(m_mockCCInputHandlerClient, scrollEnd());
     m_inputHandler->handleInputEvent(gesture);
 }
@@ -227,13 +227,13 @@ TEST_F(WebCompositorInputHandlerImplTest, gestureScrollOnMainThread)
     VERIFY_AND_RESET_MOCKS();
 
     gesture.type = WebInputEvent::GestureScrollUpdate;
-    gesture.deltaY = 40;
+    gesture.data.scrollUpdate.deltaY = 40;
     m_inputHandler->handleInputEvent(gesture);
 
     VERIFY_AND_RESET_MOCKS();
 
     gesture.type = WebInputEvent::GestureScrollEnd;
-    gesture.deltaY = 0;
+    gesture.data.scrollUpdate.deltaY = 0;
     m_inputHandler->handleInputEvent(gesture);
 }
 
@@ -266,7 +266,7 @@ TEST_F(WebCompositorInputHandlerImplTest, gesturePinch)
     VERIFY_AND_RESET_MOCKS();
 
     gesture.type = WebInputEvent::GesturePinchUpdate;
-    gesture.deltaX = 1.5;
+    gesture.data.pinchUpdate.scale = 1.5;
     gesture.x = 7;
     gesture.y = 13;
     EXPECT_CALL(m_mockCCInputHandlerClient, pinchGestureUpdate(1.5, WebCore::IntPoint(7, 13)));
@@ -275,7 +275,7 @@ TEST_F(WebCompositorInputHandlerImplTest, gesturePinch)
     VERIFY_AND_RESET_MOCKS();
 
     gesture.type = WebInputEvent::GesturePinchUpdate;
-    gesture.deltaX = 0.5;
+    gesture.data.pinchUpdate.scale = 0.5;
     gesture.x = 9;
     gesture.y = 6;
     EXPECT_CALL(m_mockCCInputHandlerClient, pinchGestureUpdate(.5, WebCore::IntPoint(9, 6)));
@@ -298,7 +298,7 @@ TEST_F(WebCompositorInputHandlerImplTest, gestureFlingStarted)
         .WillOnce(testing::Return(WebCore::CCInputHandlerClient::ScrollStarted));
 
     gesture.type = WebInputEvent::GestureFlingStart;
-    gesture.deltaX = 10;
+    gesture.data.flingStart.velocityX = 10;
     EXPECT_CALL(m_mockCCInputHandlerClient, scheduleAnimation());
     m_inputHandler->handleInputEvent(gesture);
 
@@ -359,8 +359,8 @@ TEST_F(WebCompositorInputHandlerImplTest, gestureFlingAnimates)
     WebPoint flingPoint = WebPoint(7, 13);
     WebPoint flingGlobalPoint = WebPoint(17, 23);
     int modifiers = 7;
-    gesture.deltaX = flingDelta.x;
-    gesture.deltaY = flingDelta.y;
+    gesture.data.flingStart.velocityX = flingDelta.x;
+    gesture.data.flingStart.velocityY = flingDelta.y;
     gesture.x = flingPoint.x;
     gesture.y = flingPoint.y;
     gesture.globalX = flingGlobalPoint.x;
@@ -443,8 +443,8 @@ TEST_F(WebCompositorInputHandlerImplTest, gestureFlingTransferResets)
     WebPoint flingPoint = WebPoint(7, 13);
     WebPoint flingGlobalPoint = WebPoint(17, 23);
     int modifiers = 1;
-    gesture.deltaX = flingDelta.x;
-    gesture.deltaY = flingDelta.y;
+    gesture.data.flingStart.velocityX = flingDelta.x;
+    gesture.data.flingStart.velocityY = flingDelta.y;
     gesture.x = flingPoint.x;
     gesture.y = flingPoint.y;
     gesture.globalX = flingGlobalPoint.x;
@@ -522,8 +522,8 @@ TEST_F(WebCompositorInputHandlerImplTest, gestureFlingTransferResets)
     flingPoint = WebPoint(95, 87);
     flingGlobalPoint = WebPoint(32, 71);
     modifiers = 2;
-    gesture.deltaX = flingDelta.x;
-    gesture.deltaY = flingDelta.y;
+    gesture.data.flingStart.velocityX = flingDelta.x;
+    gesture.data.flingStart.velocityY = flingDelta.y;
     gesture.x = flingPoint.x;
     gesture.y = flingPoint.y;
     gesture.globalX = flingGlobalPoint.x;
index b256f4b..691146f 100644 (file)
@@ -1,3 +1,16 @@
+2012-09-05  Rick Byers  <rbyers@chromium.org>
+
+        Update chromium DumpRenderTree for new WebGestureEvent fields
+        https://bugs.webkit.org/show_bug.cgi?id=95573
+
+        Reviewed by James Robinson.
+
+        Update EventSender to write gesture details into the appropriate
+        type-specific WebGestureEvent fields.
+        * DumpRenderTree/chromium/TestRunner/EventSender.cpp:
+        (EventSender::gestureEvent):
+        (EventSender::gestureFlingStart):
+
 2012-09-05  Dirk Pranke  <dpranke@chromium.org>
 
         NRWT lies about the number of tests that it's skipping when used with --repeat-each
index cafaca9..d5eaac4 100644 (file)
@@ -1153,12 +1153,12 @@ void EventSender::gestureEvent(WebInputEvent::Type type, const CppArgumentList&
 
     switch (type) {
     case WebInputEvent::GestureScrollUpdate:
-        event.deltaX = static_cast<float>(arguments[0].toDouble());
-        event.deltaY = static_cast<float>(arguments[1].toDouble());
+        event.data.scrollUpdate.deltaX = static_cast<float>(arguments[0].toDouble());
+        event.data.scrollUpdate.deltaY = static_cast<float>(arguments[1].toDouble());
         event.x = m_currentGestureLocation.x;
         event.y = m_currentGestureLocation.y;
-        m_currentGestureLocation.x = m_currentGestureLocation.x + event.deltaX;
-        m_currentGestureLocation.y = m_currentGestureLocation.y + event.deltaY;
+        m_currentGestureLocation.x = m_currentGestureLocation.x + event.data.scrollUpdate.deltaX;
+        m_currentGestureLocation.y = m_currentGestureLocation.y + event.data.scrollUpdate.deltaY;
         break;
 
     case WebInputEvent::GestureScrollBegin:
@@ -1167,16 +1167,14 @@ void EventSender::gestureEvent(WebInputEvent::Type type, const CppArgumentList&
         event.y = m_currentGestureLocation.y;
         break;
     case WebInputEvent::GestureScrollEnd:
-        event.deltaX = static_cast<float>(arguments[0].toDouble());
-        event.deltaY = static_cast<float>(arguments[1].toDouble());
         event.x = m_currentGestureLocation.x;
         event.y = m_currentGestureLocation.y;
         break;
     case WebInputEvent::GestureTap:
-        if (arguments.size() >= 3) {
-            // Tap count.
-            event.deltaX = static_cast<float>(arguments[2].toDouble());
-        }
+        if (arguments.size() >= 3)
+            event.data.tap.tapCount = static_cast<float>(arguments[2].toDouble());
+        else
+          event.data.tap.tapCount = 1;
         event.x = point.x;
         event.y = point.y;
         break;
@@ -1232,8 +1230,8 @@ void EventSender::gestureFlingStart(const CppArgumentList& arguments, CppVariant
     event.globalX = event.x;
     event.globalY = event.y;
 
-    event.deltaX = static_cast<float>(arguments[2].toDouble());
-    event.deltaY = static_cast<float>(arguments[3].toDouble());
+    event.data.flingStart.velocityX = static_cast<float>(arguments[2].toDouble());
+    event.data.flingStart.velocityY = static_cast<float>(arguments[3].toDouble());
     event.timeStampSeconds = getCurrentEventTimeSec();
     webview()->handleInputEvent(event);
 }