From 63a77901e6d4182505dae7abe8d7640961166993 Mon Sep 17 00:00:00 2001 From: mtlcl410 <2368091+mtlcl410@users.noreply.github.com> Date: Thu, 29 Oct 2026 13:33:08 +0800 Subject: [PATCH 1/4] M12: an XFA page master's content is its own on every page, in the layout and in scripts Master-page content repeated on each page shared one SOM path (`master[0]`), so its fields shared one data node and one script node. Each page's copy is now `master[n]`: - the layout names it so; - data binds it per page, except a field bound globally or by explicit ref, which stays shared (XFA 3.3, "Page Background"); - the live form has one page-area node per page laid out from it, counted from the generated fields, so a button on page 2 runs its click script as itself. - an event listed before a script laid the form out again can name an object that is gone (a page the form no longer fills): it is not run, rather than run with `this` at the form's root, where `this.presence = "hidden"` hid the whole form. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CBVyQEwtmEw3mS1MoAiwrK --- crates/engine/src/tests.rs | 51 ++++++++++++++++++++++++ crates/engine/src/xfa.rs | 22 ++++++++--- crates/xfa/src/data/path.rs | 36 ++++++++++++++++- crates/xfa/src/layout/pages.rs | 8 +++- crates/xfa/src/lib.rs | 2 +- crates/xfa/src/model.rs | 4 ++ crates/xfa/src/parse.rs | 2 + crates/xfa/src/script.rs | 71 +++++++++++++++++++++++++--------- crates/xfa/src/tests.rs | 41 ++++++++++++++++++++ 9 files changed, 210 insertions(+), 27 deletions(-) diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 833fa16b9f..1bcf3801c3 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -6626,6 +6626,57 @@ fn repeated_xfa_print_buttons_run_their_click_script() { } } +/// A button on the page master runs its click script as the copy on the page that was clicked: +/// the field it writes next to it changes on that page only. +#[test] +fn a_page_master_button_writes_the_field_on_its_own_page() { + let template = pdfcraft_xfa::fixtures::repeated_print_button_template().replace( + "", + r#" +