From 3ea5ea0b2b5cec9831d5e5a3522f46b0d4f9b8c1 Mon Sep 17 00:00:00 2001 From: SGavrl <277843151+SGavrl@users.noreply.github.com> Date: Thu, 23 Jul 2026 19:23:31 +0000 Subject: [PATCH] test: gate constrained replaced geometry --- crates/obscura-render/tests/layout_test.rs | 26 +++++++++++++++ render-repros/checks.json | 3 ++ render-repros/max-height-replaced.html | 39 ++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 render-repros/max-height-replaced.html diff --git a/crates/obscura-render/tests/layout_test.rs b/crates/obscura-render/tests/layout_test.rs index e1f52a3..c3f8102 100644 --- a/crates/obscura-render/tests/layout_test.rs +++ b/crates/obscura-render/tests/layout_test.rs @@ -296,6 +296,32 @@ fn list_indentation_is_reset_from_the_container() { ); } +#[test] +fn replaced_max_height_clamps_intrinsic_aspect_transfer() { + let tree = parse_html(include_str!( + "../../../render-repros/max-height-replaced.html" + )); + let image_id = tree.get_element_by_id("image").unwrap(); + let intrinsic = HashMap::from([(image_id, (648.0, 440.0))]); + let layout = layout_dom_with_images(&tree, (900.0, 1000.0), &intrinsic); + let card = layout.rects[&tree.get_element_by_id("card").unwrap()]; + let image = layout.rects[&image_id]; + assert!( + (card.x - 0.0).abs() < 0.01 + && (card.y - 0.0).abs() < 0.01 + && (card.width - 394.0).abs() < 0.01 + && (card.height - 608.0).abs() < 0.01, + "card: {card:?}" + ); + assert!( + (image.x - 32.0).abs() < 0.01 + && (image.y - 64.0).abs() < 0.01 + && (image.width - 330.0).abs() < 0.01 + && (image.height - 200.0).abs() < 0.01, + "image: {image:?}" + ); +} + #[test] fn transforms_establish_absolute_and_fixed_containing_blocks() { let html = r##" diff --git a/render-repros/checks.json b/render-repros/checks.json index a68428b..85e0ea9 100644 --- a/render-repros/checks.json +++ b/render-repros/checks.json @@ -114,6 +114,9 @@ {"name": "ordered list reset removes indentation", "color": "#862e9c", "x": 0, "y": 80, "width": 400, "height": 20}, {"name": "ex padding follows font x height", "color": "#e8590c", "x": 0, "y": 120, "width": 44, "height": 22} ], + "max-height-replaced": [ + {"name": "max height clamps intrinsic aspect transfer", "color": "#1971c2", "x": 32, "y": 64, "width": 330, "height": 200} + ], "mixed-content-block": [ {"name": "full-width block child", "color": "#ccddff", "width": 400} ], diff --git a/render-repros/max-height-replaced.html b/render-repros/max-height-replaced.html new file mode 100644 index 0000000..b997030 --- /dev/null +++ b/render-repros/max-height-replaced.html @@ -0,0 +1,39 @@ + + +
+ +