Source/WebKit/chromium: Wire gesture tap events, add support for gesture events in...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Aug 2011 21:28:37 +0000 (21:28 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Aug 2011 21:28:37 +0000 (21:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=66105

Patch by Sadrul Habib Chowdhury <sadrul@chromium.org> on 2011-08-12
Reviewed by Darin Fisher.

* public/WebInputEvent.h:
* src/WebInputEventConversion.cpp:
(WebKit::PlatformGestureEventBuilder::PlatformGestureEventBuilder):
* src/WebPopupMenuImpl.cpp:
(WebKit::WebPopupMenuImpl::handleInputEvent):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::handleInputEvent):

Tools: DRT: Add support for gesture events.
https://bugs.webkit.org/show_bug.cgi?id=66105

Patch by Sadrul Habib Chowdhury <sadrul@chromium.org> on 2011-08-12
Reviewed by Darin Fisher.

* DumpRenderTree/chromium/EventSender.cpp:
(EventSender::EventSender):
(EventSender::gestureScrollBegin):
(EventSender::gestureScrollEnd):
(EventSender::gestureTap):
(EventSender::gestureEvent):
* DumpRenderTree/chromium/EventSender.h:

LayoutTests: DRT: Add support for gesture events.
https://bugs.webkit.org/show_bug.cgi?id=66105

Patch by Sadrul Habib Chowdhury <sadrul@chromium.org> on 2011-08-12
Reviewed by Darin Fisher.

* fast/events/touch/gesture/gesture-click-expected.txt: Added.
* fast/events/touch/gesture/gesture-click.html: Added.
* platform/chromium/fast/events/touch/gesture/gesture-click-expected.txt: Added.

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

12 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/events/touch/gesture/gesture-click-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/touch/gesture/gesture-click.html [new file with mode: 0644]
LayoutTests/platform/chromium/fast/events/touch/gesture/gesture-click-expected.txt [new file with mode: 0644]
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/WebInputEvent.h
Source/WebKit/chromium/src/WebInputEventConversion.cpp
Source/WebKit/chromium/src/WebPopupMenuImpl.cpp
Source/WebKit/chromium/src/WebViewImpl.cpp
Tools/ChangeLog
Tools/DumpRenderTree/chromium/EventSender.cpp
Tools/DumpRenderTree/chromium/EventSender.h

index abf56534056bf6c696276057ee9b9d3b0f99b66c..8d6d7d60ce8aca548e34894a9b09beabf61dc776 100644 (file)
@@ -1,3 +1,14 @@
+2011-08-12  Sadrul Habib Chowdhury  <sadrul@chromium.org>
+
+        DRT: Add support for gesture events.
+        https://bugs.webkit.org/show_bug.cgi?id=66105
+
+        Reviewed by Darin Fisher.
+
+        * fast/events/touch/gesture/gesture-click-expected.txt: Added.
+        * fast/events/touch/gesture/gesture-click.html: Added.
+        * platform/chromium/fast/events/touch/gesture/gesture-click-expected.txt: Added.
+
 2011-08-12  David Hyatt  <hyatt@apple.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=66133
diff --git a/LayoutTests/fast/events/touch/gesture/gesture-click-expected.txt b/LayoutTests/fast/events/touch/gesture/gesture-click-expected.txt
new file mode 100644 (file)
index 0000000..775fa1a
--- /dev/null
@@ -0,0 +1,10 @@
+This tests basic gesture callbacks.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Gesture manager not implemented on this platform.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/events/touch/gesture/gesture-click.html b/LayoutTests/fast/events/touch/gesture/gesture-click.html
new file mode 100644 (file)
index 0000000..25dcc5a
--- /dev/null
@@ -0,0 +1,75 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../../js/resources/js-test-style.css">
+<script src="../../../js/resources/js-test-pre.js"></script>
+<script src="../../../js/resources/js-test-post-function.js"></script>
+</head>
+<body onload="runTest();">
+<div id="gesture">
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+var expectedMouseEvents = 4;
+var mouseEventsReceived = 0;
+var eventTypes = [ 'mousemove', 'mousedown', 'mouseup', 'click' ];
+
+function gestureEventCallback(event)
+{
+    if (window.eventSender) {
+        shouldBeEqualToString('event.type', eventTypes[mouseEventsReceived]);
+        shouldBe('event.clientX', '10');
+        shouldBe('event.clientY', '12');
+        mouseEventsReceived++;
+    } else {
+        debug(event.type);
+        debug(event.clientX);
+        debug(event.clientY);
+    }
+}
+
+// Because we may not have a gesture recognizer, we send a key press
+// event to end the test without temporal flakiness.
+function quitKeyToEndTest(event) {
+    endTest();
+}
+
+function endTest()
+{
+    if (mouseEventsReceived < expectedMouseEvents) {
+        debug('Gesture manager not implemented on this platform.');
+    }
+    // Bail.
+    successfullyParsed = true;
+    isSuccessfullyParsed();
+    layoutTestController.notifyDone();
+}
+
+function runTest() {
+    var div = document.getElementById('gesture');
+    div.addEventListener("mousedown", gestureEventCallback, false);
+    div.addEventListener("click", gestureEventCallback, false);
+    div.addEventListener("mouseup", gestureEventCallback, false);
+    div.addEventListener("mousemove", gestureEventCallback, false);
+    document.addEventListener("keydown", quitKeyToEndTest, false);
+
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+    }
+
+    if (window.eventSender) {
+        description("This tests basic gesture callbacks.");
+        // A 'tap' gesture event should generate a sequence of mouse events.
+        eventSender.gestureTap(10, 12);
+        eventSender.leapForward(10);
+        eventSender.keyDown(' ');
+    } else {
+        debug("This test requires DumpRenderTree.  Tap on the blue rect to log.")
+    }
+}
+</script>
+</body>
+</html>
diff --git a/LayoutTests/platform/chromium/fast/events/touch/gesture/gesture-click-expected.txt b/LayoutTests/platform/chromium/fast/events/touch/gesture/gesture-click-expected.txt
new file mode 100644 (file)
index 0000000..6221dd8
--- /dev/null
@@ -0,0 +1,21 @@
+This tests basic gesture callbacks.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS event.type is "mousemove"
+PASS event.clientX is 10
+PASS event.clientY is 12
+PASS event.type is "mousedown"
+PASS event.clientX is 10
+PASS event.clientY is 12
+PASS event.type is "mouseup"
+PASS event.clientX is 10
+PASS event.clientY is 12
+PASS event.type is "click"
+PASS event.clientX is 10
+PASS event.clientY is 12
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
index fd860b41ac813656e5403d44e48c2d3c973c00dd..2908cb293450c33764aef8ee3db8d6b4c6f02857 100644 (file)
@@ -1,3 +1,18 @@
+2011-08-12  Sadrul Habib Chowdhury  <sadrul@chromium.org>
+
+        Wire gesture tap events, add support for gesture events in the DRT and add a layout test for it.
+        https://bugs.webkit.org/show_bug.cgi?id=66105
+
+        Reviewed by Darin Fisher.
+
+        * public/WebInputEvent.h:
+        * src/WebInputEventConversion.cpp:
+        (WebKit::PlatformGestureEventBuilder::PlatformGestureEventBuilder):
+        * src/WebPopupMenuImpl.cpp:
+        (WebKit::WebPopupMenuImpl::handleInputEvent):
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::handleInputEvent):
+
 2011-08-12  Tommy Widenflycht  <tommyw@google.com>
 
         [Chromium] Implement the embedders for the HTML5 Track List objects
index 68f47a08dc1247d8bb815f1db4f659be58ff66db..c49af40706de062df5169a878f4dbbe162733517 100644 (file)
@@ -103,6 +103,7 @@ public:
         // WebGestureEvent
         GestureScrollBegin,
         GestureScrollEnd,
+        GestureTap,
 
         // WebTouchEvent
         TouchStart,
index 90c2c8c61768c1daedac919d1994db8f6cb07aa2..0ddea0244a898224d40af1f8f2d5cdc6ed00c76c 100644 (file)
@@ -120,6 +120,9 @@ PlatformGestureEventBuilder::PlatformGestureEventBuilder(Widget* widget, const W
     case WebInputEvent::GestureScrollEnd:
         m_type = PlatformGestureEvent::ScrollEndType;
         break;
+    case WebInputEvent::GestureTap:
+        m_type = PlatformGestureEvent::TapType;
+        break;
     default:
         ASSERT_NOT_REACHED();
     }
index e2668b1b84d9f42adcabf31904bc8b68d0503f2a..838238d257861a480a77d9d5b4722d8406088399 100644 (file)
@@ -273,6 +273,7 @@ bool WebPopupMenuImpl::handleInputEvent(const WebInputEvent& inputEvent)
 
     case WebInputEvent::GestureScrollBegin:
     case WebInputEvent::GestureScrollEnd:
+    case WebInputEvent::GestureTap:
         return GestureEvent(*static_cast<const WebGestureEvent*>(&inputEvent));
 
     case WebInputEvent::Undefined:
index 8f83808c691e96a92ce359f12783500ed02620cd..e15eb3974a493d93f06e9652b1def0c22f505e21 100644 (file)
@@ -1272,6 +1272,7 @@ bool WebViewImpl::handleInputEvent(const WebInputEvent& inputEvent)
 #if ENABLE(GESTURE_EVENTS)
     case WebInputEvent::GestureScrollBegin:
     case WebInputEvent::GestureScrollEnd:
+    case WebInputEvent::GestureTap:
         handled = gestureEvent(*static_cast<const WebGestureEvent*>(&inputEvent));
         break;
 #endif
index f4d7701a85dd7281ef0f787264a8faf7719e7666..da6364b06b626efe9af188e9cc68cbf08f07b239 100644 (file)
@@ -1,3 +1,18 @@
+2011-08-12  Sadrul Habib Chowdhury  <sadrul@chromium.org>
+
+        DRT: Add support for gesture events.
+        https://bugs.webkit.org/show_bug.cgi?id=66105
+
+        Reviewed by Darin Fisher.
+
+        * DumpRenderTree/chromium/EventSender.cpp:
+        (EventSender::EventSender):
+        (EventSender::gestureScrollBegin):
+        (EventSender::gestureScrollEnd):
+        (EventSender::gestureTap):
+        (EventSender::gestureEvent):
+        * DumpRenderTree/chromium/EventSender.h:
+
 2011-08-12  Andy Estes  <aestes@apple.com>
 
         allowRoundingHacksCallback uses the wrong argument for 'thisObject'.
index 87fb524256ec77dcdd4e16860500e1dc6d975d32..6daf6169561dc1518070f7d0b7f0950c879285fc 100644 (file)
@@ -278,6 +278,9 @@ EventSender::EventSender(TestShell* shell)
     bindMethod("touchMove", &EventSender::touchMove);
     bindMethod("touchStart", &EventSender::touchStart);
     bindMethod("updateTouchPoint", &EventSender::updateTouchPoint);
+    bindMethod("gestureScrollBegin", &EventSender::gestureScrollBegin);
+    bindMethod("gestureScrollEnd", &EventSender::gestureScrollEnd);
+    bindMethod("gestureTap", &EventSender::gestureTap);
     bindMethod("zoomPageIn", &EventSender::zoomPageIn);
     bindMethod("zoomPageOut", &EventSender::zoomPageOut);
     bindMethod("scalePageBy", &EventSender::scalePageBy);
@@ -1018,6 +1021,41 @@ void EventSender::touchCancel(const CppArgumentList&, CppVariant* result)
     sendCurrentTouchEvent(WebInputEvent::TouchCancel);
 }
 
+void EventSender::gestureScrollBegin(const CppArgumentList& arguments, CppVariant* result)
+{
+    result->setNull();
+    gestureEvent(WebInputEvent::GestureScrollBegin, arguments);
+}
+
+void EventSender::gestureScrollEnd(const CppArgumentList& arguments, CppVariant* result)
+{
+    result->setNull();
+    gestureEvent(WebInputEvent::GestureScrollEnd, arguments);
+}
+
+void EventSender::gestureTap(const CppArgumentList& arguments, CppVariant* result)
+{
+    result->setNull();
+    gestureEvent(WebInputEvent::GestureTap, arguments);
+}
+
+void EventSender::gestureEvent(WebInputEvent::Type type, const CppArgumentList& arguments)
+{
+    if (arguments.size() < 2 || !arguments[0].isNumber() || !arguments[1].isNumber())
+        return;
+
+    WebPoint point(arguments[0].toInt32(), arguments[1].toInt32());
+
+    WebGestureEvent event;
+    event.type = type;
+    event.x = point.x;
+    event.y = point.y;
+    event.globalX = point.x;
+    event.globalY = point.y;
+    event.timeStampSeconds = getCurrentEventTimeSec();
+    webview()->handleInputEvent(event);
+}
+
 //
 // Unimplemented stubs
 //
index be62294b1de60ca5b6d030492dfc879f465b5fd0..388888b0afe57096db8ecb4456997f8eed41ac6f 100644 (file)
@@ -94,6 +94,11 @@ public:
     void touchStart(const CppArgumentList&, CppVariant*);
     void updateTouchPoint(const CppArgumentList&, CppVariant*);
 
+    void gestureScrollBegin(const CppArgumentList&, CppVariant*);
+    void gestureScrollEnd(const CppArgumentList&, CppVariant*);
+    void gestureTap(const CppArgumentList&, CppVariant*);
+    void gestureEvent(WebKit::WebInputEvent::Type, const CppArgumentList&);
+
     // Unimplemented stubs
     void contextClick(const CppArgumentList&, CppVariant*);
     void enableDOMUIEventLogging(const CppArgumentList&, CppVariant*);