Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Event.timeStamp type to DOMHighResTimeStamp. #420

Merged
merged 7 commits into from
Jul 13, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions dom.bs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ 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/#
type:typedef; urlPrefix: dom-; text: DOMHighResTimeStamp
type:dfn; text: time origin
</pre>

<pre class='link-defaults'>
Expand Down Expand Up @@ -522,7 +525,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 @@ -628,8 +631,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
from the <a>time origin</a>.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that this term is also important for the normative definition, yet it doesn't appear there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

relative to, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

</dl>

The <dfn attribute for=Event><code>type</code></dfn> attribute must
Expand Down Expand Up @@ -761,15 +764,14 @@ 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. If available, the attribute should be initialized with the high resolution time of
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we enumerate when it's not?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that for synthetic events this would never be available.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by synthetic events? If you are referring to those constructed in Javascript then that is probably correct and what for example Chrome implementation does. (BTW, I think issue #76 is proposing to make timestamp a constructor argument in which case this is not true anymore)

There may be other implementation related restrictions that makes the precise occurrence time unavailable. For example on some platforms (e.g., older Windows) there is no cross-process monotonic clock which in browsers with multi-process architecture can mean we cannot use the original timestamp. Or sometimes the driver uses a different clock and timestamp is not reliable. In such cases we end up using the closest estimation we can get. I think falling back to "creation time" is acceptable here too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, a synthetic event is basically a "userland" event. It would be good if we were consistent in what value it would get there (and yes, maybe at some point we allow custom values there, but that would just end up being a branch there).

I'm not really sure how to best do it though. I only have a long term vision where user interaction events are defined in much more detail and they end up initializing this attribute properly (and by default it's just creation time, whatever that means).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I now have exact details on what to use for synthetic events (i.e., use construction time).

the occurrence that the event is signaling, for example the moment when a particular user
interaction occurred. Otherwise it should be initialized with the time representing the creation
time of the <var>event</var>.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: "s/the time representing the creation time/the creation time"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


<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=note>User agents are encouraged to make the high resolution time occurrence time
available for as many events as possible in particular those related to user interaction.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: comma after "as possible"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


<hr>

Expand Down Expand Up @@ -9569,6 +9571,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