Bug 73647 - [Qt] [WK2] Use input event timestamps in WebEvents if available
Summary: [Qt] [WK2] Use input event timestamps in WebEvents if available
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P3 Normal
Assignee: Andras Becsi
URL:
Keywords: Qt
Depends on:
Blocks:
 
Reported: 2011-12-02 04:43 PST by Andras Becsi
Modified: 2011-12-02 06:46 PST (History)
4 users (show)

See Also:


Attachments
proposed patch (5.33 KB, patch)
2011-12-02 04:47 PST, Andras Becsi
no flags Details | Formatted Diff | Diff
proposed patch (4.62 KB, patch)
2011-12-02 04:51 PST, Andras Becsi
no flags Details | Formatted Diff | Diff
proposed patch (4.58 KB, patch)
2011-12-02 05:08 PST, Andras Becsi
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andras Becsi 2011-12-02 04:43:02 PST
Qt5 input events already have a native timestamp, use this timestamp in WK2's WebEventFactoryQt instead of WTF::currentTime if it is available.
Comment 1 Andras Becsi 2011-12-02 04:47:52 PST
Created attachment 117609 [details]
proposed patch
Comment 2 WebKit Review Bot 2011-12-02 04:49:45 PST
Attachment 117609 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebKit2/ChangeLog', u'Source/WebKit..." exit_code: 1

Source/WebKit2/Shared/qt/WebEventFactoryQt.h:45:  The parameter name "e" adds no information, so it should be removed.  [readability/parameter_name] [5]
Total errors found: 1 in 3 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Andras Becsi 2011-12-02 04:51:22 PST
Created attachment 117610 [details]
proposed patch

D'oh, qtcreator...
Comment 4 Kenneth Rohde Christiansen 2011-12-02 04:55:45 PST
Comment on attachment 117610 [details]
proposed patch

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

Looks ok

> Source/WebKit2/Shared/qt/WebEventFactoryQt.cpp:42
> +static inline double computeCurrentTimeSeconds(const QInputEvent* event)

InSeconds ? TimeSeconds sounds strange.

I think currentTimeForEvent(ev) would be fine
Comment 5 Andras Becsi 2011-12-02 05:08:00 PST
Created attachment 117611 [details]
proposed patch

Renamed to currentTimeForEvent.
Comment 6 Simon Hausmann 2011-12-02 05:32:51 PST
Comment on attachment 117611 [details]
proposed patch

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

> Source/WebKit2/Shared/qt/WebEventFactoryQt.cpp:51
> +    if (event->timestamp())
> +        return static_cast<double>(event->timestamp()) / 1000;
> +
> +    return WTF::currentTime();

Hrmm, a run-time check. Isn't this going to be cause all sorts of havoc if _some_ events had time stamps and some didn't?

Imagine: first mouse events has a time stamp, second one doesn't and we use WTF::currentTime(). What if by chance WTF::currentTime() is less than the previous time stamp?

Perhaps we should try to protect ourselves against this situation. Perhaps by keeping track which events (of which type that is) have a "native" time stamp and which ones require "emulation", and
we let the first event decide. This could even be done in debug builds only.

Perhaps this is overkill, just a thought. Otherwise I think the patch is good :)
Comment 7 Andras Becsi 2011-12-02 06:17:10 PST
(In reply to comment #6)
> (From update of attachment 117611 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=117611&action=review
> 
> > Source/WebKit2/Shared/qt/WebEventFactoryQt.cpp:51
> > +    if (event->timestamp())
> > +        return static_cast<double>(event->timestamp()) / 1000;
> > +
> > +    return WTF::currentTime();
> 
> Hrmm, a run-time check. Isn't this going to be cause all sorts of havoc if _some_ events had time stamps and some didn't?
> 
> Imagine: first mouse events has a time stamp, second one doesn't and we use WTF::currentTime(). What if by chance WTF::currentTime() is less than the previous time stamp?
> 
> Perhaps we should try to protect ourselves against this situation. Perhaps by keeping track which events (of which type that is) have a "native" time stamp and which ones require "emulation", and
> we let the first event decide. This could even be done in debug builds only.
> 

All the input events should have timestamps now so this scenario should never happen.
But when creating custom events someone forgets to set the timestamp this could be a real concern.
I'm going to land this patch as is and try to figure out something which could catch these cases in debug.
Comment 8 Andras Becsi 2011-12-02 06:45:54 PST
Comment on attachment 117611 [details]
proposed patch

Clearing flags on attachment: 117611

Committed r101791: <http://trac.webkit.org/changeset/101791>
Comment 9 Andras Becsi 2011-12-02 06:46:02 PST
All reviewed patches have been landed.  Closing bug.