-
Notifications
You must be signed in to change notification settings - Fork 4
Treat "fire an event" and script execution blocks as "tasks" if outside document-associated task #37
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
Treat "fire an event" and script execution blocks as "tasks" if outside document-associated task #37
Changes from 5 commits
79f4e4c
b891acd
033ea36
0ede150
7285fb1
2f6aafa
19d2042
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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=]: | |
|
|
||
| : <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=]: | ||
|
|
@@ -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. | ||
| 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|: | ||
|
|
||
|
|
@@ -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-nulll. | ||
|
noamr marked this conversation as resolved.
Outdated
|
||
| 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> | ||
|
|
||
|
|
@@ -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 ends at the end of the [=fire an event=] algorithm rather than at the end of a single listener's execution. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not immediately obvious to me how this is set for event listeners. Can you point at the relevant algorithm?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's the [=fire an event=] algorithm I'm already pointing to :)
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reworded a bit, is this better? |
||
| </div> | ||
|
|
||
| <div algorithm="Applying source location"> | ||
|
|
@@ -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> | ||
|
|
||
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.