layouts
All repositories: gitoria
9.1 KB
// tests/display-audit.mjs — the in-page DISPLAY audit of mission 007 (found in a real Chrome, ticket #1 reopened).// DISPLAY is a JS expression (a string) for page.evaluate; it returns { w, sw, hscroll, wide, stray, spill, clipped, overlaps, covered, contrast, underHeader }:// hscroll the page scrolls sideways (scrollWidth > viewport)// wide visible elements whose box leaves the viewport (not inside a scroll area / code / table)// clipped text cut off by its own box (overflow hidden/clip, scrollWidth > clientWidth) — `ellipsis` marks a deliberate "…"// overlaps siblings (block-level, in flow) whose boxes cover each other by more than 4 px² — header items, rows, cards// covered a visible control whose centre point belongs to something else (hidden behind another element)// contrast text under 4.5:1 against its background (3:1 for large text); text over a gradient/image is not judged// spill text or a child sticking out of its own box without any clipping// stray a CLOSED popover (menu, search, sidebar) that is still on the page (a page rule overrode the browser's display:none)// underHeader the first content element starts under the sticky headerexport const DISPLAY = `(() => {const vw = window.innerWidth, vh = window.innerHeight;const vis = (el) => { const cs = getComputedStyle(el); if (cs.display === 'none' || cs.visibility === 'hidden') return false; if (el.closest('.visually-hidden')) return false; const r = el.getBoundingClientRect(); return r.width > 0 && r.height > 0; };const sel = (el) => { let s = el.tagName.toLowerCase(); if (el.id) s += '#' + el.id; else if (el.className && typeof el.className === 'string' && el.className.trim()) s += '.' + el.className.trim().split(/\\s+/).slice(0, 2).join('.'); const p = el.parentElement; if (p && p !== document.body) s = p.tagName.toLowerCase() + ' > ' + s; return s; };const txt = (el) => (el.getAttribute('aria-label') || el.textContent || el.value || el.title || '').trim().replace(/\\s+/g, ' ').slice(0, 30);const all = [...document.body.querySelectorAll('*')].filter(el => !el.closest('svg') || el.tagName.toLowerCase() === 'svg');const shown = all.filter(vis);const inScroll = (el) => !!el.closest('pre, code-editor, md-editor [contenteditable], md-editor nav, .scroll, table, [style*="overflow"]');const out = { w: vw, sw: document.documentElement.scrollWidth, hscroll: document.documentElement.scrollWidth > vw + 0.5, wide: [], clipped: [], overlaps: [], covered: [], contrast: [], underHeader: null, stray: [], spill: [] };for (const el of vw < 960 ? document.querySelectorAll('[popover]:not(:popover-open)') : []) { const r = el.getBoundingClientRect(); if (getComputedStyle(el).display !== 'none' && r.width > 0) out.stray.push({ sel: sel(el), r: [Math.round(r.left), Math.round(r.top), Math.round(r.width), Math.round(r.height)] }); }for (const el of shown) {if (inScroll(el)) continue;const r = el.getBoundingClientRect();if (r.right > vw + 0.5 || r.left < -0.5) out.wide.push({ sel: sel(el), l: Math.round(r.left), r: Math.round(r.right), text: txt(el) });}for (const el of shown) {const cs = getComputedStyle(el);if (el.scrollWidth > el.clientWidth + 1 && (cs.overflowX === 'hidden' || cs.overflowX === 'clip') && el.clientWidth > 0 && !inScroll(el) && !el.matches('html, body'))out.clipped.push({ sel: sel(el), sw: el.scrollWidth, cw: el.clientWidth, ellipsis: cs.textOverflow === 'ellipsis', text: txt(el) });}for (const el of shown) {const cs = getComputedStyle(el);if (inScroll(el) || el.matches('html, body, svg, svg *, input, textarea, select, md-editor, md-editor *') || cs.display === 'inline' || cs.display === 'contents' || cs.overflowX !== 'visible' || ![...el.childNodes].some(n => n.nodeType === 3 && n.textContent.trim())) continue;const pr = el.parentElement && el.parentElement.getBoundingClientRect(), r = el.getBoundingClientRect();if (el.scrollWidth > el.clientWidth + 1 && el.clientWidth > 0 && cs.display !== 'table-cell') out.spill.push({ sel: sel(el), sw: el.scrollWidth, cw: el.clientWidth, text: txt(el) });else if (pr && el.parentElement !== document.body && getComputedStyle(el.parentElement).overflowX !== 'visible' === false && r.right > pr.right + 1.5 && pr.width > 0 && getComputedStyle(el).position === 'static' && getComputedStyle(el.parentElement).display !== 'inline') out.spill.push({ sel: sel(el), r: Math.round(r.right), parentRight: Math.round(pr.right), text: txt(el) });}const flow = (el) => { const cs = getComputedStyle(el); return vis(el) && cs.position !== 'absolute' && cs.position !== 'fixed' && cs.display !== 'inline' && cs.display !== 'contents' && !el.matches('script, style, option, summary ~ *'); };for (const box of shown) {if (inScroll(box) || box.closest('md-editor, [popover]:not(:popover-open)')) continue;const kids = [...box.children].filter(flow);for (let i = 0; i < kids.length; i++) for (let j = i + 1; j < kids.length; j++) {const a = kids[i].getBoundingClientRect(), b = kids[j].getBoundingClientRect();const w = Math.min(a.right, b.right) - Math.max(a.left, b.left), h = Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top);// the reactions row (like / Edit / Delete) sits close under its bubble ON PURPOSE (creator 2026-10-24): its 44 px buttons overlap the bubble's// empty bottom padding by a few pixels; that is allowed only while no content of the bubble (its last child) reaches into the rowif (kids[i].matches('comment-bubble') && kids[j].matches('comment-actions')) {const last = kids[i].lastElementChild, lb = last ? last.getBoundingClientRect().bottom : a.top;if (h <= 12 && lb <= b.top + 0.5) continue;}if (w > 2 && h > 2 && w * h > 4) out.overlaps.push({ a: sel(kids[i]), b: sel(kids[j]), w: Math.round(w), h: Math.round(h), at: txt(kids[i]) + ' | ' + txt(kids[j]) });}}const ctl = shown.filter(el => el.matches('a[href], button, summary, select, textarea, input:not([type=hidden]), [role=button], [role=tab], [role=menuitem]') && !el.closest('.visually-hidden'));const pop = document.querySelector(':popover-open, dialog[open]');for (const el of ctl.slice(0, 260)) {if (pop && !pop.contains(el)) continue;if (!pop && el.closest('[popover]')) continue;if (getComputedStyle(el).position !== 'fixed' && !el.closest('application-header')) el.scrollIntoView({ block: 'center', inline: 'nearest' });let r = el.getBoundingClientRect();const x = Math.min(Math.max(r.left + r.width / 2, 0), vw - 1), y = Math.min(Math.max(r.top + r.height / 2, 0), vh - 1);if (r.height > vh || r.width > vw * 3) continue;const top = document.elementFromPoint(x, y);const ok = top && (top === el || el.contains(top) || top.contains(el) || (el.labels && [...el.labels].some(l => l === top || l.contains(top))) || (top.closest && top.closest('label') && top.closest('label').contains(el)));if (!ok) out.covered.push({ sel: sel(el), text: txt(el), by: top ? sel(top) : 'null', x: Math.round(x), y: Math.round(y) });}window.scrollTo(0, 0);const rgb = (s) => { let m = /^rgba?\\(([^)]+)\\)$/.exec(s); if (m) { const p = m[1].split(/[ ,\\/]+/).map(Number); return [p[0], p[1], p[2], p.length > 3 ? p[3] : 1]; } m = /^color\\(srgb ([^)]+)\\)$/.exec(s); if (m) { const p = m[1].split(/[ \\/]+/).map(Number); return [p[0] * 255, p[1] * 255, p[2] * 255, p.length > 3 ? p[3] : 1]; } return null; };const lum = (c) => { const f = (v) => { v /= 255; return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4); }; return 0.2126 * f(c[0]) + 0.7152 * f(c[1]) + 0.0722 * f(c[2]); };const bgOf = (el) => { let layers = []; for (let e = el; e; e = e.parentElement) { const cs = getComputedStyle(e); if (cs.backgroundImage !== 'none') return null; const c = rgb(cs.backgroundColor); if (c && c[3] > 0) { layers.push(c); if (c[3] >= 1) break; } } let base = [255, 255, 255]; for (const c of layers.reverse()) base = [0, 1, 2].map(i => c[i] * c[3] + base[i] * (1 - c[3])); return base; };const seen = new Set();for (const el of shown) {if (el.matches('md-editor, md-editor *, code-editor, code-editor *, pre, pre *') || !vis(el)) continue;const own = [...el.childNodes].some(n => n.nodeType === 3 && n.textContent.trim().length > 0);if (!own) continue;const cs = getComputedStyle(el); if (cs.opacity === '0' || el.disabled) continue;const fg = rgb(cs.color), bg = bgOf(el); if (!fg || !bg) continue;const a = fg[3], f = [0, 1, 2].map(i => fg[i] * a + bg[i] * (1 - a));const L1 = lum(f), L2 = lum(bg), ratio = (Math.max(L1, L2) + 0.05) / (Math.min(L1, L2) + 0.05);const px = parseFloat(cs.fontSize), large = px >= 24 || (px >= 18.66 && parseInt(cs.fontWeight) >= 700);if (ratio < (large ? 3 : 4.5)) { const k = sel(el) + Math.round(ratio * 10); if (!seen.has(k)) { seen.add(k); out.contrast.push({ sel: sel(el), ratio: Math.round(ratio * 100) / 100, px, text: txt(el) }); } }}const hd = document.querySelector('application-header'), first = document.querySelector('main > :first-child, main h1');if (hd && first && vis(first) && getComputedStyle(hd).position === 'sticky') { const hb = hd.getBoundingClientRect().bottom, ft = first.getBoundingClientRect().top; if (ft < hb - 1) out.underHeader = { sel: sel(first), top: Math.round(ft), headerBottom: Math.round(hb) }; }return out;})()`;
Branches
Latest commits
- 4099e64aMerge branch 'font-segoe-ui' into mainAtlas
- e14fb795|||PR Theme font: Segoe UI first (his choice 2026-11-19)Atlas
- 44071d2cMerge branch 'hl-standard-5' into mainAtlas
- 5ea64202|||PR Gate: count the new-tab check's console errors tooAtlas
- 2752ceddMerge branch 'hl-standard-4' into mainAtlas
- ac552b81|||PR Gate: keyboard (Tab/Enter/Space) and Back/Forward/reload/new-tab checks (HL-STANDARD F5, F21)Atlas
- 8cddcaa9Merge branch 'hl-standard-2' into mainAtlas
- 2b480a64|||PR Type the route parameter of main-menu build (HL-STANDARD L10)Atlas
- ab54a39dMerge branch 'hl-standard' into mainAtlas
- 04d36fcf|||PR Type function parameters and drop unneeded let (HL-STANDARD L2, L10)Atlas
- 220c8fa4Merge branch 'readme-audit' into mainAtlas
- b78fb85a|||PR README matches the codemre
- 9f351699Preserve comments and nest supported selectors without changing rendered outputmre
- 97110ad9WIP: nest accepted layout selectors; stopped at startup parse failuremre
- ce4a0baeKeep caller slot styles whole so minimal shell apps startmre
- 12cd3992Re-vendor complete Hybriel plugins and runtime to day44mre
- b05c20feBackup tar: --hard-dereference, so mpackdb sidecars are never stored as hard links (Tracker's finding)mre
- 8d9ed0b8Re-vendor complete Hybriel plugins and runtime to day39mre
- ebd00b6cNest caller slot styles in three-panemre
- 009991efNest caller slot styles in list-firstmre