Skip to content

Commit

Permalink
Fix incorrect recursion for dir=auto special cases
Browse files Browse the repository at this point in the history
dir=auto has special-case behavior for both (1) auto-directionality form-associated elements and (2) slots with assigned nodes. In these special cases dir=auto is intended to have special behavior when used on the element, but this special behavior was not intended to apply when dir=auto was used on an ancestor.

The wording for this behavior was incorrect for at least one case, where the handling of the slot case needs recursion over the assigned nodes as though they were descendants. This was uncovered by the Gecko implementor adding a test for this case as described in https://bugzilla.mozilla.org/show_bug.cgi?id=1876163#c13. Fix this by splitting "contained text auto directionality" into a separate algorithm and invoking that, rather than the complete "auto directionality" algorithm, when handling an Element assigned to a slot.

This special case handling also incorrectly missed applying exclusions of descendants (for a different set of special cases) to the special traversal for computing dir=auto on a slot element, which traverses its assigned nodes (in order) rather than its descendants.  Also fix that exclusion by adding a canExcludeRoot boolean to the "contained text auto directionality" algorithm.

Fixes #10488.
  • Loading branch information
dbaron committed Aug 21, 2024
1 parent 4553e7b commit 5b0f145
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -13775,8 +13775,10 @@ Transport Protocol">HTTP&lt;/abbr> today.&lt;/p></code></pre> <!-- DO NOT REWRAP
<ol>
<li><p><span>Assert</span>: <var>child</var> is an <code>Element</code> node.</p></li>

<li><p>Set <var>childDirection</var> to the <span>auto directionality</span> of
<var>child</var>.</p></li>
<li><p>Set <var>childDirection</var> to the <span>contained text auto directionality</span>
of <var>child</var> with <i><span
data-x="auto-directionality-can-exclude-root">canExcludeRoot</span></i> set to
true.</p></li>
</ol>
</li>

Expand All @@ -13789,15 +13791,32 @@ Transport Protocol">HTTP&lt;/abbr> today.&lt;/p></code></pre> <!-- DO NOT REWRAP
</ol>
</li>

<li><p>Return the <span>contained text auto directionality</span> of <var>element</var> with
<i><span data-x="auto-directionality-can-exclude-root">canExcludeRoot</span></i> set to
false.</p></li>
</ol>

<p>To compute the <dfn>contained text auto directionality</dfn> of an element
<var>element</var> with a boolean <dfn
data-x="auto-directionality-can-exclude-root"><var>canExcludeRoot</var></dfn>:</p>

<ol>
<li>
<p><span data-x="list iterate">For each</span> node <var>descendant</var> of
<var>element</var>'s <span data-x="descendant">descendants</span>, in <span>tree
order</span>:</p>

<ol>
<li>
<p>If <var>descendant</var>, or any of its ancestor elements that are descendants of
<var>element</var>, is one of</p>
<p>If any of</p>

<ul class="brief">
<li><var>descendant</var></li>
<li>any ancestor element of <var>descendant</var> that is a descendant of <var>element</var></li>
<li>if <var>canExcludeRoot</var> is true, <var>element</var></li>
</ul>

<p>is one of</p>

<ul class="brief">
<li>a <code>bdi</code> element</li>
Expand Down

0 comments on commit 5b0f145

Please sign in to comment.