diff --git a/index.bs b/index.bs index 1966b50..93f1941 100644 --- a/index.bs +++ b/index.bs @@ -60,6 +60,8 @@ urlPrefix: https://html.spec.whatwg.org/multipage/; spec: HTML; type: dfn; url: #running-script; text: running script; type: dfn; url: #muted-errors; for: classic script; text: muted errors; type: dfn; url: #cors-cross-origin; text: CORS cross-origin; + type: dfn; url: #implied-document; text: implied document; + type: dfn: url: #concept-task-document; text: document; for: task; urlPrefix: https://tc39.github.io/ecma262/; spec: ECMASCRIPT; type: dfn; url: #sec-code-realms; text: JavaScript Realms; urlPrefix: https://dom.spec.whatwg.org/; spec: DOM; @@ -362,6 +364,9 @@ It has the following [=struct/items=]: : pending script :: Null or a [=script timing info=], initially null. + + : script initiated + :: A boolean, initially false. script timing info is a [=struct=]. It has the following [=struct/items=]: @@ -415,6 +420,19 @@ Report Long Animation Frames {#loaf-processing-model} The relevant frame timing info for a {{Document}} |document| is its [=nearest same-origin root=]'s [=current frame timing info=]. +
+ To start recording task time if needed given an [=environment settings object=] |settingsObject|: + + Note: this is called from the [=fire an event=] algorithm and the [=create script entry point=] algorithm. + It starts recording frame timing info for the duration of the [=fire an event|event firing=] or [=create script entry point|script=], as if it was a task. + This accounts for script and event durations that are not associated with tasks, which would otherwise require an [=implied document=]. + + 1. If |settingsObject| is not a {{Document}} or its [=relevant frame timing info=] is non-null, then return false. + 1. [=Record task start time=] given the [=unsafe shared current time=] and |settingsObject|. + 1. Return true. +
+ +
To record task start time given a {{DOMHighResTimeStamp}} |unsafeTaskStartTime|, and a {{Document}} |document|: @@ -548,8 +566,8 @@ Report Long Animation Frames {#loaf-processing-model} 1. If |settings| is not a {{Window}}, then return. 1. Let |document| be |settings|'s {{Window/document}}. 1. Let |frameTimingInfo| be |document|'s [=relevant frame timing info=]. - 1. If |frameTimingInfo| is null or if |frameTimingInfo|'s [=frame timing info/pending script=] is not null, then return. - 1. Assert: |frameTimingInfo|'s [=frame timing info/pending script=]'s [=script timing info/invoker type=] is "`classic-script`". + 1. [=Assert=]: |frameTimingInfo| is non-null. + 1. If |frameTimingInfo|'s [=frame timing info/pending script=] is not null, then return. 1. Set |frameTimingInfo|'s [=frame timing info/pending script=]'s [=script timing info/execution start time=] to the [=unsafe shared current time=].
@@ -569,8 +587,10 @@ Report Long Animation Frames {#loaf-processing-model} 1. If |settings| is not a {{Window}}, then return. 1. Let |document| be |settings|'s {{Window/document}}. 1. If |document| is not [=fully active=] or {{Document/hidden}}, then return. + 1. Let |didStartRecording| be the result of calling [=start recording task time if needed=] given |document|. 1. Let |frameTimingInfo| be |document|'s [=relevant frame timing info=]. - 1. If |frameTimingInfo| is null, then return. + 1. [=Assert=]: |frameTimingInfo| is non-null. + 1. Set |frameTimingInfo|'s [=script initiated=] to |didStartRecording|. 1. If |frameTimingInfo|'s [=frame timing info/pending script=] is not null, then return. 1. Let |scriptTimingInfo| be a new [=script timing info=] whose [=script timing info/start time=] is the [=unsafe shared current time=], @@ -588,16 +608,21 @@ Report Long Animation Frames {#loaf-processing-model} 1. Let |document| be |settings|'s {{Window/document}}. 1. If |document| is not [=fully active=] or {{Document/hidden}}, then return. 1. Let |frameTimingInfo| be |document|'s [=relevant frame timing info=]. + 1. [=Assert=]: |frameTimingInfo| is not null. 1. Let |scriptTimingInfo| be |frameTimingInfo|'s [=frame timing info/pending script=]. + 1. Let |endTime| be the [=unsafe shared current time=]. 1. Set |frameTimingInfo|'s [=frame timing info/pending script=] to null. 1. If |scriptTimingInfo| is null, then return. - 1. Set |scriptTimingInfo|'s [=script timing info/end time=] to the [=unsafe shared current time=]. + 1. Set |scriptTimingInfo|'s [=script timing info/end time=] to |endTime|. 1. If |script| is a [=classic script=] whose [=classic script/muted errors=] is true, then: 1. set |scriptTimingInfo|'s [=script timing info/source url=] to the empty string. 1. set |scriptTimingInfo|'s [=script timing info/source character position=] to -1. 1. set |scriptTimingInfo|'s [=script timing info/source function name=] to the empty string. 1. If the [=duration=] between |scriptTimingInfo|'s [=script timing info/start time=] and |scriptTimingInfo|'s [=script timing info/end time=] is greater than 5 milliseconds, then [=list/append=] |scriptTimingInfo| to |frameTimingInfo|'s [=frame timing info/scripts=]. + 1. If |frameTimingInfo| is [=frame timing info/script initiated=], then [=record task end time=] given |endTime| and |document|. + + Note: For event listeners, the task lifetime is managed by the [=fire an event=] algorithm, which may invoke multiple listeners to the same event, rather than at the end of a single listener's execution.
@@ -614,8 +639,8 @@ Report Long Animation Frames {#loaf-processing-model} 1. If |settings| is not a {{Window}}, then return. 1. Let |document| be |settings|'s {{Window/document}}. 1. If |document| is not [=fully active=] or {{Document/hidden}}, then return. - 1. Let |frameTimingInfo| be |document|'s [=relevant frame timing info=]. - 1. If |frameTimingInfo| is null, then return. + 1. Let |frameTimingInfo| be the [=relevant frame timing info=] given |document|. + 1. Assert: |frameTimingInfo| is not null. 1. If |frameTimingInfo|'s [=frame timing info/pending script=] is null, then return. 1. Increment |frameTimingInfo|'s [=frame timing info/pending script=]'s [=script timing info/pause duration=] by the milliseconds value of |duration|.