Skip to content

A filter takes in what its element draws outside its box, as Chrome filters it - #93

Merged
shinyobjectz merged 2 commits into
shinyobjectz:mainfrom
JimGHTB12:filter-layer-overflow
Nov 10, 2026
Merged

shinyobjectz merged 2 commits into
shinyobjectz:mainfrom
JimGHTB12:filter-layer-overflow

Conversation

@JimGHTB12

@JimGHTB12 JimGHTB12 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

A filter cuts off whatever its element's descendants draw outside the element's own box.

<div style={{ position: "absolute", left: 40, top: 40, filter: "blur(4px)" }}>
  <div style={{ position: "absolute", left: 0, top: 0, width: 120, height: 120, background: "#f00" }} />
  <div style={{ position: "absolute", left: 140, top: 0, width: 120, height: 120, background: "#00f" }} />
</div>

Chrome draws two blurred squares. raea draws a few px of blur at the wrapper's corner and nothing else. A 60 px box with grayscale(1) shows 60 px of a 200x100 child. The same wrappers with opacity in place of the filter draw whole.

Why

blitz-paint makes a filtered element's layer from its border box grown by the filter's reach (effect_layer_clip), and raea-sys-filters sizes the layer's texture from that clip. What the descendants draw outside the box never reaches the texture. An opacity group already reaches over the element's overflow, which is why opacity was right.

Change

All in vendor/blitz-paint/src/render.rs. A filtered element's layer now reaches over the boxes it and its descendants draw, and over the out-of-flow boxes its stacking context paints past its clip (#39's from_above), then grows by the filter's reach as before.

The bounds come from a new drawn_bounds, which is scrollable_overflow's walk (blitz-dom's resolve_transforms) with two differences:

  • It stops at clips. On each axis an element clips (both, under contain: paint), the bounds are cut to that element's box grown by its overflow-clip-margin. The root element clips nothing, as in should_clip. Using the overflow itself was the first version of this change, and it was wrong: the overflow reaches through every clip, so small filtered boxes around a clipping box with large content became layers the size of the frame. Sixty of them drew no tiles at all.
  • A descendant's own filter counts with its reach, so its drop shadow outside the box is taken in.

raea-sys-filters still cuts a layer to the page grown by the reach, so no layer is larger than that.

Two commits. The second answers the two Codex review comments on the first: the stacking context's boxes painted inside the clip are no longer added whole (the walk meets them, under the clips they are painted under), and contain: paint stops the walk.

Testing

bench/filter-overflow/check.sh (new). page.tsx is probed at twelve pixels for Chrome 157's values, read from a screenshot of the same markup. clipped.tsx is 120 small filtered boxes, each showing 60 px of frame-covering content cut one of four ways (a clipping box inside, one the stacking context paints, the filtered box's own clip over a z-index child, a contain: paint box inside), and its tiles are counted.

main this branch
page.tsx, 12 probes 5 fail: both blurred squares missing, a child's drop shadow cut, a child cut at the box, and at the box's foot under a lone x clip all pass
clipped.tsx 120 of 120 tiles 120 of 120 tiles (the first commit alone: 60 of 120)
the whole 640x360 frame against Chrome 157's screenshot 57,915 pixels more than 8 levels off every pixel within 1 level
bench/opacity-out-of-flow/check.sh PASS PASS
8 frame-sized planes with a perspective transform, every third blurred (3 stills) identical to main, pixel for pixel

Run on Windows 11 (Vulkan) with release builds, main at bb0a176. tools/size.sh, layers.sh, names.sh, one-version.sh, no-void.sh and public-guard.sh pass on the branch.

Limits

  • A descendant's box-shadow or outline, and a descendant's url() filter, still end at the boxes' bounds, as they do in an opacity group.
  • A filtered element inside an element with a perspective transform is still cut to the page's rectangle in that element's own space (raea-sys-filters' region). Not touched here.
  • A filtered element whose content really does overflow far now has a larger layer, up to the page plus the reach. Memory for a page with many of them was not measured.
  • Not run: macOS and Linux, WPT, the P26 corpus. cargo dupes and cargo shear aren't installed here.

The first commit was reviewed over three rounds by GPT-6.1 Sol (high effort), a different model family from the one that wrote it. Stopping at overflow clips, the stacking context's boxes, the root element and a descendant's own filter reach all came from its findings. The last of those, and the second commit, have not been reviewed again.

Created with Claude Fable 5.2 in T3 Code (Claude Code).

🤖 Generated with Claude Code

…ilters it

blitz-paint made a filtered element's layer from its border box grown by the filter's reach, and raea-sys-filters
sizes the layer's texture from that clip. So whatever the element's descendants drew outside its box was cut off
before the filter ran: a wrapper of no size with `filter: blur(4px)` around absolutely positioned children drew a few
px of blur and nothing else, and a 60 px box with `grayscale(1)` showed 60 px of a 200x100 child. The same wrappers
with `opacity` drew whole, since an opacity group already reaches over the element's overflow.

A filtered element's layer now reaches over the boxes it and its descendants draw (drawn_bounds), and the same of
each box its stacking context paints, then grows by the filter's reach as before. drawn_bounds is
scrollable_overflow's walk (blitz-dom's resolve_transforms: each child's box through its transform) with two
differences. It is cut, on each axis an element clips, to that element's box grown by its overflow-clip-margin
(the root element clips nothing, as in should_clip). The overflow itself reaches through every clip, and a texture
made from it is as large as content nobody sees: small filtered boxes, each around a clipping box with a child
covering the frame, became layers the size of the frame, more than Vello's image atlas holds, and tiles went
missing. And a descendant with a filter of its own counts with that filter's reach (its drop shadow).
raea-sys-filters still cuts a layer to the page grown by the reach.

bench/filter-overflow/check.sh: page.tsx draws the blurred wrapper, a grayscale box around a square with its own
drop shadow, and the grayscale box three ways (as it is, clipping its overflow, clipping x alone), probed at twelve
pixels for Chrome 157's values, read from a screenshot of the same markup; clipped.tsx is 60 small filtered boxes
around clipping boxes with frame-covering content, half of them painted by the stacking context, its tiles counted.
The raea before this fails five probes; with it all pass and all 60 tiles are drawn.

Not covered: a box-shadow or an outline of a descendant, and a descendant's url() filter, still end at the boxes'
bounds; a box the stacking context paints that a clip between the two cuts is counted whole (a larger layer, never
a smaller one); and a filtered element inside an element with a perspective transform is still cut to the page's
rectangle in that element's own space (raea-sys-filters' region).

Co-Authored-By: Claude <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T22:05:13.820002Z 43e8892 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 43e8892ce2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if let Some(t) = child.transform().as_deref() {
to_own *= *t;
}
effect_layer_clip = effect_layer_clip.union(to_own.transform_rect_bbox(self.drawn_bounds(hoisted.node_id, true)));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Clip hoisted bounds before adding them to the filter region

For a small filtered overflow: hidden box containing a frame-covering position: relative; z-index: 1 child, this union adds the entire child back after drawn_bounds(node_id, false) correctly stopped at the owner's clip. draw_children actually paints that child inside the clip, so the new frame-sized texture contains almost entirely invisible content. Sixty such cards arranged like bench/filter-overflow/clipped.tsx require 124,416,000 image texels, exceeding Vello's 8192×8192 atlas; resolve_pending_images in vendor/vello_encoding/src/resolve.rs then omits images whose allocations fail. Intersect ordinary hoisted-child bounds with their applicable clips before unioning them, while preserving the separate treatment of children painted outside those clips.

Useful? React with 👍 / 👎.

Comment thread vendor/blitz-paint/src/render.rs Outdated
Comment on lines +738 to +740
let (clips_x, clips_y, grow) = styles.as_ref().filter(|_| self.root_element_id != Some(node_id)).map_or((false, false, 0.0), |s| {
let b = s.get_box();
(!matches!(b.overflow_x, Overflow::Visible), !matches!(b.overflow_y, Overflow::Visible), s.get_margin().overflow_clip_margin.offset.0.px() as f64 * self.scale.max(1.0))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Stop the bounds walk at paint-containment clips

When a filtered card contains a small contain: paint box with oversized descendants, this predicate treats both axes as unclipped because their overflow remains visible. However, render_element already clips that content through its contain_paint/should_clip condition. The new walk therefore expands the filter texture over content that cannot be painted: replacing the inner overflow: hidden in the added 60-card benchmark with contain: paint produces frame-sized textures and exceeds the image-atlas capacity, even without any hoisted children. Include the same paint-containment eligibility used by should_clip when determining the bounds walk's clipped axes.

Useful? React with 👍 / 👎.

…the boxes its stacking context paints

Two more ways the layer grew over content nobody sees, both from the Codex review of the first commit:
- the stacking context's boxes were all added whole, where hoisted_content_bbox places them. Only the ones painted
  past the clip need that (the out-of-flow boxes from containing blocks above, shinyobjectz#39's from_above, which the walk
  doesn't meet). The others are met by the walk, under the clips they are painted under, so a filtered
  `overflow: hidden` box with a frame-covering `z-index` child keeps a layer its own size;
- drawn_bounds stops at a `contain: paint` box as at an overflow clip (render_element's contain_paint).

bench/filter-overflow/clipped.tsx is now 120 boxes cut four ways, 30 each. The first commit drew 60 of its 120
tiles: each of the two new kinds made 30 layers the size of the frame, more than Vello's image atlas holds.

Co-Authored-By: Claude <noreply@anthropic.com>
@shinyobjectz
shinyobjectz merged commit d407fde into shinyobjectz:main Nov 10, 2026
4 checks passed
@shinyobjectz

Copy link
Copy Markdown
Owner

Merged, thanks. Stopping at clips was the right call, and the 120-box tile count shows it. I'll run bench/filter-overflow on macOS with the next build and report here if anything differs.

shinyobjectz added a commit that referenced this pull request Nov 16, 2026
…y (80067cc, pushed and merged), with #91's characters guide and #92's reference/feed.md (plan_close, raea-feed #61), whose stale copy failed every lane's L0 and L1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants