Skip to content

Commit

Permalink
Add unicode-bidi UA stylesheet rules
Browse files Browse the repository at this point in the history
Per spec:

  https://html.spec.whatwg.org/multipage/rendering.html#bidi-rendering

this should be in the UA stylesheet:

address, blockquote, center, div, figure, figcaption, footer,
form, header, hr, legend, listing, main, p, plaintext, pre,
summary, xmp, article, aside, h1, h2, h3, h4, h5, h6, hgroup,
nav, section, search, table, caption, colgroup, col, thead,
tbody, tfoot, tr, td, th, dir, dd, dl, dt, menu, ol, ul, li,
bdi, output, [dir=ltr i], [dir=rtl i], [dir=auto i] {
  unicode-bidi: isolate;
}

To avoid breakage, I just added the elements, and not the [dir]
related rules, nor did I change the <bdo> rules.

Firefox and WebKit are both making the same change:
https://bugzilla.mozilla.org/show_bug.cgi?id=1874033
https://bugs.webkit.org/show_bug.cgi?id=267887

The stylesheet change interacts with the code at [1], and that code
also handles some of the cases such as [dir=auto] and bdi/bdo.
I will clean up some of the code at [1] in a followup CL.

[1] https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/html/html_element.cc;l=344-363;drc=20fecf94cc2226674dfefd698e96d8d44485b19c

Fixed: 1520671
Change-Id: Icaa32061efc59d963942b0629327bb596ac224ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5240082
Auto-Submit: Mason Freed <[email protected]>
Reviewed-by: David Baron <[email protected]>
Commit-Queue: Mason Freed <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1255819}
  • Loading branch information
mfreed7 authored and chromium-wpt-export-bot committed Feb 2, 2024
1 parent 78ce8e7 commit 53f8b53
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 5 deletions.
2 changes: 2 additions & 0 deletions css/css-cascade/all-prop-initial-xml.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
// Grab initial styles from a random element, as the root can get non-initial UA styling.
const div = iframe.contentDocument.createElementNS("http://www.w3.org/1999/xhtml", "div");
root.appendChild(div);
// the document element should have unicode-bidi 'normal', while <div> has 'isolate':
div.style.unicodeBidi = 'normal';
const cs = iframe.contentWindow.getComputedStyle(div);

let actual_initial = Object.create(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
display: contents;
color: green;
border: 10px solid red;
unicode-bidi: normal;
}
</style>
<fieldset><legend class="contents">P<legend>legend</legend>ASS</legend></fieldset>
8 changes: 4 additions & 4 deletions css/css-writing-modes/unicode-bidi-parsing-001.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<div title="Initial value of unicode-bidi"
data-expected="normal"></div>
<span title="Initial value of unicode-bidi"
data-expected="normal"></span>

<div style="unicode-bidi: embed; unicode-bidi: normal"
data-expected="normal"></div>
Expand All @@ -19,8 +19,8 @@
data-expected="bidi-override"></div>

<div style="unicode-bidi: embed">
<div title="unicode-bidi should not inherit"
data-expected="normal"></div>
<span title="unicode-bidi should not inherit"
data-expected="normal"></span>
</div>

<script>
Expand Down
25 changes: 25 additions & 0 deletions html/rendering/bidi-rendering/unicode-bidi-ua-rules.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<title>unicode-bidi UA stylesheet rules</title>
<link rel="author" href="[email protected]">
<link rel="help" href="https://html.spec.whatwg.org/multipage/rendering.html#bidi-rendering">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>

<body>
<script>
const elements = ['address', 'blockquote', 'center', 'div', 'figure',
'figcaption', 'footer', 'form', 'header', 'hr', 'legend', 'listing',
'main', 'p', 'plaintext', 'pre', 'summary', 'xmp', 'article', 'aside',
'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hgroup', 'nav', 'section', 'search',
'table', 'caption', 'colgroup', 'col', 'thead', 'tbody', 'tfoot', 'tr',
'td', 'th', 'dir', 'dd', 'dl', 'dt', 'menu', 'ol', 'ul', 'li', 'bdi',
'output'];
for(let tagname of elements) {
test((t) => {
const element = document.createElement(tagname);
t.add_cleanup(() => element.remove());
document.body.appendChild(element);
assert_equals(window.getComputedStyle(element, "").unicodeBidi,'isolate');
},`UA stylesheet rule for unicode-bidi, for <${tagname}>`);
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
h3, h4, h5, h6, hgroup, nav, section, search, table, caption, colgroup, col,
thead, tbody, tfoot, tr, td, th, dir, dd, dl, dt, menu, ol, ul, li, bdi, output,
[dir=ltr i], [dir=rtl i], [dir=auto i], * /* only apply to the bogus namespace */ {
unicode-bidi: bidi-override;
unicode-bidi: isolate;
}

</style>
Expand Down

0 comments on commit 53f8b53

Please sign in to comment.