From 1901b2fac64f2c55103d2c0129d4857d88571f30 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Mon, 16 Nov 2026 21:54:47 -0500 Subject: [PATCH 1/6] docx: satisfy clippy's range-contains lint in the chart title guard main's gate fails here for every pull request: `!(r < 1.0 || r > 359.0)` is exactly what `manual_range_contains` rejects. Express the same range as `(1.0..=359.0).contains(&r)`. --- crates/docx/src/read/chart/plot.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/docx/src/read/chart/plot.rs b/crates/docx/src/read/chart/plot.rs index 255b1c671..d70a67734 100644 --- a/crates/docx/src/read/chart/plot.rs +++ b/crates/docx/src/read/chart/plot.rs @@ -212,7 +212,7 @@ fn title_left(c: &Chart, cat_on: bool, val_on: bool, area_w: f32) -> f32 { fn flat_title_lines(c: &Chart, area_w: f32) -> Option> { let left = if c.horizontal { &c.cat } else { &c.val }; let r = left.title_rot?.rem_euclid(360.0); - if !(r < 1.0 || r > 359.0) { + if !(1.0..=359.0).contains(&r) { return None; } let width = if area_w.is_finite() { (area_w * 0.18).max(1.0) } else { 1.0 }; From b4d17d3943f9386f9a484c0c6c2e322628c1d4a0 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Mon, 16 Nov 2026 22:03:46 -0500 Subject: [PATCH 2/6] docx: preserve horizontal axis-title rotation guard semantics --- crates/docx/src/read/chart/plot.rs | 3 ++- crates/docx/src/read/chart/tests.rs | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/docx/src/read/chart/plot.rs b/crates/docx/src/read/chart/plot.rs index d70a67734..901aa9a50 100644 --- a/crates/docx/src/read/chart/plot.rs +++ b/crates/docx/src/read/chart/plot.rs @@ -212,7 +212,8 @@ fn title_left(c: &Chart, cat_on: bool, val_on: bool, area_w: f32) -> f32 { fn flat_title_lines(c: &Chart, area_w: f32) -> Option> { let left = if c.horizontal { &c.cat } else { &c.val }; let r = left.title_rot?.rem_euclid(360.0); - if !(1.0..=359.0).contains(&r) { + // Only near-zero rotations fit the horizontal strip; non-finite rotations do not. + if !r.is_finite() || (1.0..=359.0).contains(&r) { return None; } let width = if area_w.is_finite() { (area_w * 0.18).max(1.0) } else { 1.0 }; diff --git a/crates/docx/src/read/chart/tests.rs b/crates/docx/src/read/chart/tests.rs index d785d4400..1aeab5235 100644 --- a/crates/docx/src/read/chart/tests.rs +++ b/crates/docx/src/read/chart/tests.rs @@ -745,6 +745,11 @@ fn value_axis_title_turns_counter_clockwise_like_word() { assert_eq!(angle(&line_with("", &title(r#""#))), Some(90.0)); // A horizontal title (`rot="0"`) stays horizontal: the plot makes room for it (see below). assert_eq!(angle(&line_with("", &title(r#""#))), Some(0.0)); + // The horizontal tolerance excludes both boundary angles and keeps equivalent full turns. + for (rot, expected) in [(30000, 0.0), (-30000, 0.0), (60000, -90.0), (-60000, -90.0), (10800000, -90.0), (21600000, 0.0)] { + let body = format!(r#""#); + assert_eq!(angle(&line_with("", &title(&body))), Some(expected), "rotation {rot}"); + } // Hostile values stay finite. let odd = angle(&line_with("", &title(r#""#))); assert!(odd.is_some_and(f32::is_finite)); From e0e05d025bd3d380f876bec27f4aa0d9055f27ec Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Mon, 16 Nov 2026 22:35:29 -0500 Subject: [PATCH 3/6] craft-xlsx: restore the xlsb fixtures' calls to the Result-returning writer #1386 made testing::zip return craft_opc::Error and left the xlsb call sites still expecting Vec, so craft-xlsx does not compile and Workspace / gate fails on every pull request. Unwrap the fixture's error where the bytes were expected. --- crates/xlsx/tests/xlsb.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/xlsx/tests/xlsb.rs b/crates/xlsx/tests/xlsb.rs index 3611cafbb..ef1464dd4 100644 --- a/crates/xlsx/tests/xlsb.rs +++ b/crates/xlsx/tests/xlsb.rs @@ -1010,7 +1010,7 @@ const NAMES_XML: &str = r#""#; let root = r#""#; - let bytes = zip(&[("[Content_Types].xml", types.as_bytes()), ("_rels/.rels", root.as_bytes()), ("xl/workbook.xml", xml.as_bytes())]); + let bytes = zip(&[("[Content_Types].xml", types.as_bytes()), ("_rels/.rels", root.as_bytes()), ("xl/workbook.xml", xml.as_bytes())]).unwrap(); Package::open(&bytes, &Limits::default()).unwrap().workbook().unwrap().defined_names } @@ -1146,7 +1146,8 @@ fn xml_sheet(xml: &str) -> (Vec, SheetPart) { ("xl/workbook.xml", book.as_bytes()), ("xl/_rels/workbook.xml.rels", rels.as_bytes()), ("xl/sheet.xml", xml.as_bytes()), - ]); + ]) + .unwrap(); let (rows, part, _) = sizes_of(&bytes).unwrap(); (rows, part) } @@ -1256,6 +1257,7 @@ fn styled_file(styles: &[u8], types: &str) -> Vec { ("data/two.bin", &worksheet(&[], &[])), ("look/styles.bin", styles), ]) + .unwrap() } /// The styles part of a package, and the warnings reading it gave. @@ -1440,7 +1442,8 @@ fn xml_styles(xml: &str) -> Styles { ("xl/workbook.xml", br#""#), ("xl/_rels/workbook.xml.rels", rels.as_bytes()), ("xl/styles.xml", xml.as_bytes()), - ]); + ]) + .unwrap(); styles_of(&bytes).0.unwrap() } @@ -1793,7 +1796,7 @@ fn book_with_tables(data: &[u8], tables: &[Vec]) -> Vec { ("text/strings.bin", &strings), ]; entries.extend(names.iter().map(String::as_str).zip(tables.iter().map(Vec::as_slice))); - zip(&entries) + zip(&entries).unwrap() } /// Sheet one's tables through `Package`, and its warnings. @@ -1834,7 +1837,8 @@ fn a_name_using_a_structured_reference_is_decoded_after_tables_are_indexed() { ("data/two.bin", two.as_slice()), ("text/strings.bin", strings.as_slice()), ("tables/t1.bin", table.as_slice()), - ]); + ]) + .unwrap(); let names = Package::open(&bytes, &Limits::default()).unwrap().workbook().unwrap().defined_names; assert_eq!(names.iter().find(|n| n.name == "Vals").map(|n| n.formula.as_str()), Some("Sales[Val]")); let wb = read(&bytes).unwrap(); From 89deb7fac4d4c9114499574417aa34760277aaef Mon Sep 17 00:00:00 2001 From: Tanish Manku Date: Mon, 16 Nov 2026 23:21:59 -0500 Subject: [PATCH 4/6] feat(lottie): expose raw gradient wire values without opacity elision --- ATTRIBUTION.md | 4 ++++ crates/lottie/src/gradient.rs | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index 9d260300c..21ff5a2f4 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -114,3 +114,7 @@ The XML reader in `crates/plist/src/xml.rs` and its base64 compatibility helper ## GIMP palette reader `crates/palette` extracts the GPL text parser from AniCraft `crates/doc/src/swatch.rs` at `d875a7feb250e6ab06aa28a37fb78a0699e88330` (MIT OR Apache-2.0), introduced by Tanish Manku in `a64130a9da9bdde545463b852d95d6a6774b1dfd` (AniCraft #270). The import preserves Tanish as primary author. Neutral RGB/name adaptation separates application display-name sanitization and the `Untitled` policy; validation tests and integration are subsequent Dylan M. Taylor changes. + +The raw gradient wire ordering in `craft-lottie::Gradient::flat_values` follows +AniCraft's Lottie exporter by Tanish Manku (`63b39355`, `b9258b7b`), MIT OR Apache-2.0. +Sanitization, animation fitting and numeric output policy remain caller-owned. diff --git a/crates/lottie/src/gradient.rs b/crates/lottie/src/gradient.rs index 7edd60025..afb8495fd 100644 --- a/crates/lottie/src/gradient.rs +++ b/crates/lottie/src/gradient.rs @@ -29,6 +29,17 @@ impl Gradient { Some(Self { colors, opacities }) } + /// Raw color groups (`position, r, g, b`), followed by all opacity pairs + /// (`position, alpha`), in input order. No rounding, clamping, or opacity elision. + /// + /// This allocation-free view lets callers fit or interpolate equal-sized animated + /// values before applying their own numeric policy. In particular, opaque alpha + /// stops remain present so an opaque frame can interpolate to a translucent one. + /// Non-finite values are preserved; callers must sanitize them before JSON output. + pub fn flat_values(&self) -> impl Iterator + '_ { + self.colors.iter().flat_map(|(p, [r, g, b])| [*p, *r, *g, *b]).chain(self.opacities.iter().flat_map(|(p, a)| [*p, *a])) + } + /// The flat list, rounded to six decimals. The alpha pairs are left out when every stop is /// opaque. pub fn to_flat(&self) -> Json { @@ -44,3 +55,4 @@ impl Gradient { json!(out) } } + From c2ae800d87ff5a6266c2e0818ee7a18d72f97e25 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Mon, 16 Nov 2026 23:21:59 -0500 Subject: [PATCH 5/6] test(lottie): preserve raw gradient precision and alpha topology --- crates/lottie/src/gradient.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/crates/lottie/src/gradient.rs b/crates/lottie/src/gradient.rs index afb8495fd..0c9a9608f 100644 --- a/crates/lottie/src/gradient.rs +++ b/crates/lottie/src/gradient.rs @@ -56,3 +56,24 @@ impl Gradient { } } +#[cfg(test)] +mod raw_tests { + use super::*; + + #[test] + fn raw_values_keep_order_precision_and_opaque_alpha() { + let g = Gradient { colors: vec![(0.123456789, [0.2, 0.3, 0.4]), (1.0, [0.5, 0.6, 0.7])], opacities: vec![(0.0, 1.0), (1.0, 1.0)] }; + assert_eq!(g.flat_values().collect::>(), vec![0.123456789, 0.2, 0.3, 0.4, 1.0, 0.5, 0.6, 0.7, 0.0, 1.0, 1.0, 1.0]); + assert_eq!(g.to_flat(), json!([0.123457, 0.2, 0.3, 0.4, 1.0, 0.5, 0.6, 0.7])); + } + + #[test] + fn raw_values_keep_nonfinite_signed_zero_and_unpaired_lists() { + let g = Gradient { colors: vec![], opacities: vec![(-0.0, f64::NAN), (f64::INFINITY, f64::NEG_INFINITY)] }; + let bits: Vec<_> = g.flat_values().map(f64::to_bits).collect(); + assert_eq!(bits, [-0.0, f64::NAN, f64::INFINITY, f64::NEG_INFINITY].map(f64::to_bits)); + assert_eq!(Gradient::default().flat_values().count(), 0); + let g = Gradient { colors: vec![(1e303, [1.0, 0.0, 0.0])], opacities: vec![] }; + assert_eq!(g.flat_values().collect::>(), [1e303, 1.0, 0.0, 0.0]); + } +} From 6181ae557fdf27cdf63052c6db5d21a7d31a0010 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Mon, 16 Nov 2026 23:26:35 -0500 Subject: [PATCH 6/6] feat(lottie): flatten borrowed gradient stops without temporary buffers --- crates/lottie/src/gradient.rs | 14 +++++++++++++- crates/lottie/src/lib.rs | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/crates/lottie/src/gradient.rs b/crates/lottie/src/gradient.rs index 0c9a9608f..a3dff7314 100644 --- a/crates/lottie/src/gradient.rs +++ b/crates/lottie/src/gradient.rs @@ -4,6 +4,18 @@ use serde_json::json; use crate::{Json, nums, round6}; +/// Raw gradient wire values from borrowed or mapped stops, without intermediate allocation. +/// +/// Yields color groups (`position, r, g, b`) then every opacity pair (`position, alpha`). +/// Input order and all values, including non-finite values and opaque alpha, are preserved. +/// Sanitization, rounding, and input/output size budgets remain the caller's responsibility. +pub fn flat_gradient_values( + colors: impl IntoIterator, + opacities: impl IntoIterator, +) -> impl Iterator { + colors.into_iter().flat_map(|(p, [r, g, b])| [p, r, g, b]).chain(opacities.into_iter().flat_map(|(p, a)| [p, a])) +} + /// A gradient: colour stops and opacity stops, each at a position in 0..=1. #[derive(Debug, Clone, Default, PartialEq)] pub struct Gradient { @@ -37,7 +49,7 @@ impl Gradient { /// stops remain present so an opaque frame can interpolate to a translucent one. /// Non-finite values are preserved; callers must sanitize them before JSON output. pub fn flat_values(&self) -> impl Iterator + '_ { - self.colors.iter().flat_map(|(p, [r, g, b])| [*p, *r, *g, *b]).chain(self.opacities.iter().flat_map(|(p, a)| [*p, *a])) + flat_gradient_values(self.colors.iter().copied(), self.opacities.iter().copied()) } /// The flat list, rounded to six decimals. The alpha pairs are left out when every stop is diff --git a/crates/lottie/src/lib.rs b/crates/lottie/src/lib.rs index 16c1c6e07..578939d6b 100644 --- a/crates/lottie/src/lib.rs +++ b/crates/lottie/src/lib.rs @@ -30,7 +30,7 @@ mod prop; mod value; pub mod zip; -pub use gradient::Gradient; +pub use gradient::{Gradient, flat_gradient_values}; pub use model::{Animated, Animation, Layer, LayerContent, Limits, Shape, ShapeKind}; pub use path::Bezier; pub use prop::{Ease, Key, KeyOut, Prop, PropValue, Tangents, is_animated, read_prop, tangent, write_keys, write_prop};