Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

Page: getBoundingClientRect stops at a freed containing-block link and answers a zero rect under display: none (#108)

shinyobjectz11dab02b513d
diff --git a/vendor/blitz-dom/src/document.rs b/vendor/blitz-dom/src/document.rs
index 60616a5b..68d23a05 100644
--- a/vendor/blitz-dom/src/document.rs
+++ b/vendor/blitz-dom/src/document.rs
@@ -2532,7 +2532,10 @@ impl BaseDocument {
let mut pos = crate::util::Point { x: 0.0, y: 0.0 };
let mut current = Some(node_id);
while let Some(id) = current {
- let node = &self.nodes[id];
+ // raea: a containing-block link is what the last construction and layout left, and freeing a node doesn't
+ // clear links to it (a `display: none` element's descendants still point at its old anonymous blocks):
+ // the walk stops at a missing node rather than panicking on its key (#108), as paint_tree's does
+ let Some(node) = self.nodes.get(id) else { break };
pos.x += node.unrounded_layout().location.x - node.scroll_offset().x as f32;
pos.y += node.unrounded_layout().location.y - node.scroll_offset().y as f32;
current = node.containing_block();
@@ -2550,7 +2553,8 @@ impl BaseDocument {
let mut any = false;
let mut current = Some(node_id);
while let Some(id) = current {
- let node = &self.nodes[id];
+ // raea: stops at a missing node, as physical_unrounded_geometry does (#108)
+ let Some(node) = self.nodes.get(id) else { break };
if id != node_id {
let s = node.scroll_offset();
m = Affine::translate((-s.x, -s.y)) * m;
@@ -2577,6 +2581,19 @@ impl BaseDocument {
})
}
+ /// raea: whether `node_id` or an ancestor is `display: none`, so it generates no box (#108).
+ fn in_display_none(&self, node_id: NodeId) -> bool {
+ let mut current = Some(node_id);
+ while let Some(id) = current {
+ let Some(node) = self.nodes.get(id) else { return false };
+ if node.primary_styles().is_some_and(|s| stylo_taffy::convert::display(s.get_box().display) == taffy::Display::None) {
+ return true;
+ }
+ current = node.parent;
+ }
+ false
+ }
+
/// Computes the size and position of the `Node` relative to the viewport
pub fn get_client_bounding_rect(&self, node_id: NodeId) -> Option<BoundingRect> {
// Non-atomic inline elements have no layout box of their own: return
@@ -2586,6 +2603,11 @@ impl BaseDocument {
}
let node = self.get_node(node_id)?;
+ // raea: an element with no box (it or an ancestor is `display: none`) answers Chrome's zero rect, not whatever
+ // its last layout left (#108)
+ if self.in_display_none(node_id) {
+ return Some(BoundingRect { x: 0.0, y: 0.0, width: 0.0, height: 0.0 });
+ }
// raea: a table row or row group has no box of its own (its cells are the table grid's items): its rect is
// its cells' union, as Chrome's row box spans them
if let Some(d) = node.display_style()
diff --git a/vendor/blitz-dom/src/node/node.rs b/vendor/blitz-dom/src/node/node.rs
index 1470ebb6..0b067cb4 100644
--- a/vendor/blitz-dom/src/node/node.rs
+++ b/vendor/blitz-dom/src/node/node.rs
@@ -1760,7 +1760,8 @@ impl Node {
return Some(node);
}
let id = node.layout_parent.get()?;
- node = self.with(id);
+ // raea: a layout parent freed since (a reconstruction's old anonymous block): no inline root (#108)
+ node = self.tree().get(id)?;
}
}
diff --git a/vendor/vendor.toml b/vendor/vendor.toml
index 55b181e0..53b34c43 100644
--- a/vendor/vendor.toml
+++ b/vendor/vendor.toml
@@ -70,7 +70,7 @@ exit = "a Blitz release that draws these"
path = "vendor/blitz-dom"
upstream = "crates.io:0.3.0-beta.4"
kind = "patch"
-reason = "inline flex/grid baselines, auto table columns, table row rects, inline image load events, SVG text fonts, SVG non-scaling strokes, url() filters; Blitz main's #1244 and #1246; a node removed in a mutation batch dropped from the style, form and title nodes the batch flushes (raea #24); a node in a 3D rendering context (or with a projection) placed again on every resolve, so it follows a preserve-3d parent whose transform a script set (raea #19); a ParseErrorReporter (not_applied.rs) on every author parse, keeping what stylo drops for the render to say once (raea #34); a bevy_text box whose lines are no finite size (an Apple bitmap-only face, which parley scales by a units-per-em of 0) measures 0 by 0, as bevy_text does; a family list ending in "raea-bevy fallback" (bevy_text's FontSource::Family) falls to the collection's fallback families, not to serif nor to the CoreText pick (parley: NO_HOOK_FAMILY); an out-of-flow box painted by the stacking context between it and its containing block, inside its opacity group (raea #39); an SVG's paint properties from CSS written into its serialized source for usvg (raea #45); transform-box: stroke-box as fill-box under non-scaling-stroke, a stylesheet's stroke in the stroke box, and the non-scaling mark on an element with its own id (raea #50); an SVG element's rewritten style attribute without a leading `;` when its own declarations were transforms alone; transform-box: view-box's reference box at the origin of user space, not at the viewBox's x and y; every inline box laid out in full while its line is only measured, since Taffy's measure cache keeps a box's size without its baseline (raea #109)"
+reason = "inline flex/grid baselines, auto table columns, table row rects, inline image load events, SVG text fonts, SVG non-scaling strokes, url() filters; Blitz main's #1244 and #1246; a node removed in a mutation batch dropped from the style, form and title nodes the batch flushes (raea #24); a node in a 3D rendering context (or with a projection) placed again on every resolve, so it follows a preserve-3d parent whose transform a script set (raea #19); a ParseErrorReporter (not_applied.rs) on every author parse, keeping what stylo drops for the render to say once (raea #34); a bevy_text box whose lines are no finite size (an Apple bitmap-only face, which parley scales by a units-per-em of 0) measures 0 by 0, as bevy_text does; a family list ending in ; getBoundingClientRect and the geometry walks stop at a freed containing-block link instead of panicking on its key, and an element in a display: none subtree answers a zero rect (raea #108)"raea-bevy fallback" (bevy_text's FontSource::Family) falls to the collection's fallback families, not to serif nor to the CoreText pick (parley: NO_HOOK_FAMILY); an out-of-flow box painted by the stacking context between it and its containing block, inside its opacity group (raea #39); an SVG's paint properties from CSS written into its serialized source for usvg (raea #45); transform-box: stroke-box as fill-box under non-scaling-stroke, a stylesheet's stroke in the stroke box, and the non-scaling mark on an element with its own id (raea #50); an SVG element's rewritten style attribute without a leading `;` when its own declarations were transforms alone; transform-box: view-box's reference box at the origin of user space, not at the viewBox's x and y; every inline box laid out in full while its line is only measured, since Taffy's measure cache keeps a box's size without its baseline (raea #109)"
exit = "a Blitz release with #1244/#1246 and these"
[parley_engine]