diff --git a/bench/filter-overflow/check.sh b/bench/filter-overflow/check.sh
new file mode 100755
index 000000000..7ce2f2d0c
--- /dev/null
+++ b/bench/filter-overflow/check.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+# A filter takes in all its element draws, as Chrome filters it: what its descendants draw outside its box too.
+# raea-page's filter layer was the element's border box grown by the filter's reach, so a blurred wrapper of no size
+# lost its absolutely positioned children (a few px of blur were left), and a 60 px box with grayscale(1) showed 60 px
+# of a 200x100 child. page.tsx draws both, and the same box clipping its overflow (which must still cut the child)
+# and clipping x alone (which cuts its side and shows all its height), and a grayscale box around a square whose
+# own drop shadow falls outside it. Each probe is Chrome 157's pixel, within 3.
+# The layer stops at a clip in the way: clipped.tsx's 120 small filtered boxes each show 60 px of a child that
+# covers the frame, cut four ways, 30 boxes each (a clipping box inside, one the stacking context paints, the
+# filtered box's own clip over a z-indexed child, a `contain: paint` box inside). 30 layers the size of the frame
+# are more than Vello's image atlas holds, so its 120 tiles are counted (from the frame's mean: each is 60x60 of
+# grey 92 on white). Exits 1 on a failure.
+# bench/filter-overflow/check.sh (RAEA_BIN: the raea to run, default target/release/raea)
+cd "$(dirname "$0")/../.." || exit 2
+BIN=${RAEA_BIN:-$PWD/target/release/raea}
+export RAEA_SIGN=0 RAEA_MARK=0 RAEA_EXPORT_CACHE=0
+OUT=$(mktemp -d "${TMPDIR:-/tmp}/raea-filter-overflow.XXXXXX")
+trap 'rm -rf "$OUT"' EXIT
+for c in page clipped; do
+ mkdir -p "$OUT/$c"
+ "$BIN" render bench/filter-overflow/$c.tsx --at 0 -o "$OUT/$c" > "$OUT/$c.log" 2>&1 && [ -f "$OUT/$c/frame-00000.png" ] || { echo "FAIL $c: the render failed"; sed 's/^/ /' "$OUT/$c.log" | tail -4; exit 1; }
+done
+status=0
+want() { # X,Y R G B WHAT: page.tsx's pixel, each channel within 3
+ local p; p=$(magick "$OUT/page/frame-00000.png" -alpha off -format "%[fx:int(255*p{$1}.r+0.5)] %[fx:int(255*p{$1}.g+0.5)] %[fx:int(255*p{$1}.b+0.5)]" info:)
+ read -r r g b <<< "$p"
+ (( r - $2 <= 3 && $2 - r <= 3 && g - $3 <= 3 && $3 - g <= 3 && b - $4 <= 3 && $4 - b <= 3 )) || { echo "FAIL at $1: $p, wanted $2 $3 $4 ($5)"; status=1; }
+}
+want 100,100 255 0 0 "a blurred wrapper's first child, its middle"
+want 240,100 0 0 255 "its second child"
+want 430,90 54 54 54 "a grayscale box's red child"
+want 530,90 54 54 54 "the child's own drop shadow, outside the box"
+want 480,90 255 255 255 "between them"
+want 70,250 92 92 92 "a grayscale box's child, inside the box"
+want 190,270 92 92 92 "the child past the box"
+want 190,330 255 255 255 "below the child"
+want 370,250 92 92 92 "a clipping box's child, inside the box"
+want 450,270 255 255 255 "its child past the box, clipped"
+want 500,300 92 92 92 "a box clipping x alone: its child below the box"
+want 580,250 255 255 255 "and its child past its side, clipped"
+tiles=$(magick "$OUT/clipped/frame-00000.png" -alpha off -colorspace gray -format "%[fx:int((1-mean)*1920*1080/(3600*(1-92/255))+0.5)]" info:)
+[ "$tiles" = 120 ] || { echo "FAIL clipped.tsx: $tiles of its 120 tiles drawn"; status=1; }
+[ $status = 0 ] && echo "PASS a filter over what its element draws outside its box"
+exit $status
diff --git a/bench/filter-overflow/clipped.tsx b/bench/filter-overflow/clipped.tsx
new file mode 100644
index 000000000..0343cf231
--- /dev/null
+++ b/bench/filter-overflow/clipped.tsx
@@ -0,0 +1,24 @@
+// 120 small filtered boxes, each showing 60 px of a child that covers the frame from any of them, cut four ways, 30
+// boxes each: by a clipping box inside; by one positioned with a z-index (the filtered box's stacking context paints
+// it); by the filtered box's own clip, the child positioned with a z-index; and by a `contain: paint` box inside.
+// 120 grey 60 px tiles on white. A filter's layer reaches over what its element draws, and stops at a clip in
+// the way: made from the element's overflow, which reaches through clips, each of these layers would be the size of
+// the frame, and 30 of them are more than Vello's image atlas holds, of either kind. bench/filter-overflow/check.sh
+import { AbsoluteFill, Composition, registerRoot } from "raea";
+function O() {
+ return (
+
+ {Array.from({ length: 120 }, (_, i) => {
+ const kind = Math.floor(i / 30);
+ const cover = ;
+ const inner = [{ overflow: "hidden" }, { overflow: "hidden", position: "relative", zIndex: 1 }, null, { contain: "paint" }][kind];
+ return (
+
+ {inner ?
{cover}
: cover}
+
+ );
+ })}
+
+ );
+}
+registerRoot(() => );
diff --git a/bench/filter-overflow/page.tsx b/bench/filter-overflow/page.tsx
new file mode 100644
index 000000000..9cbf6a706
--- /dev/null
+++ b/bench/filter-overflow/page.tsx
@@ -0,0 +1,26 @@
+// A filter takes in all its element draws, what its descendants draw outside its box included. Top: a wrapper of no
+// size with a blur, around two absolutely positioned squares; and a 60 px box with grayscale(1) around a red square
+// whose own drop shadow falls 100 px to its right. Below, a 60 px box with grayscale(1) holding a 200x100 green
+// child, three ways: as it is (all of the child shows), clipping its overflow (60 px of it), and clipping x alone
+// (60 px wide, all 100 px tall). bench/filter-overflow/check.sh
+import { AbsoluteFill, Composition, registerRoot } from "raea";
+const square = (left: number, background: string) =>
;
+const box = (left: number, clip: object) => (
+
+);
+function O() {
+ return (
+
+ {square(0, "#f00")}{square(140, "#00f")}
+
+ {box(40, {})}
+ {box(340, { overflow: "hidden" })}
+ {box(480, { overflowX: "clip", overflowY: "visible" })}
+
+ );
+}
+registerRoot(() => );
diff --git a/vendor/blitz-paint/src/render.rs b/vendor/blitz-paint/src/render.rs
index 5a7d211ce..3e9fb3b4c 100644
--- a/vendor/blitz-paint/src/render.rs
+++ b/vendor/blitz-paint/src/render.rs
@@ -722,6 +722,56 @@ impl<'dom, 'a> BlitzDomPainter<'dom, 'a> {
(if plain { Phase::Blocks } else { Phase::Inlines }, plain)
}
+ /// raea: the boxes `node_id` and its descendants draw, in its own space: `scrollable_overflow`'s walk (blitz-dom's
+ /// resolve_transforms), cut on each axis an element clips (both, under `contain: paint`) to that element's box
+ /// grown by its overflow-clip-margin, as its clip cuts what is drawn (the root element clips nothing: `should_clip`).
+ /// The overflow itself reaches through every clip, so a layer made from it is as large as content nobody sees: a
+ /// filtered card around a small clipping box with a page of content in it would be drawn into a texture the size
+ /// of the page. With `own_filter`, grown by the reach of the element's own filter, which draws past its boxes (a
+ /// descendant's drop shadow).
+ fn drawn_bounds(&self, node_id: NodeId, own_filter: bool) -> Rect {
+ let dom = self.dom.as_ref();
+ let Some(node) = dom.get_node(node_id) else { return Rect::ZERO };
+ let size = node.final_layout().size;
+ let own = Rect::new(0.0, 0.0, size.width as f64 * self.scale, size.height as f64 * self.scale);
+ let styles = node.primary_styles();
+ 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, paint) = (s.get_box(), contains_paint(s));
+ (paint || !matches!(b.overflow_x, Overflow::Visible), paint || !matches!(b.overflow_y, Overflow::Visible), s.get_margin().overflow_clip_margin.offset.0.px() as f64 * self.scale.max(1.0))
+ });
+ let filtered = |r: Rect| match styles.as_ref().filter(|_| own_filter).and_then(|s| convert_filters(&s.get_effects().filter.0)) {
+ Some(f) => {
+ let reach = f.expansion_rect();
+ Rect::new(r.x0 + reach.x0, r.y0 + reach.y0, r.x1 + reach.x1, r.y1 + reach.y1)
+ }
+ None => r,
+ };
+ let clip = own.inflate(grow.max(0.0), grow.max(0.0));
+ if clips_x && clips_y {
+ return filtered(clip);
+ }
+ let mut all = own;
+ let in_flow = node.layout_children.borrow();
+ let in_flow = in_flow.iter().flatten().copied().filter(|&c| dom.get_node(c).is_some_and(|c| !c.is_out_of_flow()));
+ let pseudos = [node.before(), node.after()].into_iter().flatten().filter(|&c| dom.get_node(c).is_some_and(|c| !c.is_out_of_flow()));
+ for child_id in in_flow.chain(node.hoisted_children.borrow().iter().copied()).chain(pseudos) {
+ let Some(child) = dom.get_node(child_id) else { continue };
+ let at = child.final_layout().location;
+ let mut to_own = Affine::translate((at.x as f64 * self.scale, at.y as f64 * self.scale));
+ if let Some(t) = child.transform().as_deref() {
+ to_own *= *t;
+ }
+ all = all.union(to_own.transform_rect_bbox(self.drawn_bounds(child_id, true)));
+ }
+ if clips_x {
+ (all.x0, all.x1) = (all.x0.max(clip.x0), all.x1.min(clip.x1));
+ }
+ if clips_y {
+ (all.y0, all.y1) = (all.y0.max(clip.y0), all.y1.min(clip.y1));
+ }
+ filtered(all)
+ }
+
fn render_element(
&self,
scene: &mut impl PaintScene,
@@ -1183,6 +1233,24 @@ impl<'dom, 'a> BlitzDomPainter<'dom, 'a> {
.unwrap_or(Rect::ZERO);
let mut effect_layer_clip = cx.frame.border_box_path().bounding_box();
+ // raea: a filter's input is all the element draws, what its descendants draw outside its box
+ // included, as Chrome filters it (a 0x0 wrapper's absolutely positioned children were cut off at its
+ // box, a blur's reach of them left): its boxes up to the clips in their way (`drawn_bounds`), and the
+ // same of each out-of-flow box its stacking context paints past its clip, from a containing block
+ // above it (#39's `from_above`: the walk doesn't meet those), where hoisted_content_bbox places it.
+ // The stacking context's other boxes are met by the walk, under the clips they're painted under
+ if filter.is_some() {
+ effect_layer_clip = effect_layer_clip.union(self.drawn_bounds(node_id, false));
+ for hoisted in node.stacking_context.iter().flat_map(|sc| sc.children.iter()).filter(|c| cx.from_above(c.node_id)) {
+ let Some(child) = self.dom.as_ref().get_node(hoisted.node_id) else { continue };
+ let (p, at) = (hoisted.position(node.tree(), node_id), child.final_layout().location);
+ let mut to_own = Affine::translate(((p.x + at.x) as f64 * self.scale, (p.y + at.y) as f64 * self.scale));
+ 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)));
+ }
+ }
effect_layer_clip.x0 += filter_expansion_area.x0;
effect_layer_clip.y0 += filter_expansion_area.y0;
effect_layer_clip.x1 += filter_expansion_area.x1;
@@ -2428,6 +2496,14 @@ fn create_css_rect(style: &ComputedValues, layout: &Layout, scale: f64) -> CssBo
frame
}
+/// raea: whether `contain: paint` clips an element's contents, as render_element's `contain_paint` has it (not a
+/// non-atomic inline's, nor an internal table box's other than a cell)
+fn contains_paint(styles: &style::properties::ComputedValues) -> bool {
+ let display = styles.clone_display();
+ let table_part = display.outside() == DisplayOutside::InternalTable && display.inside() != DisplayInside::TableCell;
+ styles.get_box().clone_contain().contains(Contain::PAINT) && !display.is_inline_flow() && !table_part
+}
+
/// raea: what an overflow clip clips to: overflow-clip-margin's visual box (the padding box by default), grown by its
/// offset (bevy_ui's OverflowClipMargin, ComputedNode::resolve_clip_rect). A grown one is a rect, as Bevy's clip is.
fn overflow_clip_box(frame: &CssBox, m: &style::values::computed::OverflowClipMargin) -> crate::kurbo_css::BoxShape {
diff --git a/vendor/vendor.toml b/vendor/vendor.toml
index ac84fa754..c78600307 100644
--- a/vendor/vendor.toml
+++ b/vendor/vendor.toml
@@ -63,7 +63,7 @@ exit = "a bevy_ui_widgets release on parley 0.12"
path = "vendor/blitz-paint"
upstream = "crates.io:0.3.0-beta.4"
kind = "patch"
-reason = "angled tile gradients, many-tile gradient layers as one brush, text-shadow, ellipsis, inline-box opacity, box-shadow blur as Chrome's; filters by GPU passes (B4a/B4b); z-index boxes clipped by the overflow between them and their stacking context; a range input's thumb; what an element paints at an offset of its own (background position and tiles, box and text shadows, scroll, inline SVG) placed in its own axes under a rotated ancestor (#18); background-clip: text, its background masked by the text of the element and everything in it (#37) as Chrome does, unscrolled; inline text in a scroller scrolled once, not twice (#46); a rounded corner where one side has no width (a left-only border on a rounded box), which drew nothing; a bevy_ui node's box shadow (data-raea-bevy-shadow, its BoxShadowSamples) drawn as bevy_ui draws it: spread by its width and its height and corners by the same ratio, then blurred as box_shadow.wesl blurs it, from a CPU bitmap (render/bevy_shadow.rs); a stacking context's out-of-flow boxes from containing blocks above it kept in its layer and not culled (raea #39)"
+reason = "angled tile gradients, many-tile gradient layers as one brush, text-shadow, ellipsis, inline-box opacity, box-shadow blur as Chrome's; filters by GPU passes (B4a/B4b); z-index boxes clipped by the overflow between them and their stacking context; a range input's thumb; what an element paints at an offset of its own (background position and tiles, box and text shadows, scroll, inline SVG) placed in its own axes under a rotated ancestor (#18); background-clip: text, its background masked by the text of the element and everything in it (#37) as Chrome does, unscrolled; inline text in a scroller scrolled once, not twice (#46); a rounded corner where one side has no width (a left-only border on a rounded box), which drew nothing; a bevy_ui node's box shadow (data-raea-bevy-shadow, its BoxShadowSamples) drawn as bevy_ui draws it: spread by its width and its height and corners by the same ratio, then blurred as box_shadow.wesl blurs it, from a CPU bitmap (render/bevy_shadow.rs); a stacking context's out-of-flow boxes from containing blocks above it kept in its layer and not culled (raea #39); a filter's layer over the boxes the element and its descendants draw (up to the overflow clips in their way), not its border box alone"
exit = "a Blitz release that draws these"
[blitz-dom]