Changeset 96657 in webkit


Ignore:
Timestamp:
Oct 4, 2011 3:48:18 PM (13 years ago)
Author:
commit-queue@webkit.org
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 <varunjain@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:
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r96611 r96657  
     12011-10-04  Varun Jain  <varunjain@chromium.org>
     2
     3        Fix position check for double tap gesture detection. A double tap
     4        should not be detected if the two taps are far from each other.
     5        https://bugs.webkit.org/show_bug.cgi?id=69270
     6
     7        Reviewed by Darin Fisher.
     8
     9        Test: Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp
     10
     11        * platform/chromium/GestureRecognizerChromium.cpp:
     12        (WebCore::GestureRecognizerChromium::isSecondClickInsideManhattanSquare):
     13        (WebCore::GestureRecognizerChromium::updateValues):
     14        (WebCore::GestureRecognizerChromium::click):
     15        * platform/chromium/GestureRecognizerChromium.h:
     16
    1172011-10-04  Nayan Kumar K  <nayankk@motorola.com>
    218
  • trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp

    r96365 r96657  
    4646    , m_lastTouchTime(0.0)
    4747    , m_lastClickTime(0.0)
     48    , m_lastClickPosition()
    4849    , m_lastTouchPosition()
    4950    , m_lastTouchScreenPosition()
     
    112113}
    113114
     115bool GestureRecognizerChromium::isSecondClickInsideManhattanSquare(const PlatformTouchPoint& point)
     116{
     117    int manhattanDistance = abs(point.pos().x() - m_lastClickPosition.x()) + abs(point.pos().y() - m_lastClickPosition.y());
     118    return manhattanDistance < maximumTouchMoveInPixelsForClick;
     119}
     120
    114121bool GestureRecognizerChromium::isOverMinFlickSpeed()
    115122{
     
    176183        m_xVelocity = (touchPoint.pos().x() - m_lastTouchPosition.x()) / interval;
    177184        m_yVelocity = (touchPoint.pos().y() - m_lastTouchPosition.y()) / interval;
    178         m_lastTouchPosition = touchPoint.pos();
    179         m_lastTouchScreenPosition = touchPoint.screenPos();
    180185    }
    181186    m_lastTouchTime = touchTime;
     187    m_lastTouchPosition = touchPoint.pos();
     188    m_lastTouchScreenPosition = touchPoint.screenPos();
    182189    if (state() == NoGesture) {
    183190        m_firstTouchTime = touchTime;
     
    231238        gestureAdded = true;
    232239        appendClickGestureEvent(point, gestures);
    233         if (isInSecondClickTimeWindow())
     240        if (isInSecondClickTimeWindow() && isSecondClickInsideManhattanSquare(point))
    234241            appendDoubleClickGestureEvent(point, gestures);
    235        m_lastClickTime = m_lastTouchTime;
     242        m_lastClickTime = m_lastTouchTime;
     243        m_lastClickPosition = m_lastTouchPosition;
    236244    }
    237245    reset();
  • trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.h

    r96365 r96657  
    7676    bool isInSecondClickTimeWindow();
    7777    bool isInsideManhattanSquare(const PlatformTouchPoint&);
     78    bool isSecondClickInsideManhattanSquare(const PlatformTouchPoint&);
    7879    bool isOverMinFlickSpeed();
    7980    void setState(State value) { m_state = value; }
     
    9495    double m_lastTouchTime;
    9596    double m_lastClickTime;
     97    IntPoint m_lastClickPosition;
    9698    IntPoint m_lastTouchPosition;
    9799    IntPoint m_lastTouchScreenPosition;
  • trunk/Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp

    r96365 r96657  
    358358
    359359    BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed);
    360     BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press);
    361     gm.setLastTouchTime(gm.lastTouchTime() - 0.01);
     360    BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press, 1000. + 0.7 + 0.01);
    362361    Gestures gestureStart(gm.processTouchEventForGestures(pressEvent, false));
    363362    ASSERT_EQ(1u, gestureStart->size());
     
    366365
    367366    BuildablePlatformTouchPoint move(10, 50, PlatformTouchPoint::TouchMoved);
    368     BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move);
     367    BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move, 1000. + 0.7 + 0.02);
    369368    Gestures gestureMove(gm.processTouchEventForGestures(moveEvent, false));
    370369    ASSERT_EQ(2u, gestureMove->size());
     
    374373
    375374    BuildablePlatformTouchPoint release(10, 50, PlatformTouchPoint::TouchReleased);
    376     BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release);
    377     gm.setFirstTouchTime(gm.firstTouchTime() - 0.01);
     375    BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release, 1000. + 0.7 + 0.03);
    378376    Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false));
    379377    ASSERT_EQ(1u, gestureEnd->size());
    380378    ASSERT_EQ(PlatformGestureEvent::ScrollEndType, (*gestureEnd)[0].type());
     379    ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
     380}
     381
     382#if OS(MAC_OS_X)
     383#define MAYBE_doubleTapGestureIncompleteDueToSecondClickPositionTest DISABLED_doubleTapGestureIncompleteDueToSecondClickPositionTest
     384#else
     385#define MAYBE_doubleTapGestureIncompleteDueToSecondClickPositionTest doubleTapGestureIncompleteDueToSecondClickPositionTest
     386#endif
     387
     388TEST_F(GestureRecognizerTest, MAYBE_doubleTapGestureIncompleteDueToSecondClickPositionTest)
     389{
     390    InspectableGestureRecognizerChromium gm;
     391    SimulateAndTestFirstClick(gm);
     392    ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
     393
     394    IntPoint awayFromFirstClick(24, 26);
     395
     396    BuildablePlatformTouchPoint press(awayFromFirstClick.x(), awayFromFirstClick.y(), PlatformTouchPoint::TouchPressed);
     397    BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press, 1000. + 0.7 + 0.01);
     398    Gestures gestureStart(gm.processTouchEventForGestures(pressEvent, false));
     399    ASSERT_EQ(1u, gestureStart->size());
     400    ASSERT_EQ(PlatformGestureEvent::TapDownType, (*gestureStart)[0].type());
     401    ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state());
     402
     403    BuildablePlatformTouchPoint release(awayFromFirstClick.x(), awayFromFirstClick.y(), PlatformTouchPoint::TouchReleased);
     404    BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release, 1000. + 0.7 + 0.025);
     405    Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false));
     406    ASSERT_EQ(1u, gestureEnd->size());
     407    ASSERT_EQ(PlatformGestureEvent::TapType, (*gestureEnd)[0].type());
    381408    ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
    382409}
     
    421448
    422449    BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed);
    423     BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press);
     450    BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press, 1000.);
    424451    Gestures gestureStart(gm.processTouchEventForGestures(pressEvent, false));
    425452    ASSERT_EQ(1u, gestureStart->size());
     
    428455
    429456    BuildablePlatformTouchPoint move(10, 16, PlatformTouchPoint::TouchMoved);
    430     BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move);
     457    BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move, 1000.);
    431458    Gestures gestureMove(gm.processTouchEventForGestures(moveEvent, false));
    432459    ASSERT_EQ(0u, gestureMove->size());
     
    434461
    435462    BuildablePlatformTouchPoint release(10, 16, PlatformTouchPoint::TouchReleased);
    436     BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release);
    437 
    438     // set first touch time so that we pass the test for
    439     // minimumTouchDownDurationInSecondsForClick
    440     gm.setFirstTouchTime(gm.firstTouchTime() - 0.01);
     463    BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release, 1000. + 0.011);
    441464    Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false));
    442465    ASSERT_EQ(1u, gestureEnd->size());
     
    488511
    489512    BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed);
    490     BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press);
     513    BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press, 1000.);
    491514    gm.processTouchEventForGestures(pressEvent, false);
    492515
     
    494517
    495518    BuildablePlatformTouchPoint move(10, 50, PlatformTouchPoint::TouchMoved);
    496     BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move);
    497     gm.setLastTouchTime(gm.lastTouchTime() - 0.2);
     519    BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move, 1000. + 0.2);
    498520    Gestures gestureStart(gm.processTouchEventForGestures(moveEvent, false));
    499521    bool scrollStarted = false, scrollUpdated = false;
     
    516538
    517539    BuildablePlatformTouchPoint release(10, 50, PlatformTouchPoint::TouchReleased);
    518     BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release);
    519     gm.setLastTouchTime(gm.lastTouchTime() - 0.2);
     540    BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release, 1000. + 0.2 + 0.2);
    520541    bool scrollEnd = false;
    521542    Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false));
     
    541562
    542563    BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed);
    543     BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press);
     564    BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press, 1000.);
    544565    Gestures gestureStart(gm.processTouchEventForGestures(pressEvent, false));
    545566    ASSERT_EQ((unsigned int)1, gestureStart->size());
     
    548569
    549570    BuildablePlatformTouchPoint move(10, 50, PlatformTouchPoint::TouchMoved);
    550     BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move);
     571    BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move, 1000. + 0.02);
    551572    Gestures gestureMove(gm.processTouchEventForGestures(moveEvent, false));
    552573    bool scrollStarted = false, scrollUpdated = false;
     
    569590
    570591    BuildablePlatformTouchPoint release(10, 50, PlatformTouchPoint::TouchReleased);
    571     BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release);
     592    BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release, 1000. + 0.06);
    572593    Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false));
    573594    ASSERT_EQ((unsigned int) 1, gestureEnd->size());
    574595    ASSERT_EQ(PlatformGestureEvent::ScrollEndType, (*gestureEnd)[0].type());
    575     ASSERT_GT((*gestureEnd)[0].deltaX(), 0);
    576     ASSERT_GT((*gestureEnd)[0].deltaY(), 0);
     596    ASSERT_EQ((*gestureEnd)[0].deltaX(), 0);
     597    ASSERT_EQ((*gestureEnd)[0].deltaY(), 1750.);
    577598    ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
    578599}
Note: See TracChangeset for help on using the changeset viewer.