From 65ea96da4c72487928237c504809885bb2f30f48 Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Wed, 11 Nov 2026 11:37:07 +0100 Subject: [PATCH] style: fmt and a type alias for clippy Co-authored-by: Peter Yatsyshin --- crates/automation/tests/it/main.rs | 2 +- crates/engine/src/js.rs | 8 +++++++- crates/engine/src/lib.rs | 4 ++-- crates/engine/src/live_scripts.rs | 18 +++++++++++------- crates/engine/src/live_scripts_tests.rs | 3 ++- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/crates/automation/tests/it/main.rs b/crates/automation/tests/it/main.rs index 42fd5459a3..be655a10a2 100644 --- a/crates/automation/tests/it/main.rs +++ b/crates/automation/tests/it/main.rs @@ -15,8 +15,8 @@ mod hostile_args; mod list_selection; mod model_3d; mod model_render; -mod page_actions; mod optimize_content_boundaries; +mod page_actions; mod portfolio_info; mod redact_after_stray_q_form; mod redact_text_after_q; diff --git a/crates/engine/src/js.rs b/crates/engine/src/js.rs index fb431966fd..d0fb11529a 100644 --- a/crates/engine/src/js.rs +++ b/crates/engine/src/js.rs @@ -1046,7 +1046,13 @@ impl Session { } /// Convert the worker snapshot delta and reset requests into permission-checked atomic document edits. - pub(crate) fn apply_script_outcome(&mut self, id: DocId, states: &[pdfcraft_js::FieldState], mut o: Outcome, opening: bool) -> Result { + pub(crate) fn apply_script_outcome( + &mut self, + id: DocId, + states: &[pdfcraft_js::FieldState], + mut o: Outcome, + opening: bool, + ) -> Result { if o.execution_refused { o.changed.clear(); o.requests.clear(); diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index e737798d97..4b9a3cd7ab 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -36,8 +36,8 @@ pub mod find_replace; mod history; pub mod js; mod layers; -mod live_scripts; pub mod links; +mod live_scripts; pub mod model3d; mod object_clip; pub mod ocr; @@ -75,8 +75,8 @@ use std::sync::Arc; pub use links::{ MAX_REMOTE_DOCUMENT_BYTES, RemoteDocumentPathError, read_remote_document, remote_document_path_is_absolute, resolve_remote_document_path, }; -pub use pdfcraft_edit::strip_subset_tag; pub use live_scripts::{MAX_TIMER_RUNS, ScriptRun}; +pub use pdfcraft_edit::strip_subset_tag; pub use rich_copy::RichCopy; pub use signature_image::{ImageSignaturePreview, SignatureImage}; pub use signature_scan::{PhotoRect, ScanError, SignaturePhoto, Turn}; diff --git a/crates/engine/src/live_scripts.rs b/crates/engine/src/live_scripts.rs index 0b70771b5a..1657d9deaa 100644 --- a/crates/engine/src/live_scripts.rs +++ b/crates/engine/src/live_scripts.rs @@ -98,7 +98,12 @@ pub(crate) fn js_layers(doc: &Document) -> Vec { /// A field as scripts see it: as the document has it, but shown as page actions and timers /// left it (its `display` and push button icon), so a button stepping an animation steps from /// the frame on screen. -pub(crate) fn live_state(doc: &Document, cos: &pdfcraft_cos::Document, f: &pdfcraft_forms::Field, info: &pdfcraft_js::DocInfo) -> pdfcraft_js::FieldState { +pub(crate) fn live_state( + doc: &Document, + cos: &pdfcraft_cos::Document, + f: &pdfcraft_forms::Field, + info: &pdfcraft_js::DocInfo, +) -> pdfcraft_js::FieldState { let mut s = field_state(cos, f, info); if let Some(d) = doc.live.shown.get(&f.name) { s.display = *d; @@ -145,11 +150,7 @@ pub(crate) fn with_live_view(doc: &Document, config: pdfcraft_render::RenderConf }) .flatten() .collect(); - pdfcraft_render::RenderConfig { - annotations: std::sync::Arc::new(annotations), - appearances: std::sync::Arc::new(appearances), - ..config - } + pdfcraft_render::RenderConfig { annotations: std::sync::Arc::new(annotations), appearances: std::sync::Arc::new(appearances), ..config } } /// Draw the viewer with how fields show now. @@ -175,9 +176,12 @@ pub(crate) fn set_layers(doc: &mut Document, layers: &[(usize, bool)]) -> bool { changed } +/// Push buttons given another icon, by name: the icon's form object (`None`: no icon). +type IconChanges = Vec<(String, Option)>; + /// The `display` and icon changes in `o`, against the fields as they were (`states`), taken out /// of it: shown in the view instead of written into the document. -fn take_view_changes(states: &[pdfcraft_js::FieldState], o: &mut Outcome) -> (Vec<(String, i32)>, Vec<(String, Option)>) { +fn take_view_changes(states: &[pdfcraft_js::FieldState], o: &mut Outcome) -> (Vec<(String, i32)>, IconChanges) { let mut shown = Vec::new(); let mut icons = Vec::new(); for a in &mut o.changed { diff --git a/crates/engine/src/live_scripts_tests.rs b/crates/engine/src/live_scripts_tests.rs index c902b22562..2087e1dbb8 100644 --- a/crates/engine/src/live_scripts_tests.rs +++ b/crates/engine/src/live_scripts_tests.rs @@ -205,7 +205,8 @@ fn get_ocgs_turns_a_layer_in_the_view() { let out = pdf(&[ "<< /Type /Catalog /Pages 2 0 R /OCProperties << /OCGs [5 0 R] /D << /Order [5 0 R] >> >> >>".into(), "<< /Type /Pages /Kids [3 0 R] /Count 1 /MediaBox [0 0 200 300] >>".into(), - "<< /Type /Page /Parent 2 0 R /Contents 4 0 R /Resources << /Properties << /L1 5 0 R >> >> /AA << /O << /S /JavaScript /JS 6 0 R >> >> >>".into(), + "<< /Type /Page /Parent 2 0 R /Contents 4 0 R /Resources << /Properties << /L1 5 0 R >> >> /AA << /O << /S /JavaScript /JS 6 0 R >> >> >>" + .into(), "<< /Length 41 >>\nstream\n/OC /L1 BDC 1 0 0 rg 0 0 200 300 re f EMC\nendstream".into(), "<< /Type /OCG /Name (Red) >>".into(), format!("<< /Length {} >>\nstream\n{open}\nendstream", open.len()),