Bug 39493

Summary: Touch events do not affect the :active CSS state
Product: WebKit Reporter: Ben Murdoch <benm>
Component: WebCore Misc.Assignee: Ben Murdoch <benm>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, android-webkit-unforking, commit-queue, eric, gdk, hausmann, kim.1.gronholm, simon.fraser, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 32485    
Attachments:
Description Flags
Proposed patch and test.
none
Patch and layout test changes.
none
Rebased patch / layout test.
none
Rebased patch / layout test, fixed style error.
steveblock: review+, benm: commit-queue-
Use a typedef as suggested.
simon.fraser: review-
Patch with typedef. none

Description Ben Murdoch 2010-05-21 09:04:42 PDT
When using touch events, clicking an element with an active state defined in CSS does not cause a transition into that state.

I'm working on a patch for this.
Comment 1 Ben Murdoch 2010-05-24 07:36:41 PDT
Created attachment 56884 [details]
Proposed patch and test.
Comment 2 WebKit Review Bot 2010-05-24 07:41:55 PDT
Attachment 56884 [details] did not pass style-queue:

Failed to run "['WebKitTools/Scripts/check-webkit-style', '--no-squash']" exit_code: 1
WebCore/page/EventHandler.cpp:2771:  A case label should not be indented, but line up with its switch statement.  [whitespace/indent] [4]
Total errors found: 1 in 9 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Ben Murdoch 2010-05-24 07:48:21 PDT
Created attachment 56886 [details]
Patch and layout test changes.

Correct style on switch statement.
Comment 4 Ben Murdoch 2010-06-07 05:02:20 PDT
ping .... thoughts anyone? :)
Comment 5 Kim Grönholm 2010-06-08 01:07:59 PDT
Hi Ben and sorry for late reply.

I was thinking about the definition of the :active pseudo-class:
"•The :active pseudo-class applies while an element is being activated by the user. For example, between the times the user presses the mouse button and releases it. On systems with more than one mouse button, :active applies only to the primary or primary activation button (typically the "left" mouse button), and any aliases thereof." (http://www.w3.org/TR/css3-selectors/#the-user-action-pseudo-classes-hover-act)

Should we only do transition to the active state from left mouse button events since those are the ones that actually activate e.g. a link? And then mapping touch events to mouse events on system/whatever level makes the links work and also enable the active state transitions (since eventhandler thinks that left mouse button was used).

This is just a thought, what do you think?
Comment 6 Ben Murdoch 2010-06-08 11:57:10 PDT
(In reply to comment #5)

Hey Kim,

Thanks for the comments. We don't convert the touches on android to  mouse events until the touch sequence is complete - i.e. the finger is released again, by which time the active class wouldn't apply anymore. Although they are similar, I don't think mouse and touch events are the same enough to do conversion sooner than this. We don't know the intent of the user's touch until later - were they just meaning to pan the page or perform a long press for the context menu for example (in which case we wouldn't want to trigger links/send mouse events to webcore ... or set the active state).

There's a good example of using active on divs with touch handlers at this page: http://xdev.org/anim/browser/ the divs should turn blue while you are touching them. The motivation behind trying to come up with a fix for this is to bring WebKit touch support in line with that of the iPhone :)

Cheers, Ben
Comment 7 Kim Grönholm 2010-06-08 12:35:35 PDT
Ah.. Right, that's a good point, I see now :) And it is common not to send the left mouse button press immediately.. This is fine on my behalf.
Comment 8 Ben Murdoch 2010-07-12 03:17:12 PDT
Thanks for taking a look Kim. I suspect that I'll need to rebase this patch now but rather than just uploading a new rebased one I could also make any changes that reviewers suggest at the same time. Any thoughts guys? :)

Thanks, Ben
Comment 9 Ben Murdoch 2010-07-20 05:55:51 PDT
Created attachment 62058 [details]
Rebased patch / layout test.
Comment 10 WebKit Review Bot 2010-07-20 06:01:13 PDT
Attachment 62058 [details] did not pass style-queue:

Failed to run "['WebKitTools/Scripts/check-webkit-style']" exit_code: 1
WebCore/page/EventHandler.cpp:2857:  A case label should not be indented, but line up with its switch statement.  [whitespace/indent] [4]
Total errors found: 1 in 8 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 11 Ben Murdoch 2010-07-20 06:07:29 PDT
Created attachment 62063 [details]
Rebased patch / layout test, fixed style error.
Comment 12 Ben Murdoch 2010-07-20 07:26:31 PDT
Hmm, strange that the Mac EWS isn't happy - built fine for me locally.

I'm trying a clean build locally to try and see what the problem is.
Comment 13 Ben Murdoch 2010-07-20 08:33:38 PDT
Hmm, built completely fine on my local machine. Perhaps some flakiness in the bot... doesn't seem to provide any extra information other than "fail"...
Comment 14 Steve Block 2010-07-20 08:48:16 PDT
Comment on attachment 62063 [details]
Rebased patch / layout test, fixed style error.

Kim's the expert here, but given his previous review, r=me
Comment 15 Ben Murdoch 2010-07-21 02:14:47 PDT
Comment on attachment 62063 [details]
Rebased patch / layout test, fixed style error.

I can't repro the Mac build problem, so going to try landing. Will watch the build pages carefully.
Comment 16 Ben Murdoch 2010-07-21 03:06:34 PDT
Patch landed as r63807; there was a break on Mac (not sure why it didn't repro on my local MacBook build though) and the fix for that break (simple xcodeproj update) landed in r63808.
Comment 17 Simon Fraser (smfr) 2010-07-21 09:55:26 PDT
Using an int for hitType is ugly. This should be a typedef.
Comment 18 Ben Murdoch 2010-07-21 11:59:43 PDT
Created attachment 62215 [details]
Use a typedef as suggested.
Comment 19 Ben Murdoch 2010-07-21 12:01:10 PDT
Reopening based on SImon's comments.
Comment 20 Simon Fraser (smfr) 2010-07-21 12:05:19 PDT
Comment on attachment 62215 [details]
Use a typedef as suggested.

You should use the same type in HitTestRequest, like this:

class HitTestRequest {
public:
    enum RequestTypeFlags {
        ReadOnly = 1 << 1,
        ...
    };

    typedef unsigned HitTestRequestType;

    HitTestRequest(HitTestRequestType requestType) ...

private:
    HitTestRequestType m_requestType;
}
etc.
Comment 21 Ben Murdoch 2010-07-21 12:53:15 PDT
Created attachment 62222 [details]
Patch with typedef.

I couldn't find anywhere else in WebCore that is using an int/unsigned for this purpose that needed updating. WDYT?

Thanks, Ben
Comment 22 Simon Fraser (smfr) 2010-07-21 13:34:53 PDT
Comment on attachment 62222 [details]
Patch with typedef.

r=me. Thanks for the cleanup!
Comment 23 WebKit Commit Bot 2010-07-22 07:07:33 PDT
Comment on attachment 62222 [details]
Patch with typedef.

Clearing flags on attachment: 62222

Committed r63888: <http://trac.webkit.org/changeset/63888>
Comment 24 Adam Barth 2010-08-10 22:42:11 PDT
This patch claims to have been landed.