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.
This commit is contained in:
Abdessamad Derraz committed 2026-11-19 18:42:55 +01:00
1 parent cb23f7f8a4
commit 9760c2fadd
3 files changed
+28 -11

No files matched your search

+8 -1
View File
@@ -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:], "", "</div>"]
def generate_cross_reference(
+8 -1
View File
@@ -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"))
+12 -9
View File
@@ -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: