layout: Add initial support for bidirectional text (BiDi) (#33148)

This adds supports for right-to-left text assigning bidi levels to all
line items when necessary. This includes support for the `dir` attribute
as well as corresponding CSS properties like `unicode-bidi`. It only
implements right-to-left rendering for inline layout at the moment and
doesn't include support for `dir=auto`. Because of missing features,
this causes quite a few tests to start failing, as references become
incorrect due to right-to-left rendering being active in some cases,
but not others (before it didn't exist at all).

Analysis of most of the new failures:

```
- /css/css-flexbox/gap-001-rtl.html
  /css/css-flexbox/gap-004-rtl.html
 - Require implementing BiDi in Flexbox, because the start and
   end inline margins are opposite the order of items.

- /css/CSS2/bidi-text/direction-applies-to-*.xht
  /css/CSS2/bidi-text/direction-applies-to-002.xht
  /css/CSS2/bidi-text/direction-applies-to-003.xht
  /css/CSS2/bidi-text/direction-applies-to-004.xht
  - Broken due to a bug in tables, not allocating the
    right amount of width for a column.

- /css/css-lists/inline-list.html
  - This fails because we wrongly insert a soft wrap opportunity between the
    start of an inline box and its first content.

- /css/css-text/bidi/bidi-lines-001.html
  /css/css-text/bidi/bidi-lines-002.html
  /css/CSS2/text/bidi-flag-emoji.html
  - We do not fully support unicode-bidi: plaintext

- /css/css-text/text-align/text-align-end-010.html
  /css/css-text/text-align/text-align-justify-006.html
  /css/css-text/text-align/text-align-start-010.html
  /html/dom/elements/global-attributes/*
  - We do not support dir=auto yet.

- /css/css-text/white-space/tab-bidi-001.html
  - Servo doesn't support tab stops

- /css/CSS2/positioning/abspos-block-level-001.html
  /css/css-text/word-break/word-break-normal-ar-000.html
  - Do not yet support RTL layout in block

- /css/css-text/white-space/pre-wrap-018.html
  - Even in RTL contexts, spaces at the end of the line must hang and
    not be reordered

- /css/css-text/white-space/trailing-space-and-text-alignment-rtl-002.html
  - We are letting spaces hang with white-space: pre, but they shouldn't
    hang.
```

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
This commit is contained in:
Martin Robinson 2024-08-21 07:28:54 -07:00 committed by GitHub
parent 65bd5a3b99
commit 56280c6242
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
189 changed files with 547 additions and 762 deletions

View file

@ -1,2 +0,0 @@
[bidi-box-model-006.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[bidi-breaking-001.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[bidi-breaking-002.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[bidi-glyph-mirroring-002.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[bidi-inline-001.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[bidi-inline-002.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[direction-002.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[direction-003.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[direction-applies-to-001.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[direction-applies-to-002.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[direction-applies-to-003.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[direction-applies-to-004.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[direction-applies-to-007.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[direction-applies-to-008.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[direction-applies-to-009.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[direction-applies-to-012.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[direction-applies-to-013.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[direction-applies-to-014.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[direction-applies-to-015.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[line-breaking-bidi-003.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[unicode-bidi-001.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[unicode-bidi-002.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[unicode-bidi-applies-to-008.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[bidi-generated-content-001.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[bidi-generated-content-002.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[inline-formatting-context-023.xht]
expected: FAIL

View file

@ -1,2 +1,2 @@
[bidi-001.xht]
[blocks-018.xht]
expected: FAIL

View file

@ -1,2 +1,2 @@
[bidi-002.xht]
[blocks-019.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[replaced-intrinsic-002.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[abspos-block-level-001.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[left-offset-003.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[left-offset-percentage-001.xht]
expected: FAIL

View file

@ -0,0 +1,2 @@
[bidi-flag-emoji.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[text-align-white-space-006.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[text-align-white-space-008.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[text-indent-rtl-002.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[white-space-bidirectionality-001.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[white-space-collapsing-bidi-002.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[inline-formatting-context-001.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[all-prop-001.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[gap-001-rtl.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[gap-004-rtl.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[gap-007-rtl.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[inline-list.html]
expected: FAIL

View file

@ -3,9 +3,6 @@
[Logical properties in animations respect the writing-mode]
expected: FAIL
[Logical properties in animations respect the direction]
expected: FAIL
[Logical properties are able to override physical properties in @keyframes declaration blocks]
expected: FAIL
@ -26,6 +23,3 @@
[Animations update when the writing-mode is changed through a CSS variable]
expected: FAIL
[Animations update when the direction is changed]
expected: FAIL

View file

@ -2,9 +2,6 @@
[Logical properties in transitions respect the writing-mode]
expected: FAIL
[Logical properties in transitions respect the direction]
expected: FAIL
[Transitions update when the writing-mode is changed]
expected: FAIL
@ -20,11 +17,5 @@
[Transitions update when the writing-mode is changed through a CSS variable]
expected: FAIL
[Transitions update when the direction is changed]
expected: FAIL
[Transitions from logical to physical update when the direction is changed]
expected: FAIL
[Transitions from physical to logical update when the direction is changed]
expected: FAIL

View file

@ -1,13 +1,4 @@
[logical-box-border-shorthands.html]
[Test that logical border-* properties share computed values with their physical associates, with 'writing-mode: horizontal-tb; direction: rtl; '.]
expected: FAIL
[Test that border-* properties honor order of appearance when both logical and physical associates are declared, with 'writing-mode: horizontal-tb; direction: rtl; '.]
expected: FAIL
[Test that border-* properties honor selector specificty when both logical and physical associates are declared, with 'writing-mode: horizontal-tb; direction: rtl; '.]
expected: FAIL
[Test that logical border-* properties share computed values with their physical associates, with 'writing-mode: vertical-rl; direction: rtl; '.]
expected: FAIL

View file

@ -1,2 +0,0 @@
[logical-values-float-clear-1.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[logical-values-float-clear-2.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[logical-values-float-clear-3.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[logical-values-float-clear-4.html]
expected: FAIL

View file

@ -1,7 +1,4 @@
[marker-default-styles.html]
[Computed value of 'unicode-bidi' for outside symbol]
expected: FAIL
[Computed value of 'font-variant-numeric' for outside symbol]
expected: FAIL
@ -11,9 +8,6 @@
[Computed value of 'text-indent' for outside symbol]
expected: FAIL
[Computed value of 'unicode-bidi' for outside decimal]
expected: FAIL
[Computed value of 'font-variant-numeric' for outside decimal]
expected: FAIL
@ -23,9 +17,6 @@
[Computed value of 'text-indent' for outside decimal]
expected: FAIL
[Computed value of 'unicode-bidi' for outside string]
expected: FAIL
[Computed value of 'font-variant-numeric' for outside string]
expected: FAIL
@ -35,9 +26,6 @@
[Computed value of 'text-indent' for outside string]
expected: FAIL
[Computed value of 'unicode-bidi' for outside marker]
expected: FAIL
[Computed value of 'font-variant-numeric' for outside marker]
expected: FAIL
@ -47,9 +35,6 @@
[Computed value of 'text-indent' for outside marker]
expected: FAIL
[Computed value of 'unicode-bidi' for inside symbol]
expected: FAIL
[Computed value of 'font-variant-numeric' for inside symbol]
expected: FAIL
@ -59,9 +44,6 @@
[Computed value of 'text-indent' for inside symbol]
expected: FAIL
[Computed value of 'unicode-bidi' for inside decimal]
expected: FAIL
[Computed value of 'font-variant-numeric' for inside decimal]
expected: FAIL
@ -71,9 +53,6 @@
[Computed value of 'text-indent' for inside decimal]
expected: FAIL
[Computed value of 'unicode-bidi' for inside string]
expected: FAIL
[Computed value of 'font-variant-numeric' for inside string]
expected: FAIL
@ -83,9 +62,6 @@
[Computed value of 'text-indent' for inside string]
expected: FAIL
[Computed value of 'unicode-bidi' for inside marker]
expected: FAIL
[Computed value of 'font-variant-numeric' for inside marker]
expected: FAIL

View file

@ -1,2 +0,0 @@
[marker-unicode-bidi-default-ref.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[marker-unicode-bidi-normal-ref.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[clone-nowrap-intrinsic-size-bidi.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[slice-nowrap-intrinsic-size-bidi.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[text-decoration-skip-spaces-003.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[bidi-lines-001.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[bidi-lines-002.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[text-align-007.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[text-align-end-001.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[text-align-end-003.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[text-align-end-005.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[text-align-end-007.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[text-align-end-010.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[text-align-end-014.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[text-align-justify-001.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[text-align-justify-003.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[text-align-justify-006.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[text-align-last-010.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[text-align-last-011.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[text-align-last-justify-rtl.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[text-align-match-parent-001.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[text-align-start-001.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[text-align-start-003.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[text-align-start-005.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[text-align-start-007.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[text-align-start-010.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[text-align-start-014.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[shaping-join-001.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[shaping-join-002.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[shaping-no-join-001.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[shaping-no-join-002.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[shaping-tatweel-001.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[eol-spaces-bidi-002.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[pre-wrap-018.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[tab-bidi-001.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[trailing-space-and-text-alignment-rtl-002.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[word-break-normal-ar-000.html]
expected: FAIL

View file

@ -100,6 +100,3 @@
[Testing 'writing-mode'.]
expected: FAIL
[Testing 'direction'.]
expected: FAIL

View file

@ -1,4 +0,0 @@
[elementsFromPoint-inline-htb-rtl.html]
[elementsFromPoint should return all elements under a point]
expected: FAIL

View file

@ -1,4 +0,0 @@
[getClientRects-br-htb-rtl.html]
[Position of the BR element]
expected: FAIL

View file

@ -0,0 +1,2 @@
[getClientRects-inline.html]
expected: FAIL

View file

@ -23,3 +23,51 @@
[scrollHeight with negative margins: display: block; overflow: scroll;]
expected: FAIL
[scrollWidth with negative margins: display: block; overflow: visible; direction: ltr;]
expected: FAIL
[scrollHeight with negative margins: display: block; overflow: visible; direction: ltr;]
expected: FAIL
[scrollWidth with negative margins: display: block; overflow: hidden; direction: ltr;]
expected: FAIL
[scrollHeight with negative margins: display: block; overflow: hidden; direction: ltr;]
expected: FAIL
[scrollWidth with negative margins: display: block; overflow: auto; direction: ltr;]
expected: FAIL
[scrollHeight with negative margins: display: block; overflow: auto; direction: ltr;]
expected: FAIL
[scrollWidth with negative margins: display: block; overflow: scroll; direction: ltr;]
expected: FAIL
[scrollHeight with negative margins: display: block; overflow: scroll; direction: ltr;]
expected: FAIL
[scrollWidth with negative margins: display: block; overflow: visible; direction: rtl;]
expected: FAIL
[scrollHeight with negative margins: display: block; overflow: visible; direction: rtl;]
expected: FAIL
[scrollWidth with negative margins: display: block; overflow: hidden; direction: rtl;]
expected: FAIL
[scrollHeight with negative margins: display: block; overflow: hidden; direction: rtl;]
expected: FAIL
[scrollWidth with negative margins: display: block; overflow: auto; direction: rtl;]
expected: FAIL
[scrollHeight with negative margins: display: block; overflow: auto; direction: rtl;]
expected: FAIL
[scrollWidth with negative margins: display: block; overflow: scroll; direction: rtl;]
expected: FAIL
[scrollHeight with negative margins: display: block; overflow: scroll; direction: rtl;]
expected: FAIL

View file

@ -1,6 +0,0 @@
[cssstyledeclaration-csstext-all-shorthand.html]
['all' shorthand with all longhands]
expected: FAIL
['all' shorthand with 'direction' and 'unicode-bidi']
expected: FAIL

View file

@ -82,24 +82,3 @@
[list-style-type: lower-roman]
expected: FAIL
[direction: ltr]
expected: FAIL
[direction: rtl]
expected: FAIL
[direction: inherit]
expected: FAIL
[unicode-bidi: normal]
expected: FAIL
[unicode-bidi: embed]
expected: FAIL
[unicode-bidi: bidi-override]
expected: FAIL
[unicode-bidi: inherit]
expected: FAIL

View file

@ -0,0 +1,2 @@
[dir_auto-EN-L.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[dir_auto-EN-R.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[dir_auto-L.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[dir_auto-N-EN-L.html]
expected: FAIL

Some files were not shown because too many files have changed in this diff Show more