Repository navigation
Masks: re-read boxes at every shot, clip to overflow, cover overflowing children - #86
Merged
Merged
Conversation
…ng children Fixes #72 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A box-less display:contents ancestor with a position set made an absolute mask look clipped by overflow ancestors it escapes, so the mask came out empty. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tmashara
force-pushed
the
claude/issue-72-mask-geometry
branch
from
October 29, 2026 18:39
c6252ec to
fd9de67
Compare
This was referenced Oct 29, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three fixes to where a mask is painted, all in
src/capture.ts.What and why
1. Boxes are re-read at every shot. Mask boxes were read once, after settle, and that rect was painted in every stability attempt. Anything that re-lays out after the read (a ScrollTrigger pin refreshing after
scrollTo(0,0)) was painted at its old position, so the masked content leaked.shoot()now reads the boxes right before and right after each screenshot and paints both sets, so a box that moves while the shot is taken stays covered. A box that moves between attempts makes the painted shots differ, so the existing stability loop marks old and new rectsunstableinstead of painting a stale rect. The tiled path, recheck and the #83 retry all go throughcapture()and get this too.2. Masks are clipped to their
overflowancestors. A masked element taller than itsoverflow:hiddenwrapper was painted at its full box, covering content outside the wrapper that both sides render. The in-page read now cuts each rect to the border box of every ancestor that clips it (per axis; skippinginline/display:contentsancestors, honouring the containing block of absolute and fixed boxes, stopping atbodyso the viewport edge does the rest).3. A mask covers what its children paint outside its box. Masking a video.js player left its poster (positioned above the player) unmasked, which needed a second mask on every page. Every visible descendant that paints outside the element now gets its own rect, each clipped by its own ancestors (a carousel track's off-screen slides aren't painted) and dropped if it ends up inside the element's box.
checkVisibility({ opacityProperty, visibilityProperty })excludesopacity:0/visibility:hiddendescendants (a closed dropdown under a masked header). Always on; no option.To keep (3) cheap,
paintBoxesfills raw pixels instead of compositing one sharp input per rect.What stays as today
locatereturns a locator inside a frame gets frame-viewport coordinates from an in-page read, somaskRectsreturnsnullthere and that locator falls back to today'sboundingBox()(no clip, no descendants).--mask-mediamasks theiframeelement in the main frame, so it takes the new path.innerText, restore),masksFor, andlocate/snapshot(which already skip the whole masked subtree) are untouched.Performance
paintBoxeson a 1440×20000 PNG (this machine):The in-page read: 5 ms for a 5k-node masked subtree, 30–38 ms for 50k nodes; ×2 reads ×≤3 attempts, so at most ~0.25 s per shot on a very large mask. The full visual suite took ≈143 s here with this change (not compared against
main).Behaviour change
Mask pixels change: masks now grow by what their children paint outside them and shrink where an
overflowancestor clips them. Accepted-diff entries that cover a masked area may stop matching and need re-accepting — in CI, since hashes recorded on macOS don't match Linux.How tested
New guard-rail fixture
tests/fixtures/pages/mask-geometryand configtests/fixtures/configs/mask-geometry.mjs, with two tests intests/visual/guardrails.test.ts(masks): unmasked it differs; masked it reachesdiffPixels === 0, plus six pixel probes per side. Each part was checked to bite by reverting just that part:maincheckVisibilityopacity:0menu magentanpm run typecheck,lint,format:check,npm test(314) andnpm run test:visual(339) pass.Fixes #72
🤖 Generated with Claude Code