From 0f4aab063c416de9e4957578ad12aa44c0a0d1cc Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Fri, 15 Oct 2021 15:59:45 +0300 Subject: [PATCH] Revamp after PR review --- source | 142 ++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 89 insertions(+), 53 deletions(-) diff --git a/source b/source index 945f182913c..e97c4147120 100644 --- a/source +++ b/source @@ -2184,6 +2184,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute position variable
  • skip ASCII whitespace
  • The ordered map data structure and the associated definitions for + key, value, entry, exists, @@ -2191,7 +2192,9 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute setting the value of an entry, removing an entry, clear, + empty, getting the keys, + getting the values, size, and iterate
  • The list data structure and the associated definitions for @@ -4089,7 +4092,6 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute @@ -88978,7 +88980,7 @@ dictionary PageTransitionEventInit : EventInitforcibly close eventSource.

  • -
  • Empty window's list of active timers.

  • +
  • Empty window's map of active timers.

  • @@ -93188,16 +93190,15 @@ import "https://example.com/foo/../module2.mjs"; which is initially false. It is used to prevent reentrant invocation of the perform a microtask checkpoint algorithm.

    -

    Each window event loop has a DOMHighResTimeStamp +

    Each window event loop has a DOMHighResTimeStamp last render opportunity time, initially set to zero.

    -

    Each window event loop has a DOMHighResTimeStamp +

    Each window event loop has a DOMHighResTimeStamp last idle period start time, initially set to zero.

    -

    To get the same-loop windows for a - window event loop loop, return all Window objects whose - relevant agent's event loop is - loop.

    +

    To get the same-loop windows for a window event loop loop, + return all Window objects whose relevant agent's + event loop is loop.

    Queuing tasks
    @@ -93579,46 +93580,73 @@ import "https://example.com/foo/../module2.mjs";
  • this event loop's microtask queue is empty
  • hasARenderingOpportunity is false
  • -
  • -

    currently running task's source is - not the idle-task task source - -

    This is to ensure that the idle tasks themselves don't generate a new idle - period. See - requestIdleCallback #96.

    -
  • -

    then for each Window win in the same-loop windows for - this event loop, start an idle period for win with the - following steps to compute the current idle period deadline:

    +

    then:

    1. -

      Let deadline be this event loop's - last idle period start time plus 50.

      +

      Let computeDeadline be the following steps:

      -

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

      -
    2. +
        +
      1. +

        Let deadline be this event loop's + last idle period start time plus 50.

        -
      2. Check for potential pending rendering: If any Window in the - same-loop windows for this event loop's map of animation frame - callbacks is not empty, or if the user agent believes that the Window - might have pending rendering updates, set deadline to this event loop's - last render opportunity time plus 16, if it is less than - deadline.

      3. +

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

        + -
      4. Check for pending timers: for each Window win in the - same-loop windows for this event loop: For each timerEntry - in window's list of active timers, set deadline to the - result of calling timerEntry's estimate next callback time if it is - less than deadline.

      5. +
      6. Let hasPendingRenders be false. -

      7. If deadline is less than the current high resolution time, - return zero.

      8. +
      9. +

        For each Window windowInSameLoop the same-loop windows + for this event loop, do the following:

        -
      10. Return deadline.

      11. +
          +
        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 estimate in timerCallbackEstimates, do the + following:

          + +
            +
          1. Let timeoutDeadline be the result of calling + estimateTimerCallback.

          2. + +
          3. If timeoutDeadline is less than deadline, set + deadline to timeoutDeadline.

          4. +
          +
        6. +
        + + +
      12. +

        If hasPendingRenders is true, then:

        + +
          +
        1. Let nextRenderDeadline be this event loop's + last render opportunity time plus 16.

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

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

      15. +
      + + +
    3. For each Window win in the same-loop windows for + this event loop, start an idle period for win with + computeDeadline.

  • @@ -96035,10 +96063,16 @@ enum DOMParserSupportedType {

    Objects that implement the WindowOrWorkerGlobalScope mixin have a list of active timers. Each entry in this lists is identified by a number, which must - be unique within the list for the lifetime of the object that implements the - WindowOrWorkerGlobalScope mixin, and has an estimate next callback time, - an algorithm returing a DOMHighResTimestamp.

    + export>map of active timers, which is a map, initially empty. Each + key in this map is identified by a number, which must be unique + within the list for the lifetime of the object that implements the + WindowOrWorkerGlobalScope mixin, and each value is an + algorithm returing a DOMHighResTimeStamp, representing the next estimated callback + time for that timer.

    + +

    To get the list of active timers for WindowOrWorkerGlobalScope + global, return the result of getting + the keys for global's map of active timers.


    @@ -96062,14 +96096,12 @@ enum DOMParserSupportedType { id="dom-windowtimers-clearTimeout">clearTimeout(handle) and clearInterval(handle) methods must - clear the entry identified as handle from the list of active timers of the - WindowOrWorkerGlobalScope object on which the method was invoked, if any, where - handle is the argument passed to the method. (If handle does not identify an - entry in the list of active timers of the WindowOrWorkerGlobalScope - object on which the method was invoked, the method does nothing.)

    + remove map of active timers[handle] of + the WindowOrWorkerGlobalScope object on which the method was invoked, if any, where + handle is the argument passed to the method.

    Because clearTimeout() and clearInterval() clear entries from the same list, either method + data-x="dom-clearInterval">clearInterval() clear entries from the same map, either method can be used to clear timers created by setTimeout() or setInterval().

    @@ -96106,8 +96138,8 @@ enum DOMParserSupportedType { following substeps:

      -
    1. If the entry for handle in the list of active timers has been - cleared, then abort these steps.

    2. +
    3. If handle does not exist in the + map of active timers, then abort these steps.

    4. Run the appropriate set of steps from the following list:

      @@ -96207,8 +96239,8 @@ enum DOMParserSupportedType {
    5. Let startTime be the current high resolution time.

    6. -

      Set the estimate next callback time algorithm for the entry in the - list of active timers associated with handle to the following steps:

      +

      Set map of active timers[handle] to the + following steps:

      1. @@ -96216,6 +96248,9 @@ enum DOMParserSupportedType { plus the duration in milliseconds in which the document has not been fully active since startTime, plus a number representing an implementation-defined length of time in milliseconds.

        + +

        The implementation-defined extra times allows implementation to extend the + length of timeout according to its own heuristics and optimizations.

      2. Let now be the current high resolution time.

      3. @@ -102345,7 +102380,8 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope
      4. -

        Empty the worker global scope's list of active timers.

        +

        Clear the worker global scope's + map of active timers.