On Mon, Jun 15, 2015 at 8:58 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> On 6/15/15 2:34 PM, Ilya Grigorik wrote:
>
>> DOMHighResTimeStamp now(optional (Window or WorkerGlobalScope)
>> timeOriginBasis);
>>
>
> (Window or Worker), I assume?
>
> - same behavior as previously when called without arguments - i.e. time
>> in ms from time origin of current context.
>>
>
> More precisely, from the time origin of the global of the Performance
> object that is the "this" value for the function call, right?
Yes to both of the above - thanks!
> As a result, if I get a timestamp from a worker or a different window I
>> can: receivedTimestamp - performance.now(sourceOfTimestamp) to translate
>> into current timeline?
>>
>
> No, it would have to be:
>
> receivedTimestamp +
> (performance.now() - performance.now(sourceOfTimestamp))
>
> and it took me a bit of thinking through the time origins to come up with
> that. :( Also, it will obviously be off by however long it takes to make
> one (or two, depending) performance.now() calls.
Right, good catch. Well, as an alternative route, we could do something
like this instead:
partial interface Performance {
DOMHighResTimeStamp translate(DOMHighResTimeStamp time, (Window or
Worker) timeSource);
};
As in, you give it the time and the timeSource it came from, and we
"translate" it into a timestamp relative to the "time origin of the global
of the Performance object that is the 'this' value for the functional
call".
Would that be a better route?