Truly independent web browser
LibWeb: Limit the UA stylesheet's [dir] rules to HTML elements
Andreas Klingcf38defbc02c
diff --git a/Libraries/LibWeb/CSS/Default.css b/Libraries/LibWeb/CSS/Default.cssindex 770593ae131..0394aa61440 100644--- a/Libraries/LibWeb/CSS/Default.css+++ b/Libraries/LibWeb/CSS/Default.css@@ -3,6 +3,11 @@* After that, rules from the HTML spec follow.*/+/* AD-HOC: The HTML spec puts every rendering section block below under @namespace "http://www.w3.org/1999/xhtml";.+ * @namespace must come before all other rules, so we declare a prefix here and use it where it matters.+ */+@namespace html url(http://www.w3.org/1999/xhtml);+html {font-family: serif;}@@ -419,11 +424,11 @@ nobr wbr {* https://html.spec.whatwg.org/multipage/rendering.html#bidi-rendering*/-[dir]:dir(ltr), bdi:dir(ltr), input[type=tel i]:dir(ltr) {+html|*[dir]:dir(ltr), bdi:dir(ltr), input[type=tel i]:dir(ltr) {direction: ltr;}-[dir]:dir(rtl), bdi:dir(rtl) {+html|*[dir]:dir(rtl), bdi:dir(rtl) {direction: rtl;}@@ -431,7 +436,7 @@ address, blockquote, center, div, figure, figcaption, footer, form, header, hr,legend, listing, main, p, plaintext, pre, summary, xmp, article, aside,:heading, hgroup, nav, search, section, 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] {+html|*[dir=ltr i], html|*[dir=rtl i], html|*[dir=auto i] {unicode-bidi: isolate;}diff --git a/Tests/LibWeb/Text/expected/css/ua-dir-rules-html-namespace-only.txt b/Tests/LibWeb/Text/expected/css/ua-dir-rules-html-namespace-only.txtnew file mode 100644index 00000000000..485878bc76e--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/ua-dir-rules-html-namespace-only.txt@@ -0,0 +1,3 @@+html: direction=rtl unicode-bidi=isolate+mathml: direction=rtl unicode-bidi=normal+svg: direction=ltr unicode-bidi=normaldiff --git a/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/direction/direction.txt b/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/direction/direction.txtindex d28225cdc6c..b4683eb95e0 100644--- a/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/direction/direction.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/direction/direction.txt@@ -2,5 +2,5 @@ Harness status: OKFound 1 tests-1 Fail-Fail Check direction\ No newline at end of file+1 Pass+Pass Check direction\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/css/ua-dir-rules-html-namespace-only.html b/Tests/LibWeb/Text/input/css/ua-dir-rules-html-namespace-only.htmlnew file mode 100644index 00000000000..150b6daf537--- /dev/null+++ b/Tests/LibWeb/Text/input/css/ua-dir-rules-html-namespace-only.html@@ -0,0 +1,13 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<div id="html" dir="rtl"></div>+<math><mrow id="mathml" dir="rtl"></mrow></math>+<svg><g id="svg" dir="rtl"></g></svg>+<script>+ test(() => {+ for (const id of ["html", "mathml", "svg"]) {+ const style = getComputedStyle(document.getElementById(id));+ println(`${id}: direction=${style.direction} unicode-bidi=${style.unicodeBidi}`);+ }+ });+</script>