Bug 67930

Summary: Implement flick gesture in Chromium Gesture Recognizer
Product: WebKit Reporter: Varun Jain <varunjain>
Component: New BugsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: dglazkov, rjkroege, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Description Varun Jain 2011-09-12 05:33:14 PDT
Implement flick gesture in Chromium Gesture Recognizer
Comment 1 Varun Jain 2011-09-12 05:34:56 PDT
Created attachment 107040 [details]
Patch
Comment 2 Robert Kroeger 2011-09-12 07:48:38 PDT
Comment on attachment 107040 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=107040&action=review

Good start. Please freshen.

> Source/WebCore/page/EventHandler.cpp:2213
> +        // FIXME: Stop flick if one is in progress.

This code is ultimately going to be dispatching events through what https://bugs.webkit.org/show_bug.cgi?id=67822 evolves into. In particular, implementing this FIXME requires dispatching the TapDownType to the target node/frame iff it has refcount > 1. (But if you wade through the review, you'll see that I have some work ahead on this.)

> Source/WebCore/page/EventHandler.cpp:2227
> +    case PlatformGestureEvent::FlickType:

no. we don't need another type.

We had decided that a flick starts on scroll end that has a velocity. You ought not to need a FlickType

> Source/WebCore/platform/PlatformGestureEvent.h:44
> +        FlickType,

no. (I said this before.)

> Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp:149
> +    gestures->append(PlatformGestureEvent(PlatformGestureEvent::FlickType, touchPoint.pos(), touchPoint.screenPos(), m_lastTouchTime, 0.f, 0.f, m_shiftKey, m_ctrlKey, m_altKey, m_metaKey));

no. See above.

> Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp:223
> +        appendScrollGestureEnd(point, gestures);

remove appendFlickGesture, add ScrollEnd with velo.

> Source/WebCore/platform/chromium/PopupContainer.cpp:311
> +    case PlatformGestureEvent::FlickType:

Less new event types make your life easier.

> Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp:472
> +{

More. Adjusted. With the traces for actual event sequences that I emailed out earlier.
Comment 3 Varun Jain 2011-09-12 10:25:44 PDT
Created attachment 107062 [details]
Patch
Comment 4 Varun Jain 2011-09-12 10:28:26 PDT
Removed separate FlickType... PTAL

(In reply to comment #2)
> (From update of attachment 107040 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=107040&action=review
> 
> Good start. Please freshen.
> 
> > Source/WebCore/page/EventHandler.cpp:2213
> > +        // FIXME: Stop flick if one is in progress.
> 
> This code is ultimately going to be dispatching events through what https://bugs.webkit.org/show_bug.cgi?id=67822 evolves into. In particular, implementing this FIXME requires dispatching the TapDownType to the target node/frame iff it has refcount > 1. (But if you wade through the review, you'll see that I have some work ahead on this.)
> 
> > Source/WebCore/page/EventHandler.cpp:2227
> > +    case PlatformGestureEvent::FlickType:
> 
> no. we don't need another type.
> 
> We had decided that a flick starts on scroll end that has a velocity. You ought not to need a FlickType
> 
> > Source/WebCore/platform/PlatformGestureEvent.h:44
> > +        FlickType,
> 
> no. (I said this before.)
> 
> > Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp:149
> > +    gestures->append(PlatformGestureEvent(PlatformGestureEvent::FlickType, touchPoint.pos(), touchPoint.screenPos(), m_lastTouchTime, 0.f, 0.f, m_shiftKey, m_ctrlKey, m_altKey, m_metaKey));
> 
> no. See above.
> 
> > Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp:223
> > +        appendScrollGestureEnd(point, gestures);
> 
> remove appendFlickGesture, add ScrollEnd with velo.
> 
> > Source/WebCore/platform/chromium/PopupContainer.cpp:311
> > +    case PlatformGestureEvent::FlickType:
> 
> Less new event types make your life easier.
> 
> > Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp:472
> > +{
> 
> More. Adjusted. With the traces for actual event sequences that I emailed out earlier.
Comment 5 Robert Kroeger 2011-09-13 08:57:26 PDT
Comment on attachment 107062 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=107062&action=review

looks good to me.

> Source/WebCore/ChangeLog:8
> +        No new tests. (OOPS!)

Not so! You wrote unit tests. And if you leave this in, the commit queue will bounce the CL.

> Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp:40
> +static const float minFlickSpeed = 1000.0;

I lowered this to 300.f (and you should have the trailing f to avoid a temporary.)
Comment 6 Varun Jain 2011-09-28 16:30:34 PDT
Created attachment 109088 [details]
Patch
Comment 7 Varun Jain 2011-09-28 16:30:43 PDT
(In reply to comment #5)
> (From update of attachment 107062 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=107062&action=review
> 
> looks good to me.
> 
> > Source/WebCore/ChangeLog:8
> > +        No new tests. (OOPS!)
> 
> Not so! You wrote unit tests. And if you leave this in, the commit queue will bounce the CL.

Done

> 
> > Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp:40
> > +static const float minFlickSpeed = 1000.0;
> 
> I lowered this to 300.f (and you should have the trailing f to avoid a temporary.)

Done
Comment 8 Dimitri Glazkov (Google) 2011-09-29 08:46:43 PDT
Comment on attachment 109088 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=109088&action=review

> Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp:105
> +    return sqrt(m_xVelocity * m_xVelocity + m_yVelocity * m_yVelocity) > minFlickSpeed;

Whoa, math!

> Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp:616
> +        , new TouchPointAndEvent(256, 348, 1308336245.407, PlatformTouchPoint::TouchPressed, WebCore::TouchStart)

These commas are freaky. Can me move them to the right places?
Comment 9 Robert Kroeger 2011-09-29 08:55:33 PDT
Comment on attachment 109088 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=109088&action=review

> Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp:41
> +static const float minFlickSpeed = 300.f;

I think recent on-device experience suggests that this should be higher.

> Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp:105
> +    return sqrt(m_xVelocity * m_xVelocity + m_yVelocity * m_yVelocity) > minFlickSpeed;

velocities are float. so use sqrtf

> Source/WebCore/platform/chromium/GestureRecognizerChromium.h:96
> +    IntPoint m_lastTouchPosition;

good hygiene would requires these to have initializers and be  included in the reset.

> Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp:580
> +struct TouchPointAndEvent {

I wouldn't have done this like this. I would have just had an array  of structs. But maybe this is nicer. It seems more complex than it needs to be.

I would have done: 
static EventBlah* foo[] = { { ... }, { ... } };
for (int i = 0; i < sizeof(foo) / sizeof(EventBlah*); i++) { /* do stuff */ }

> Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp:583
> +        : m_point(x, y, state),

the , goes under the : I think
Comment 10 Varun Jain 2011-09-29 09:26:04 PDT
Created attachment 109167 [details]
Patch
Comment 11 Varun Jain 2011-09-29 10:08:25 PDT
(In reply to comment #8)
> (From update of attachment 109088 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=109088&action=review
> 
> > Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp:105
> > +    return sqrt(m_xVelocity * m_xVelocity + m_yVelocity * m_yVelocity) > minFlickSpeed;
> 
> Whoa, math!
> 
> > Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp:616
> > +        , new TouchPointAndEvent(256, 348, 1308336245.407, PlatformTouchPoint::TouchPressed, WebCore::TouchStart)
> 
> These commas are freaky. Can me move them to the right places?

Done
Comment 12 Varun Jain 2011-09-29 10:08:51 PDT
Created attachment 109172 [details]
Patch
Comment 13 Varun Jain 2011-09-29 10:12:17 PDT
(In reply to comment #9)
> (From update of attachment 109088 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=109088&action=review
> 
> > Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp:41
> > +static const float minFlickSpeed = 300.f;
> 
> I think recent on-device experience suggests that this should be higher.
> 
> > Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp:105
> > +    return sqrt(m_xVelocity * m_xVelocity + m_yVelocity * m_yVelocity) > minFlickSpeed;
> 
> velocities are float. so use sqrtf

removed sqrt

> 
> > Source/WebCore/platform/chromium/GestureRecognizerChromium.h:96
> > +    IntPoint m_lastTouchPosition;
> 
> good hygiene would requires these to have initializers and be  included in the reset.
> 

done

> > Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp:580
> > +struct TouchPointAndEvent {
> 
> I wouldn't have done this like this. I would have just had an array  of structs. But maybe this is nicer. It seems more complex than it needs to be.
> 
> I would have done: 
> static EventBlah* foo[] = { { ... }, { ... } };
> for (int i = 0; i < sizeof(foo) / sizeof(EventBlah*); i++) { /* do stuff */ }
> 
> > Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp:583
> > +        : m_point(x, y, state),

I think I am missing something. What we have is an array of touch sequences where each sequence is composed of touch events. Each event is defined as a touchPoint and TouchEvent... so thats what the data structures represent. Do you have a better data structure?


> 
> the , goes under the : I think

Done
Comment 14 Robert Kroeger 2011-09-29 10:17:49 PDT
OK. You convinced me on the tests. Looks good to me.
Comment 15 WebKit Review Bot 2011-09-29 15:16:03 PDT
Comment on attachment 109172 [details]
Patch

Clearing flags on attachment: 109172

Committed r96365: <http://trac.webkit.org/changeset/96365>
Comment 16 WebKit Review Bot 2011-09-29 15:16:08 PDT
All reviewed patches have been landed.  Closing bug.