Bug 147740 - TouchEvent and Touch should have constructors
Summary: TouchEvent and Touch should have constructors
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: UI Events (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Beth Dakin
URL:
Keywords: InRadar
Depends on: 158883 162709 162713 162728 162734 162736 162757 162787 162806
Blocks:
  Show dependency treegraph
 
Reported: 2015-08-06 12:14 PDT by Rick Byers
Modified: 2016-10-04 08:57 PDT (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rick Byers 2015-08-06 12:14:55 PDT
Most UIEvents at this point have a DOM Event constructor.  TouchEvent is a notable exception.  It's not a big use case, but JS-generated events are sometimes useful and (IMHO) ideally all event types would be consistent in this regard.  Is there any interest in adding constructors to WebKit?  Should be trivial.

We (Touch Event Community Group) have recently added constructor definitions to the draft TouchEvents level 2 spec: http://w3c.github.io/touch-events/touchevents.html#touchevent-interface (bug: https://github.com/w3c/touch-events/issues/10).  Any feedback on the design?  I'm happy to make changes before pages start depending on the API.

http://crbug.com/508675 tracks shipping these in blink.
Comment 1 Rick Byers 2015-11-09 22:16:13 PST
Beth, is this little tweak something you hope to do at some point?
Comment 2 Beth Dakin 2015-11-09 23:07:11 PST
(In reply to comment #1)
> Beth, is this little tweak something you hope to do at some point?

Thanks for cc'ing me! Could be interesting. :-)
Comment 3 Radar WebKit Bug Importer 2016-05-03 08:04:55 PDT
<rdar://problem/26063585>
Comment 4 Rick Byers 2016-06-14 14:03:30 PDT
/cc grouts who seems to be doing other TouchEvents works (yay!)
Comment 5 Chris Dumez 2016-06-17 12:06:06 PDT
I am working on the TouchEvent constructor.
Comment 6 Chris Dumez 2016-06-17 14:34:11 PDT
Added a TouchEvent constructor via Bug 158883. It looks like WebKit on iOS already has a constructor for Touch so closing.
Comment 7 Rick Byers 2016-09-26 12:01:48 PDT
Chris, does the Touch constructor on iOS follow the spec (and normal DOM constructor pattern) in taking a dictionary?  foolip@ says he can only get it working by passing a list of parameters similar to createTouch.
Comment 8 Rick Byers 2016-09-26 12:02:54 PDT
Reference: https://codereview.chromium.org/2352333002/
Comment 9 Chris Dumez 2016-09-26 12:06:08 PDT
(In reply to comment #7)
> Chris, does the Touch constructor on iOS follow the spec (and normal DOM
> constructor pattern) in taking a dictionary?  foolip@ says he can only get
> it working by passing a list of parameters similar to createTouch.

It does not look like we support passing a Dictionary at the moment, it takes in a list of parameters :/
Comment 10 Rick Byers 2016-09-26 12:24:33 PDT
> It does not look like we support passing a Dictionary at the moment, it takes in a list of parameters :/

Ugh, yeah that's not going to be interoperable (the whole point of the constructors is to avoid having to keep extending a long argument list).

Ok if we reopen this to track getting WebKit passing this test?
https://github.com/w3c/web-platform-tests/blob/master/touch-events/touch-touchevent-constructor.html
Comment 11 Rick Byers 2016-09-28 11:26:00 PDT
Note that if issue 157269 isn't going to be fixed, than the Safari-specific TouchEvent constructor should probably also have a way to set these non-standard properties on TouchEvent.

I have now come across one script that is relying on these properties on Safari: http://s0.2mdn.net/instream/video/client.js, and as a result other libraries cannot move from initTouchEvent to the TouchEvent constructor without breaking this script.
Comment 12 Rick Byers 2016-09-28 11:26:47 PDT
Darn sorry, used the wrong hotword.  See "bug 15726" for the clientX/clientY issue above.
Comment 13 Rick Byers 2016-09-28 11:27:24 PDT
Damn damn, not my day :-)

See "bug 157269" for the clientX/clientY issue above.
Comment 14 Chris Dumez 2016-10-04 08:57:53 PDT
Resolved in sub-bugs.