From 44fe2b6ddc784ad3e705cd8487f753c565c69d19 Mon Sep 17 00:00:00 2001 From: ldm0 Date: Sun, 18 Oct 2026 03:37:42 +0800 Subject: [PATCH] fix(layout): honor intrinsic minima in grid tracks and rows Pin the separate Taffy71617899 and4a618c7b fixes: resolve authored intrinsic item minima for auto-track contributions and before fixing the width used to measure row height. A smaller preferred width must not hide the minimum in either path. MOL-465: browser regression covers min-content/max-content with auto,0px and50px preferred widths, track positions and row heights. The two pre-fix failures were next-column x40 instead of60 and row height60 instead of20. The Webfont grid nontermination control still completes. cargo fmt --all; cargo clippy --workspace --all-targets --all-features -- -D warnings; cargo nextest run --no-fail-fast:20277 passed,18 skipped. Initial partial-fix failure logs retained. Original-commit: 3b602b42404fbaec9789944bb7031142ea88ca77 --- Cargo.lock | 2 +- Cargo.toml | 2 +- moli/tests/fetch_cli/layout_regressions.rs | 70 ++++++++++++++++++++++ 3 files changed, 72 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c21543ab45..8a11fa9d2d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5550,7 +5550,7 @@ dependencies = [ [[package]] name = "taffy" version = "0.13.0" -source = "git+https://github.com/ldm0/taffy?rev=5453d6cdda8d2dd12b87e5237686e0adaf7cc0bc#5453d6cdda8d2dd12b87e5237686e0adaf7cc0bc" +source = "git+https://github.com/ldm0/taffy?rev=4a618c7b6b7f9c3fbd8b8b0eaf9918ebd2cf9969#4a618c7b6b7f9c3fbd8b8b0eaf9918ebd2cf9969" dependencies = [ "arrayvec", "serde", diff --git a/Cargo.toml b/Cargo.toml index 51143ee7e7..98836bdfaa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -117,7 +117,7 @@ stylo_dom = { git = "https://github.com/lexmount/stylo", rev = "0c7e8baf63b6714e stylo_static_prefs = { git = "https://github.com/lexmount/stylo", rev = "0c7e8baf63b6714e7614834fadbc09710f3c3d27" } stylo_traits = { git = "https://github.com/lexmount/stylo", rev = "0c7e8baf63b6714e7614834fadbc09710f3c3d27" } svgtypes = { git = "https://github.com/lexmount/svgtypes", branch = "moli" } -taffy = { git = "https://github.com/ldm0/taffy", rev = "5453d6cdda8d2dd12b87e5237686e0adaf7cc0bc" } +taffy = { git = "https://github.com/ldm0/taffy", rev = "4a618c7b6b7f9c3fbd8b8b0eaf9918ebd2cf9969" } [workspace.lints.clippy] disallowed_methods = "deny" diff --git a/moli/tests/fetch_cli/layout_regressions.rs b/moli/tests/fetch_cli/layout_regressions.rs index c61a942b93..16088d49e6 100644 --- a/moli/tests/fetch_cli/layout_regressions.rs +++ b/moli/tests/fetch_cli/layout_regressions.rs @@ -66,3 +66,73 @@ fn fractional_grid_track_limits_terminate_with_a_finite_item_width() -> Result<( assert!((width - 202.44017).abs() < 0.05, "{width}"); Ok(()) } + +fn probe_font_document(body: &str) -> String { + let font = STANDARD.encode(include_bytes!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/../moli-layout/tests/fixtures/moli-ahem.woff2" + ))); + format!( + "{body}" + ) +} + +const GEOMETRY: &str = r#"(async () => { + await document.fonts.ready; + return Object.fromEntries([...document.querySelectorAll('[id]')].map(element => { + const rect = element.getBoundingClientRect(); + return [element.id, {x: rect.x, width: rect.width, height: rect.height}]; + })); +})()"#; + +fn assert_dimension(value: &Value, id: &str, dimension: &str, expected: f64) { + let actual = value[id][dimension] + .as_f64() + .expect("dimension must be numeric"); + assert!( + (actual - expected).abs() < 0.05, + "{id}.{dimension}: {actual} != {expected}" + ); +} + +#[test] +fn auto_grid_tracks_honor_intrinsic_item_minima_before_measuring_row_height() -> Result<()> { + let mut body = String::new(); + for keyword in ["min-content", "max-content"] { + for width in ["auto", "0px", "50px"] { + let key = format!("{keyword}-{width}"); + let grid_width = if keyword == "min-content" { 140 } else { 200 }; + body.push_str(&format!( + "
aaaa bbbbb ccc
" + )); + } + } + let value = run_layout(&probe_font_document(&body), GEOMETRY, true)?; + for keyword in ["min-content", "max-content"] { + for width in ["auto", "0px", "50px"] { + let key = format!("{keyword}-{width}"); + let maximum = keyword == "max-content"; + let item_width = if maximum { 168.0 } else { 60.0 }; + assert_dimension(&value, &format!("item-{key}"), "width", item_width); + assert_dimension( + &value, + &format!("item-{key}"), + "height", + if maximum { 20.0 } else { 60.0 }, + ); + assert_dimension( + &value, + &format!("grid-{key}"), + "height", + if maximum { 20.0 } else { 60.0 }, + ); + assert_dimension( + &value, + &format!("next-{key}"), + "x", + if maximum { 168.0 } else { 60.0 }, + ); + } + } + Ok(()) +}