diff --git a/crates/obscura-render/tests/layout_test.rs b/crates/obscura-render/tests/layout_test.rs index 93281b1..2d7cc6d 100644 --- a/crates/obscura-render/tests/layout_test.rs +++ b/crates/obscura-render/tests/layout_test.rs @@ -450,6 +450,48 @@ fn text_alignment_does_not_shrink_flex_items() { ); } +#[test] +fn inline_block_flex_items_keep_block_inner_flow() { + let tree = parse_html(include_str!("../../../render-repros/inline-block-flex-items.html")); + let layout = layout_dom(&tree, (900.0, 1000.0)); + let rect = |id| layout.rects[&tree.get_element_by_id(id).unwrap()]; + let brand = rect("brand"); + let title = rect("title"); + let links = rect("links"); + let one = rect("one"); + let two = rect("two"); + let three = rect("three"); + let chips = rect("chips"); + let alpha = rect("alpha"); + let beta = rect("beta"); + let gamma = rect("gamma"); + assert!( + (brand.x - 0.0).abs() < 0.01 + && (brand.width - 382.0).abs() < 0.01 + && (title.x - 32.0).abs() < 0.01 + && (title.width - 350.0).abs() < 0.01, + "brand: {brand:?}, title: {title:?}" + ); + assert!( + (links.x - 525.0).abs() < 0.01 + && (links.width - 90.0).abs() < 0.01 + && (one.y - 0.0).abs() < 0.01 + && (two.y - 20.0).abs() < 0.01 + && (three.y - 40.0).abs() < 0.01, + "links: {links:?}, items: {one:?} {two:?} {three:?}" + ); + assert!( + (chips.x - 0.0).abs() < 0.01 + && (chips.y - 140.0).abs() < 0.01 + && (chips.width - 90.0).abs() < 0.01 + && (chips.height - 20.0).abs() < 0.01 + && (alpha.x - 0.0).abs() < 0.01 + && (beta.x - 30.0).abs() < 0.01 + && (gamma.x - 60.0).abs() < 0.01, + "chips: {chips:?}, items: {alpha:?} {beta:?} {gamma:?}" + ); +} + #[test] fn opposing_floats_share_header_band_through_inline_wrapper() { let tree = parse_html(include_str!("../../../render-repros/opposing-header-floats.html")); diff --git a/render-repros/checks.json b/render-repros/checks.json index d521fd4..c084b1f 100644 --- a/render-repros/checks.json +++ b/render-repros/checks.json @@ -74,6 +74,11 @@ {"name": "grid shorthand creates explicit columns", "color": "#087f5b", "width": 287, "height": 60, "count": 3}, {"name": "custom property grid shorthand creates explicit columns", "color": "#1971c2", "width": 287, "height": 60, "count": 3} ], + "inline-block-flex-items": [ + {"name": "inline block title keeps its max content width", "color": "#087f5b", "x": 32, "y": 0, "width": 350, "height": 20}, + {"name": "inline block list shrink wraps and stacks children", "color": "#1971c2", "x": 525, "y": 0, "width": 90, "height": 60}, + {"name": "table stand-in does not blockify inline-block list", "color": "#c2255c", "x": 0, "y": 140, "width": 90, "height": 20} + ], "mixed-content-block": [ {"name": "full-width block child", "color": "#ccddff", "width": 400} ], diff --git a/render-repros/inline-block-flex-items.html b/render-repros/inline-block-flex-items.html new file mode 100644 index 0000000..03f104c --- /dev/null +++ b/render-repros/inline-block-flex-items.html @@ -0,0 +1,71 @@ + + +
+ +