Title: [132406] trunk
Revision
132406
Author
[email protected]
Date
2012-10-24 14:54:16 -0700 (Wed, 24 Oct 2012)

Log Message

Handle two-finger tap gestures in the same way as long-press gestures
https://bugs.webkit.org/show_bug.cgi?id=99947

Reviewed by Adam Barth.

Source/WebCore:

Currently a long-press gesture is used to dispatch a context menu (for platforms
defining CONTEXT_MENUS) or to select text (for Android). Additionally, for platforms
defining TOUCH_ADJUSTMENT, gesture target fuzzing is performed on the location and
touch area of the long-press gesture.

This CL will cause two-finger tap gestures to be handled in the same way as long-press
gestures. The location and touch area of a two-finger tap gesture will correspond to
the location and touch area of the first finger down; the location/area of the second
finger will be ignored.

Test: touchadjustment/touch-links-two-finger-tap.html

* page/EventHandler.cpp:
(WebCore::EventHandler::handleGestureLongPress):
(WebCore):
(WebCore::EventHandler::handleGestureForTextSelectionOrContextMenu):
(WebCore::EventHandler::handleGestureTwoFingerTap):
(WebCore::EventHandler::adjustGesturePosition):
* page/EventHandler.h:
(EventHandler):

Source/WebKit/chromium:

Set the area of a two-finger tap gesture to be the area of the enclosing
rectangle for the first finger down.

* src/WebInputEventConversion.cpp:
(WebKit::PlatformGestureEventBuilder::PlatformGestureEventBuilder):

LayoutTests:

New layout test for dispatching context menus on a two-finger tap
gesture when touch adjustment is enabled.

* touchadjustment/touch-links-two-finger-tap-expected.txt: Added.
* touchadjustment/touch-links-two-finger-tap.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (132405 => 132406)


--- trunk/LayoutTests/ChangeLog	2012-10-24 21:51:56 UTC (rev 132405)
+++ trunk/LayoutTests/ChangeLog	2012-10-24 21:54:16 UTC (rev 132406)
@@ -1,3 +1,16 @@
+2012-10-24  Terry Anderson  <[email protected]>
+
+        Handle two-finger tap gestures in the same way as long-press gestures
+        https://bugs.webkit.org/show_bug.cgi?id=99947
+
+        Reviewed by Adam Barth.
+
+        New layout test for dispatching context menus on a two-finger tap
+        gesture when touch adjustment is enabled.
+
+        * touchadjustment/touch-links-two-finger-tap-expected.txt: Added.
+        * touchadjustment/touch-links-two-finger-tap.html: Added.
+
 2012-10-24  Chris Fleizach  <[email protected]>
 
         AX:When aria-label is used, the text under an element is still appearing as the AXTitle

Added: trunk/LayoutTests/touchadjustment/touch-links-two-finger-tap-expected.txt (0 => 132406)


--- trunk/LayoutTests/touchadjustment/touch-links-two-finger-tap-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/touchadjustment/touch-links-two-finger-tap-expected.txt	2012-10-24 21:54:16 UTC (rev 132406)
@@ -0,0 +1,17 @@
+Tests if a two finger tap gesture on links will trigger a context menu when touch adjustment is used.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Testing direct hits.
+PASS
+PASS
+PASS
+Testing indirect hits.
+PASS
+PASS
+PASS
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/touchadjustment/touch-links-two-finger-tap.html (0 => 132406)


--- trunk/LayoutTests/touchadjustment/touch-links-two-finger-tap.html	                        (rev 0)
+++ trunk/LayoutTests/touchadjustment/touch-links-two-finger-tap.html	2012-10-24 21:54:16 UTC (rev 132406)
@@ -0,0 +1,87 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>Touch Adjustment : Testing that a context menu will appear on a two-finger tap - bug 99947</title>
+    <script src=""
+    <script src=""
+    <style>
+        #sandbox {
+            position: absolute;
+            left: 0px;
+            top: 0px;
+        }
+    </style>
+</head>
+
+<body>
+
+<div id="sandbox">
+<p><a href="" id="link1">I</a> propose to consider <a href="" id="link2">the question</a>, "Can machines think?"<br>This should begin with definitions of the meaning of the terms "machine" and <a href="" id="link3">"think."</a></p>
+</div>
+
+<p id='description'></p>
+<div id='console'></div>
+
+<script>
+    var element;
+    var adjustedNode;
+    // Set up shortcut access to elements
+    var e = {};
+    ['sandbox', 'link1', 'link2', 'link3'].forEach(function(a) {
+        e[a] = document.getElementById(a);
+    });
+
+    document._oncontextmenu_ = function() { debug("PASS"); }
+
+    function testTwoFingerTap(touchpoint)
+    {
+        if (eventSender.gestureTwoFingerTap)
+            eventSender.gestureTwoFingerTap(touchpoint.left, touchpoint.top);
+        else
+            debug("gestureTwoFingerTap not implemented by this platform.");
+    }
+
+    function testDirectTouch(element)
+    {
+        // Touch directly in the center of the element.
+        var touchpoint = offsetTouchPoint(findAbsoluteBounds(element), 'center', 0, 20, 30);
+        testTwoFingerTap(touchpoint);
+    }
+
+    function testIndirectTouch(element)
+    {
+        // Touch just right of the element.
+        var touchpoint = offsetTouchPoint(findAbsoluteBounds(element), 'right', 10, 30, 20);
+        testTwoFingerTap(touchpoint);
+    }
+
+    function testDirectTouches()
+    {
+        debug('Testing direct hits.');
+        testDirectTouch(e.link1);
+        testDirectTouch(e.link2);
+        testDirectTouch(e.link3);
+    }
+
+    function testIndirectTouches()
+    {
+        debug('Testing indirect hits.');
+        testIndirectTouch(e.link1);
+        testIndirectTouch(e.link2);
+        testIndirectTouch(e.link3);
+    }
+
+    function runTests()
+    {
+        if (window.testRunner && window.internals && internals.touchNodeAdjustedToBestClickableNode) {
+            description('Tests if a two finger tap gesture on links will trigger a context menu when touch adjustment is used.');
+            testDirectTouches();
+            testIndirectTouches();
+            e.sandbox.style.display = 'none';
+        }
+    }
+    runTests();
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (132405 => 132406)


--- trunk/Source/WebCore/ChangeLog	2012-10-24 21:51:56 UTC (rev 132405)
+++ trunk/Source/WebCore/ChangeLog	2012-10-24 21:54:16 UTC (rev 132406)
@@ -1,3 +1,31 @@
+2012-10-24  Terry Anderson  <[email protected]>
+
+        Handle two-finger tap gestures in the same way as long-press gestures
+        https://bugs.webkit.org/show_bug.cgi?id=99947
+
+        Reviewed by Adam Barth.
+
+        Currently a long-press gesture is used to dispatch a context menu (for platforms 
+        defining CONTEXT_MENUS) or to select text (for Android). Additionally, for platforms 
+        defining TOUCH_ADJUSTMENT, gesture target fuzzing is performed on the location and 
+        touch area of the long-press gesture.
+
+        This CL will cause two-finger tap gestures to be handled in the same way as long-press 
+        gestures. The location and touch area of a two-finger tap gesture will correspond to 
+        the location and touch area of the first finger down; the location/area of the second 
+        finger will be ignored.
+
+        Test: touchadjustment/touch-links-two-finger-tap.html
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::handleGestureLongPress):
+        (WebCore):
+        (WebCore::EventHandler::handleGestureForTextSelectionOrContextMenu):
+        (WebCore::EventHandler::handleGestureTwoFingerTap):
+        (WebCore::EventHandler::adjustGesturePosition):
+        * page/EventHandler.h:
+        (EventHandler):
+
 2012-10-24  Chris Fleizach  <[email protected]>
 
         AX:When aria-label is used, the text under an element is still appearing as the AXTitle

Modified: trunk/Source/WebCore/page/EventHandler.cpp (132405 => 132406)


--- trunk/Source/WebCore/page/EventHandler.cpp	2012-10-24 21:51:56 UTC (rev 132405)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2012-10-24 21:54:16 UTC (rev 132406)
@@ -2574,6 +2574,11 @@
 
 bool EventHandler::handleGestureLongPress(const PlatformGestureEvent& gestureEvent)
 {
+    return handleGestureForTextSelectionOrContextMenu(gestureEvent);
+}
+
+bool EventHandler::handleGestureForTextSelectionOrContextMenu(const PlatformGestureEvent& gestureEvent)
+{
 #if OS(ANDROID)
     IntPoint hitTestPoint = m_frame->view()->windowToContents(gestureEvent.position());
     HitTestResult result = hitTestResultAtPoint(hitTestPoint, true);
@@ -2593,11 +2598,7 @@
 
 bool EventHandler::handleGestureTwoFingerTap(const PlatformGestureEvent& gestureEvent)
 {
-#if ENABLE(CONTEXT_MENUS)
-    return sendContextMenuEventForGesture(gestureEvent);
-#else
-    return false;
-#endif
+    return handleGestureForTextSelectionOrContextMenu(gestureEvent);
 }
 
 bool EventHandler::handleGestureScrollUpdate(const PlatformGestureEvent& gestureEvent)
@@ -2670,6 +2671,7 @@
         bestClickableNodeForTouchPoint(gestureEvent.position(), IntSize(gestureEvent.area().width() / 2, gestureEvent.area().height() / 2), adjustedPoint, targetNode);
         break;
     case PlatformEvent::GestureLongPress:
+    case PlatformEvent::GestureTwoFingerTap:
         bestContextMenuNodeForTouchPoint(gestureEvent.position(), IntSize(gestureEvent.area().width() / 2, gestureEvent.area().height() / 2), adjustedPoint, targetNode);
         break;
     default:

Modified: trunk/Source/WebCore/page/EventHandler.h (132405 => 132406)


--- trunk/Source/WebCore/page/EventHandler.h	2012-10-24 21:51:56 UTC (rev 132405)
+++ trunk/Source/WebCore/page/EventHandler.h	2012-10-24 21:54:16 UTC (rev 132406)
@@ -365,6 +365,7 @@
 #if ENABLE(GESTURE_EVENTS)
     bool handleGestureScrollCore(const PlatformGestureEvent&, PlatformWheelEventGranularity, bool latchedWheel);
     bool handleGestureTapDown();
+    bool handleGestureForTextSelectionOrContextMenu(const PlatformGestureEvent&);
 #endif
 
     Frame* m_frame;

Modified: trunk/Source/WebKit/chromium/ChangeLog (132405 => 132406)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-10-24 21:51:56 UTC (rev 132405)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-10-24 21:54:16 UTC (rev 132406)
@@ -1,3 +1,16 @@
+2012-10-24  Terry Anderson  <[email protected]>
+
+        Handle two-finger tap gestures in the same way as long-press gestures
+        https://bugs.webkit.org/show_bug.cgi?id=99947
+
+        Reviewed by Adam Barth.
+
+        Set the area of a two-finger tap gesture to be the area of the enclosing
+        rectangle for the first finger down.
+
+        * src/WebInputEventConversion.cpp:
+        (WebKit::PlatformGestureEventBuilder::PlatformGestureEventBuilder):
+
 2012-10-24  Eric Uhrhane  <[email protected]>
 
         https://bugs.webkit.org/show_bug.cgi?id=99202

Modified: trunk/Source/WebKit/chromium/src/WebInputEventConversion.cpp (132405 => 132406)


--- trunk/Source/WebKit/chromium/src/WebInputEventConversion.cpp	2012-10-24 21:51:56 UTC (rev 132405)
+++ trunk/Source/WebKit/chromium/src/WebInputEventConversion.cpp	2012-10-24 21:54:16 UTC (rev 132406)
@@ -171,6 +171,7 @@
         break;
     case WebInputEvent::GestureTwoFingerTap:
         m_type = PlatformEvent::GestureTwoFingerTap;
+        m_area = IntSize(e.data.twoFingerTap.firstFingerWidth, e.data.twoFingerTap.firstFingerHeight);
         break;
     case WebInputEvent::GestureLongPress:
         m_type = PlatformEvent::GestureLongPress;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to