Merge remote-tracking branch 'upstream/main' into fix/checkbox-kid-on-states-l4

# Conflicts:
#	crates/xfdf/src/tests.rs
This commit is contained in:
mtlcl410 committed 2026-11-06 01:04:02 +08:00
commit bf56dfe7af
153 files changed
+13549 -950

No files matched your search

+22
View File
@@ -60,6 +60,21 @@ pub struct ScriptResult {
pub trait Scripts {
/// Run `script` for `event` on `target`, whose value is `value`; `fields` is the whole form.
fn run(&mut self, event: FieldEvent, script: &str, target: &Field, value: &str, fields: &[Field]) -> ScriptResult;
/// [`Self::run`] again for an appearance, with dates written in English names (`util.printd`)
/// because no font of the field can draw the date language's (#5303); what it logs was
/// already logged by the first run. `None` when it can't: no English dates here, or the
/// script failed. What it returns is what the script made, even when that is the value.
fn rerun_with_english_dates(
&mut self,
_event: FieldEvent,
_script: &str,
_target: &Field,
_value: &str,
_fields: &[Field],
) -> Option<ScriptResult> {
None
}
}
/// No script engine (or JavaScript turned off): scripts change nothing.
@@ -98,6 +113,13 @@ pub(crate) fn formatted(doc: &Document, f: &Field, value: &str, scripts: &mut dy
Some(r.value)
}
/// [`formatted`] with dates in English names, for widgets whose fonts can't draw the date
/// language's; `None` when the field has no Format script or the English run didn't happen.
pub(crate) fn formatted_in_english(doc: &Document, f: &Field, value: &str, scripts: &mut dyn Scripts) -> Option<String> {
let js = f.actions.scripts.format.as_ref()?;
scripts.rerun_with_english_dates(FieldEvent::Format, js, f, value, &fields(doc)).map(|r| r.value)
}
/// Apply script changes to other fields (values written without re-running their scripts;
/// read-only, required and visibility as flags). `except` is the event's own field, whose value
/// the event sets.