From 32a94add0ba234b762edd439175dc0115c30d10a Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Thu, 18 Nov 2021 13:13:15 -0500 Subject: [PATCH] Handle shadow DOM and focusing Closes #2393, by making behave the same as delegatesFocus: they both "delegate focus" to either autofocus="" if it's specified on a (non-shadow-including) descendant, or the first focusable element among their shadow-including descendants if not. --- source | 62 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/source b/source index 6cec40e3e13..234caa8a2f8 100644 --- a/source +++ b/source @@ -58171,16 +58171,9 @@ interface HTMLDialogElement : HTMLElement {
  1. If subject is inert, return.

  2. -
  3. -

    Let control be the first descendant element of subject, in tree - order, that is not inert and has the autofocus attribute specified.

    - -

    If there isn't one, then let control be the first non-inert - descendant element of subject, in tree order. +

  4. Let control be the focus delegate of subject.

  5. -

    If there isn't one of those either, then let control be subject.

    - +
  6. If control is null, then set control to subject.

  7. Run the focusing steps for control.

    @@ -75189,27 +75182,8 @@ END:VCARD currently focused area of a top-level browsing context's DOM anchor, then return null.

  8. -
  9. Let autofocus delegate be the autofocus delegate for - root given focus trigger.

  10. - -
  11. If autofocus delegate is not null, then return autofocus - delegate.

  12. - -
  13. If focus trigger is "click", then let possible - focus delegates be the list of all click focusable focusable areas whose DOM anchor is a shadow-including - descendant of root.

  14. - -
  15. Otherwise, let possible focus delegates be the list of all focusable areas whose DOM anchor is a - shadow-including descendant of root.

  16. - -
  17. If possible focus delegates is empty, then return null.

  18. - -
  19. Sort possible focus delegates by shadow-including tree - order of their DOM anchors.

  20. - -
  21. Return possible focus delegates[0].

  22. +
  23. Return the focus delegate for root given focus + trigger.

For sequential focusability, the @@ -75224,6 +75198,34 @@ END:VCARD

Return null.

+

The focus delegate for a focus target, given an optional string + focus trigger (default "other"), is given by the following + steps:

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

  2. + +
  3. If autofocus delegate is not null, then return autofocus + delegate.

  4. + +
  5. If focus trigger is "click", then let possible + focus delegates be the list of all click focusable focusable areas whose DOM anchor is a shadow-including + descendant of focus target.

  6. + +
  7. Otherwise, let possible focus delegates be the list of all focusable areas whose DOM anchor is a + shadow-including descendant of focus target.

  8. + +
  9. If possible focus delegates is empty, then return null.

  10. + +
  11. Sort possible focus delegates by shadow-including tree order of + their DOM anchors.

  12. + +
  13. Return possible focus delegates[0].

  14. +
+

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