From 383e1a95fa6615d1ed9c0a0c5f3d11794cfccc4c Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Wed, 13 Oct 2021 11:53:31 -0400 Subject: [PATCH] Improve autofocus and delegatesFocus interaction Now, when focusing a shadow host with delegates focus set, we try to focus the first focusable area with the autofocus attribute set, instead of just the first focusable area. (If no focusable area has autofocus set, then we use the first one, like before.) Closes #833. --- source | 73 +++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 21 deletions(-) diff --git a/source b/source index 0690ef89ed7..786daa581b9 100644 --- a/source +++ b/source @@ -2966,6 +2966,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • The child concept
  • The root and shadow-including root concepts
  • The inclusive ancestor, + descendant, shadow-including descendant, shadow-including inclusive descendant, and shadow-including inclusive ancestor concepts
  • @@ -74985,8 +74986,8 @@ END:VCARD

    To get the focusable area for a focus target that is either an element that is not a focusable area, or is a browsing context, given an - optional string focus trigger, run the first matching set of steps from the following - list:

    + optional string focus trigger (default "other"), run the first + matching set of steps from the following list:

    If focus target is an area element with one or more shapes that are @@ -75022,28 +75023,28 @@ END:VCARD
      -
    1. If focus target is a shadow-including inclusive ancestor of the +
    2. If focus target is a shadow-including inclusive ancestor of the currently focused area of a top-level browsing context's DOM anchor, - then return null.

    3. + then return null.

      -
    4. -

      Otherwise:

      +
    5. Let autofocus delegate be the autofocus delegate for focus + target given focus trigger.

    6. -
        -
      1. If focus trigger is "click", then let possible - focus delegates be the list of all click focusable focusable areas whose DOM anchor is a descendant - of focus target in the flat tree.
      2. - -
      3. Otherwise, let possible focus delegates be the list of all focusable areas whose DOM anchor is a descendant - of focus target in the flat tree.
      4. - -
      5. Return the first focusable area in tree order of their DOM anchors in possible focus delegates, or null if - possible focus delegates is empty.
      6. -
      - +
    7. If autofocus delegate is not null, then return autofocus + delegate.

    8. + +
    9. If focus trigger is "click", then let possible + focus delegates be the list of all click focusable focusable areas whose DOM anchor is a descendant + of focus target in the flat tree.

    10. + +
    11. Otherwise, let possible focus delegates be the list of all focusable areas whose DOM anchor is a descendant + of focus target in the flat tree.

    12. + +
    13. Return the first focusable area in tree order of who their + DOM anchors are in possible focus delegates, or + null if possible focus delegates is empty.

    For sequential focusability, the @@ -75058,6 +75059,36 @@ END:VCARD

    Return null.

    +

    The autofocus delegate for a focus target given a focus + trigger is given by the following steps:

    + +
      +
    1. +

      For each descendant descendant of focus target, in + tree order:

      + +
        +
      1. If descendant does not have an autofocus content attribute, then + continue.

      2. + +
      3. Let focusable area be descendant, if descendant is a + focusable area; otherwise let focusable area be the result of getting the focusable area for descendant + given focus trigger.

      4. + +
      5. If focusable area is null, then continue.

      6. + +
      7. If focusable area is not click focusable and focus + trigger is "click", then continue.

      8. + +
      9. Return focusable area.

      10. +
      +
    2. + +
    3. Return null.

    4. +
    +

    The focusing steps for an object new focus target that is either a focusable area, or an element that is not a focusable area, or a browsing context, are as follows. They can optionally be run with a fallback