Skip to content

Commit

Permalink
Make dir=auto fall back to the parent's directionality rather than ltr.
Browse files Browse the repository at this point in the history
When dir=auto fails to find text with strong directionality (or a <slot>
element) to determine the directionality of the element, it should fall
back to the directionality that it would have inherited from its parent
(or, for <slot>, its shadow host) rather than falling back to ltr.

This requires updating directionality invalidation to account for the
possibility that elements with dir=auto can inherit directionality.

This is based on the proposed behavior described in:
whatwg/html#3699 (comment)
which is in the process of being specified in:
whatwg/html#9554
whatwg/html#9796

This is one of two changes needed to fix the failure of:
external/wpt/html/dom/elements/global-attributes/dir-shadow-41.html
in the still-unlanded WPT PR at
#29820

Bug: 576815
Change-Id: I9fc7c85875074ad41704ab45ec70c7632c3f8d31
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4805163
Commit-Queue: David Baron <dbaron@chromium.org>
Reviewed-by: Di Zhang <dizhangg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1202893}
  • Loading branch information
dbaron authored and chromium-wpt-export-bot committed Sep 28, 2023
1 parent b6bb687 commit fe5ba77
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions html/dom/elements/global-attributes/dir_auto-N-EN-ref.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<meta name="assert" content="
When dir='auto', the direction is set according to the first strong character
of the text, ignoring neutrals and numbers.
If there is no strong character, as in this test, the direction defaults to LTR." />
If there is no strong character, as in this test, the direction defaults to the parent." />
<style>
input, textarea {
font-size:1em;
Expand All @@ -35,15 +35,15 @@
<p dir="ltr">@123!</p>
</div>
<div dir="rtl">
<p dir="ltr">@123!</p>
<p dir="rtl">@123!</p>
</div>
</div>
<div class="ref">
<div dir="ltr">
<p dir="ltr">@123!</p>
</div>
<div dir="rtl">
<p dir="ltr">@123!</p>
<p dir="rtl">@123!</p>
</div>
</div>
</body>
Expand Down
4 changes: 2 additions & 2 deletions html/dom/elements/global-attributes/dir_auto-N-EN.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<meta name="assert" content="
When dir='auto', the direction is set according to the first strong character
of the text, ignoring neutrals and numbers.
If there is no strong character, as in this test, the direction defaults to LTR." />
If there is no strong character, as in this test, the direction defaults to the parent." />
<style>
input, textarea {
font-size:1em;
Expand Down Expand Up @@ -44,7 +44,7 @@
<p dir="ltr">@123!</p>
</div>
<div dir="rtl">
<p dir="ltr">@123!</p>
<p dir="rtl">@123!</p>
</div>
</div>
</body>
Expand Down

0 comments on commit fe5ba77

Please sign in to comment.