RESOLVED FIXED 97355
[chromium] Modify gesture highlight behaviour. Cancel on GestureLongPress and animate on GestureTapCancel.
https://bugs.webkit.org/show_bug.cgi?id=97355
Summary [chromium] Modify gesture highlight behaviour. Cancel on GestureLongPress and...
W. James MacLean
Reported 2012-09-21 13:17:07 PDT
[chromium] Modify gesture highlight behaviour. Cancel on GestureLongPress and animate on GestureTapCancel.
Attachments
Patch (23.35 KB, patch)
2012-09-21 13:23 PDT, W. James MacLean
no flags
Patch (24.04 KB, patch)
2012-10-03 17:39 PDT, W. James MacLean
no flags
Patch (23.79 KB, patch)
2012-10-05 11:03 PDT, W. James MacLean
no flags
W. James MacLean
Comment 1 2012-09-21 13:23:20 PDT
Adrienne Walker
Comment 2 2012-10-01 14:59:18 PDT
Comment on attachment 165178 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=165178&action=review > Source/WebKit/chromium/src/LinkHighlight.cpp:-79 > - // We don't want to show the highlight until startAnimation is called, even though the highlight > - // layer may be added to the tree immediately. Why is this comment no longer true? What has changed? > Source/WebKit/chromium/src/WebViewImpl.cpp:747 > + fprintf(stderr, "wjm: GestureLongPress event.\n"); ... > Source/WebKit/chromium/src/WebViewImpl.cpp:779 > + if (m_linkHighlight && !m_linkHighlight->isAnimating()) > + m_linkHighlight->startHighlightAnimation(); This is just a small nit, but it almost seems like startHighlightAnimation() should internally make it impossible to call multiple times. For example, if it were startHighlightAnimationIfNeeded, then callers don't have to know about isAnimating or not and can't screw it up. > Source/WebKit/chromium/src/WebViewImpl.cpp:787 > + if (m_linkHighlight && !m_linkHighlight->isAnimating()) > + m_linkHighlight->startHighlightAnimation(); Are you maybe missing some "break" statements here in this switch statement? Surely GesturePinchBegin should not start and then immediately clear the link highlight?
W. James MacLean
Comment 3 2012-10-03 17:08:47 PDT
Comment on attachment 165178 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=165178&action=review >> Source/WebKit/chromium/src/LinkHighlight.cpp:-79 >> - // layer may be added to the tree immediately. > > Why is this comment no longer true? What has changed? In the old behaviour, we started the animation right away, and used this to display the highlight. In the new behaviour, we show the highlight right away, and do the following: - as long as the user holds their finger down, the highlight remains - after a delay GestureLongPress is received, cancelling the highlight, *or* - the user moves their finger to initiate GestureScrollBegin, and the highlight animates away, *or* - the use lifts their finger, completing GestureTap and the highlight disappears (we may or may not navigate away at this point). It used to be that that there was a delay in adding the highlight to the tree, then the animation started a brief time later, giving us time to cancel it before it ever appeared. >> Source/WebKit/chromium/src/WebViewImpl.cpp:747 >> + fprintf(stderr, "wjm: GestureLongPress event.\n"); > > ... D'oh! Removed ... >> Source/WebKit/chromium/src/WebViewImpl.cpp:779 >> + m_linkHighlight->startHighlightAnimation(); > > This is just a small nit, but it almost seems like startHighlightAnimation() should internally make it impossible to call multiple times. For example, if it were startHighlightAnimationIfNeeded, then callers don't have to know about isAnimating or not and can't screw it up. Yeah, I considered this, wasn't sure, and flipped a coin. I like the name change though - fixed. >> Source/WebKit/chromium/src/WebViewImpl.cpp:787 >> + m_linkHighlight->startHighlightAnimation(); > > Are you maybe missing some "break" statements here in this switch statement? Surely GesturePinchBegin should not start and then immediately clear the link highlight? Hmm, yes, this is muddled. Fixed in new patch.
W. James MacLean
Comment 4 2012-10-03 17:39:46 PDT
Adrienne Walker
Comment 5 2012-10-04 10:47:21 PDT
Comment on attachment 167008 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=167008&action=review Why are the tests in chromium-linux here too? Are there no link highlights on other platforms? > Source/WebKit/chromium/src/WebViewImpl.cpp:744 > + fprintf(stderr, "wjm: GestureTapDown event.\n"); ... > Source/WebKit/chromium/src/WebViewImpl.cpp:766 > + if (event.type == WebInputEvent::GestureScrollBegin || event.type == WebInputEvent::GestureTapCancel) Can I suggest pulling out all the link highlight behavior into its own switch statement where you just have a list of events that should fade out the highlight and a list of events that should clear the highlight, all in one place. This giant switch statement is hard enough to read as it is, and the gesture -> link highlight behavior mapping is undertested. I worry about somebody in the future adding a new gesture to this switch statement that might accidentally and incorrectly start cancelling link highlights.
W. James MacLean
Comment 6 2012-10-04 11:26:27 PDT
(In reply to comment #5) > (From update of attachment 167008 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=167008&action=review > > Why are the tests in chromium-linux here too? Are there no link highlights on other platforms? At present this is just used on ChromeOS (linux + touch-enabled). Once behaviour is vetted here, we will add Win 8 into the mix. > > Source/WebKit/chromium/src/WebViewImpl.cpp:744 > > + fprintf(stderr, "wjm: GestureTapDown event.\n"); > > ... > > > Source/WebKit/chromium/src/WebViewImpl.cpp:766 > > + if (event.type == WebInputEvent::GestureScrollBegin || event.type == WebInputEvent::GestureTapCancel) > > Can I suggest pulling out all the link highlight behavior into its own switch statement where you just have a list of events that should fade out the highlight and a list of events that should clear the highlight, all in one place. > > This giant switch statement is hard enough to read as it is, and the gesture -> link highlight behavior mapping is undertested. I worry about somebody in the future adding a new gesture to this switch statement that might accidentally and incorrectly start cancelling link highlights. I like the sound of that, will revise and upload a new patch.
W. James MacLean
Comment 7 2012-10-05 11:03:01 PDT
Adrienne Walker
Comment 8 2012-10-05 11:53:44 PDT
Comment on attachment 167351 [details] Patch R=me. Thanks for those changes. I feel like that's way easier to understand.
W. James MacLean
Comment 9 2012-10-05 11:58:09 PDT
Comment on attachment 167351 [details] Patch Agreed, they do make it easier to read ... thanks!
WebKit Review Bot
Comment 10 2012-10-05 12:05:40 PDT
Comment on attachment 167351 [details] Patch Clearing flags on attachment: 167351 Committed r130539: <http://trac.webkit.org/changeset/130539>
WebKit Review Bot
Comment 11 2012-10-05 12:05:45 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.