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:

      +
    1. Set this event loop's last idle period start time to the + unsafe shared current time.

    2. +
    3. -

      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.

      • -
      +
        +
      1. +

        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.

        -
      2. +

        The cap of 50ms in the future is to ensure responsiveness to new user input + within the threshold of human perception.

        + -
      3. -

        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.

        -
      4. +
      5. Let hasPendingRenders be false.

      6. -
      7. If docs is not empty, then set hasARenderingOpportunity to - true and set this event loop's last render opportunity time to - taskStartTime.

      8. +
      9. +

        For each windowInSameLoop of the same-loop windows + for this event loop:

        -
      10. -

        Unnecessary rendering: Remove from docs all Document objects - which meet both of the following conditions:

        +
          +
        1. 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.

        2. -
            -
          • the user agent believes that updating the rendering of the Document's - node navigable would have no visible effect, and
          • +
          • Let timerCallbackEstimates be the result of + getting the values of + windowInSameLoop's map of active timers.

          • -
          • the Document's map of animation frame callbacks is empty.
          • -
          +
        3. For each timeoutDeadline of timerCallbackEstimates, if + timeoutDeadline is less than deadline, set + deadline to timeoutDeadline.

        4. +
        +
      11. + +
      12. +

        If hasPendingRenders is true, then:

        + +
          +
        1. +

          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.

          +
        2. + +
        3. If nextRenderDeadline is less than + deadline, then return nextRenderDeadline.

        4. +
        +
      13. + +
      14. Return deadline.

      15. +
    4. +
    5. 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

    6. +
    +
  • + +
  • +

    If this is a worker event loop, then:

    + +
    1. -

      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.

      -
      -
    2. +
        +
      1. Let now be the current high resolution time given the + DedicatedWorkerGlobalScope. HRT

      2. -
      3. For each fully active Document in docs, - reveal that Document.

      4. +
      5. Run the animation frame callbacks for that + DedicatedWorkerGlobalScope, passing in now as the + timestamp.

      6. -
      7. For each fully active Document in docs, flush - autofocus candidates for that Document if its node navigable - is a top-level traversable.

      8. +
      9. Update the rendering of that dedicated worker to reflect the current state.

      10. +
      -
    3. For each fully active Document in docs, run - the resize steps for that Document. CSSOMVIEW

    4. +

      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.

      + -
    5. For each fully active Document in docs, run - the scroll steps for that Document. CSSOMVIEW

    6. +
    7. 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.

    8. +
    +
  • + -
  • 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

  • +
      +
    1. Wait until at least one navigable whose active document's relevant agent's event loop is this event loop might have a + rendering opportunity.

    2. -
    3. For each fully active Document in docs, run - the fullscreen steps for that Document. FULLSCREEN

    4. +
    5. Let frameTimestamp be the unsafe shared current time.

    6. -
    7. 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:

      +
    8. +

      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:

        -
      1. Let canvas be the value of context's canvas attribute, if context is a - CanvasRenderingContext2D, or the associated OffscreenCanvas - object for context otherwise.

      2. +
      3. +

        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.

        • +
        -
      4. Set context's context lost - to true.

      5. +

        In the steps below that iterate over docs, each Document must be + processed in the order it is found in the list.

        + -
      6. Reset the rendering context to its default state given context.

      7. +
      8. +

        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.

        +
      9. -
      10. Let shouldRestore be the result of firing - an event named contextlost at - canvas, with the cancelable attribute - initialized to true.

      11. +
      12. If docs is not empty, then set this event loop's + last render opportunity time to taskStartTime.

      13. -
      14. If shouldRestore is false, then abort these steps.

      15. +
      16. +

        Unnecessary rendering: Remove from docs all Document objects + which meet both of the following conditions:

        -
      17. 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.

      18. +
          +
        • the user agent believes that updating the rendering of the Document's + node navigable would have no visible effect, and
        • -
        • Set context's context lost - to false.

        • +
        • the Document's map of animation frame callbacks is empty.
        • +
        + -
      19. Fire an event named contextrestored at canvas.

      20. -
      -
    9. +
    10. +

      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.

      +
      +
    11. -
    12. 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.

    13. +
    14. For each fully active Document in docs, + reveal that Document.

    15. -
    16. -

      For each fully active Document doc in - docs:

      +
    17. For each fully active Document in docs, flush + autofocus candidates for that Document if its node navigable + is a top-level traversable.

    18. -
        -
      1. Let resizeObserverDepth be 0.

      2. +
      3. For each fully active Document in docs, run + the resize steps for that Document. CSSOMVIEW

      4. -
      5. -

        While true:

        +
      6. For each fully active Document in docs, run + the scroll steps for that Document. CSSOMVIEW

      7. -
          -
        1. Recalculate styles and update layout for doc.

        2. +
        3. For each fully active Document in docs, + evaluate media queries and report changes for that Document. + CSSOMVIEW

        4. -
        5. Let hadInitialVisibleContentVisibilityDetermination be false.

        6. +
        7. 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

        8. -
        9. For each element element with 'auto' used value of 'content-visibility':

          -
            -
          1. 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.

          2. +
          3. For each fully active Document in docs, run + the fullscreen steps for that Document. FULLSCREEN

          4. + +
          5. +

            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:

            + +
              +
            1. Let canvas be the value of context's canvas attribute, if context is a + CanvasRenderingContext2D, or the associated OffscreenCanvas + object for context otherwise.

            2. + +
            3. Set context's context lost + to true.

            4. + +
            5. Reset the rendering context to its default state given context.

            6. + +
            7. Let shouldRestore be the result of firing + an event named contextlost at + canvas, with the cancelable attribute + initialized to true.

            8. + +
            9. If shouldRestore is false, then abort these steps.

            10. + +
            11. 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.

            12. + +
            13. Set context's context lost + to false.

            14. -
            15. Determine proximity to the viewport for element.

            16. +
            17. Fire an event named contextrestored at canvas.

            18. +
            +
          6. + +
          7. 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.

          8. + +
          9. +

            For each fully active Document doc in + docs:

            + +
              +
            1. Let resizeObserverDepth be 0.

            2. + +
            3. +

              While true:

              -
            4. If checkForInitialDetermination is true and element is now relevant to the user, +

                +
              1. Recalculate styles and update layout for doc.

              2. + +
              3. Let hadInitialVisibleContentVisibilityDetermination be false.

              4. + +
              5. +

                For each element element with 'auto' used value of + 'content-visibility':

                + +
                  +
                1. 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.

                2. + +
                3. Determine proximity to the viewport for element.

                4. + +
                5. If checkForInitialDetermination is true and element is now + relevant to the user, then set hadInitialVisibleContentVisibilityDetermination to true.

              6. -
              7. If hadInitialVisibleContentVisibilityDetermination is true, then continue.

                +
              8. If hadInitialVisibleContentVisibilityDetermination is true, then + continue.

                The intent of this step is for the initial viewport proximity @@ -108389,159 +108524,6 @@ import "https://example.com/foo/../module2.mjs"; docs run process top layer removals given doc.

            5. - -
            6. -

              If this is a window event loop, then run the following steps - in parallel:

              - -
                -
              1. 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.

              2. - -
              3. Let frameTimestamp be the unsafe shared current time.

              4. - -
              5. -

                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.

                -
              6. -
              -
            7. - -
            8. -

              If all of the following are true:

              - -
                -
              • this is a window event loop;
              • - -
              • there is no task in this event loop's - task queues whose document is fully active;
              • - -
              • this event loop's microtask queue is empty; and
              • - -
              • hasARenderingOpportunity is false,
              • -
              - -

              then: - -

                -
              1. Set this event loop's last idle period start time to the - unsafe shared current time.

              2. - -
              3. -

                Let computeDeadline be the following steps:

                - -
                  -
                1. -

                  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.

                  -
                2. - -
                3. Let hasPendingRenders be false.

                4. - -
                5. -

                  For each windowInSameLoop of the same-loop windows - for this event loop:

                  - -
                    -
                  1. 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.

                  2. - -
                  3. Let timerCallbackEstimates be the result of - getting the values of - windowInSameLoop's map of active timers.

                  4. - -
                  5. For each timeoutDeadline of timerCallbackEstimates, if - timeoutDeadline is less than deadline, set - deadline to timeoutDeadline.

                  6. -
                  -
                6. - -
                7. -

                  If hasPendingRenders is true, then:

                  - -
                    -
                  1. -

                    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.

                    -
                  2. - -
                  3. If nextRenderDeadline is less than - deadline, then return nextRenderDeadline.

                  4. -
                  -
                8. - -
                9. Return deadline.

                10. -
                -
              4. - -
              5. 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

              6. -
              -
            9. - -
            10. -

              If this is a worker event loop, then:

              - -
                -
              1. -

                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:

                - - -
                  -
                1. Let now be the current high resolution time given the - DedicatedWorkerGlobalScope. HRT

                2. - -
                3. Run the animation frame callbacks for that - DedicatedWorkerGlobalScope, passing in now as the - timestamp.

                4. - -
                5. Update the rendering of that dedicated worker to reflect the current state.

                6. -
                - -

                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.

                -
              2. - -
              3. 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.

              4. -
              -