From 9760c2fadd056ef49ca6ae3dbe3fafbd831122b6 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Thu, 19 Nov 2026 18:07:36 +0100 Subject: [PATCH] fix: size the upstream table by a class The cross-reference upstream table was reached with .sl-heading-wrapper:has(> #by-upstream-emulator) ~ section, which the browser matched again for every block added after any heading of any page: about 400 ms of style work while the gaps page loads (mobile, 4x CPU throttling, 586 ms down to 200 ms). The table sits in a .rb-xref-upstream block, and the address column is its second. --- scripts/sitegen/crossref.py | 9 ++++++++- tests/test_site_css.py | 9 ++++++++- website/src/styles/retrobios.css | 21 ++++++++++++--------- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/scripts/sitegen/crossref.py b/scripts/sitegen/crossref.py index c421e25dd..6ec96af27 100644 --- a/scripts/sitegen/crossref.py +++ b/scripts/sitegen/crossref.py @@ -242,7 +242,14 @@ def _render_xref_by_upstream( + f" | {upstream_cell} | {', '.join(_breakable(r) for r in revisions) or '-'} " f"| {', '.join(classifications)} | {len(plats)} |" ) - return lines + # A class the stylesheet sizes the columns by. Found from the heading + # with `.sl-heading-wrapper:has(> #by-upstream-emulator) ~ section`, the + # rule was checked again for every block the browser added after any + # heading of any page: 400 ms of style work on the gaps page (mobile, + # 4x CPU throttling). + table = lines.index("| Cores | Upstream | Revisions | Classification | Platforms |") + return [*lines[:table], markup.block_open("div", 'class="rb-xref-upstream"'), "", + *lines[table:], "", ""] def generate_cross_reference( diff --git a/tests/test_site_css.py b/tests/test_site_css.py index 8ed0b5e72..165d88762 100644 --- a/tests/test_site_css.py +++ b/tests/test_site_css.py @@ -201,9 +201,16 @@ class ThemeStylesheet(unittest.TestCase): self.assertNotRegex(self.css, r"\.rb-meta-card td \{ overflow-wrap: anywhere") self.assertIn("overflow-wrap: anywhere", _rules(self.css, ".rb-meta-card td code")[0]) self.assertIn("width: 40%", "".join(_rules(self.css, ".rb-meta-card td:first-child"))) - upstream = _rules(self.css, "#by-upstream-emulator")[0] + upstream = _rules(self.css, ".rb-xref-upstream td:nth-child(2)")[0] self.assertIn("max-width: 22rem", upstream) + def test_no_has_before_a_sibling_combinator(self): + """`.sl-heading-wrapper:has(> #by-upstream-emulator) ~ section` was + matched again for every block added after any heading: 400 ms of + style work on the gaps page (mobile, 4x CPU throttling).""" + for selector, _body in _blocks(self.css): + self.assertNotRegex(selector, r":has\([^)]*\)[^,{]*~", selector) + def test_two_column_tables_stack_label_over_value(self): self.assertIn("content: none", _rules(self.css, "table[data-rb-stack='kv'] td::before")[0]) self.assertTrue(_rules(self.css, "table[data-rb-stack='kv'] td:first-child")) diff --git a/website/src/styles/retrobios.css b/website/src/styles/retrobios.css index 6a7435329..8a7608de2 100644 --- a/website/src/styles/retrobios.css +++ b/website/src/styles/retrobios.css @@ -409,27 +409,30 @@ .rb-meta-card td:first-child { font-weight: 600; color: var(--rb-text-secondary); width: 11rem; } /* Cross-reference by upstream, the last table of its page: the address - column wraps instead of pushing the cores and platforms off screen. */ -.sl-markdown-content .sl-heading-wrapper:has(> #by-upstream-emulator) ~ section td:has(a[href^='http']) { + column wraps instead of pushing the cores and platforms off screen. The + table sits in .rb-xref-upstream (sitegen/crossref.py): reached from its + heading with :has() and `~ section`, the rules were matched again for + every block added after any heading of any page. */ +.sl-markdown-content .rb-xref-upstream td:nth-child(2) { max-width: 22rem; overflow-wrap: anywhere; } /* Beside the column, the five columns share its width: at 1440 px the Platforms column sat 100 px past the edge. */ @media (min-width: 50rem) { - .sl-markdown-content .sl-heading-wrapper:has(> #by-upstream-emulator) ~ section table { + .sl-markdown-content .rb-xref-upstream table { display: table; table-layout: fixed; width: 100%; } - .sl-markdown-content .sl-heading-wrapper:has(> #by-upstream-emulator) ~ section td { + .sl-markdown-content .rb-xref-upstream td { overflow-wrap: anywhere; } - .sl-markdown-content .sl-heading-wrapper:has(> #by-upstream-emulator) ~ section th:nth-child(1) { width: 25%; } - .sl-markdown-content .sl-heading-wrapper:has(> #by-upstream-emulator) ~ section th:nth-child(2) { width: 26%; } - .sl-markdown-content .sl-heading-wrapper:has(> #by-upstream-emulator) ~ section th:nth-child(3) { width: 15%; } - .sl-markdown-content .sl-heading-wrapper:has(> #by-upstream-emulator) ~ section th:nth-child(4) { width: 20%; } - .sl-markdown-content .sl-heading-wrapper:has(> #by-upstream-emulator) ~ section th:nth-child(5) { width: 14%; } + .sl-markdown-content .rb-xref-upstream th:nth-child(1) { width: 25%; } + .sl-markdown-content .rb-xref-upstream th:nth-child(2) { width: 26%; } + .sl-markdown-content .rb-xref-upstream th:nth-child(3) { width: 15%; } + .sl-markdown-content .rb-xref-upstream th:nth-child(4) { width: 20%; } + .sl-markdown-content .rb-xref-upstream th:nth-child(5) { width: 14%; } } /* The id a platform writes for a system, beside the name in its heading: