Skip to content

Commit 4d6609f

Browse files
authored
Yet more fixes to focus delegation
Fixes #8156. Fixes #8157. See also previous work in #7361, #7284, and #7079.
1 parent b9a961d commit 4d6609f

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

source

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -76857,51 +76857,59 @@ partial interface <span id="NavigatorUserActivation-partial">Navigator</span> {
7685776857
<dd><p>Return null.</p></dd>
7685876858
</dl>
7685976859

76860-
<p>The <dfn>focus delegate</dfn> for a <var>focus target</var>, given an optional string
76861-
<var>focus trigger</var> (default "<code data-x="">other</code>"), is given by the following
76860+
<p>The <dfn>focus delegate</dfn> for a <var>focusTarget</var>, given an optional string
76861+
<var>focusTrigger</var> (default "<code data-x="">other</code>"), is given by the following
7686276862
steps:</p>
7686376863

7686476864
<ol>
76865-
<li><p>Let <var>autofocus delegate</var> be the <span>autofocus delegate</span> for <var>focus
76866-
target</var> given <var>focus trigger</var>.</p></li>
76867-
76868-
<li><p>If <var>autofocus delegate</var> is not null, then return <var>autofocus
76869-
delegate</var>.</p></li>
76870-
76871-
<li><p>If <var>focus target</var> is a <span>shadow host</span> and its <span
76865+
<li><p>If <var>focusTarget</var> is a <span>shadow host</span> and its <span
7687276866
data-x="concept-element-shadow-root">shadow root</span>'s <span>delegates focus</span> is false,
7687376867
then return null.</p></li>
7687476868

76875-
<li><p>Let <var>parent</var> be <var>focus target</var>.</p></li>
76869+
<li><p>Let <var>whereToLook</var> be <var>focusTarget</var>.</p></li>
76870+
76871+
<li><p>If <var>whereToLook</var> is a <span>shadow host</span>, then set <var>whereToLook</var>
76872+
to <var>whereToLook</var>'s <span data-x="concept-element-shadow-root">shadow
76873+
root</span>.</p></li>
76874+
76875+
<li><p>Let <var>autofocusDelegate</var> be the <span>autofocus delegate</span> for
76876+
<var>whereToLook</var> given <var>focusTrigger</var>.</p></li>
7687676877

76877-
<li><p>If <var>parent</var> is a <span>shadow host</span>, then set <var>parent</var> to
76878-
<var>parent</var>'s <span data-x="concept-element-shadow-root">shadow root</span>.</p></li>
76878+
<li><p>If <var>autofocusDelegate</var> is not null, then return
76879+
<var>autofocusDelegate</var>.</p></li>
7687976880

7688076881
<li>
76881-
<p><span data-x="list iterate">For each</span> <var>child</var> of <var>parent</var>'s <span
76882-
data-x="concept-tree-child">children</span>:</p>
76882+
<p><span data-x="list iterate">For each</span> <var>descendant</var> of
76883+
<var>whereToLook</var>'s <span data-x="descendant">descendants</span>, in <span>tree
76884+
order</span>:</p>
7688376885

7688476886
<ol>
76887+
<li><p>If <var>descendant</var> is a <span>focusable area</span>, then return
76888+
<var>descendant</var>.</p></li>
76889+
7688576890
<li>
76886-
<p>Let <var>focusable area</var> be <var>child</var>, if <var>child</var> is a
76887-
<span>focusable area</span>; otherwise let <var>focusable area</var> be the result of <span
76888-
data-x="get the focusable area">getting the focusable area</span> for <var>child</var> given
76889-
<var>focus trigger</var>.</p>
76891+
<p>Let <var>focusableArea</var> be the result of <span data-x="get the focusable
76892+
area">getting the focusable area</span> for <var>descendant</var> given
76893+
<var>focusTrigger</var>.</p>
7689076894

7689176895
<p class="note">This step can end up recursing, i.e., the <span>get the focusable area</span>
76892-
steps might return the <span>focus delegate</span> of <var>child</var>.</p>
76896+
steps might return the <span>focus delegate</span> of <var>descendant</var>.</p>
7689376897
</li>
7689476898

76895-
<li><p>If <var>focusable area</var> is not null, then return <var>focusable
76896-
area</var>.</p></li>
76899+
<li><p>If <var>focusableArea</var> is not null, then return <var>focusableArea</var>.</p></li>
7689776900
</ol>
76901+
76902+
<p class="note">It's important that we are <em>not</em> looking at the <span
76903+
data-x="shadow-including descendant">shadow-including descendants</span> here, but instead only
76904+
at the <span data-x="descendant">descendants</span>. <span data-x="shadow host">Shadow
76905+
hosts</span> are instead handled by the recursive case mentioned above.</p>
7689876906
</li>
7689976907

7690076908
<li><p>Return null.</p></li>
7690176909
</ol>
7690276910

7690376911
<p class="note">The above algorithm essentially returns the first suitable <span>focusable
76904-
area</span> where the path between its <span>DOM anchor</span> and <var>focus target</var>
76912+
area</span> where the path between its <span>DOM anchor</span> and <var>focusTarget</var>
7690576913
delegates focus at any shadow tree boundaries.</p>
7690676914

7690776915
<p>The <dfn>autofocus delegate</dfn> for a <var>focus target</var> given a <var>focus

0 commit comments

Comments
 (0)