fix(engine): correct PageBackgroundFill y-coordinate for partial-height bands#75
Merged
Merged
Conversation
…ht bands A page-background fill with heightRatio < 1.0 was painted from the page bottom upward instead of from the documented yRatio top edge, so a band with yRatio=0 rendered at the bottom of the page. PlacedFragment.y is the PDF-native bottom-left origin (y grows up — see PdfShapeFragmentRenderHandler), so the top-down ratios now convert via y = (1 - yRatio - heightRatio) * pageHeight. Full-page and full-height column fills resolve to y=0, unchanged, so existing fills and visual baselines are unaffected. Adds top/bottom/mid-band regression tests — partial-height placement was previously untested because every factory helper uses heightRatio=1, where top and bottom are indistinguishable.
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.
Summary
Fixes the
PageBackgroundFilly-coordinate so a partial-height band lands where the API documents.The bug
PlacedFragment.yis the PDF-native bottom-left origin (y grows up;PdfShapeFragmentRenderHandlercallsaddRect(x, y, w, h)with(x, y)as the bottom-left).DocumentPageBackgrounds.apply()sety = yRatio * pageHeight, so a band withyRatio = 0— documented as the top edge — rendered at the bottom. Latent until now because every factory helper usesheightRatio = 1, where top and bottom are indistinguishable.The fix
y = (1 - yRatio - heightRatio) * pageHeight. Full-page and full-height column fills resolve toy = 0— unchanged, so existing fills and visual baselines are unaffected.Test plan
PageBackgroundTest13/13 greenmvnw clean verify -pl .— 997 tests, 0 failures (no visual baseline shifted)Part of the v1.6.5 engine work (audit §4, variant A). PR-7 adds
topBand/bottomBand/bandfactory helpers on top of this corrected coordinate model.