fix(style): reject translucent gradient stops instead of rendering them opaque#203
Merged
Merged
Conversation
…em opaque Gradients render through PDF axial/radial shadings, which carry no alpha channel, so PdfShadingSupport dropped a stop colour's alpha and a translucent stop rendered fully opaque with no diagnostic. DocumentPaint.Stop now rejects a colour with alpha below 255 at construction, naming the offending alpha — matching the offset guard already on the record and the SVG reader's existing refusal of stop-opacity. The DocumentPaint.linear(from, to) sugar inherits the guard. Opaque gradients are unaffected and stay byte-identical. Tests: DocumentPaintTest pins the opaque / translucent / offset cases and the linear-sugar path. ./mvnw test -pl . green (1392); all example PDFs regenerate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
DocumentPaintgradients render through PDF axial / radial shadings, whichcarry no alpha channel.
PdfShadingSupportreads only a stop colour's RGB, so atranslucent stop rendered fully opaque with no diagnostic — the silent
wrong-render the codebase otherwise refuses (the SVG reader already rejects
stop-opacity, charts rejectNaNseries values, etc.).What changed
DocumentPaint.Stop's compact constructor now rejects a colour with alpha below255, naming the offending alpha and pointing at the fix (flatten the
transparency into the stop colour, or apply opacity to the whole shape). This
sits next to the offset guard already on the record, and the
DocumentPaint.linear(from, to)two-colour sugar inherits it because it buildsstops. Opaque gradients are unaffected and stay byte-identical.
Binary-compatible: the record signature is unchanged (a behaviour guard, not an
API-shape change), so the japicmp gate stays green.
Verification
./mvnw test -pl .→ BUILD SUCCESS, 1392 tests, 0 failures.DocumentPaintTestpins opaque-accepted, translucent-rejected (rgbaalpha 0 and
withOpacity(0.5)), offset-out-of-range, and thelinearsugarinheriting the guard.
GenerateAllExamplesregenerates every example PDF (the gradient-heavyfeature-catalog / business-report / engine-deck / vector-path included) with
no rejection — confirming nothing in the suite or examples constructs a
translucent stop.
Lane: canonical (
document.style). No public API-shape change; behaviour guard only.