From 5f9067bd6cc94ac0b8e04af0fe0fe1d297a3fbf7 Mon Sep 17 00:00:00 2001 From: mtlcl410 <2368091+mtlcl410@users.noreply.github.com> Date: Thu, 29 Oct 2026 22:09:27 +0800 Subject: [PATCH] M12: test a positioned XFA subform's minH cases, and that a table row keeps its minH A positioned subform without `h` is as tall as its content: with a `minH` below the content, with content taller than its `minH`, and with a hidden child, which takes no room. A fixed `h` stays the height whatever the content. A table row keeps its `minH`, as XFA 3.3 p. 719 says: no row in the 245 dynamic forms we test has a `minH` without an `h`, so there is no reader behaviour to follow instead. The test fails with this PR's change to `measure` reverted (the hidden-child case is stretched to its `minH`), and with rows made to drop their `minH` (the row grows by 0pt). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv --- crates/xfa/src/tests.rs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/crates/xfa/src/tests.rs b/crates/xfa/src/tests.rs index 77abe54074..4c2c89a5e1 100644 --- a/crates/xfa/src/tests.rs +++ b/crates/xfa/src/tests.rs @@ -2749,6 +2749,45 @@ fn a_subform_is_as_tall_as_its_content_whatever_its_minimum_height() { assert!((top("") - flowed).abs() < 0.01, "positioned: {} against {flowed}", top("")); } +/// The cases around a positioned subform's `minH`: a `minH` below the content, content taller +/// than `minH`, a fixed `h`, and hidden children (which take no room). A table row, which no +/// form we test gives a `minH` without an `h`, keeps its `minH` as XFA 3.3 p. 719 says. +#[test] +fn a_positioned_subform_takes_its_content_height_and_a_row_keeps_its_minimum() { + // The field after a positioned 7.5in-wide bar starts where the bar ends. + let after = |bar_attrs: &str, content: &str| { + let body = format!( + r#"{content}"# + ); + let form = layout_xml(&one_area_form(r#"layout="tb""#, &body)).unwrap(); + widgets(&form.pages[0])[0].rect.y + }; + let line = |h: &str| format!(r#"Line"#); + let bare = after("", &line("0.2in")); + let inch = 72.0; + // A `minH` below the content, and content taller than the `minH`: the content's height. + assert!((after(r#"minH="0.1in""#, &line("0.2in")) - bare).abs() < 0.01); + assert!((after(r#"minH="0.1in""#, &line("1in")) - after("", &line("1in"))).abs() < 0.01); + assert!(after("", &line("1in")) - bare > 0.7 * inch, "taller content pushes the field down"); + // A fixed `h` is the height, whatever the content. + assert!((after(r#"h="2in""#, &line("0.2in")) - after(r#"h="2in""#, &line("1in"))).abs() < 0.01); + assert!(after(r#"h="2in""#, &line("0.2in")) - bare > 1.7 * inch, "h=2in, not the 0.2in content"); + // A hidden child takes no room. + let hidden = format!(r#"{}Hidden"#, line("0.2in")); + assert!((after(r#"minH="3in""#, &hidden) - bare).abs() < 0.01, "{} against {bare}", after(r#"minH="3in""#, &hidden)); + + // A table row keeps its `minH`: one holding a 0.2in cell with `minH="3in"` is 3in tall. + let after_table = |row_min_h: &str| { + let body = format!( + r#"One"# + ); + let form = layout_xml(&one_area_form(r#"layout="tb""#, &body)).unwrap(); + widgets(&form.pages[0])[0].rect.y + }; + let grown = after_table(r#"minH="3in""#) - after_table(""); + assert!((grown - 2.8 * inch).abs() < 0.01, "the row grew by {grown}pt"); +} + #[test] fn the_form_packet_restores_a_caption_a_script_changed() { let body = r#"