Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
fix(layout): resolve intrinsic width constraints in shared sizing
ldm0e10fe9c4405a
diff --git a/Cargo.lock b/Cargo.lockindex 4079b5201..fd4f1b345 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -5539,7 +5539,7 @@ dependencies = [[[package]]name = "taffy"version = "0.13.0"-source = "git+https://github.com/ldm0/taffy?rev=645bf5a49df607a8bff34ec90c5343901d04f10e#645bf5a49df607a8bff34ec90c5343901d04f10e"+source = "git+https://github.com/ldm0/taffy?rev=2b54aa97792a13a6a962202422a80c7385012935#2b54aa97792a13a6a962202422a80c7385012935"dependencies = ["arrayvec","serde",diff --git a/Cargo.toml b/Cargo.tomlindex ce1970d8f..684d0ff6d 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -117,7 +117,7 @@ stylo_dom = { git = "https://github.com/lexmount/stylo", rev = "0c7e8baf63b6714estylo_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 = "645bf5a49df607a8bff34ec90c5343901d04f10e" }+taffy = { git = "https://github.com/ldm0/taffy", rev = "2b54aa97792a13a6a962202422a80c7385012935" }[workspace.lints.clippy]disallowed_methods = "deny"diff --git a/moli-layout/src/taffy_tree.rs b/moli-layout/src/taffy_tree.rsindex d06abaa22..3d5737d80 100644--- a/moli-layout/src/taffy_tree.rs+++ b/moli-layout/src/taffy_tree.rs@@ -1661,8 +1661,8 @@ where} else {inputs};- let resolved_intrinsic_inputs =- taffy::compute::resolve_intrinsic_width_inputs(self, node_id, intrinsic_inputs);+ let resolved_width_inputs =+ taffy::compute::resolve_used_width_inputs(self, node_id, intrinsic_inputs);let inputs = LayoutInput {// The float parent has already removed horizontal margins from the// child's available space. Restoring them above is only an adapter@@ -1670,7 +1670,7 @@ where// subtraction; carrying that restored space into layout would make// an auto-width float stretch across its margins again. Only the// resolved border-box width crosses this seam.- known_dimensions: resolved_intrinsic_inputs.known_dimensions,+ known_dimensions: resolved_width_inputs.inputs.known_dimensions,..inputs};if self.is_viewport_taffy_node(node_id) {diff --git a/moli-layout/tests/phase4_layout_contract.rs b/moli-layout/tests/phase4_layout_contract.rsindex 728800a5a..1071b98f3 100644--- a/moli-layout/tests/phase4_layout_contract.rs+++ b/moli-layout/tests/phase4_layout_contract.rs@@ -243,6 +243,100 @@ fn assert_close(actual: f32, expected: f32) {assert!((actual - expected).abs() < 0.05, "{actual} != {expected}");}+#[test]+fn grid_wrapped_max_content_item_contributes_its_constrained_height() {+ assert_grid_intrinsic_item_contributes_constrained_height(Dimension::auto());+}++#[test]+fn grid_intrinsic_minimum_and_percentage_maximum_contribute_constrained_height() {+ assert_grid_intrinsic_item_contributes_constrained_height(Dimension::min_content());+}++fn assert_grid_intrinsic_item_contributes_constrained_height(min_width: Dimension) {+ // Blink's GridLayoutAlgorithm::ContributionSizeForGridItem measures the+ // block contribution against the resolved inline grid area, including+ // max-width, rather than using the unconstrained max-content line height.+ let source = Source(vec![+ Node::element(+ "root",+ "div",+ LayoutElementCategory::Generic,+ None,+ vec![1, 5],+ ),+ Node::element("grid", "div", LayoutElementCategory::Generic, None, vec![2]),+ Node::element(+ "measure",+ "span",+ LayoutElementCategory::Generic,+ None,+ vec![3, 4],+ ),+ Node::text("text", "sorts your email "),+ Node::element(+ "icon",+ "span",+ LayoutElementCategory::Generic,+ None,+ Vec::new(),+ ),+ Node::element(+ "following",+ "div",+ LayoutElementCategory::Generic,+ None,+ Vec::new(),+ ),+ ]);+ let mut styles = Styles::default();+ styles+ .primary+ .insert(0, style(LayoutDisplay::Block, PaintColor::TRANSPARENT));+ styles.primary.insert(+ 1,+ style(LayoutDisplay::Grid, GREEN).tap_taffy(|taffy| {+ taffy.display = taffy::Display::Grid;+ taffy.size.width = Dimension::length(350.0);+ taffy.grid_template_columns = vec![taffy::style_helpers::minmax(+ taffy::style_helpers::length(0.0),+ taffy::style_helpers::fr(1.0),+ )];+ }),+ );+ styles.primary.insert(+ 2,+ style(LayoutDisplay::Block, PaintColor::TRANSPARENT)+ .tap_taffy(|taffy| {+ taffy.size.width = Dimension::max_content();+ taffy.min_size.width = min_width;+ taffy.max_size.width = Dimension::percent(1.0);+ taffy.justify_self = Some(taffy::AlignSelf::CENTER);+ })+ .with_text_metrics(47.0, 52.0),+ );+ styles+ .primary+ .insert(4, sized(LayoutDisplay::InlineBlock, 60.0, 47.0, RED));+ styles+ .primary+ .insert(5, sized(LayoutDisplay::Block, 350.0, 20.0, BLUE));++ let snapshot = render(&source, &mut styles, 400, 300);+ let grid = rect(&snapshot, GREEN);+ let icon = rect(&snapshot, RED);+ let following = rect(&snapshot, BLUE);+ assert!(+ grid.height >= 104.0,+ "the auto row must include both wrapped lines: {grid:?}"+ );+ assert!(+ icon.bottom() <= following.y,+ "the next block must follow the wrapped icon"+ );+ assert_eq!(following.y, grid.bottom());+}+#[test]fn table_caption_tracks_rows_cells_and_common_spans_share_one_wrapper_geometry() {use LayoutElementCategory::Table;