From 1866cffcb41af9ad94ff662963237e1752d15c64 Mon Sep 17 00:00:00 2001 From: James Graham Date: Tue, 7 Jan 2025 09:22:34 +0000 Subject: [PATCH] Improve support for actions involving multiple navigables This makes the following changes: * Actions are always dispatched first to the top-level traversable rather than directly to the target navigable. It is assumed that the action will end up interacting with the target traversable, but may not e.g. if there is an element obscuring the target, or the focus is in the wrong place. * To support the above, coordinates are computed relative to the viewport of the top-level traversable rather than the target navigable. * A new coordinate origin type is introduced which has the form: ``` { type: "viewport", context: } ``` This is designed to allow targeting inside a specific iframe without that iframe needing to be the target of the overall actions chain. The existing behaviour that if the main target navigable is deleted the action chain is terminated remains. This makes the behaviour consistent between top-level traversables and iframes, and also between different actions. --- index.html | 180 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 125 insertions(+), 55 deletions(-) diff --git a/index.html b/index.html index 88179a51..899ab5b3 100644 --- a/index.html +++ b/index.html @@ -8093,37 +8093,36 @@

Input state

To get the input state given session -and browsing context: +and top-level traversable:

    -
  1. Assert: browsing context is a top-level browsing +

  2. Assert: top-level traversable is a top-level browsing context.

  3. Let input state map be session's browsing context input state map.

  4. If input state map does not - [=map/exist|contain=] browsing context, set input - state map[browsing context] to create an input + [=map/exist|contain=] top-level traversable, set input + state map[top-level traversable] to create an input state. -

  5. Return input state map[browsing - context]. +

  6. Return input state map[top-level traversable].

To reset the input state given session -and browsing context: +and top-level traversable:

    -
  1. Assert: browsing context is a top-level browsing +

  2. Assert: top-level traversable is a top-level browsing context.

  3. Let input state map be session's browsing context input state map. -

  4. If input state map[browsing context] - [=map/exists=], then [=remove=] input state map[browsing - context]. +

  5. If input state map[top-level + traversable] [=map/exists=], then [=remove=] + input state map[top-level traversable].

To create an input state: @@ -8286,7 +8285,7 @@

Ticks

content observable effects that must be consistent across implementations. To accommodate this, the specification requires that remote ends perform implementation-specific action - dispatch steps on a browsing context context, + dispatch steps on a navigable context, and a list of events and their properties. These steps must be equivalent to performing the given input device manipulations on context, such that trusted events corresponding to the @@ -8341,10 +8340,16 @@

Processing actions

To get coordinates relative to an origin given source, x offset, y offset, -origin, browsing context, and actions +origin, target navigable, and actions options:

    +
  1. Let top-level traversable be target + navigable&pos;s [=navigable/top-level traversable=]. + +

  2. Let origin navigable be target + navigable. +

  3. Run the substeps of the first matching value of origin

    @@ -8371,12 +8376,36 @@

    Processing actions

+
An Object where getting a property + named "type" results in "viewport" +
+
    +
  1. Let origin navigable id be the result + of getting a property named "context" + from origin. + +

  2. Set origin navigable to the result of + trying to [=get a navigable=] with + origin navigable. + +

  3. If origin navigable is no longer open, + return error with error code no such window. + +

  4. If origin navigable&pos;s [=navigable/top-level + traversable=] is not equal to top-level traversable, + the return error with error code no such frame. + +

  5. Let x equal x offset and + y equal y offset. +

+
+
Otherwise
  1. Let element be the result of trying to run actions options' get element origin - steps with origin and browsing context. + steps with origin and target navigable.

  2. If element is null, return error with error code no such element. @@ -8392,9 +8421,43 @@

    Processing actions

+
  • Let (x, y) be convert to top-level + traversable viewport coordinates with origin + navigable, x, and y. +

  • Return (x, y) +

    To convert to top-level traversable viewport coordinates +given origin navigable, x and y: + +

      +
    1. Let navigable be origin navigable. + +

    2. While navigable is not null: + +

        + +
      1. Let container to the [=navigable/container=] of navigable. + +

      2. If container is null then break. + +

      3. Let rectangle be the first element of the {{DOMRect}} sequence + returned by calling {{Element/getClientRects()}} on element. + + Note: this is phrased as calling a DOM method, but should be + interpreted as invoking the underlying algorithm used to implement that DOM method. + +

      4. Set x to x + rectangle's x coordinate. + +

      5. Set y to y + rectangle's y coordinate. + +

      6. Set navigable to the the [=navigable/parent=] of navigable. +

      + +
    3. Return the tuple (x, y). +

    +

    To extract an action sequence given input state, parameters, and actions options: @@ -8973,9 +9036,10 @@

    Processing actions

    origin equal "viewport".
  • If origin is not equal to "viewport" - or "pointer", and actions options is - element origin steps given origin return false, - return error with error code invalid argument. + or "pointer", and the actions options + is element origin steps given origin return false, + return error with error code invalid + argument.

  • Set the origin property of action to origin. @@ -9142,15 +9206,15 @@

    Dispatching actions

    To dispatch actions given input -state, actions by tick, browsing -context, and actions options: +state, actions by tick, target navigable, +and actions options:

    1. Wait for an action queue token with input state.

    2. Let actions result be the result of dispatch actions inner with input state, actions by - tick, browsing context, and actions options. + tick, target navigable, and actions options.

    3. Dequeue input state's actions queue.

      Assert: this returns token @@ -9159,23 +9223,20 @@

      Dispatching actions

    To dispatch actions inner given input -state, actions by tick, browsing -context, and actions options: +state, actions by tick, target navigable, +and actions options:

    1. For each item tick actions in actions by tick:

        -
      1. If browsing context is no longer open, return - error with error code no such window. -
      2. Let tick duration be the result of computing the tick duration with argument tick actions.

      3. Try to dispatch tick actions with input state, tick actions, tick duration, - browsing context, and actions options. + target navigable, and actions options.

      4. Wait until the following conditions are all met: @@ -9226,12 +9287,15 @@

        Dispatching actions

        To dispatch tick actions given input state, tick actions, tick duration, - browsing context, and actions options: + target navigable, and actions options:

        1. For each action object in tick actions:

            +
          1. If target navigable is no longer open, return + error with error code no such window. +
          2. Let input id be equal to the value of action object's id property. @@ -9249,6 +9313,9 @@

            Dispatching actions

          3. Let subtype be action object's subtype. +

          4. Let top-level traversable be target + navigable's top-level traversable. +

          5. Let algorithm be the value of the column dispatch action algorithm from the following table where the source type column is source type and @@ -9271,8 +9338,9 @@

            Dispatching actions

          6. Try to run algorithm with arguments action object, source, global key - state, tick duration, browsing - context, and actions options. + state, tick duration, top-level + traversable , target navigable, and actions + options.
          7. If subtype is "keyDown", append a copy of action object with the subtype @@ -9290,7 +9358,7 @@

            Dispatching actions

          To dispatch a list of actions given input -state, actions, browsing context, +state, actions, target navigable, and actions options:

        @@ -9316,7 +9384,8 @@

        General actions

        To dispatch a pause action given action object, source, global key state, tick duration, -browsing context, and actions options: +top-level traversable, target navigable, +and actions options:

        1. Return success with data null. @@ -9587,8 +9656,9 @@

          Keyboard actions

          To dispatch a keyDown action given action -object, source, global key state, tick -duration, browsing context, and actions options: +object, source, global key state, +tick duration, top-level traversable, +target navigable, and actions options:

          1. Let raw key be equal to the @@ -9629,7 +9699,7 @@

            Keyboard actions

            property.
          2. Perform implementation-specific action dispatch steps - on browsing context equivalent to pressing a key on the + on top-level traversable equivalent to pressing a key on the keyboard in accordance with the requirements of [[UI-EVENTS]], and producing the following events, as appropriate, with the specified properties. This will always produce events including at least @@ -9689,8 +9759,8 @@

            Keyboard actions

            To dispatch a keyUp action given, action object, source, global key state, -tick duration, browsing context, -and actions options: +tick duration, top-level traversable, +target navigable, and actions options:

            1. Let raw key be equal to @@ -9731,7 +9801,7 @@

              Keyboard actions

              from sources's pressed property.
            2. Perform implementation-specific action dispatch steps - on browsing context equivalent to releasing a key on the + on top-level traversable equivalent to releasing a key on the keyboard in accordance with the requirements of [[UI-EVENTS]], and producing at least the following events with the specified properties: @@ -9767,8 +9837,8 @@

              Pointer actions

              To dispatch a pointerDown action given action object, source, global key - state, tick duration, browsing context, - and actions options: + state, tick duration, top-level traversable, + target navigable, and actions options:

              1. Let pointerType be equal to @@ -9818,7 +9888,7 @@

                Pointer actions

                azimuthAngle property.
              2. Perform implementation-specific action dispatch steps - on browsing context equivalent to pressing the button + on top-level traversable equivalent to pressing the button numbered button on the pointer with pointerId equal to source's pointerId, having type pointerType at viewport x coordinate x, @@ -9843,8 +9913,8 @@

                Pointer actions

                To dispatch a pointerUp action given, action object, source, global key -state, tick duration, browsing context, -and actions options: +state, tick duration, top-level traversable, +target navigable, and actions options:

                1. Let pointerType be equal to @@ -9869,7 +9939,7 @@

                  Pointer actions

                  property.
                2. Perform implementation-specific action dispatch steps - on browsing context equivalent to releasing the button + on top-level traversable equivalent to releasing the button numbered button on the pointer with pointerId equal to input source's pointerId, having type pointerType at viewport x coordinate x, @@ -9892,8 +9962,8 @@

                  Pointer actions

                  To dispatch a pointerMove action given action object, source, global key state, -tick duration, browsing context, -and actions options: +tick duration, top-level traversable, +target navigable, and actions options:

                  1. Let x offset be equal to the x @@ -9908,7 +9978,7 @@

                    Pointer actions

                  2. Let (x, y) be the result of trying to get coordinates relative to an origin with source, x offset, y offset, - origin, browsing context, and actions + origin, target navigable, and actions options.

                  3. If x is less than 0 or greater than the width of @@ -10017,7 +10087,7 @@

                    Pointer actions

                    state's buttons property.
                  4. Perform implementation-specific action dispatch steps - on browsing context equivalent to moving the pointer + on top-level traversable equivalent to moving the pointer with pointerId equal to input source's pointerId, having type pointerType from viewport x coordinate current x, viewport y @@ -10083,12 +10153,12 @@

                    Pointer actions

                    To dispatch a pointerCancel action given action object, source, global key state, -tick duration, browsing context, -and actions options: +tick duration, top-level traversable, +target navigable, and actions options:

                    1. Perform implementation-specific action dispatch steps - on browsing context equivalent to cancelling the any + on top-level traversable equivalent to cancelling the any action of the pointer with pointerId equal to source's pointerId item. having type pointerType, in accordance with the requirements of [[UI-EVENTS]] and [[POINTER-EVENTS]]. @@ -10103,8 +10173,8 @@

                      Wheel actions

                      To dispatch a scroll action given action object, source, global key state, -tick duration, browsing context, -and actions options: +tick duration, top-level traversable, +target navigable, and actions options:

                      1. Let x offset be equal to the x @@ -10119,7 +10189,7 @@

                        Wheel actions

                      2. Let (x, y) be the result of trying to get coordinates relative to an origin with source, x offset, y offset, - origin, browsing context, and actions + origin, target navigable, and actions options.

                      3. If x is less than 0 or greater than the width of @@ -10198,7 +10268,7 @@

                        Wheel actions

                        1. Perform implementation-specific action dispatch steps - on browsing context equivalent to wheel scroll at + on top-level traversable equivalent to wheel scroll at viewport x coordinate x, viewport y coordinate y, deltaX value delta x, deltaY value delta y, in accordance with the requirements of