Title: [94772] trunk
Revision
94772
Author
commit-qu...@webkit.org
Date
2011-09-08 11:30:40 -0700 (Thu, 08 Sep 2011)

Log Message

Split Tap gesture detection into TapDown and Tap.
We need this distinction to highlight links when they are first touched. The link is
followed only if the tap is completed, otherwise, if a scroll is detected, the highlight
goes away.
https://bugs.webkit.org/show_bug.cgi?id=67645

Patch by Varun Jain <varunj...@google.com> on 2011-09-08
Reviewed by Dimitri Glazkov.

*  Source/WebCore/page/EventHandler.cpp:
*  Source/WebCore/platform/PlatformGestureEvent.h:

Modified Paths

Diff

Modified: trunk/ChangeLog (94771 => 94772)


--- trunk/ChangeLog	2011-09-08 18:28:42 UTC (rev 94771)
+++ trunk/ChangeLog	2011-09-08 18:30:40 UTC (rev 94772)
@@ -1,3 +1,16 @@
+2011-09-08  Varun Jain  <varunj...@google.com>
+
+        Split Tap gesture detection into TapDown and Tap.
+        We need this distinction to highlight links when they are first touched. The link is
+        followed only if the tap is completed, otherwise, if a scroll is detected, the highlight
+        goes away.
+        https://bugs.webkit.org/show_bug.cgi?id=67645
+
+        Reviewed by Dimitri Glazkov.
+
+        *  Source/WebCore/page/EventHandler.cpp:
+        *  Source/WebCore/platform/PlatformGestureEvent.h:
+
 2011-09-07  Alexei Svitkine  <asvitk...@chromium.org>
 
         Add test infrastructure to test rubber-banding overhang drawing along with layout tests for existing Chromium Mac overhang drawing in the non-gpu path.

Modified: trunk/Source/WebCore/page/EventHandler.cpp (94771 => 94772)


--- trunk/Source/WebCore/page/EventHandler.cpp	2011-09-08 18:28:42 UTC (rev 94771)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2011-09-08 18:30:40 UTC (rev 94772)
@@ -2209,6 +2209,8 @@
     // end gesture as well.
 
     switch (gestureEvent.type()) {
+    case PlatformGestureEvent::TapDownType:
+        break;
     case PlatformGestureEvent::TapType: {
         // FIXME: Refactor this code to not hit test multiple times once hit testing has been corrected as suggested above.
         PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globalPosition(), NoButton, MouseEventMoved, /* clickCount */ 1, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp());

Modified: trunk/Source/WebCore/platform/PlatformGestureEvent.h (94771 => 94772)


--- trunk/Source/WebCore/platform/PlatformGestureEvent.h	2011-09-08 18:28:42 UTC (rev 94771)
+++ trunk/Source/WebCore/platform/PlatformGestureEvent.h	2011-09-08 18:30:40 UTC (rev 94772)
@@ -38,7 +38,8 @@
         ScrollBeginType,
         ScrollEndType,
         ScrollUpdateType,
-        TapType
+        TapType,
+        TapDownType,
     };
 
     PlatformGestureEvent()

Modified: trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp (94771 => 94772)


--- trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp	2011-09-08 18:28:42 UTC (rev 94771)
+++ trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp	2011-09-08 18:30:40 UTC (rev 94772)
@@ -92,6 +92,11 @@
     return manhattanDistance < maximumTouchMoveInPixelsForClick;
 }
 
+void GestureRecognizerChromium::appendTapDownGestureEvent(const PlatformTouchPoint& touchPoint, Gestures gestures)
+{
+    gestures->append(PlatformGestureEvent(PlatformGestureEvent::TapDownType, m_firstTouchPosition, m_firstTouchScreenPosition, m_lastTouchTime, 0.f, 0.f, m_shiftKey, m_ctrlKey, m_altKey, m_metaKey));
+}
+
 void GestureRecognizerChromium::appendClickGestureEvent(const PlatformTouchPoint& touchPoint, Gestures gestures)
 {
     gestures->append(PlatformGestureEvent(PlatformGestureEvent::TapType, m_firstTouchPosition, m_firstTouchScreenPosition, m_lastTouchTime, 0.f, 0.f, m_shiftKey, m_ctrlKey, m_altKey, m_metaKey));
@@ -160,7 +165,7 @@
 bool GestureRecognizerChromium::touchDown(const PlatformTouchPoint& touchPoint, Gestures gestures)
 {
     setState(PendingSyntheticClick);
-    // FIXME: Divide TapType into down and up events.
+    appendTapDownGestureEvent(touchPoint, gestures);
     return false;
 }
 

Modified: trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.h (94771 => 94772)


--- trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.h	2011-09-08 18:28:42 UTC (rev 94771)
+++ trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.h	2011-09-08 18:30:40 UTC (rev 94772)
@@ -66,6 +66,7 @@
 
     static unsigned int signature(State, unsigned, PlatformTouchPoint::State, bool);
     void addEdgeFunction(State, unsigned finger, PlatformTouchPoint::State, bool touchHandledByJavaScript, GestureTransitionFunction);
+    void appendTapDownGestureEvent(const PlatformTouchPoint&, Gestures);
     void appendClickGestureEvent(const PlatformTouchPoint&, Gestures);
     void appendScrollGestureBegin(const PlatformTouchPoint&, Gestures);
     void appendScrollGestureEnd(const PlatformTouchPoint&, Gestures);
@@ -87,7 +88,6 @@
     IntPoint m_firstTouchScreenPosition;
     double m_firstTouchTime;
     State m_state;
-    IntPoint m_lastTouchPosition;
     double m_lastTouchTime;
 
     bool m_ctrlKey;

Modified: trunk/Source/WebCore/platform/chromium/PopupContainer.cpp (94771 => 94772)


--- trunk/Source/WebCore/platform/chromium/PopupContainer.cpp	2011-09-08 18:28:42 UTC (rev 94771)
+++ trunk/Source/WebCore/platform/chromium/PopupContainer.cpp	2011-09-08 18:30:40 UTC (rev 94772)
@@ -313,6 +313,7 @@
     }
     case PlatformGestureEvent::ScrollBeginType:
     case PlatformGestureEvent::ScrollEndType:
+    case PlatformGestureEvent::TapDownType:
         break;
     }
     return false;

Modified: trunk/Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp (94771 => 94772)


--- trunk/Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp	2011-09-08 18:28:42 UTC (rev 94771)
+++ trunk/Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp	2011-09-08 18:30:40 UTC (rev 94772)
@@ -157,6 +157,8 @@
     virtual void TearDown() { }
 };
 
+typedef OwnPtr<Vector<WebCore::PlatformGestureEvent> > Gestures;
+
 TEST_F(GestureRecognizerTest, hash)
 {
     InspectableGestureRecognizerChromium testGm;
@@ -282,6 +284,63 @@
     ASSERT_EQ(0.0, gm.lastTouchTime() - gm.firstTouchTime());
 }
 
+TEST_F(GestureRecognizerTest, tapDownWithoutTapGestureTest)
+{
+    InspectableGestureRecognizerChromium gm;
+    ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
+
+    BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed);
+    BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press);
+    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);
+    Gestures gestureMove(gm.processTouchEventForGestures(moveEvent, false));
+    for (unsigned int i = 0; i < gestureMove->size(); i++)
+        ASSERT_NE(PlatformGestureEvent::TapType, (*gestureMove)[i].type());
+    ASSERT_EQ(GestureRecognizerChromium::Scroll, gm.state());
+
+    BuildablePlatformTouchPoint release(10, 50, PlatformTouchPoint::TouchReleased);
+    BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release);
+    Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false));
+    for (unsigned int i = 0; i < gestureEnd->size(); i++)
+        ASSERT_NE(PlatformGestureEvent::TapType, (*gestureEnd)[i].type());
+    ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
+}
+
+TEST_F(GestureRecognizerTest, tapDownWithTapGestureTest)
+{
+    InspectableGestureRecognizerChromium gm;
+    ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
+
+    BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed);
+    BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press);
+    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, 16, PlatformTouchPoint::TouchMoved);
+    BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move);
+    Gestures gestureMove(gm.processTouchEventForGestures(moveEvent, false));
+    ASSERT_EQ((unsigned int)0, 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);
+    Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false));
+    ASSERT_EQ((unsigned int)1, gestureEnd->size());
+    ASSERT_EQ(PlatformGestureEvent::TapType, (*gestureEnd)[0].type());
+    ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
+}
+
 TEST_F(GestureRecognizerTest, gestureScrollEvents)
 {
     InspectableGestureRecognizerChromium gm;
@@ -296,7 +355,7 @@
 
     BuildablePlatformTouchPoint move(10, 50, PlatformTouchPoint::TouchMoved);
     BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move);
-    OwnPtr<Vector<WebCore::PlatformGestureEvent> > gestureStart(gm.processTouchEventForGestures(moveEvent, false));
+    Gestures gestureStart(gm.processTouchEventForGestures(moveEvent, false));
     bool scrollStarted = false, scrollUpdated = false;
     for (unsigned int i = 0; i < gestureStart->size(); i++) {
         switch ((*gestureStart)[i].type()) {
@@ -318,7 +377,7 @@
     BuildablePlatformTouchPoint release(10, 50, PlatformTouchPoint::TouchReleased);
     BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release);
     bool scrollEnd = false;
-    OwnPtr<Vector<WebCore::PlatformGestureEvent> > gestureEnd(gm.processTouchEventForGestures(releaseEvent, false));
+    Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false));
     for (unsigned int i = 0; i < gestureEnd->size(); i++) {
         switch ((*gestureEnd)[i].type()) {
         case PlatformGestureEvent::ScrollEndType:
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to