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 layout: an inline box is laid out in full while its line is only measured, so a relayout keeps its baseline (#109)

shinyobjectz7fb6251bf937
diff --git a/sdk/ui/parity/cases/p12-css/inline-block-transform-relayout.tsx b/sdk/ui/parity/cases/p12-css/inline-block-transform-relayout.tsx
new file mode 100644
index 00000000..da42ea7d
--- /dev/null
+++ b/sdk/ui/parity/cases/p12-css/inline-block-transform-relayout.tsx
@@ -0,0 +1,21 @@
+// A title of inline-block spans whose one span's transform changes after the first layout: a transform takes no part
+// in layout, so the line box, and the block under it, stay where they were (#109: the line grew by the font's descent
+// on a relayout, since the unchanged spans came back from the layout cache with their size but no baseline, and sat
+// on the line by their bottom margin edge; a per-character spring title jumped 24 px on single frames).
+// proves: css.properties.transform, css.properties.display.inline-block
+import { useState } from "react";
+export const steps = [{ click: "toggle" }];
+export default function Case() {
+ const [moved, setMoved] = useState(false);
+ return (
+ <div data-testid="root" className="flex h-full w-full flex-col items-center bg-white p-4">
+ <button data-testid="toggle" className="mb-2 bg-slate-200 px-2" onClick={() => setMoved(!moved)}>toggle</button>
+ <div data-testid="title" style={{ whiteSpace: "pre", fontFamily: "Parity Mono", fontSize: 40, lineHeight: 1.2 }}>
+ {[..."2026 11"].map((ch, i) => (
+ <span key={i} style={{ display: "inline-block", transform: `translateY(${i === 1 && moved ? 0.5 : 0}px)` }}>{ch}</span>
+ ))}
+ </div>
+ <div data-testid="after" className="mt-2 h-1 w-64 bg-blue-600" />
+ </div>
+ );
+}
diff --git a/vendor/blitz-dom/src/layout/inline.rs b/vendor/blitz-dom/src/layout/inline.rs
index 2adc922b..b707a78f 100644
--- a/vendor/blitz-dom/src/layout/inline.rs
+++ b/vendor/blitz-dom/src/layout/inline.rs
@@ -470,13 +470,14 @@ impl LayoutPassState<'_> {
&& is_block_axis_scroll_container)
&& !contain_layout;
let mut box_inputs = inline_box_inputs(style.size().width, margin, child_inputs);
- // raea: a flex or grid box is laid out in full even when the line is only being measured: Taffy's
- // flexbox and grid return their size without a baseline when asked for size alone, and the box then sat
- // on the line's baseline by its bottom margin edge, so a block holding an inline-flex measured taller than
- // Chrome's (the strut's descent under it) wherever its parent measures it first (a column flex)
- if !is_flow {
- box_inputs.run_mode = taffy::RunMode::PerformLayout;
- }
+ // raea: an inline box is laid out in full even when the line is only being measured. Asked for size alone,
+ // Taffy's flexbox and grid return no baseline, and its cache keeps a measured box's size without its
+ // baseline (Cache::get, from_outer_size): a box then sits on the line's baseline by its bottom margin
+ // edge, and the line measures taller than Chrome's by the strut's descent wherever its parent measures
+ // it first (a column flex). An inline-flex did that on its first layout; an inline-block did it on a
+ // relayout, once a sibling's style changed and the line's unchanged boxes came back from the cache: a
+ // title of per-character spans jumped 24 px on the frames one span's transform left zero (#109)
+ box_inputs.run_mode = taffy::RunMode::PerformLayout;
drop(style);
if is_out_of_flow || is_floated {
diff --git a/vendor/vendor.toml b/vendor/vendor.toml
index 0d7f400b..cc7c46a3 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"
+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)"
exit = "a Blitz release with #1244/#1246 and these"
[parley_engine]