From 43e8892ce23a7b5b7b0aa60cb2f67c2f8e3782d8 Mon Sep 17 00:00:00 2001 From: James Dimachkie Date: Tue, 10 Nov 2026 12:21:53 -0800 Subject: [PATCH 1/2] A filter takes in what its element draws outside its box, as Chrome filters 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 --- bench/filter-overflow/check.sh | 43 ++++++++++++++++++++ bench/filter-overflow/clipped.tsx | 20 ++++++++++ bench/filter-overflow/page.tsx | 26 ++++++++++++ vendor/blitz-paint/src/render.rs | 66 +++++++++++++++++++++++++++++++ vendor/vendor.toml | 2 +- 5 files changed, 156 insertions(+), 1 deletion(-) create mode 100755 bench/filter-overflow/check.sh create mode 100644 bench/filter-overflow/clipped.tsx create mode 100644 bench/filter-overflow/page.tsx diff --git a/bench/filter-overflow/check.sh b/bench/filter-overflow/check.sh new file mode 100755 index 000000000..5c559050e --- /dev/null +++ b/bench/filter-overflow/check.sh @@ -0,0 +1,43 @@ +#!/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 60 small filtered boxes each hold a clipping box with a child +# that covers the frame (30 of the clipping boxes in flow, 30 painted by the filtered box's stacking context), and 30 +# layers the size of the frame are more than Vello's image atlas holds, so its 60 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" = 60 ] || { echo "FAIL clipped.tsx: $tiles of its 60 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..3d3a9c847 --- /dev/null +++ b/bench/filter-overflow/clipped.tsx @@ -0,0 +1,20 @@ +// 60 small filtered boxes, each around a clipping box of its size holding a child that covers the frame from any of +// them (the last 30 clipping boxes positioned with a z-index, so the filtered box's stacking context paints them): +// 60 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: 60 }, (_, i) => ( +
+
+
+
+
+ ))} + + ); +} +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..ab258bdc4 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 to that element's box grown by its + /// overflow-clip-margin, as its overflow 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 = 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)) + }); + 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,22 @@ 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 box its stacking context paints, where that puts it (hoisted_content_bbox's places) + 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()) { + 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; 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] From 4c773e5fcf63e9b726b5042f4c550d04869e4821 Mon Sep 17 00:00:00 2001 From: James Dimachkie Date: Tue, 10 Nov 2026 14:13:17 -0800 Subject: [PATCH 2/2] A filter's layer stops at paint containment and at its own clip over 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, #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 --- bench/filter-overflow/check.sh | 11 ++++++----- bench/filter-overflow/clipped.tsx | 22 +++++++++++++--------- vendor/blitz-paint/src/render.rs | 22 ++++++++++++++++------ 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/bench/filter-overflow/check.sh b/bench/filter-overflow/check.sh index 5c559050e..7ce2f2d0c 100755 --- a/bench/filter-overflow/check.sh +++ b/bench/filter-overflow/check.sh @@ -5,10 +5,11 @@ # 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 60 small filtered boxes each hold a clipping box with a child -# that covers the frame (30 of the clipping boxes in flow, 30 painted by the filtered box's stacking context), and 30 -# layers the size of the frame are more than Vello's image atlas holds, so its 60 tiles are counted (from the -# frame's mean: each is 60x60 of grey 92 on white). Exits 1 on a failure. +# 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} @@ -38,6 +39,6 @@ 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" = 60 ] || { echo "FAIL clipped.tsx: $tiles of its 60 tiles drawn"; status=1; } +[ "$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 index 3d3a9c847..0343cf231 100644 --- a/bench/filter-overflow/clipped.tsx +++ b/bench/filter-overflow/clipped.tsx @@ -1,19 +1,23 @@ -// 60 small filtered boxes, each around a clipping box of its size holding a child that covers the frame from any of -// them (the last 30 clipping boxes positioned with a z-index, so the filtered box's stacking context paints them): -// 60 grey 60 px tiles on white. A filter's layer reaches over what its element draws, and stops at a clip in +// 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: 60 }, (_, i) => ( -
-
-
+ {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}
-
- ))} + ); + })} ); } diff --git a/vendor/blitz-paint/src/render.rs b/vendor/blitz-paint/src/render.rs index ab258bdc4..3e9fb3b4c 100644 --- a/vendor/blitz-paint/src/render.rs +++ b/vendor/blitz-paint/src/render.rs @@ -723,8 +723,8 @@ impl<'dom, 'a> BlitzDomPainter<'dom, 'a> { } /// 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 to that element's box grown by its - /// overflow-clip-margin, as its overflow clip cuts what is drawn (the root element clips nothing: `should_clip`). + /// 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 @@ -736,8 +736,8 @@ impl<'dom, 'a> BlitzDomPainter<'dom, 'a> { 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 = 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)) + 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) => { @@ -1236,10 +1236,12 @@ impl<'dom, 'a> BlitzDomPainter<'dom, 'a> { // 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 box its stacking context paints, where that puts it (hoisted_content_bbox's places) + // 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()) { + 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)); @@ -2494,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 {