Panes: curves kept off a peeking pane in browsers that keep a masked layer's painting
Each mask takes a new name when its holes change, so the curve layer's own attribute changes and it is painted again. Moving between panes in a column that already peeks draws the curves again too. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab
This commit is contained in:
1 parent
a2ec5a6eab
commit
9dec4df1fd
2 files changed
+19
-9
No files matched your search
+6
-4
@@ -418,13 +418,15 @@ export const curveFaults = (page: Page) =>
|
||||
}
|
||||
// What peeks: its place left clear of every curve but its own; nothing left over once it is back.
|
||||
const peeked = [...document.querySelectorAll<HTMLElement>("[data-peek]")];
|
||||
const holes = [...document.querySelectorAll<SVGRectElement>("#ie-curve-holes rect.hole")].map((r) => ({ x: +r.getAttribute("x")! + box.left, y: +r.getAttribute("y")! + box.top, w: +r.getAttribute("width")!, h: +r.getAttribute("height")! }));
|
||||
const holes = [...document.querySelectorAll<SVGRectElement>('mask[data-kind="ie-curve-holes"] rect.hole')].map((r) => ({ x: +r.getAttribute("x")! + box.left, y: +r.getAttribute("y")! + box.top, w: +r.getAttribute("width")!, h: +r.getAttribute("height")! }));
|
||||
const under = document.querySelector<SVGGElement>(".curves g.under");
|
||||
/** Whether a layer is masked by the mask of this kind (its name changes with its holes). */
|
||||
const masked = (g: SVGGElement | null, kind: string) => g?.getAttribute("mask") === `url(#${document.querySelector(`mask[data-kind="${kind}"]`)?.id})`;
|
||||
const over = [...document.querySelectorAll<SVGPathElement>(".curves g.over path")];
|
||||
for (const p of peeked) {
|
||||
const r = p.getBoundingClientRect();
|
||||
if (!holes.some((h) => Math.abs(h.x - r.left) < 1.5 && Math.abs(h.y - r.top) < 1.5 && Math.abs(h.w - r.width) < 1.5 && Math.abs(h.h - r.height) < 1.5)) faults.push(`peeking ${p.className}: its place is not clear of the curves`);
|
||||
if (under && under.getAttribute("mask") !== "url(#ie-curve-holes)") faults.push("peeking: the curves under it are not masked");
|
||||
if (under && !masked(under, "ie-curve-holes")) faults.push("peeking: the curves under it are not masked");
|
||||
}
|
||||
const owns = (id: string | undefined) => peeked.some((q) => q.contains(document.querySelector(`.pane[data-tid="${id}"]`)));
|
||||
// A pane peeking out of a column that peeks too: the column's other panes' curves are over the column, under that pane (it may cover their tabs).
|
||||
@@ -433,10 +435,10 @@ export const curveFaults = (page: Page) =>
|
||||
for (const p of over) if (!paneOwns(p.dataset.from) && !paneOwns(p.dataset.to)) faults.push(`${p.dataset.key}: over what peeks, but not its own`);
|
||||
const mid = document.querySelector<SVGGElement>(".curves g.mid");
|
||||
for (const p of document.querySelectorAll<SVGPathElement>(".curves g.mid path")) if (paneOwns(p.dataset.from) || paneOwns(p.dataset.to) || (!owns(p.dataset.from) && !owns(p.dataset.to))) faults.push(`${p.dataset.key}: over the peeking column and under the pane peeking in it, but not only the column's`);
|
||||
const paneHoles = [...document.querySelectorAll<SVGRectElement>("#ie-curve-mid rect.hole")].map((r) => ({ x: +r.getAttribute("x")! + box.left, y: +r.getAttribute("y")! + box.top }));
|
||||
const paneHoles = [...document.querySelectorAll<SVGRectElement>('mask[data-kind="ie-curve-mid"] rect.hole')].map((r) => ({ x: +r.getAttribute("x")! + box.left, y: +r.getAttribute("y")! + box.top }));
|
||||
for (const p of peeked.filter((q) => q.classList.contains("pane") && peeked.some((c) => c !== q && c.contains(q)))) {
|
||||
const r = p.getBoundingClientRect();
|
||||
if (!paneHoles.some((h) => Math.abs(h.x - r.left) < 1.5 && Math.abs(h.y - r.top) < 1.5) || mid?.getAttribute("mask") !== "url(#ie-curve-mid)") faults.push(`peeking ${p.className}: its column's other curves are not kept off it`);
|
||||
if (!paneHoles.some((h) => Math.abs(h.x - r.left) < 1.5 && Math.abs(h.y - r.top) < 1.5) || !masked(mid, "ie-curve-mid")) faults.push(`peeking ${p.className}: its column's other curves are not kept off it`);
|
||||
}
|
||||
const bar = document.querySelector<HTMLElement>(".pane > .selbar");
|
||||
const barShown = !!bar && bar.style.visibility !== "hidden";
|
||||
|
||||
+13
-5
@@ -1028,9 +1028,11 @@ export function Panes() {
|
||||
// Within a column that is out already: only the pane part changes.
|
||||
const col = pane?.parentElement as HTMLElement | undefined;
|
||||
if (col && peeked.includes(col)) {
|
||||
for (const it of peeked.filter((x) => x !== col)) lower(it);
|
||||
const gone = peeked.filter((x) => x !== col);
|
||||
for (const it of gone) lower(it);
|
||||
peeked = [col];
|
||||
peekedFor = pane;
|
||||
if (gone.length) schedule();
|
||||
} else hide();
|
||||
if (!pane || !its.some((x) => !peeked.includes(x))) return;
|
||||
pending = pane;
|
||||
@@ -1938,6 +1940,9 @@ function curves(el: HTMLElement | null, svg: SVGSVGElement | null) {
|
||||
markRuled(els, rules);
|
||||
}
|
||||
|
||||
/** Counts the masks' names (layers). */
|
||||
let maskSeq = 0;
|
||||
|
||||
/**
|
||||
* The curves' three layers: those under what peeks (with holes where it is, and where the selection
|
||||
* bar is); those of a peeking column's other panes, over the column but under a pane of it that
|
||||
@@ -1960,9 +1965,9 @@ function layers(svg: SVGSVGElement, area: DOMRect, holes: { x: number; y: number
|
||||
}
|
||||
// Each part made if missing (a drawing an earlier build of the page began has fewer layers).
|
||||
for (const id of ["ie-curve-holes", "ie-curve-mid", "ie-curve-bar"]) {
|
||||
if (defs.querySelector(`#${id}`)) continue;
|
||||
if (defs.querySelector(`mask[data-kind="${id}"]`)) continue;
|
||||
const m = document.createElementNS(NS, "mask");
|
||||
m.id = id;
|
||||
m.dataset.kind = id;
|
||||
m.setAttribute("maskUnits", "userSpaceOnUse");
|
||||
defs.appendChild(m);
|
||||
}
|
||||
@@ -1982,10 +1987,13 @@ function layers(svg: SVGSVGElement, area: DOMRect, holes: { x: number; y: number
|
||||
const mid = svg.querySelector<SVGGElement>("g.mid")!;
|
||||
const over = svg.querySelector<SVGGElement>("g.over")!;
|
||||
const fill = (id: string, g: SVGGElement, hs: typeof holes) => {
|
||||
const m = svg.querySelector<SVGMaskElement>(`#${id}`)!;
|
||||
const m = svg.querySelector<SVGMaskElement>(`mask[data-kind="${id}"]`)!;
|
||||
const key = hs.map((h) => [h.x, h.y, h.w, h.h].map(Math.round).join(",")).join(";");
|
||||
if (m.dataset.key === key) return;
|
||||
m.dataset.key = key;
|
||||
// A new name each time the holes change, so the layer's own attribute changes with them: a browser
|
||||
// that keeps a masked layer's painting while only the mask's rects change draws it again.
|
||||
m.id = `${id}-${++maskSeq}`;
|
||||
if (!hs.length) {
|
||||
g.removeAttribute("mask");
|
||||
m.replaceChildren();
|
||||
@@ -2000,7 +2008,7 @@ function layers(svg: SVGSVGElement, area: DOMRect, holes: { x: number; y: number
|
||||
return r;
|
||||
});
|
||||
m.replaceChildren(all, ...cut);
|
||||
g.setAttribute("mask", `url(#${id})`);
|
||||
g.setAttribute("mask", `url(#${m.id})`);
|
||||
};
|
||||
fill("ie-curve-holes", under, holes);
|
||||
fill("ie-curve-mid", mid, midHoles);
|
||||
|
||||
Reference in new issue
Block a user