-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix incorrect recursion for dir=auto special cases. #10561
Conversation
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 in the HTML spec for this behavior got this 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 . I believe this was a mistake in the spec and should be fixed.
cc @shallawa who's been taking over this work in WebKit |
I described more such cases in #10488 and my initial understanding is that this PR would fix these too. This sounds reasonable to me, but I'm no longer employed at Mozilla. Therefore this PR impacts these tests that are currently passing in Chromium, so Chromiums implementation might not be fully compliant with this spec change. |
Ah, I'd forgotten about that. This doesn't fix all of the cases in #10488, since it doesn't apply the skipping rules in 3.1. |
I think I've updated this to fully fix #10488. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good now.
One further note here: there are effectively two sub-parts to the change:
Change (1) requires code updates in both Gecko and Chromium; change (2) matches current Chromium code but requires code updates in Gecko (and one WPT update). I just wrote the Chromium code change for (1), so after I compile it I'll figure out what WPT updates are needed. Then I'll separately prepare the WPT updates for change (2) as well (which as far as current tests affect just one test where Gecko and Chromium disagree). |
I posted the first half and second half of the changes I mentioned; WPT PRs will be created automatically once the changes are reviewed. However, before that happens, I need to figure out how to fix an assertion failure that I triggered with one of the new tests I wrote. |
|
||
<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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still very much a mouthful :) But I don't have good ideas how to make this easier to read.
This fixes Chromium code and web platform tests to match half of the spec update in whatwg/html#10488 and whatwg/html#10561 . Prior to this change (in both spec and Chromium implementation) subtrees that were intended to be excluded from dir=auto traversal were not being excluded if they were an assigned node in a slot with dir=auto (which has a special traversal to traverse in the order of the assigned nodes, despite the general traversal being on the dom tree and not the flat tree). This fix is behind the DirAutoFixSlotExclusions flag in case we need to disable it. This also updates the test for bdi elements to only check for bdi elements in the HTML namespace. Bug: 576815, 352191350 Change-Id: I58a3bef05d27ba83a7e6b8e34d7bba74a8e0a482
This fixes Chromium code and web platform tests to match half of the spec update in whatwg/html#10488 and whatwg/html#10561 . Prior to this change (in both spec and Chromium implementation) subtrees that were intended to be excluded from dir=auto traversal were not being excluded if they were an assigned node in a slot with dir=auto (which has a special traversal to traverse in the order of the assigned nodes, despite the general traversal being on the dom tree and not the flat tree). This fix is behind the DirAutoFixSlotExclusions flag in case we need to disable it. This also updates the test for bdi elements to only check for bdi elements in the HTML namespace. Bug: 576815, 352191350 Change-Id: I58a3bef05d27ba83a7e6b8e34d7bba74a8e0a482 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5796604 Reviewed-by: Di Zhang <dizhangg@chromium.org> Commit-Queue: David Baron <dbaron@chromium.org> Cr-Commit-Position: refs/heads/main@{#1343841}
…cestors This fixes web platform tests to match half of the spec update in whatwg/html#10488 and whatwg/html#10561 . Prior to this change (in spec and Gecko, although not in the Chromium code) the special rules for dir=auto traversals that were intended to apply only to dir=auto on an element and not to dir=auto on its ancestors (relating to auto-directionality form-associated elements and to slots) were being applied in one ancestor case, where the special element was an assigned node of a slot. This makes the test changes corresponding to the fix to the HTML spec. Bug: 576815, 352191350 Change-Id: I6ffa8e22acc6f71777df1165655eaa1c8891867e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5798082 Commit-Queue: David Baron <dbaron@chromium.org> Reviewed-by: Di Zhang <dizhangg@chromium.org> Cr-Commit-Position: refs/heads/main@{#1343842}
This fixes Chromium code and web platform tests to match half of the spec update in whatwg/html#10488 and whatwg/html#10561 . Prior to this change (in both spec and Chromium implementation) subtrees that were intended to be excluded from dir=auto traversal were not being excluded if they were an assigned node in a slot with dir=auto (which has a special traversal to traverse in the order of the assigned nodes, despite the general traversal being on the dom tree and not the flat tree). This fix is behind the DirAutoFixSlotExclusions flag in case we need to disable it. This also updates the test for bdi elements to only check for bdi elements in the HTML namespace. Bug: 576815, 352191350 Change-Id: I58a3bef05d27ba83a7e6b8e34d7bba74a8e0a482 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5796604 Reviewed-by: Di Zhang <dizhangg@chromium.org> Commit-Queue: David Baron <dbaron@chromium.org> Cr-Commit-Position: refs/heads/main@{#1343841}
This fixes Chromium code and web platform tests to match half of the spec update in whatwg/html#10488 and whatwg/html#10561 . Prior to this change (in both spec and Chromium implementation) subtrees that were intended to be excluded from dir=auto traversal were not being excluded if they were an assigned node in a slot with dir=auto (which has a special traversal to traverse in the order of the assigned nodes, despite the general traversal being on the dom tree and not the flat tree). This fix is behind the DirAutoFixSlotExclusions flag in case we need to disable it. This also updates the test for bdi elements to only check for bdi elements in the HTML namespace. Bug: 576815, 352191350 Change-Id: I58a3bef05d27ba83a7e6b8e34d7bba74a8e0a482 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5796604 Reviewed-by: Di Zhang <dizhangg@chromium.org> Commit-Queue: David Baron <dbaron@chromium.org> Cr-Commit-Position: refs/heads/main@{#1343841}
…cestors This fixes web platform tests to match half of the spec update in whatwg/html#10488 and whatwg/html#10561 . Prior to this change (in spec and Gecko, although not in the Chromium code) the special rules for dir=auto traversals that were intended to apply only to dir=auto on an element and not to dir=auto on its ancestors (relating to auto-directionality form-associated elements and to slots) were being applied in one ancestor case, where the special element was an assigned node of a slot. This makes the test changes corresponding to the fix to the HTML spec. Bug: 576815, 352191350 Change-Id: I6ffa8e22acc6f71777df1165655eaa1c8891867e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5798082 Commit-Queue: David Baron <dbaron@chromium.org> Reviewed-by: Di Zhang <dizhangg@chromium.org> Cr-Commit-Position: refs/heads/main@{#1343842}
…cestors This fixes web platform tests to match half of the spec update in whatwg/html#10488 and whatwg/html#10561 . Prior to this change (in spec and Gecko, although not in the Chromium code) the special rules for dir=auto traversals that were intended to apply only to dir=auto on an element and not to dir=auto on its ancestors (relating to auto-directionality form-associated elements and to slots) were being applied in one ancestor case, where the special element was an assigned node of a slot. This makes the test changes corresponding to the fix to the HTML spec. Bug: 576815, 352191350 Change-Id: I6ffa8e22acc6f71777df1165655eaa1c8891867e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5798082 Commit-Queue: David Baron <dbaron@chromium.org> Reviewed-by: Di Zhang <dizhangg@chromium.org> Cr-Commit-Position: refs/heads/main@{#1343842}
This fixes Chromium code to match half of the spec update in whatwg/html#10488 and whatwg/html#10561 . I previously thought the code was fine, but I realize a small update is needed. In particular, the code could apply element-only rules for dir=auto to elements (in particular, button-type inputs) that are auto-directionality form-associated elements but were not in the list of exclusions. This also fixes the list of exclusions to exclude specifically textarea, so that any actual text content of input elements (but not the value) is traversed as required by the spec. This also removes the no-longer needed is_deferred argument to ResolveAutoDirectionality. Bug: 576815, 352191350 Change-Id: I7c13b9661d23f8904727c8298a8dca6360d6d732
I think this is now ready to land. I've already merged most of the test changes and the rest should auto-merge within a few hours. |
This fixes Chromium code to match half of the spec update in whatwg/html#10488 and whatwg/html#10561 . I previously thought the code was fine, but I realize a small update is needed. In particular, the code could apply element-only rules for dir=auto to elements (in particular, button-type inputs) that are auto-directionality form-associated elements but were not in the list of exclusions. This also fixes the list of exclusions to exclude specifically textarea, so that any actual text content of input elements (but not the value) is traversed as required by the spec. This also removes the no-longer needed is_deferred argument to ResolveAutoDirectionality. Bug: 576815, 352191350 Change-Id: I7c13b9661d23f8904727c8298a8dca6360d6d732 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5798880 Commit-Queue: David Baron <dbaron@chromium.org> Reviewed-by: Di Zhang <dizhangg@chromium.org> Commit-Queue: Di Zhang <dizhangg@chromium.org> Cr-Commit-Position: refs/heads/main@{#1344402}
This fixes Chromium code to match half of the spec update in whatwg/html#10488 and whatwg/html#10561 . I previously thought the code was fine, but I realize a small update is needed. In particular, the code could apply element-only rules for dir=auto to elements (in particular, button-type inputs) that are auto-directionality form-associated elements but were not in the list of exclusions. This also fixes the list of exclusions to exclude specifically textarea, so that any actual text content of input elements (but not the value) is traversed as required by the spec. This also removes the no-longer needed is_deferred argument to ResolveAutoDirectionality. Bug: 576815, 352191350 Change-Id: I7c13b9661d23f8904727c8298a8dca6360d6d732 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5798880 Commit-Queue: David Baron <dbaron@chromium.org> Reviewed-by: Di Zhang <dizhangg@chromium.org> Commit-Queue: Di Zhang <dizhangg@chromium.org> Cr-Commit-Position: refs/heads/main@{#1344402}
This fixes Chromium code and web platform tests to match half of the spec update in whatwg/html#10488 and whatwg/html#10561 . Prior to this change (in both spec and Chromium implementation) subtrees that were intended to be excluded from dir=auto traversal were not being excluded if they were an assigned node in a slot with dir=auto (which has a special traversal to traverse in the order of the assigned nodes, despite the general traversal being on the dom tree and not the flat tree). This fix is behind the DirAutoFixSlotExclusions flag in case we need to disable it. This also updates the test for bdi elements to only check for bdi elements in the HTML namespace. Bug: 576815, 352191350 Change-Id: I58a3bef05d27ba83a7e6b8e34d7bba74a8e0a482 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5796604 Reviewed-by: Di Zhang <dizhangg@chromium.org> Commit-Queue: David Baron <dbaron@chromium.org> Cr-Commit-Position: refs/heads/main@{#1343841}
…cestors This fixes web platform tests to match half of the spec update in whatwg/html#10488 and whatwg/html#10561 . Prior to this change (in spec and Gecko, although not in the Chromium code) the special rules for dir=auto traversals that were intended to apply only to dir=auto on an element and not to dir=auto on its ancestors (relating to auto-directionality form-associated elements and to slots) were being applied in one ancestor case, where the special element was an assigned node of a slot. This makes the test changes corresponding to the fix to the HTML spec. Bug: 576815, 352191350 Change-Id: I6ffa8e22acc6f71777df1165655eaa1c8891867e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5798082 Commit-Queue: David Baron <dbaron@chromium.org> Reviewed-by: Di Zhang <dizhangg@chromium.org> Cr-Commit-Position: refs/heads/main@{#1343842}
This fixes Chromium code to match half of the spec update in whatwg/html#10488 and whatwg/html#10561 . I previously thought the code was fine, but I realize a small update is needed. In particular, the code could apply element-only rules for dir=auto to elements (in particular, button-type inputs) that are auto-directionality form-associated elements but were not in the list of exclusions. This also fixes the list of exclusions to exclude specifically textarea, so that any actual text content of input elements (but not the value) is traversed as required by the spec. This also removes the no-longer needed is_deferred argument to ResolveAutoDirectionality. Bug: 576815, 352191350 Change-Id: I7c13b9661d23f8904727c8298a8dca6360d6d732 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5798880 Commit-Queue: David Baron <dbaron@chromium.org> Reviewed-by: Di Zhang <dizhangg@chromium.org> Commit-Queue: Di Zhang <dizhangg@chromium.org> Cr-Commit-Position: refs/heads/main@{#1344402}
…ly to assigned nodes in a slot., a=testonly Automatic update from web-platform-tests Fix dir=auto traversal exclusions to apply to assigned nodes in a slot. This fixes Chromium code and web platform tests to match half of the spec update in whatwg/html#10488 and whatwg/html#10561 . Prior to this change (in both spec and Chromium implementation) subtrees that were intended to be excluded from dir=auto traversal were not being excluded if they were an assigned node in a slot with dir=auto (which has a special traversal to traverse in the order of the assigned nodes, despite the general traversal being on the dom tree and not the flat tree). This fix is behind the DirAutoFixSlotExclusions flag in case we need to disable it. This also updates the test for bdi elements to only check for bdi elements in the HTML namespace. Bug: 576815, 352191350 Change-Id: I58a3bef05d27ba83a7e6b8e34d7bba74a8e0a482 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5796604 Reviewed-by: Di Zhang <dizhangg@chromium.org> Commit-Queue: David Baron <dbaron@chromium.org> Cr-Commit-Position: refs/heads/main@{#1343841} -- wpt-commits: 24bea5f38d235db99296614c07bcab105825b6f8 wpt-pr: 47670
…pply element-only rules to ancestors, a=testonly Automatic update from web-platform-tests Update dir=auto traversal tests to not apply element-only rules to ancestors This fixes web platform tests to match half of the spec update in whatwg/html#10488 and whatwg/html#10561 . Prior to this change (in spec and Gecko, although not in the Chromium code) the special rules for dir=auto traversals that were intended to apply only to dir=auto on an element and not to dir=auto on its ancestors (relating to auto-directionality form-associated elements and to slots) were being applied in one ancestor case, where the special element was an assigned node of a slot. This makes the test changes corresponding to the fix to the HTML spec. Bug: 576815, 352191350 Change-Id: I6ffa8e22acc6f71777df1165655eaa1c8891867e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5798082 Commit-Queue: David Baron <dbaron@chromium.org> Reviewed-by: Di Zhang <dizhangg@chromium.org> Cr-Commit-Position: refs/heads/main@{#1343842} -- wpt-commits: fddc4be423e3243af4b3b4fb410361579ea97193 wpt-pr: 47678
…ent-only rules to ancestors, a=testonly Automatic update from web-platform-tests Fix dir=auto traversal to not apply element-only rules to ancestors This fixes Chromium code to match half of the spec update in whatwg/html#10488 and whatwg/html#10561 . I previously thought the code was fine, but I realize a small update is needed. In particular, the code could apply element-only rules for dir=auto to elements (in particular, button-type inputs) that are auto-directionality form-associated elements but were not in the list of exclusions. This also fixes the list of exclusions to exclude specifically textarea, so that any actual text content of input elements (but not the value) is traversed as required by the spec. This also removes the no-longer needed is_deferred argument to ResolveAutoDirectionality. Bug: 576815, 352191350 Change-Id: I7c13b9661d23f8904727c8298a8dca6360d6d732 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5798880 Commit-Queue: David Baron <dbaron@chromium.org> Reviewed-by: Di Zhang <dizhangg@chromium.org> Commit-Queue: Di Zhang <dizhangg@chromium.org> Cr-Commit-Position: refs/heads/main@{#1344402} -- wpt-commits: 5fd1516871dc70888b9895f887109c39713db03e wpt-pr: 47697
…ly to assigned nodes in a slot., a=testonly Automatic update from web-platform-tests Fix dir=auto traversal exclusions to apply to assigned nodes in a slot. This fixes Chromium code and web platform tests to match half of the spec update in whatwg/html#10488 and whatwg/html#10561 . Prior to this change (in both spec and Chromium implementation) subtrees that were intended to be excluded from dir=auto traversal were not being excluded if they were an assigned node in a slot with dir=auto (which has a special traversal to traverse in the order of the assigned nodes, despite the general traversal being on the dom tree and not the flat tree). This fix is behind the DirAutoFixSlotExclusions flag in case we need to disable it. This also updates the test for bdi elements to only check for bdi elements in the HTML namespace. Bug: 576815, 352191350 Change-Id: I58a3bef05d27ba83a7e6b8e34d7bba74a8e0a482 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5796604 Reviewed-by: Di Zhang <dizhanggchromium.org> Commit-Queue: David Baron <dbaronchromium.org> Cr-Commit-Position: refs/heads/main{#1343841} -- wpt-commits: 24bea5f38d235db99296614c07bcab105825b6f8 wpt-pr: 47670 UltraBlame original commit: 5a235bc5aaa335bfffff109a441b242acdd3192c
…pply element-only rules to ancestors, a=testonly Automatic update from web-platform-tests Update dir=auto traversal tests to not apply element-only rules to ancestors This fixes web platform tests to match half of the spec update in whatwg/html#10488 and whatwg/html#10561 . Prior to this change (in spec and Gecko, although not in the Chromium code) the special rules for dir=auto traversals that were intended to apply only to dir=auto on an element and not to dir=auto on its ancestors (relating to auto-directionality form-associated elements and to slots) were being applied in one ancestor case, where the special element was an assigned node of a slot. This makes the test changes corresponding to the fix to the HTML spec. Bug: 576815, 352191350 Change-Id: I6ffa8e22acc6f71777df1165655eaa1c8891867e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5798082 Commit-Queue: David Baron <dbaronchromium.org> Reviewed-by: Di Zhang <dizhanggchromium.org> Cr-Commit-Position: refs/heads/main{#1343842} -- wpt-commits: fddc4be423e3243af4b3b4fb410361579ea97193 wpt-pr: 47678 UltraBlame original commit: 9594de798831efee3071b69a642ba03e168cf33f
…ly to assigned nodes in a slot., a=testonly Automatic update from web-platform-tests Fix dir=auto traversal exclusions to apply to assigned nodes in a slot. This fixes Chromium code and web platform tests to match half of the spec update in whatwg/html#10488 and whatwg/html#10561 . Prior to this change (in both spec and Chromium implementation) subtrees that were intended to be excluded from dir=auto traversal were not being excluded if they were an assigned node in a slot with dir=auto (which has a special traversal to traverse in the order of the assigned nodes, despite the general traversal being on the dom tree and not the flat tree). This fix is behind the DirAutoFixSlotExclusions flag in case we need to disable it. This also updates the test for bdi elements to only check for bdi elements in the HTML namespace. Bug: 576815, 352191350 Change-Id: I58a3bef05d27ba83a7e6b8e34d7bba74a8e0a482 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5796604 Reviewed-by: Di Zhang <dizhanggchromium.org> Commit-Queue: David Baron <dbaronchromium.org> Cr-Commit-Position: refs/heads/main{#1343841} -- wpt-commits: 24bea5f38d235db99296614c07bcab105825b6f8 wpt-pr: 47670 UltraBlame original commit: 5a235bc5aaa335bfffff109a441b242acdd3192c
…pply element-only rules to ancestors, a=testonly Automatic update from web-platform-tests Update dir=auto traversal tests to not apply element-only rules to ancestors This fixes web platform tests to match half of the spec update in whatwg/html#10488 and whatwg/html#10561 . Prior to this change (in spec and Gecko, although not in the Chromium code) the special rules for dir=auto traversals that were intended to apply only to dir=auto on an element and not to dir=auto on its ancestors (relating to auto-directionality form-associated elements and to slots) were being applied in one ancestor case, where the special element was an assigned node of a slot. This makes the test changes corresponding to the fix to the HTML spec. Bug: 576815, 352191350 Change-Id: I6ffa8e22acc6f71777df1165655eaa1c8891867e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5798082 Commit-Queue: David Baron <dbaronchromium.org> Reviewed-by: Di Zhang <dizhanggchromium.org> Cr-Commit-Position: refs/heads/main{#1343842} -- wpt-commits: fddc4be423e3243af4b3b4fb410361579ea97193 wpt-pr: 47678 UltraBlame original commit: 9594de798831efee3071b69a642ba03e168cf33f
…ent-only rules to ancestors, a=testonly Automatic update from web-platform-tests Fix dir=auto traversal to not apply element-only rules to ancestors This fixes Chromium code to match half of the spec update in whatwg/html#10488 and whatwg/html#10561 . I previously thought the code was fine, but I realize a small update is needed. In particular, the code could apply element-only rules for dir=auto to elements (in particular, button-type inputs) that are auto-directionality form-associated elements but were not in the list of exclusions. This also fixes the list of exclusions to exclude specifically textarea, so that any actual text content of input elements (but not the value) is traversed as required by the spec. This also removes the no-longer needed is_deferred argument to ResolveAutoDirectionality. Bug: 576815, 352191350 Change-Id: I7c13b9661d23f8904727c8298a8dca6360d6d732 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5798880 Commit-Queue: David Baron <dbaron@chromium.org> Reviewed-by: Di Zhang <dizhangg@chromium.org> Commit-Queue: Di Zhang <dizhangg@chromium.org> Cr-Commit-Position: refs/heads/main@{#1344402} -- wpt-commits: 5fd1516871dc70888b9895f887109c39713db03e wpt-pr: 47697
…ly to assigned nodes in a slot., a=testonly Automatic update from web-platform-tests Fix dir=auto traversal exclusions to apply to assigned nodes in a slot. This fixes Chromium code and web platform tests to match half of the spec update in whatwg/html#10488 and whatwg/html#10561 . Prior to this change (in both spec and Chromium implementation) subtrees that were intended to be excluded from dir=auto traversal were not being excluded if they were an assigned node in a slot with dir=auto (which has a special traversal to traverse in the order of the assigned nodes, despite the general traversal being on the dom tree and not the flat tree). This fix is behind the DirAutoFixSlotExclusions flag in case we need to disable it. This also updates the test for bdi elements to only check for bdi elements in the HTML namespace. Bug: 576815, 352191350 Change-Id: I58a3bef05d27ba83a7e6b8e34d7bba74a8e0a482 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5796604 Reviewed-by: Di Zhang <dizhangg@chromium.org> Commit-Queue: David Baron <dbaron@chromium.org> Cr-Commit-Position: refs/heads/main@{#1343841} -- wpt-commits: 24bea5f38d235db99296614c07bcab105825b6f8 wpt-pr: 47670
…pply element-only rules to ancestors, a=testonly Automatic update from web-platform-tests Update dir=auto traversal tests to not apply element-only rules to ancestors This fixes web platform tests to match half of the spec update in whatwg/html#10488 and whatwg/html#10561 . Prior to this change (in spec and Gecko, although not in the Chromium code) the special rules for dir=auto traversals that were intended to apply only to dir=auto on an element and not to dir=auto on its ancestors (relating to auto-directionality form-associated elements and to slots) were being applied in one ancestor case, where the special element was an assigned node of a slot. This makes the test changes corresponding to the fix to the HTML spec. Bug: 576815, 352191350 Change-Id: I6ffa8e22acc6f71777df1165655eaa1c8891867e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5798082 Commit-Queue: David Baron <dbaron@chromium.org> Reviewed-by: Di Zhang <dizhangg@chromium.org> Cr-Commit-Position: refs/heads/main@{#1343842} -- wpt-commits: fddc4be423e3243af4b3b4fb410361579ea97193 wpt-pr: 47678
<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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just realized, this is a really odd algorithm. One goes through all the descendants, but if element is one of the things below, continue. The behavior is ok, but this is quite hard to read. I can blame myself for not thinking this more while reviewing :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's really intended to represent a tree traversal that excludes certain subtrees. However, we don't have good spec language for that. (Maybe we should write some!)
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 in the HTML spec for this behavior got this 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 . I believe this was a mistake in the spec and is fixed in this change 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. This change also fixes that exclusion by adding a canExcludeRoot boolean to the "contained text auto directionality" algorithm.
This is a followup to PR #9796 (fixing #3699). Fixes #10488.
(See WHATWG Working Mode: Changes for more details.)
Cc @vinhill who implemented this in Gecko and @nt1m who is implementing in WebKit.
Note that https://github.com/web-platform-tests/wpt/blob/b6bca1a1aa8042d6651dc8ac9a0541cd506377b2/html/dom/elements/global-attributes/dir-auto-dynamic-changes.window.js#L381 is the test that is testing the behavior that I believe was a mistake in the spec.
/dom.html ( diff )