From 2ae1d412dbf59a0b02a47d73dd5cb0c329404bd6 Mon Sep 17 00:00:00 2001 From: David Baron Date: Mon, 19 Aug 2024 16:43:31 -0700 Subject: [PATCH] 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 https://github.com/whatwg/html/issues/10488 and https://github.com/whatwg/html/pull/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 Commit-Queue: David Baron Cr-Commit-Position: refs/heads/main@{#1343841} --- .../dir-auto-dynamic-changes.window.js | 5 +---- .../dir-slots-directionality.html | 16 ++++++++-------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/html/dom/elements/global-attributes/dir-auto-dynamic-changes.window.js b/html/dom/elements/global-attributes/dir-auto-dynamic-changes.window.js index d57d8664dfaff8c..28be3f9936ef374 100644 --- a/html/dom/elements/global-attributes/dir-auto-dynamic-changes.window.js +++ b/html/dom/elements/global-attributes/dir-auto-dynamic-changes.window.js @@ -371,12 +371,9 @@ test(() => { `); let slot = shadow.querySelector("slot"); - assert_equals(html_direction(slot), "rtl"); - let inp = tree.querySelector("input"); - inp.value = "abc"; assert_equals(html_direction(slot), "ltr"); tree.remove(); -}, 'dir=auto slot is updated by text in value of input element children'); +}, 'dir=auto slot is not affected by text in value of input element children'); test(() => { let [tree, shadow] = setup_tree(` diff --git a/html/dom/elements/global-attributes/dir-slots-directionality.html b/html/dom/elements/global-attributes/dir-slots-directionality.html index c0a11ba9a90949b..f482d44b3329cc0 100644 --- a/html/dom/elements/global-attributes/dir-slots-directionality.html +++ b/html/dom/elements/global-attributes/dir-slots-directionality.html @@ -173,9 +173,9 @@ let div = tree.querySelector("#root"); assert_equals(html_direction(div), "ltr"); let slot = shadow.querySelector("slot"); - assert_equals(html_direction(slot), "rtl"); + assert_equals(html_direction(slot), "ltr"); tree.remove(); -}, 'dir=auto slot ignores dir attribute of assigned nodes'); +}, 'dir=auto slot ignores assigned nodes with dir attribute'); test(() => { let [tree, shadow] = setup_tree(` @@ -188,9 +188,9 @@ `); let slot = shadow.querySelector("slot"); - assert_equals(html_direction(slot), "rtl"); + assert_equals(html_direction(slot), "ltr"); tree.remove(); -}, 'dir=auto slot considers text in bdi assigned nodes'); +}, 'dir=auto slot ignores text in bdi assigned nodes'); test(() => { let [tree, shadow] = setup_tree(` @@ -205,13 +205,13 @@ let inp = tree.querySelector("input"); assert_equals(html_direction(inp), "ltr"); let slot = shadow.querySelector("slot"); - assert_equals(html_direction(slot), "rtl"); + assert_equals(html_direction(slot), "ltr"); tree.remove(); [tree, shadow] = setup_tree(`
- + اختبر
@@ -221,8 +221,8 @@ inp = tree.querySelector("input"); assert_equals(html_direction(inp), "ltr"); slot = shadow.querySelector("slot"); - assert_equals(html_direction(slot), "ltr", "no strong character in value counts as ltr"); + assert_equals(html_direction(slot), "rtl"); tree.remove(); -}, 'dir=auto slot considers text in value of input element children'); +}, 'dir=auto slot ignores text in value of input element children');