From e5faac8e5242fac338e58d7cfe777fca1a46d2ae Mon Sep 17 00:00:00 2001 From: mtlcl410 <2368091+mtlcl410@users.noreply.github.com> Date: Fri, 30 Oct 2026 20:23:17 +0800 Subject: [PATCH] M12: an XFA page counts for its page area even when all its master fields are hidden Each page laying the form out writes names the page area it was made from (PCXfaArea), and page_area_uses counts those pages, so a page whose only master field a script hid keeps its master nodes in the script model and a later script can show them again (review). A file laid out before pages were named is still read from its generated fields. Adds two tests from wireless89's review: page-local and shared master values through relayout, save, reopen and print, and the page whose last master widget is hidden. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv --- crates/engine/src/tests.rs | 116 +++++++++++++++++++++++++++++++++ crates/xfa/src/layout/items.rs | 2 + crates/xfa/src/layout/pages.rs | 2 +- crates/xfa/src/lib.rs | 2 +- crates/xfa/src/pdf.rs | 8 +++ crates/xfa/src/script.rs | 23 +++++-- 6 files changed, 147 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 1bcf3801c3..46ab4e82d8 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -9386,3 +9386,119 @@ fn repeated_backdrop_artwork_survives_background_undo_redo_and_both_save_modes() s.apply(rewritten, Edit::RemoveMarks { kind: MarkKind::Background }).unwrap(); black(&s, rewritten); } + +/// A page still exists after its only master widget is hidden: its master nodes stay in the +/// script model, so a later script can address them again (test from wireless89's review of +/// #5368). +#[test] +fn xfa_page_master_instance_survives_hiding_its_last_widget() { + let template = pdfcraft_xfa::fixtures::repeated_print_button_template() + .replace(r#"xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 0, 0, 0, 0);"#, r#"this.presence = "hidden";"#) + .replace( + "", + r#"