Changeset 95452 in webkit
- Timestamp:
- Sep 19, 2011 12:13:04 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r95451 r95452 1 2011-09-19 Robert Kroeger <rjkroege@chromium.org> 2 3 [chromium] Gesture recognizer fires taptype only every other touch 4 down/up sequence https://bugs.webkit.org/show_bug.cgi?id=68368 5 6 Reviewed by Adam Barth. 7 8 The addition of doubletap detection to the gesture recognizer missed some of the 9 outgoing edges in the recognizer state machine. This change simplifies the logic 10 and handles all outgoing edges. 11 12 * platform/chromium/GestureRecognizerChromium.cpp: 13 (WebCore::GestureRecognizerChromium::GestureRecognizerChromium): 14 (WebCore::GestureRecognizerChromium::isInSecondClickTimeWindow): 15 (WebCore::GestureRecognizerChromium::updateValues): 16 (WebCore::GestureRecognizerChromium::touchDown): 17 (WebCore::GestureRecognizerChromium::click): 18 * platform/chromium/GestureRecognizerChromium.h: 19 1 20 2011-09-19 Tom Sepez <tsepez@chromium.org> 2 21 -
trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp
r94797 r95452 37 37 static const double maximumTouchDownDurationInSecondsForClick = 0.8; 38 38 static const double minimumTouchDownDurationInSecondsForClick = 0.01; 39 static const double maximumSecondsBetweenDoubleClick = 0.7; 39 40 static const int maximumTouchMoveInPixelsForClick = 20; 40 41 … … 63 64 addEdgeFunction(Scroll, FirstFinger, Released, false, &GestureRecognizerChromium::scrollEnd); 64 65 addEdgeFunction(Scroll, FirstFinger, Cancelled, false, &GestureRecognizerChromium::scrollEnd); 65 66 addEdgeFunction(FirstClickReceived, FirstFinger, Pressed, false, &GestureRecognizerChromium::touchDown);67 addEdgeFunction(PendingDoubleClick, FirstFinger, Cancelled, false, &GestureRecognizerChromium::noGesture);68 addEdgeFunction(PendingDoubleClick, FirstFinger, Released, false, &GestureRecognizerChromium::doubleClick);69 addEdgeFunction(PendingDoubleClick, FirstFinger, Moved, false, &GestureRecognizerChromium::maybeDoubleClick);70 addEdgeFunction(PendingDoubleClick, FirstFinger, Stationary, false, &GestureRecognizerChromium::maybeDoubleClick);71 66 } 72 67 … … 96 91 { 97 92 double duration(m_lastTouchTime - m_lastClickTime); 98 return duration >= minimumTouchDownDurationInSecondsForClick && duration < maximumTouchDownDurationInSecondsForClick;93 return duration < maximumSecondsBetweenDoubleClick; 99 94 } 100 95 … … 160 155 void GestureRecognizerChromium::updateValues(const double touchTime, const PlatformTouchPoint& touchPoint) 161 156 { 162 if (state() == FirstClickReceived) {163 m_firstTouchTime = touchTime;164 m_lastClickTime = m_lastTouchTime;165 }166 157 m_lastTouchTime = touchTime; 167 158 if (state() == NoGesture) { … … 186 177 bool GestureRecognizerChromium::touchDown(const PlatformTouchPoint& touchPoint, Gestures gestures) 187 178 { 188 ASSERT(state() == NoGesture || state() == FirstClickReceived);189 179 appendTapDownGestureEvent(touchPoint, gestures); 190 if (state() == FirstClickReceived && isInSecondClickTimeWindow() && isInsideManhattanSquare(touchPoint)) {191 setState(PendingDoubleClick);192 return false;193 }194 180 setState(PendingSyntheticClick); 195 181 return false; … … 204 190 } 205 191 206 bool GestureRecognizerChromium::doubleClick(const PlatformTouchPoint& point, Gestures gestures) 207 { 192 bool GestureRecognizerChromium::noGesture(const PlatformTouchPoint&, Gestures) 193 { 194 reset(); 195 return false; 196 } 197 198 bool GestureRecognizerChromium::click(const PlatformTouchPoint& point, Gestures gestures) 199 { 200 bool gestureAdded = false; 208 201 if (isInClickTimeWindow() && isInsideManhattanSquare(point)) { 209 setState(NoGesture); 210 appendDoubleClickGestureEvent(point, gestures); 211 return true; 212 } 213 return noGesture(point, gestures); 214 } 215 216 bool GestureRecognizerChromium::maybeDoubleClick(const PlatformTouchPoint& point, Gestures gestures) 217 { 218 ASSERT(state() == GestureRecognizerChromium::PendingDoubleClick); 219 if (point.state() == PlatformTouchPoint::TouchMoved && !isInsideManhattanSquare(point)) 220 return noGesture(point, gestures); 221 return false; 222 } 223 224 bool GestureRecognizerChromium::noGesture(const PlatformTouchPoint&, Gestures) 225 { 202 gestureAdded = true; 203 appendClickGestureEvent(point, gestures); 204 if (isInSecondClickTimeWindow()) 205 appendDoubleClickGestureEvent(point, gestures); 206 m_lastClickTime = m_lastTouchTime; 207 } 226 208 reset(); 227 return false; 228 } 229 230 bool GestureRecognizerChromium::click(const PlatformTouchPoint& point, Gestures gestures) 231 { 232 if (isInClickTimeWindow() && isInsideManhattanSquare(point)) { 233 setState(FirstClickReceived); 234 appendClickGestureEvent(point, gestures); 235 return true; 236 } 237 return noGesture(point, gestures); 209 return gestureAdded; 238 210 } 239 211 -
trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.h
r94797 r95452 50 50 PendingSyntheticClick, 51 51 Scroll, 52 FirstClickReceived,53 PendingDoubleClick,54 52 }; 55 53 … … 88 86 bool scrollEnd(const PlatformTouchPoint&, Gestures); 89 87 90 bool doubleClick(const PlatformTouchPoint&, Gestures);91 bool maybeDoubleClick(const PlatformTouchPoint&, Gestures);92 93 88 WTF::HashMap<int, GestureTransitionFunction> m_edgeFunctions; 94 89 IntPoint m_firstTouchPosition; -
trunk/Source/WebKit/chromium/ChangeLog
r95449 r95452 1 2011-09-19 Robert Kroeger <rjkroege@chromium.org> 2 3 [chromium] Gesture recognizer fires taptype only every other touch 4 down/up sequence https://bugs.webkit.org/show_bug.cgi?id=68368 5 6 Reviewed by Adam Barth. 7 8 The addition of doubletap detection to the gesture recognizer missed some of the 9 outgoing edges in the recognizer state machine. Thsi change simplifies the logic 10 and handles all outgoing edges. 11 12 13 * tests/InnerGestureRecognizerTest.cpp: 14 Additional tests added to ensure that all edges in the state 15 machine are accounted for. 16 (BuildablePlatformTouchEvent::BuildablePlatformTouchEvent): 17 (SimulateAndTestFirstClick): 18 (TEST_F): 19 1 20 2011-09-19 Peter Rybin <peter.rybin@gmail.com> 2 21 -
trunk/Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp
r94797 r95452 141 141 class BuildablePlatformTouchEvent : public WebCore::PlatformTouchEvent { 142 142 public: 143 BuildablePlatformTouchEvent(WebCore::TouchEventType type, PlatformTouchPoint& point )143 BuildablePlatformTouchEvent(WebCore::TouchEventType type, PlatformTouchPoint& point, double time) 144 144 { 145 145 m_type = type; 146 146 m_touchPoints.append(point); 147 m_timestamp = time; 148 } 149 150 BuildablePlatformTouchEvent(WebCore::TouchEventType type, PlatformTouchPoint& point) 151 { 152 m_type = type; 153 m_touchPoints.append(point); 154 m_timestamp = 100.; 147 155 } 148 156 }; … … 162 170 163 171 BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed); 164 BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press );172 BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press, 1000.); 165 173 OwnPtr<Vector<WebCore::PlatformGestureEvent> > gestureStart(gm.processTouchEventForGestures(pressEvent, false)); 166 174 ASSERT_EQ((unsigned int)1, gestureStart->size()); … … 169 177 170 178 BuildablePlatformTouchPoint release(10, 16, PlatformTouchPoint::TouchReleased); 171 BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release); 172 gm.setFirstTouchTime(gm.firstTouchTime() - 0.01); 179 BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release, 1000. + 0.7); 173 180 OwnPtr<Vector<WebCore::PlatformGestureEvent> > gestureEnd(gm.processTouchEventForGestures(releaseEvent, false)); 174 181 ASSERT_EQ((unsigned int)1, gestureEnd->size()); … … 307 314 InspectableGestureRecognizerChromium gm; 308 315 SimulateAndTestFirstClick(gm); 309 ASSERT_EQ(GestureRecognizerChromium::FirstClickReceived, gm.state()); 316 ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state()); 317 318 BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed); 319 BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press, 1000 + .5); 320 Gestures gestureStart(gm.processTouchEventForGestures(pressEvent, false)); 321 ASSERT_EQ((unsigned int)1, gestureStart->size()); 322 ASSERT_EQ(PlatformGestureEvent::TapDownType, (*gestureStart)[0].type()); 323 ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state()); 324 325 BuildablePlatformTouchPoint move(10, 16, PlatformTouchPoint::TouchMoved); 326 BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move, 1000 + .5 + .01); 327 Gestures gestureMove(gm.processTouchEventForGestures(moveEvent, false)); 328 ASSERT_EQ((unsigned int)0, gestureMove->size()); 329 ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state()); 330 331 BuildablePlatformTouchPoint release(10, 16, PlatformTouchPoint::TouchReleased); 332 BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release, 1000 + .5 + .02); 333 Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false)); 334 ASSERT_EQ((unsigned int)2, gestureEnd->size()); 335 ASSERT_EQ(PlatformGestureEvent::TapType, (*gestureEnd)[0].type()); 336 ASSERT_EQ(PlatformGestureEvent::DoubleTapType, (*gestureEnd)[1].type()); 337 ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state()); 338 } 339 340 TEST_F(GestureRecognizerTest, doubleTapGestureIncompleteTest) 341 { 342 InspectableGestureRecognizerChromium gm; 343 SimulateAndTestFirstClick(gm); 344 ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state()); 310 345 311 346 BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed); … … 315 350 ASSERT_EQ((unsigned int)1, gestureStart->size()); 316 351 ASSERT_EQ(PlatformGestureEvent::TapDownType, (*gestureStart)[0].type()); 317 ASSERT_EQ(GestureRecognizerChromium::Pending DoubleClick, gm.state());318 319 BuildablePlatformTouchPoint move(10, 16, PlatformTouchPoint::TouchMoved);352 ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state()); 353 354 BuildablePlatformTouchPoint move(10, 50, PlatformTouchPoint::TouchMoved); 320 355 BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move); 321 356 Gestures gestureMove(gm.processTouchEventForGestures(moveEvent, false)); 322 ASSERT_EQ((unsigned int)0, gestureMove->size()); 323 ASSERT_EQ(GestureRecognizerChromium::PendingDoubleClick, gm.state()); 324 325 BuildablePlatformTouchPoint release(10, 16, PlatformTouchPoint::TouchReleased); 357 ASSERT_EQ((unsigned int)2, gestureMove->size()); 358 ASSERT_EQ(PlatformGestureEvent::ScrollBeginType, (*gestureMove)[0].type()); 359 ASSERT_EQ(PlatformGestureEvent::ScrollUpdateType, (*gestureMove)[1].type()); 360 ASSERT_EQ(GestureRecognizerChromium::Scroll, gm.state()); 361 362 BuildablePlatformTouchPoint release(10, 50, PlatformTouchPoint::TouchReleased); 326 363 BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release); 327 364 gm.setFirstTouchTime(gm.firstTouchTime() - 0.01); 328 365 Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false)); 329 366 ASSERT_EQ((unsigned int)1, gestureEnd->size()); 330 ASSERT_EQ(PlatformGestureEvent::DoubleTapType, (*gestureEnd)[0].type()); 331 ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state()); 332 } 333 334 TEST_F(GestureRecognizerTest, doubleTapGestureIncompleteTest) 335 { 336 InspectableGestureRecognizerChromium gm; 337 SimulateAndTestFirstClick(gm); 338 ASSERT_EQ(GestureRecognizerChromium::FirstClickReceived, gm.state()); 339 340 BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed); 341 BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press); 342 gm.setLastTouchTime(gm.lastTouchTime() - 0.01); 343 Gestures gestureStart(gm.processTouchEventForGestures(pressEvent, false)); 344 ASSERT_EQ((unsigned int)1, gestureStart->size()); 345 ASSERT_EQ(PlatformGestureEvent::TapDownType, (*gestureStart)[0].type()); 346 ASSERT_EQ(GestureRecognizerChromium::PendingDoubleClick, gm.state()); 347 348 BuildablePlatformTouchPoint move(10, 50, PlatformTouchPoint::TouchMoved); 349 BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move); 350 Gestures gestureMove(gm.processTouchEventForGestures(moveEvent, false)); 351 ASSERT_EQ((unsigned int)0, gestureMove->size()); 352 ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state()); 353 354 BuildablePlatformTouchPoint release(10, 50, PlatformTouchPoint::TouchReleased); 355 BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release); 356 gm.setFirstTouchTime(gm.firstTouchTime() - 0.01); 357 Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false)); 358 ASSERT_EQ((unsigned int)0, gestureEnd->size()); 367 ASSERT_EQ(PlatformGestureEvent::ScrollEndType, (*gestureEnd)[0].type()); 359 368 ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state()); 360 369 } … … 414 423 ASSERT_EQ((unsigned int)1, gestureEnd->size()); 415 424 ASSERT_EQ(PlatformGestureEvent::TapType, (*gestureEnd)[0].type()); 416 ASSERT_EQ(GestureRecognizerChromium::FirstClickReceived, gm.state()); 417 } 425 ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state()); 426 } 427 428 TEST_F(GestureRecognizerTest, noDoubleTapGestureBecauseOfInterTouchIntervalTest) 429 { 430 InspectableGestureRecognizerChromium gm; 431 SimulateAndTestFirstClick(gm); 432 ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state()); 433 434 BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed); 435 // Values are from GestureRecognizerChromium.cpp 436 BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press, 1000 + .8 + 10 + .1); 437 Gestures gestureStart(gm.processTouchEventForGestures(pressEvent, false)); 438 ASSERT_EQ((unsigned int)1, gestureStart->size()); 439 ASSERT_EQ(PlatformGestureEvent::TapDownType, (*gestureStart)[0].type()); 440 ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state()); 441 442 BuildablePlatformTouchPoint move(10, 16, PlatformTouchPoint::TouchMoved); 443 BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move, 1000 + .8 + 10 + .1 + .05); 444 Gestures gestureMove(gm.processTouchEventForGestures(moveEvent, false)); 445 ASSERT_EQ((unsigned int)0, gestureMove->size()); 446 ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state()); 447 448 BuildablePlatformTouchPoint release(11, 17, PlatformTouchPoint::TouchReleased); 449 BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release, 1000 + .8 + 10 + .1 + .02); 450 Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false)); 451 ASSERT_EQ((unsigned int)1, gestureEnd->size()); 452 ASSERT_EQ(PlatformGestureEvent::TapType, (*gestureEnd)[0].type()); 453 ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state()); 454 } 455 456 418 457 419 458 TEST_F(GestureRecognizerTest, gestureScrollEvents)
Note: See TracChangeset
for help on using the changeset viewer.