Skip to content

Commit 4bee04e

Browse files
vanceingallsclaude
andauthored
fix(core): a mover's ::before and ::after outside its box stay in the blur (#7295)
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
1 parent b6f2bec commit 4bee04e

4 files changed

Lines changed: 32 additions & 15 deletions

File tree

‎packages/core/src/runtime/captureMotionBlur/frames.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,32 @@ function growToRect(box: Box, back: Affine, r: DOMRect): void {
5353
}
5454
}
5555

56+
const POSITIONED = new Set(["absolute", "fixed"]);
57+
const NO_CONTENT = new Set(["none", "normal"]);
58+
59+
function pseudoBox(el: HTMLElement, which: "::before" | "::after"): Box | null {
60+
const cs = getComputedStyle(el, which);
61+
if (NO_CONTENT.has(cs.content) || !POSITIONED.has(cs.position)) return null;
62+
const left = parseFloat(cs.left) + el.clientLeft;
63+
const top = parseFloat(cs.top) + el.clientTop;
64+
const width = parseFloat(cs.width);
65+
const height = parseFloat(cs.height);
66+
if (![left, top, width, height].every(Number.isFinite)) return null;
67+
return [left, top, left + width, top + height];
68+
}
69+
70+
function growToBox(box: Box, other: Box | null): void {
71+
if (!other) return;
72+
box[0] = Math.min(box[0], other[0]);
73+
box[1] = Math.min(box[1], other[1]);
74+
box[2] = Math.max(box[2], other[2]);
75+
box[3] = Math.max(box[3], other[3]);
76+
}
77+
5678
function grownBox(el: HTMLElement, pose: Affine, scene: HTMLElement, frameW: number): Box {
5779
const box: Box = [0, 0, el.offsetWidth, el.offsetHeight];
80+
growToBox(box, pseudoBox(el, "::before"));
81+
growToBox(box, pseudoBox(el, "::after"));
5882
const back = clientToMover(pose, scene, frameW);
5983
if (!back) return box;
6084
const own = el.getBoundingClientRect();

‎packages/engine/src/services/__fixtures__/motionBlur/sweepFixtures.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ const SWEEP_FIXTURES = [
105105
name: "pseudo-after",
106106
css: ".m::after { content: ''; position: absolute; left: 130px; top: 10px; width: 60px; height: 60px; background: #ffd166; border-radius: 50% }",
107107
}),
108+
sweepFixture({
109+
name: "pseudo-before",
110+
css: ".m::before { content: ''; position: absolute; left: -90px; top: 10px; width: 60px; height: 60px; background: #ffd166; border-radius: 50% }",
111+
}),
108112
// E: the mover's own clip-path.
109113
sweepFixture({
110114
name: "own-clip-polygon",

‎packages/engine/src/services/__fixtures__/motionBlur/thresholds.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ export const SWEEP_SYMPTOMS = {
5252
A: 47.67,
5353
B: 148.63,
5454
C: 73.02,
55-
D_CAPTURE: 107.66,
56-
D_FILTER: 107.66,
5755
E: 27.6,
5856
F_CAPTURE: 40.62,
5957
H: 135.67,

‎packages/engine/src/services/captureMotionBlur.sweep.browser.test.ts‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,10 @@ const CASES: readonly SweepCase[] = [
115115
measuredMae: S.C,
116116
},
117117
},
118-
...(["capture", "filter"] as const).map(
119-
(tier): SweepCase => ({
120-
fixture: "pseudo-after",
121-
tier,
122-
frame: 14,
123-
check: "inside",
124-
bug: {
125-
finding: "D",
126-
reason: "an ::after drawn outside the mover's box is cut off",
127-
regions: [rect(376, 150, 72, 68)],
128-
measuredMae: tier === "capture" ? S.D_CAPTURE : S.D_FILTER,
129-
},
130-
}),
118+
...(["pseudo-after", "pseudo-before"] as const).flatMap((fixture) =>
119+
(["capture", "filter"] as const).map(
120+
(tier): SweepCase => ({ fixture, tier, frame: 14, check: "inside" }),
121+
),
131122
),
132123
{
133124
fixture: "own-clip-polygon",

0 commit comments

Comments
 (0)