Skip to content

Commit

Permalink
Make Event's timeStamp use DOMHighResTimeStamp
Browse files Browse the repository at this point in the history
  • Loading branch information
majido authored and annevk committed Jul 13, 2017
1 parent c4c1c8b commit 912d587
Showing 1 changed file with 34 additions and 11 deletions.
45 changes: 34 additions & 11 deletions dom.bs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ urlPrefix: https://w3c.github.io/ServiceWorker/#; spec: SERVICE-WORKERS
urlPrefix: https://tc39.github.io/ecma262/#; spec: ECMASCRIPT
text: Construct; url: sec-construct; type: abstract-op
text: Realm; url: realm; type: dfn
urlPrefix: https://w3c.github.io/hr-time/#; spec: HR-TIME
type:typedef; urlPrefix: dom-; text: DOMHighResTimeStamp
type:dfn; text: time origin
type:dfn; text: clock resolution

</pre>

<pre class=link-defaults>
Expand Down Expand Up @@ -465,7 +470,7 @@ interface Event {
readonly attribute boolean composed;

[Unforgeable] readonly attribute boolean isTrusted;
readonly attribute DOMTimeStamp timeStamp;
readonly attribute DOMHighResTimeStamp timeStamp;

void initEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false); // historical
};
Expand Down Expand Up @@ -571,8 +576,8 @@ algorithm below.
false otherwise.

<dt><code><var>event</var> . {{Event/timeStamp}}</code>
<dd>Returns the creation time of <var>event</var> as the number of milliseconds that
passed since 00:00:00 UTC on 1 January 1970.
<dd>Returns the <var>event</var>'s timestamp as the number of milliseconds measured relative to
the <a>time origin</a>.
</dl>

The <dfn attribute for=Event><code>type</code></dfn> attribute must
Expand Down Expand Up @@ -704,15 +709,12 @@ initialized to false.
the user agent to dispatch an <a>event</a> whose {{Event/isTrusted}} attribute is initialized to
false.

The <dfn attribute for=Event><code>timeStamp</code></dfn> attribute
must return the value it was initialized to. When an
<a>event</a> is created the attribute must be
initialized to the number of milliseconds that have passed since
00:00:00 UTC on 1 January 1970, ignoring leap seconds.
<!-- leap seconds are ignored by JavaScript too -->
The <dfn attribute for=Event><code>timeStamp</code></dfn> attribute must return the value it was
initialized to.

<p class=XXX>This is highly likely to change and already does not reflect implementations well.
Please see <a href=https://github.com/whatwg/dom/issues/23>dom #23</a> for more details.
<p class=warning> User agents are strongly encouraged to set minimum resolution of the
{{Event/timeStamp}} attribute to 5 microseconds following the existing <a>clock resolution</a>
recommendation. [[!HR-TIME]]

<hr>

Expand Down Expand Up @@ -817,6 +819,10 @@ must be run, given the arguments <var>type</var> and <var>eventInitDict</var>:

<li><p>Initialize <var>event</var>'s {{Event/type}} attribute to <var>type</var>.

<li><p>Initialize <var>event</var>'s {{Event/timeStamp}} attribute to a {{DOMHighResTimeStamp}}
representing the high resolution time from the <a>time origin</a> to the occurrence of the call
to the <var>event</var>'s <a>constructor</a>.

<li><p>For each <a>dictionary member</a> present in <var>eventInitDict</var>, find the attribute on
<var>event</var> whose <a spec=webidl>identifier</a> matches the key of the
<a>dictionary member</a> and then set the attribute to the value of that <a>dictionary member</a>.
Expand Down Expand Up @@ -849,6 +855,16 @@ it, and optionally given a <a>Realm</a> <var>realm</var>, run these steps:</p>
<a>dictionary member</a> and then set the attribute to the default value of that
<a>dictionary member</a>.

<li><p>Set <var>event</var>'s {{Event/timeStamp}} attribute to a {{DOMHighResTimeStamp}}
representing the high resolution time from the <a>time origin</a> to the occurrence that the
event is signaling.

<p class=note>For example, in macOS the occurrence time for input actions are available via the
timestamp property of corresponding <code>NSEvent</code> objects. So in this case, the
{{Event/timeStamp}} value should be equivalent to the <code>NSEvent</code>'s timestamp offset by
<a>time origin</a>, translated in milliseconds, and with its precision adjusted to meet the
recommended minimum <a>clock resolution</a>.

<li><p>Initialize <var>event</var>'s {{Event/isTrusted}} attribute to true.

<li><p>Return <var>event</var>.
Expand Down Expand Up @@ -5111,6 +5127,9 @@ invoked, must run these steps:

<li><p>Initialize <var>event</var>'s {{Event/type}} attribute to the empty string.

<li><p>Initialize <var>event</var>'s {{Event/timeStamp}} attribute to a {{DOMHighResTimeStamp}}
representing the high resolution time from the <a>time origin</a> to now.

<li><p>Initialize <var>event</var>'s {{Event/isTrusted}} attribute to false.

<li><p>Unset <var>event</var>'s <a>initialized flag</a>.
Expand Down Expand Up @@ -9517,6 +9536,9 @@ other chapters are defined by the <cite>UI Events</cite> specification.
<li>The propagation and canceled flags are unset when invoking
{{Event/initEvent()}} rather than after
dispatch.
<li>{{Event/timeStamp}} is no longer a {{DOMTimeStamp}} representing creation time of event as
the number of milliseconds that passed since 00:00:00 UTC on 1 January 1970, but instead a
{{DOMHighResTimeStamp}}.
</ul>


Expand Down Expand Up @@ -9778,6 +9800,7 @@ Kirill Topolyan,
Koji Ishii,
Lachlan Hunt,
Lauren Wood,
Majid Valipour,
Malte Ubl,
Manish Goregaokar,
Manish Tripathi,
Expand Down

0 comments on commit 912d587

Please sign in to comment.