Title: [96657] trunk
Revision
96657
Author
commit-qu...@webkit.org
Date
2011-10-04 15:48:18 -0700 (Tue, 04 Oct 2011)

Log Message

Fix position check for double tap gesture detection. A double tap
should not be detected if the two taps are far from each other.
https://bugs.webkit.org/show_bug.cgi?id=69270

Patch by Varun Jain <varunj...@chromium.org> on 2011-10-04
Reviewed by Darin Fisher.

Test: Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp

* platform/chromium/GestureRecognizerChromium.cpp:
(WebCore::GestureRecognizerChromium::isSecondClickInsideManhattanSquare):
(WebCore::GestureRecognizerChromium::updateValues):
(WebCore::GestureRecognizerChromium::click):
* platform/chromium/GestureRecognizerChromium.h:

Modified Paths

Diff

Modified: trunk/ChangeLog (96656 => 96657)


--- trunk/ChangeLog	2011-10-04 22:45:29 UTC (rev 96656)
+++ trunk/ChangeLog	2011-10-04 22:48:18 UTC (rev 96657)
@@ -1,3 +1,19 @@
+2011-10-04  Varun Jain  <varunj...@chromium.org>
+
+        Fix position check for double tap gesture detection. A double tap
+        should not be detected if the two taps are far from each other.
+        https://bugs.webkit.org/show_bug.cgi?id=69270
+
+        Reviewed by Darin Fisher.
+
+        Test: Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp
+
+        * platform/chromium/GestureRecognizerChromium.cpp:
+        (WebCore::GestureRecognizerChromium::isSecondClickInsideManhattanSquare):
+        (WebCore::GestureRecognizerChromium::updateValues):
+        (WebCore::GestureRecognizerChromium::click):
+        * platform/chromium/GestureRecognizerChromium.h:
+
 2011-10-04  Nayan Kumar K  <naya...@motorola.com>
 
         [WebKit2][gtk] Generate gtk-doc for WebKit2-GTK.

Modified: trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp (96656 => 96657)


--- trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp	2011-10-04 22:45:29 UTC (rev 96656)
+++ trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp	2011-10-04 22:48:18 UTC (rev 96657)
@@ -45,6 +45,7 @@
     , m_state(GestureRecognizerChromium::NoGesture)
     , m_lastTouchTime(0.0)
     , m_lastClickTime(0.0)
+    , m_lastClickPosition()
     , m_lastTouchPosition()
     , m_lastTouchScreenPosition()
     , m_xVelocity(0.0)
@@ -111,6 +112,12 @@
     return manhattanDistance < maximumTouchMoveInPixelsForClick;
 }
 
+bool GestureRecognizerChromium::isSecondClickInsideManhattanSquare(const PlatformTouchPoint& point)
+{
+    int manhattanDistance = abs(point.pos().x() - m_lastClickPosition.x()) + abs(point.pos().y() - m_lastClickPosition.y());
+    return manhattanDistance < maximumTouchMoveInPixelsForClick;
+}
+
 bool GestureRecognizerChromium::isOverMinFlickSpeed()
 {
     return (m_xVelocity * m_xVelocity + m_yVelocity * m_yVelocity) > minFlickSpeedSquared;
@@ -175,10 +182,10 @@
         double interval(touchTime - m_lastTouchTime);
         m_xVelocity = (touchPoint.pos().x() - m_lastTouchPosition.x()) / interval;
         m_yVelocity = (touchPoint.pos().y() - m_lastTouchPosition.y()) / interval;
-        m_lastTouchPosition = touchPoint.pos();
-        m_lastTouchScreenPosition = touchPoint.screenPos();
     }
     m_lastTouchTime = touchTime;
+    m_lastTouchPosition = touchPoint.pos();
+    m_lastTouchScreenPosition = touchPoint.screenPos();
     if (state() == NoGesture) {
         m_firstTouchTime = touchTime;
         m_firstTouchPosition = touchPoint.pos();
@@ -230,9 +237,10 @@
     if (isInClickTimeWindow() && isInsideManhattanSquare(point)) {
         gestureAdded = true;
         appendClickGestureEvent(point, gestures);
-        if (isInSecondClickTimeWindow())
+        if (isInSecondClickTimeWindow() && isSecondClickInsideManhattanSquare(point))
             appendDoubleClickGestureEvent(point, gestures);
-       m_lastClickTime = m_lastTouchTime;
+        m_lastClickTime = m_lastTouchTime;
+        m_lastClickPosition = m_lastTouchPosition;
     }
     reset();
     return gestureAdded;

Modified: trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.h (96656 => 96657)


--- trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.h	2011-10-04 22:45:29 UTC (rev 96656)
+++ trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.h	2011-10-04 22:48:18 UTC (rev 96657)
@@ -75,6 +75,7 @@
     bool isInClickTimeWindow();
     bool isInSecondClickTimeWindow();
     bool isInsideManhattanSquare(const PlatformTouchPoint&);
+    bool isSecondClickInsideManhattanSquare(const PlatformTouchPoint&);
     bool isOverMinFlickSpeed();
     void setState(State value) { m_state = value; }
     void updateValues(double touchTime, const PlatformTouchPoint&);
@@ -93,6 +94,7 @@
     State m_state;
     double m_lastTouchTime;
     double m_lastClickTime;
+    IntPoint m_lastClickPosition;
     IntPoint m_lastTouchPosition;
     IntPoint m_lastTouchScreenPosition;
     float m_xVelocity;

Modified: trunk/Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp (96656 => 96657)


--- trunk/Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp	2011-10-04 22:45:29 UTC (rev 96656)
+++ trunk/Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp	2011-10-04 22:48:18 UTC (rev 96657)
@@ -357,15 +357,14 @@
     ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
 
     BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed);
-    BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press);
-    gm.setLastTouchTime(gm.lastTouchTime() - 0.01);
+    BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press, 1000. + 0.7 + 0.01);
     Gestures gestureStart(gm.processTouchEventForGestures(pressEvent, false));
     ASSERT_EQ(1u, gestureStart->size());
     ASSERT_EQ(PlatformGestureEvent::TapDownType, (*gestureStart)[0].type());
     ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state());
 
     BuildablePlatformTouchPoint move(10, 50, PlatformTouchPoint::TouchMoved);
-    BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move);
+    BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move, 1000. + 0.7 + 0.02);
     Gestures gestureMove(gm.processTouchEventForGestures(moveEvent, false));
     ASSERT_EQ(2u, gestureMove->size());
     ASSERT_EQ(PlatformGestureEvent::ScrollBeginType, (*gestureMove)[0].type());
@@ -373,14 +372,42 @@
     ASSERT_EQ(GestureRecognizerChromium::Scroll, gm.state());
 
     BuildablePlatformTouchPoint release(10, 50, PlatformTouchPoint::TouchReleased);
-    BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release);
-    gm.setFirstTouchTime(gm.firstTouchTime() - 0.01);
+    BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release, 1000. + 0.7 + 0.03);
     Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false));
     ASSERT_EQ(1u, gestureEnd->size());
     ASSERT_EQ(PlatformGestureEvent::ScrollEndType, (*gestureEnd)[0].type());
     ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
 }
 
+#if OS(MAC_OS_X)
+#define MAYBE_doubleTapGestureIncompleteDueToSecondClickPositionTest DISABLED_doubleTapGestureIncompleteDueToSecondClickPositionTest
+#else
+#define MAYBE_doubleTapGestureIncompleteDueToSecondClickPositionTest doubleTapGestureIncompleteDueToSecondClickPositionTest
+#endif
+
+TEST_F(GestureRecognizerTest, MAYBE_doubleTapGestureIncompleteDueToSecondClickPositionTest)
+{
+    InspectableGestureRecognizerChromium gm;
+    SimulateAndTestFirstClick(gm);
+    ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
+
+    IntPoint awayFromFirstClick(24, 26);
+
+    BuildablePlatformTouchPoint press(awayFromFirstClick.x(), awayFromFirstClick.y(), PlatformTouchPoint::TouchPressed);
+    BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press, 1000. + 0.7 + 0.01);
+    Gestures gestureStart(gm.processTouchEventForGestures(pressEvent, false));
+    ASSERT_EQ(1u, gestureStart->size());
+    ASSERT_EQ(PlatformGestureEvent::TapDownType, (*gestureStart)[0].type());
+    ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state());
+
+    BuildablePlatformTouchPoint release(awayFromFirstClick.x(), awayFromFirstClick.y(), PlatformTouchPoint::TouchReleased);
+    BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release, 1000. + 0.7 + 0.025);
+    Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false));
+    ASSERT_EQ(1u, gestureEnd->size());
+    ASSERT_EQ(PlatformGestureEvent::TapType, (*gestureEnd)[0].type());
+    ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
+}
+
 TEST_F(GestureRecognizerTest, tapDownWithoutTapGestureTest)
 {
     InspectableGestureRecognizerChromium gm;
@@ -420,24 +447,20 @@
     ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
 
     BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed);
-    BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press);
+    BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press, 1000.);
     Gestures gestureStart(gm.processTouchEventForGestures(pressEvent, false));
     ASSERT_EQ(1u, gestureStart->size());
     ASSERT_EQ(PlatformGestureEvent::TapDownType, (*gestureStart)[0].type());
     ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state());
 
     BuildablePlatformTouchPoint move(10, 16, PlatformTouchPoint::TouchMoved);
-    BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move);
+    BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move, 1000.);
     Gestures gestureMove(gm.processTouchEventForGestures(moveEvent, false));
     ASSERT_EQ(0u, gestureMove->size());
     ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state());
 
     BuildablePlatformTouchPoint release(10, 16, PlatformTouchPoint::TouchReleased);
-    BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release);
-
-    // set first touch time so that we pass the test for
-    // minimumTouchDownDurationInSecondsForClick
-    gm.setFirstTouchTime(gm.firstTouchTime() - 0.01);
+    BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release, 1000. + 0.011);
     Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false));
     ASSERT_EQ(1u, gestureEnd->size());
     ASSERT_EQ(PlatformGestureEvent::TapType, (*gestureEnd)[0].type());
@@ -487,14 +510,13 @@
     ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
 
     BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed);
-    BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press);
+    BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press, 1000.);
     gm.processTouchEventForGestures(pressEvent, false);
 
     ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state());
 
     BuildablePlatformTouchPoint move(10, 50, PlatformTouchPoint::TouchMoved);
-    BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move);
-    gm.setLastTouchTime(gm.lastTouchTime() - 0.2);
+    BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move, 1000. + 0.2);
     Gestures gestureStart(gm.processTouchEventForGestures(moveEvent, false));
     bool scrollStarted = false, scrollUpdated = false;
     for (unsigned int i = 0; i < gestureStart->size(); i++) {
@@ -515,8 +537,7 @@
     ASSERT_EQ(GestureRecognizerChromium::Scroll, gm.state());
 
     BuildablePlatformTouchPoint release(10, 50, PlatformTouchPoint::TouchReleased);
-    BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release);
-    gm.setLastTouchTime(gm.lastTouchTime() - 0.2);
+    BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release, 1000. + 0.2 + 0.2);
     bool scrollEnd = false;
     Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false));
     for (unsigned int i = 0; i < gestureEnd->size(); i++) {
@@ -540,14 +561,14 @@
     ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
 
     BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed);
-    BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press);
+    BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press, 1000.);
     Gestures gestureStart(gm.processTouchEventForGestures(pressEvent, false));
     ASSERT_EQ((unsigned int)1, gestureStart->size());
     ASSERT_EQ(PlatformGestureEvent::TapDownType, (*gestureStart)[0].type());
     ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state());
 
     BuildablePlatformTouchPoint move(10, 50, PlatformTouchPoint::TouchMoved);
-    BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move);
+    BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move, 1000. + 0.02);
     Gestures gestureMove(gm.processTouchEventForGestures(moveEvent, false));
     bool scrollStarted = false, scrollUpdated = false;
     for (unsigned int i = 0; i < gestureMove->size(); i++) {
@@ -568,12 +589,12 @@
     ASSERT_EQ(GestureRecognizerChromium::Scroll, gm.state());
 
     BuildablePlatformTouchPoint release(10, 50, PlatformTouchPoint::TouchReleased);
-    BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release);
+    BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release, 1000. + 0.06);
     Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false));
     ASSERT_EQ((unsigned int) 1, gestureEnd->size());
     ASSERT_EQ(PlatformGestureEvent::ScrollEndType, (*gestureEnd)[0].type());
-    ASSERT_GT((*gestureEnd)[0].deltaX(), 0);
-    ASSERT_GT((*gestureEnd)[0].deltaY(), 0);
+    ASSERT_EQ((*gestureEnd)[0].deltaX(), 0);
+    ASSERT_EQ((*gestureEnd)[0].deltaY(), 1750.);
     ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to