Repository navigation
Skip non-integer colour transform values instead of zeroing them - #1491
Silvertree2010 wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Review checks for #1491
I also ran a temporary reviewer-only matrix through |
FredApps
left a comment
There was a problem hiding this comment.
ReviewerA — source-read COMMENT (not an approval)
I read the code hunk: a colour transform whose value is not an integer (for example 1.5 or a string) is skipped instead of being turned into 0, which used to apply e.g. a 0% alpha or lum. The t.value().is_none() check keeps transforms without values. Correct; the test is in the diff.
I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.
Status: waiting_author.
aiongg
left a comment
There was a problem hiding this comment.
AI-generated review (Opus). Not a maintainer decision.
No blocking problems found (not certain).
color_value now drops a value-bearing colour transform whose JSON value is not a usable i32, so it is no longer turned into 0. Valueless transforms and the rest of the colour are kept.
- crates/engine/src/cmd.rs:416-421: the
n.is_some() || t.value().is_none()check keeps comp/inv/gray and keeps every valid integer, including 0 and negative values. Only a missing, string, float or out-of-range value is dropped. - crates/engine/src/cmd.rs:645-653: the test covers a string, an integer-shaped float, a fraction and a value above the i32 range, plus one valid integer.
- crates/pptx/src/read/dml.rs:58 still turns a missing or unparsable
valinto 0 throughColorTransform::from_xml, and crates/pptx/src/xml.rs:72-73 clamps out-of-range values where this PR drops them. This is left for a separate change, as the description says. - The same transform loop is also changed by the ordered
modswork in #1432 and #1345, so this change will need a small rebase onto whichever format lands.
Claims checked:
- verified: A transform that carries a value is skipped, instead of being set to 0, when its value is a string, a float or out of the i32 range. (crates/engine/src/cmd.rs:416 gives n = None for non-i64 or out-of-range values. cmd.rs:419 pushes the transform only if n is Some or the transform has no value. crat…
- verified: The rest of the colour is kept; one bad key does not reject the colour. (crates/engine/src/cmd.rs:415-424: the loop continues past a skipped key and still returns Some(c).)
- verified: Transforms without a value (comp, inv, gray) are unaffected. (crates/color/src/lib.rs:321-338: value() returns None for Comp, Inv and Gray, so cmd.rs:419 still pushes them.)
- verified: ColorTransform::from_xml is not changed and still defaults a missing value to 0 for its other callers. (crates/color/src/lib.rs:340-341 is unchanged. Its other caller is crates/pptx/src/read/dml.rs:58.)
- verified: A regression test covers a string, 75000.0, 0.75 and a number above the i32 range, and checks that a valid integer still works. (crates/engine/src/cmd.rs:645-653 asserts that the mods are empty for each bad value and that integer 75000 gives LumMod(75000).)
Recommendation: merge, after a maintainer's decision.
Reviewed at 1e79c63.
|
Automated message. Not a maintainer decision. This branch conflicts with main. Could you merge or rebase main into it? The conflict needs a person to resolve. |
Found while testing crates/engine/src/cmd.rs:~425 (color_value) Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1e79c63 to
0bce106
Compare
There was a problem hiding this comment.
AI-generated review (Opus). Not a maintainer decision.
Changes needed:
In color_value, a transform with a value is now skipped, rather than set to 0, when its JSON value is not an i32. Transforms without a value (comp, inv, gray) are still kept.
- crates/engine/src/cmd.rs:416-421: the filter
n.is_some() || t.value().is_none()keeps valid integers and valueless transforms, and drops strings, floats, null and out-of-range numbers. The base colour is unchanged. - The regression test covers a string, an integer-shaped float, a fractional float and a value above the i32 range, and checks that a valid integer still gives
LumMod(75000). - issue 1432 rewrites the same transform loop in crates/engine/src/cmd.rs and adds equivalent filtering, so this change will need to be reconciled with it.
Claims checked:
- verified: A value-bearing transform whose value is a string, a float or out of i32 range is now skipped instead of being set to 0 (crates/engine/src/cmd.rs:416 gives None for any non-i64 or out-of-range value. crates/engine/src/cmd.rs:419 pushes the transform only when n is Some or the transform has no value…
- verified: Transforms without a value (comp, inv, gray) are unaffected, and the rest of the colour is kept (crates/color/src/lib.rs:321-338 returns None from value() for Comp, Inv and Gray, so crates/engine/src/cmd.rs:419 still pushes them. The base colour from crates/engine/src/cmd.rs:399-414 is unchanged)
- verified: ColorTransform::from_xml still defaults a missing value to 0 for other callers (crates/color/src/lib.rs:341
val.unwrap_or(0)is unchanged. The other caller is crates/pptx/src/read/dml.rs:68) - unverified: A regression test covers a string, 75000.0, 0.75 and a number above i32, plus a valid integer (The test a_non_integer_colour_transform_is_skipped_not_zeroed in crates/engine/src/cmd.rs, added in the tests module after line 694)
Reviewed at 0bce106.
Recommendation: update the pull request; it will be reviewed again.
Found while testing
crates/engine/src/cmd.rs:~425 (color_value)(no existing issue): Colour object with a non-integer transform value gets that transform set to 0, which turns the colour black.Cause
color_valueconverts each transform value withas_i64()andi32::try_from. A string, a float or an out-of-range number givesNone, andColorTransform::from_xmlturnsNoneinto 0. The result isLumMod(0)(black) orAlpha(0)(fully transparent), with no error.Fix
In
color_value, a transform that carries a value is now skipped when its value isn't a usable i32. The rest of the colour is kept. Transforms without a value (comp, inv, gray) are unaffected. A regression test covers a string, 75000.0, 0.75 and a number above the i32 range, and checks that a valid integer still works.Verified
cmd::tests::a_non_integer_colour_transform_is_skipped_not_zeroed: fails onmainwithout the fix and passes with it (cargo test -p deckcraft-engine --lib a_non_integer_colour).cargo xtask cipasses exceptbackstage::tests::start_screen_opens_the_palette_and_preferences, which also fails onmainwithout this change.Not changed
ColorTransform::from_xmlstill defaults a missing value to 0, because other callers pass it that way. The whole colour is not rejected, so one bad key doesn't fail a load.🤖 Generated with AI by ApolloOffice, see the Co-Authored-By trailers for the models
Summary by CodeRabbit