From febef9741f0a6799b64fdf80ef5a62c93b364731 Mon Sep 17 00:00:00 2001 From: yetone Date: Sun, 1 Nov 2026 08:53:40 +0800 Subject: [PATCH] gui: a thumb is put under its option on the window's resize, before the ResizeObserver A phone draws its options at 13px with 11px padding (the first commit of this branch), and desktop at 12px and 10px. When the window crossed the phone width, a thumb kept its old size until thumbFit ran. In Routing at 560 to 1100 in WebKit, the group-names strip's thumb ran 4px past the view, and the view got a sideways scrollbar 10px tall. thumbFit then moved the thumb back, which changed the view's height inside its own callback, and WebKit reported a ResizeObserver loop (routing-held-dot, routing-rule-columns). Found by tagging each ResizeObserver with its creation stack. Then, on the first frame after the resize, I hid the view's descendants one at a time to see which one widened it. Broken by hand: without this change routing-held-dot is red 5 of 5 in WebKit at 560px, and with the phone's option size back at 44px it passes. Run: routing-held-dot, routing-rule-columns and the 14 GUI files that mention the thumb, on mote, both engines: 189 of 189 pass. Budget: the code and its comment were made shorter so the core scripts stay under TestCoreScriptBudget's 1,533,105, which isn't raised. After the rebase, in the 116-file run below: routing-held-dot, routing-rule-columns and segs-glide pass in both engines. --- internal/gui/assets/app.js | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index d7f06dd6d..7e2df6eca 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -8912,21 +8912,19 @@ function thumbNow(th) { const thumbPick = (box, on) => [...box.children].filter((c) => !c.classList.contains("thumb")).indexOf(on); const thumbSame = (a, b) => Math.abs(a.x - b.x) < 0.5 && Math.abs((a.y || 0) - (b.y || 0)) < 0.5 && Math.abs(a.w - b.w) < 0.5; // a control shown, or sized again (the fonts come in, the language changes, -// the window narrows): its thumb is put under its option, still +// the window narrows, on its resize first): its thumb is put under its option +function thumbRefit(box) { + const th = box.querySelector(":scope > .thumb"), on = box.querySelector(":scope > .on"), to = th && on && thumbTo(box, on); + if (!to) return; + const control = thumbKey(box, thumbKeys.get(box)), last = control && thumbs.get(control), pick = thumbPick(box, on); + if (last?.th === th && last.pick === pick && thumbSame(last.to, to) && th.style.width) return; + thumbPut(th, to); + if (control) thumbs.set(control, { th, pick, to }); +} const thumbFit = new ResizeObserver((es) => { - for (const { target: box } of es) { - if (!box.isConnected) { thumbFit.unobserve(box); continue; } - const th = box.querySelector(":scope > .thumb"), on = box.querySelector(":scope > .on"); - const to = th && on && thumbTo(box, on); - if (!to) continue; - const control = thumbKey(box, thumbKeys.get(box)); - const last = control && thumbs.get(control); - const pick = thumbPick(box, on); - if (last?.th === th && last.pick === pick && thumbSame(last.to, to) && th.style.width) continue; - thumbPut(th, to); - if (control) thumbs.set(control, { th, pick, to }); - } + for (const { target: box } of es) box.isConnected ? thumbRefit(box) : thumbFit.unobserve(box); }); +addEventListener("resize", () => document.querySelectorAll(".segs").forEach(thumbRefit)); function slide(box, key) { const control = thumbKey(box, key); const last = control && thumbs.get(control);