Skip to content
Merged
Changes from all commits
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
37 changes: 31 additions & 6 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -362,6 +364,9 @@ It has the following [=struct/items=]:

: <dfn>pending script</dfn>
:: Null or a [=script timing info=], initially null.

: <dfn>script initiated</dfn>
:: A boolean, initially false.
</dl>

<dfn export>script timing info</dfn> is a [=struct=]. It has the following [=struct/items=]:
Expand Down Expand Up @@ -415,6 +420,19 @@ Report Long Animation Frames {#loaf-processing-model}
The <dfn>relevant frame timing info</dfn> for a {{Document}} |document| is its [=nearest same-origin root=]'s [=current frame timing info=].
</div>

<div algorithm="Record if needed">
To <dfn export>start recording task time if needed</dfn> given an [=environment settings object=] |settingsObject|:

Note: this is called from the [=fire an event=] algorithm and the [=create script entry point=] algorithm.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IIUC, "fire an event" doesn't directly call this, but indirectly calls "create script entry point", which calls this. It might be good to rephrase

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ah I see the confusion. This needs a corresponding DOM PR. I'll post one and link them.

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.
</div>


<div algorithm="Record task start time">
To <dfn export>record task start time</dfn> given a {{DOMHighResTimeStamp}} |unsafeTaskStartTime|, and a {{Document}} |document|:

Expand Down Expand Up @@ -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=].
</div>

Expand All @@ -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=],
Expand All @@ -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.
</div>

<div algorithm="Applying source location">
Expand All @@ -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|.
</div>
Expand Down
Loading