[webkit-dev] Constructors for DOM4 Events

Kentaro Hara haraken at chromium.org
Sun Sep 30 18:32:25 PDT 2012


TL;DR: Would it be OK to implement constructors for DOM4 Events in
WebKit without waiting for the spec?


== Background ==

Events should have constructors. 'new XXXEvent()' is much easier than
'e = document.createEvent(...); e.initXXXEvent(_a_lot_of_arguments_)'.
We have already implemented constructors for a bunch of Events such as
Event, CustomEvent, ProgressEvent, etc [5]. However, we have not yet
implemented constructors for DOM4 Events (i.e. UIEvent, MouseEvent,
KeyboardEvent, WheelEvent, TextEvent, CompositionEvent) because they
are not yet speced.

Recently PointerEvent was speced with [Constructor] [2]. Considering
that PointerEvent inherits MouseEvent, now we want to support
[Constructor] on MouseEvent
too. In terms of implementation, it is possible to implement
[Constructor] on PointerEvent without implementing [Constructor] on
MouseEvent. However, implementing [Constructor] on both PointerEvent
and MouseEvent would be best.

== Rationale for implementing constructors for DOM4 Events ==

I have been discussing this topic for one year, in www-dom@ [4] and a
www.w3.org bug [3]. It looks like there is a consensus on introducing
constructors for DOM4 Events. However, the spec is still a draft [1]
and the www.w3.org bug [3] is marked as LATER. Last week I discussed
the timeline of the spec with Jacob Rossi (a.k.a. a spec author of
PointerEvent and DOM4 Events). According to him:

- Their primary focus is on finishing DOM3 Events first.
- With DOM3 Events in Candidate Recommendation, they are going to
start working on the DOM4 Events. They will discuss it in TPAC.
- They will introduce constructors to DOM4 Events.

In summary, constructors for DOM4 Events are going to be speced, but
it will take time. So I would like to implement them in WebKit a bit
ahead of the spec (and thus implement PointerEvent constructors too).
If you have any concern, please let me know.


== References ==
[1] The spec draft by Jacob Rossi:
http://html5labs.interoperabilitybridges.com/dom4events/

[2] The spec of Pointer Events:
http://www.w3.org/Submission/pointer-events/

[3] www.w3.org bug:
https://www.w3.org/Bugs/Public/show_bug.cgi?id=14051

[4] Discussion on www-dom@:
http://lists.w3.org/Archives/Public/www-dom/2011OctDec/0081.html
http://lists.w3.org/Archives/Public/www-dom/2012JanMar/0025.html

[5] WebKit bug:
https://bugs.webkit.org/show_bug.cgi?id=67824


-- 
Kentaro Hara, Tokyo, Japan (http://haraken.info)


More information about the webkit-dev mailing list