diff --git a/source b/source index 98ee0cbb759..b55b778d8af 100644 --- a/source +++ b/source @@ -108122,195 +108122,330 @@ import "https://example.com/foo/../module2.mjs"; -
Let Update the rendering be the following steps given an - unsafe moment frameTimestamp:
+If this is a window event loopthat has no task in this event loop's + task queues whose document is fully active, then:
Set this event loop's last idle period start time to the + unsafe shared current time.
Let docs be all Document
objects whose relevant
- agent's event loop is this event loop,
- sorted arbitrarily except that the following conditions must be met:
Let computeDeadline be the following steps:
-Any Document
B whose container document is A must be listed
- after A in the list.
If there are two documents A and B that both have the same - non-null container document C, then - the order of A and B in the list must match the shadow-including - tree order of their respective navigable - containers in C's node tree.
Let deadline be this event loop's + last idle period start time plus 50.
-In the steps below that iterate over docs, each Document
must be
- processed in the order it is found in the list.
The cap of 50ms in the future is to ensure responsiveness to new user input + within the threshold of human perception.
+Rendering opportunities: Remove from docs all Document
- objects whose node navigables do not have a
- rendering opportunity.
A navigable has a rendering opportunity if the user agent is - currently able to present the contents of the navigable to the user, accounting - for hardware refresh rate constraints and user agent throttling for performance reasons, but - considering content presentable even if it's outside the viewport.
- -A navigable has no rendering
- opportunities if its active document is
- render-blocked or if it is suppressed for view transitions;
- otherwise, rendering opportunities are determined
- based on hardware constraints such as display refresh rates and other factors such as page
- performance or whether the document's visibility state is "visible
". Rendering opportunities typically occur at regular intervals.
This specification does not mandate any particular model for selecting - rendering opportunities. But for example, if the browser is attempting to achieve a 60Hz - refresh rate, then rendering opportunities occur at a maximum of every 60th of a second - (about 16.7ms). If the browser finds that a navigable is not able to sustain - this rate, it might drop to a more sustainable 30 rendering opportunities per second for that - navigable, rather than occasionally dropping frames. Similarly, if a - navigable is not visible, the user agent might decide to drop that page to a - much slower 4 rendering opportunities per second, or even less.
-Let hasPendingRenders be false.
If docs is not empty, then set hasARenderingOpportunity to - true and set this event loop's last render opportunity time to - taskStartTime.
For each windowInSameLoop of the same-loop windows + for this event loop:
-Unnecessary rendering: Remove from docs all Document
objects
- which meet both of the following conditions:
If windowInSameLoop's map of animation frame callbacks is + not empty, or if the user agent believes that the + windowInSameLoop might have pending rendering updates, set + hasPendingRenders to true.
Document
's
- node navigable would have no visible effect, andLet timerCallbackEstimates be the result of + getting the values of + windowInSameLoop's map of active timers.
Document
's map of animation frame callbacks is empty.For each timeoutDeadline of timerCallbackEstimates, if + timeoutDeadline is less than deadline, set + deadline to timeoutDeadline.
If hasPendingRenders is true, then:
+ +Let nextRenderDeadline be this event loop's + last render opportunity time plus (1000 divided by the current refresh + rate).
+ +The refresh rate can be hardware- or implementation-specific. For a refresh rate of + 60Hz, the nextRenderDeadline would be about 16.67ms after the + last render opportunity time.
+If nextRenderDeadline is less than + deadline, then return nextRenderDeadline.
Return deadline.
For each win of the same-loop windows for + this event loop, perform the start an idle period algorithm for + win with the following step: return the result of calling + computeDeadline, coarsened given win's + relevant settings object's cross-origin isolated + capability. REQUESTIDLECALLBACK
If this is a worker event loop, then:
+ +Remove from docs all Document
objects for which the user agent
- believes that it's preferable to skip updating the rendering for other reasons.
If this event loop's agent's single realm's global object is a supported
+ DedicatedWorkerGlobalScope
and the user agent believes that it would benefit from
+ having its rendering updated at this time, then:
The step labeled Rendering opportunities prevents the user agent from updating the - rendering when it is unable to present new content to the user (there's no rendering - opportunity).
- -The step labeled Unnecessary rendering prevents the user agent from updating the - rendering when there's no new content to draw.
- -This step enables the user agent to prevent the steps below from running for other - reasons, for example, to ensure certain tasks are executed - immediately after each other, with only microtask checkpoints interleaved (and without, e.g., animation frame callbacks interleaved). Concretely, a - user agent might wish to coalesce timer callbacks together, with no intermediate rendering - updates.
-Let now be the current high resolution time given the
+ DedicatedWorkerGlobalScope
. HRT
For each fully active Document
in docs,
- reveal that Document
.
Run the animation frame callbacks for that
+ DedicatedWorkerGlobalScope
, passing in now as the
+ timestamp.
For each fully active Document
in docs, flush
- autofocus candidates for that Document
if its node navigable
- is a top-level traversable.
Update the rendering of that dedicated worker to reflect the current state.
For each fully active Document
in docs, run
- the resize steps for that Document
. CSSOMVIEW
Similar to the notes for updating the + rendering in a window event loop, a user agent can determine the rate of + rendering in the dedicated worker.
+For each fully active Document
in docs, run
- the scroll steps for that Document
. CSSOMVIEW
If there are no tasks in the event
+ loop's task queues and the
+ WorkerGlobalScope
object's closing flag is true, then destroy the
+ event loop, aborting these steps, resuming the run a worker steps
+ described in the Web workers section below.
For each fully active Document
in docs,
- evaluate media queries and report changes for that Document
.
- CSSOMVIEW
A window event loop must also run the following in parallel, as long + as it exists:
-For each fully active Document
in docs,
- update animations and send events for that Document
, passing in
- relative high resolution time given frameTimestamp and that
- Document
's relevant global object as the timestamp.
- WEBANIMATIONS
Wait until at least one navigable whose active document's relevant agent's event loop is this event loop might have a + rendering opportunity.
For each fully active Document
in docs, run
- the fullscreen steps for that Document
. FULLSCREEN
Let frameTimestamp be the unsafe shared current time.
For each fully active Document
in docs, if
- the user agent detects that the backing storage associated with a
- CanvasRenderingContext2D
or an OffscreenCanvasRenderingContext2D
,
- context, has been lost, then it must run the context lost steps for each
- such context:
For each navigable that might have a rendering opportunity, + queue a global task on the rendering task source given + navigable's active document's + relevant global object to update the rendering:
Let canvas be the value of context's canvas
attribute, if context is a
- CanvasRenderingContext2D
, or the associated OffscreenCanvas
- object for context otherwise.
Let docs be all Document
objects whose relevant
+ agent's event loop is this event loop,
+ sorted arbitrarily except that the following conditions must be met:
Any Document
B whose container document is A must be listed
+ after A in the list.
If there are two documents A and B that both have the same + non-null container document C, then + the order of A and B in the list must match the shadow-including + tree order of their respective navigable + containers in C's node tree.
Set context's context lost - to true.
In the steps below that iterate over docs, each Document
must be
+ processed in the order it is found in the list.
Reset the rendering context to its default state given context.
Rendering opportunities: Remove from docs all Document
+ objects whose node navigables do not have a
+ rendering opportunity.
A navigable has a rendering opportunity if the user agent is + currently able to present the contents of the navigable to the user, accounting + for hardware refresh rate constraints and user agent throttling for performance reasons, but + considering content presentable even if it's outside the viewport.
+ +A navigable has no rendering
+ opportunities if its active document is
+ render-blocked or if it is suppressed for view transitions;
+ otherwise, rendering opportunities are determined
+ based on hardware constraints such as display refresh rates and other factors such as page
+ performance or whether the document's visibility state is "visible
". Rendering opportunities typically occur at regular intervals.
This specification does not mandate any particular model for selecting + rendering opportunities. But for example, if the browser is attempting to achieve a 60Hz + refresh rate, then rendering opportunities occur at a maximum of every 60th of a second + (about 16.7ms). If the browser finds that a navigable is not able to sustain + this rate, it might drop to a more sustainable 30 rendering opportunities per second for that + navigable, rather than occasionally dropping frames. Similarly, if a + navigable is not visible, the user agent might decide to drop that page to a + much slower 4 rendering opportunities per second, or even less.
+Let shouldRestore be the result of firing
- an event named contextlost
at
- canvas, with the cancelable
attribute
- initialized to true.
If docs is not empty, then set this event loop's + last render opportunity time to taskStartTime.
If shouldRestore is false, then abort these steps.
Unnecessary rendering: Remove from docs all Document
objects
+ which meet both of the following conditions:
Attempt to restore context by creating a backing storage using - context's attributes and associating them with context. If this fails, - then abort these steps.
Document
's
+ node navigable would have no visible effect, andSet context's context lost - to false.
Document
's map of animation frame callbacks is empty.Fire an event named contextrestored
at canvas.
Remove from docs all Document
objects for which the user agent
+ believes that it's preferable to skip updating the rendering for other reasons.
The step labeled Rendering opportunities prevents the user agent from updating the + rendering when it is unable to present new content to the user (there's no rendering + opportunity).
+ +The step labeled Unnecessary rendering prevents the user agent from updating the + rendering when there's no new content to draw.
+ +This step enables the user agent to prevent the steps below from running for other + reasons, for example, to ensure certain tasks are executed + immediately after each other, with only microtask checkpoints interleaved (and without, e.g., animation frame callbacks interleaved). Concretely, a + user agent might wish to coalesce timer callbacks together, with no intermediate rendering + updates.
+For each fully active Document
in docs, run
- the animation frame callbacks for that Document
, passing in the
- relative high resolution time given frameTimestamp and that
- Document
's relevant global object as the timestamp.
For each fully active Document
in docs,
+ reveal that Document
.
For each fully active Document
doc in
- docs:
For each fully active Document
in docs, flush
+ autofocus candidates for that Document
if its node navigable
+ is a top-level traversable.
Let resizeObserverDepth be 0.
For each fully active Document
in docs, run
+ the resize steps for that Document
. CSSOMVIEW
While true:
+For each fully active Document
in docs, run
+ the scroll steps for that Document
. CSSOMVIEW
Recalculate styles and update layout for doc.
For each fully active Document
in docs,
+ evaluate media queries and report changes for that Document
.
+ CSSOMVIEW
Let hadInitialVisibleContentVisibilityDetermination be false.
For each fully active Document
in docs,
+ update animations and send events for that Document
, passing in
+ relative high resolution time given frameTimestamp and that
+ Document
's relevant global object as the timestamp.
+ WEBANIMATIONS
For each element element with 'auto' used value of 'content-visibility':
-Let checkForInitialDetermination be true if element's - proximity to the viewport is not determined and it is not relevant to the user. - Otherwise, let checkForInitialDetermination be false.
For each fully active Document
in docs, run
+ the fullscreen steps for that Document
. FULLSCREEN
For each fully active Document
in docs, if
+ the user agent detects that the backing storage associated with a
+ CanvasRenderingContext2D
or an OffscreenCanvasRenderingContext2D
,
+ context, has been lost, then it must run the context lost steps for
+ each such context:
Let canvas be the value of context's canvas
attribute, if context is a
+ CanvasRenderingContext2D
, or the associated OffscreenCanvas
+ object for context otherwise.
Set context's context lost + to true.
Reset the rendering context to its default state given context.
Let shouldRestore be the result of firing
+ an event named contextlost
at
+ canvas, with the cancelable
attribute
+ initialized to true.
If shouldRestore is false, then abort these steps.
Attempt to restore context by creating a backing storage using + context's attributes and associating them with context. If this fails, + then abort these steps.
Set context's context lost + to false.
Determine proximity to the viewport for element.
Fire an event named contextrestored
at canvas.
For each fully active Document
in docs, run
+ the animation frame callbacks for that Document
, passing in the
+ relative high resolution time given frameTimestamp and that
+ Document
's relevant global object as the timestamp.
For each fully active Document
doc in
+ docs:
Let resizeObserverDepth be 0.
While true:
-If checkForInitialDetermination is true and element is now relevant to the user, +
Recalculate styles and update layout for doc.
Let hadInitialVisibleContentVisibilityDetermination be false.
For each element element with 'auto' used value of + 'content-visibility':
+ +Let checkForInitialDetermination be true if element's + proximity to the viewport is not determined and it is not + relevant to the user. + Otherwise, let checkForInitialDetermination be false.
Determine proximity to the viewport for element.
If checkForInitialDetermination is true and element is now + relevant to the user, then set hadInitialVisibleContentVisibilityDetermination to true.
If hadInitialVisibleContentVisibilityDetermination is true, then continue.
+If hadInitialVisibleContentVisibilityDetermination is true, then + continue.
If this is a window event loop, then run the following steps - in parallel:
- -Wait until at least one navigable navigable whose active document's relevant agent's event loop is this event loop might have a - rendering opportunity.
Let frameTimestamp be the unsafe shared current time.
For each navigable that might have a rendering opportunity, - queue a global task on the rendering task source given - navigable's active document's - relevant global object to update the rendering given - frameTimestamp.
- -The update the rendering steps would update all documents in this - event loop that have a rendering opportunity. The purpose of these - in parallel steps is to guarantee that the update the rendering step - is scheduled as a task.
-If all of the following are true:
- -then: - -
Set this event loop's last idle period start time to the - unsafe shared current time.
Let computeDeadline be the following steps:
- -Let deadline be this event loop's - last idle period start time plus 50.
- -The cap of 50ms in the future is to ensure responsiveness to new user input - within the threshold of human perception.
-Let hasPendingRenders be false.
For each windowInSameLoop of the same-loop windows - for this event loop:
- -If windowInSameLoop's map of animation frame callbacks is - not empty, or if the user agent believes that the - windowInSameLoop might have pending rendering updates, set - hasPendingRenders to true.
Let timerCallbackEstimates be the result of - getting the values of - windowInSameLoop's map of active timers.
For each timeoutDeadline of timerCallbackEstimates, if - timeoutDeadline is less than deadline, set - deadline to timeoutDeadline.
If hasPendingRenders is true, then:
- -Let nextRenderDeadline be this event loop's - last render opportunity time plus (1000 divided by the current refresh - rate).
- -The refresh rate can be hardware- or implementation-specific. For a refresh rate of - 60Hz, the nextRenderDeadline would be about 16.67ms after the - last render opportunity time.
-If nextRenderDeadline is less than - deadline, then return nextRenderDeadline.
Return deadline.
For each win of the same-loop windows for - this event loop, perform the start an idle period algorithm for - win with the following step: return the result of calling - computeDeadline, coarsened given win's - relevant settings object's cross-origin isolated - capability. REQUESTIDLECALLBACK
If this is a worker event loop, then:
- -If this event loop's agent's single realm's global object is a supported
- DedicatedWorkerGlobalScope
and the user agent believes that it would benefit from
- having its rendering updated at this time, then:
Let now be the current high resolution time given the
- DedicatedWorkerGlobalScope
. HRT
Run the animation frame callbacks for that
- DedicatedWorkerGlobalScope
, passing in now as the
- timestamp.
Update the rendering of that dedicated worker to reflect the current state.
Similar to the notes for updating the - rendering in a window event loop, a user agent can determine the rate of - rendering in the dedicated worker.
-If there are no tasks in the event
- loop's task queues and the
- WorkerGlobalScope
object's closing flag is true, then destroy the
- event loop, aborting these steps, resuming the run a worker steps
- described in the Web workers section below.