Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
Preserve signed atomic block margins
ldm0a73f60d08a8b
diff --git a/moli-layout/src/taffy_tree.rs b/moli-layout/src/taffy_tree.rsindex 66d8f8fd6..eedac78d3 100644--- a/moli-layout/src/taffy_tree.rs+++ b/moli-layout/src/taffy_tree.rs@@ -1681,7 +1681,7 @@ where.expect("Parley returned an inline object id outside usize");atomic_baseline_ascents[object_index] = self.atomic_inline_baseline(object.box_id, child_output)- .map(|baseline| margins.top.max(0.0) + baseline);+ .map(|baseline| margins.top + baseline);atomic[object_index] = Some(AtomicMeasurement {output: child_output,margins,@@ -2167,7 +2167,7 @@ wherex: content_offset.x + positioned.x + atomic.margins.left + inset_offset.x,y: content_offset.y+ positioned.y- + atomic.margins.top.max(0.0)+ + atomic.margins.top+ vertical_offset+ inset_offset.y,},diff --git a/moli-layout/tests/phase4_layout_contract.rs b/moli-layout/tests/phase4_layout_contract.rsindex 3146dc4c9..6d2075483 100644--- a/moli-layout/tests/phase4_layout_contract.rs+++ b/moli-layout/tests/phase4_layout_contract.rs@@ -1121,6 +1121,80 @@ fn inline_flex_and_grid_use_their_first_container_baseline() {}}+#[test]+fn negative_atomic_block_margin_uses_signed_baseline_metrics() {+ let source = Source(vec![+ Node::element(+ "root",+ "div",+ LayoutElementCategory::Generic,+ None,+ vec![1, 4],+ ),+ Node::element(+ "atomic",+ "span",+ LayoutElementCategory::Generic,+ None,+ vec![2, 3],+ ),+ Node::element(+ "first-item",+ "span",+ LayoutElementCategory::Generic,+ None,+ Vec::new(),+ ),+ Node::element(+ "last-item",+ "span",+ LayoutElementCategory::Generic,+ None,+ Vec::new(),+ ),+ Node::element(+ "tail",+ "span",+ LayoutElementCategory::Generic,+ None,+ Vec::new(),+ ),+ ]);+ let mut styles = Styles::default();+ styles.primary.insert(+ 0,+ style(LayoutDisplay::Block, GREEN)+ .tap_taffy(|taffy| taffy.size.width = Dimension::length(100.0))+ .with_text_metrics(0.0, 0.0),+ );+ styles.primary.insert(+ 1,+ style(LayoutDisplay::InlineFlex, YELLOW).tap_taffy(|taffy| {+ taffy.size.width = Dimension::length(10.0);+ taffy.flex_direction = FlexDirection::Column;+ taffy.margin.top = taffy::LengthPercentageAuto::length(-5.0);+ }),+ );+ styles+ .primary+ .insert(2, sized(LayoutDisplay::Block, 10.0, 10.0, BLUE));+ styles.primary.insert(+ 3,+ sized(LayoutDisplay::Block, 10.0, 10.0, PaintColor::TRANSPARENT),+ );+ styles+ .primary+ .insert(4, sized(LayoutDisplay::InlineBlock, 10.0, 10.0, RED));++ let snapshot = render(&source, &mut styles, 100, 60);+ let root = rect(&snapshot, GREEN);+ let atomic = rect(&snapshot, YELLOW);+ let tail = rect(&snapshot, RED);+ assert_close(root.height, 20.0);+ assert_close(atomic.height, 20.0);+ assert_close(atomic.y, tail.y);+}+#[test]fn inline_table_baseline_includes_top_caption_offset() {use LayoutElementCategory::Table;