Changeset 96657 in webkit
- Timestamp:
- Oct 4, 2011 3:48:18 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r96611 r96657 1 2011-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 1 17 2011-10-04 Nayan Kumar K <nayankk@motorola.com> 2 18 -
trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp
r96365 r96657 46 46 , m_lastTouchTime(0.0) 47 47 , m_lastClickTime(0.0) 48 , m_lastClickPosition() 48 49 , m_lastTouchPosition() 49 50 , m_lastTouchScreenPosition() … … 112 113 } 113 114 115 bool 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 114 121 bool GestureRecognizerChromium::isOverMinFlickSpeed() 115 122 { … … 176 183 m_xVelocity = (touchPoint.pos().x() - m_lastTouchPosition.x()) / interval; 177 184 m_yVelocity = (touchPoint.pos().y() - m_lastTouchPosition.y()) / interval; 178 m_lastTouchPosition = touchPoint.pos();179 m_lastTouchScreenPosition = touchPoint.screenPos();180 185 } 181 186 m_lastTouchTime = touchTime; 187 m_lastTouchPosition = touchPoint.pos(); 188 m_lastTouchScreenPosition = touchPoint.screenPos(); 182 189 if (state() == NoGesture) { 183 190 m_firstTouchTime = touchTime; … … 231 238 gestureAdded = true; 232 239 appendClickGestureEvent(point, gestures); 233 if (isInSecondClickTimeWindow() )240 if (isInSecondClickTimeWindow() && isSecondClickInsideManhattanSquare(point)) 234 241 appendDoubleClickGestureEvent(point, gestures); 235 m_lastClickTime = m_lastTouchTime; 242 m_lastClickTime = m_lastTouchTime; 243 m_lastClickPosition = m_lastTouchPosition; 236 244 } 237 245 reset(); -
trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.h
r96365 r96657 76 76 bool isInSecondClickTimeWindow(); 77 77 bool isInsideManhattanSquare(const PlatformTouchPoint&); 78 bool isSecondClickInsideManhattanSquare(const PlatformTouchPoint&); 78 79 bool isOverMinFlickSpeed(); 79 80 void setState(State value) { m_state = value; } … … 94 95 double m_lastTouchTime; 95 96 double m_lastClickTime; 97 IntPoint m_lastClickPosition; 96 98 IntPoint m_lastTouchPosition; 97 99 IntPoint m_lastTouchScreenPosition; -
trunk/Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp
r96365 r96657 358 358 359 359 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); 362 361 Gestures gestureStart(gm.processTouchEventForGestures(pressEvent, false)); 363 362 ASSERT_EQ(1u, gestureStart->size()); … … 366 365 367 366 BuildablePlatformTouchPoint move(10, 50, PlatformTouchPoint::TouchMoved); 368 BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move );367 BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move, 1000. + 0.7 + 0.02); 369 368 Gestures gestureMove(gm.processTouchEventForGestures(moveEvent, false)); 370 369 ASSERT_EQ(2u, gestureMove->size()); … … 374 373 375 374 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); 378 376 Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false)); 379 377 ASSERT_EQ(1u, gestureEnd->size()); 380 378 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 388 TEST_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()); 381 408 ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state()); 382 409 } … … 421 448 422 449 BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed); 423 BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press );450 BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press, 1000.); 424 451 Gestures gestureStart(gm.processTouchEventForGestures(pressEvent, false)); 425 452 ASSERT_EQ(1u, gestureStart->size()); … … 428 455 429 456 BuildablePlatformTouchPoint move(10, 16, PlatformTouchPoint::TouchMoved); 430 BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move );457 BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move, 1000.); 431 458 Gestures gestureMove(gm.processTouchEventForGestures(moveEvent, false)); 432 459 ASSERT_EQ(0u, gestureMove->size()); … … 434 461 435 462 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); 441 464 Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false)); 442 465 ASSERT_EQ(1u, gestureEnd->size()); … … 488 511 489 512 BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed); 490 BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press );513 BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press, 1000.); 491 514 gm.processTouchEventForGestures(pressEvent, false); 492 515 … … 494 517 495 518 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); 498 520 Gestures gestureStart(gm.processTouchEventForGestures(moveEvent, false)); 499 521 bool scrollStarted = false, scrollUpdated = false; … … 516 538 517 539 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); 520 541 bool scrollEnd = false; 521 542 Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false)); … … 541 562 542 563 BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed); 543 BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press );564 BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press, 1000.); 544 565 Gestures gestureStart(gm.processTouchEventForGestures(pressEvent, false)); 545 566 ASSERT_EQ((unsigned int)1, gestureStart->size()); … … 548 569 549 570 BuildablePlatformTouchPoint move(10, 50, PlatformTouchPoint::TouchMoved); 550 BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move );571 BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move, 1000. + 0.02); 551 572 Gestures gestureMove(gm.processTouchEventForGestures(moveEvent, false)); 552 573 bool scrollStarted = false, scrollUpdated = false; … … 569 590 570 591 BuildablePlatformTouchPoint release(10, 50, PlatformTouchPoint::TouchReleased); 571 BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release );592 BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release, 1000. + 0.06); 572 593 Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false)); 573 594 ASSERT_EQ((unsigned int) 1, gestureEnd->size()); 574 595 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.); 577 598 ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state()); 578 599 }
Note: See TracChangeset
for help on using the changeset viewer.