Skip to content

fix(layout): let a row background take effect through TableElement.Add(Row) - #655

Merged
Tim81 merged 4 commits into
mainfrom
fix/row-background
Nov 21, 2026
Merged

Tim81 merged 4 commits into
mainfrom
fix/row-background

Conversation

@Tim81

@Tim81 Tim81 commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Closes #543

Row.Background is init-only and AddRow / AddHeaderRow build their own rows, so no caller could give a row a background. The renderer already drew cell.Background ?? row.Background; the row half of that was never reachable.

What changed

  • New TableElement.Add(Row): appends a row you built with new Row { Background = ... } and returns it. The table holds the row by reference.
  • It refuses, at the call and leaving the table unchanged: a null row (ArgumentNullException, ParamName row), and a background channel that is NaN, infinite, below 0 or above 1 (ArgumentOutOfRangeException, ParamName row, ActualValue the channel). ISO 32000-2:2020, 8.6.4.3: each DeviceRGB component is a number from 0.0 to 1.0. The check is on the value as given, so 1.000001 is refused although it would be written as 1.
  • Drawing is unchanged code: each cell is filled with its own Background, else the row's, ahead of its border and text. A column the row has no cell for gets no fill; a RowSpan cell takes the colour of the row it starts in; a repeated header row repeats its fill.
  • XML docs rewritten on Row, Row(), Row.Background, Row.AddCell(Cell), the AddRow / AddHeaderRow cross-references, and TableRenderer.Draw (a row background can no longer be non-finite there).
  • PublicAPI.Unshipped.txt: one new line, in its own block. No shipped member changes.
  • CHANGELOG entry under Added.

Compatibility

AddRow() and AddHeaderRow() are unchanged. Differential probe: the same 8 documents (plain, header flag through the bool overload, header row repeated over pages, a cell background with a RowSpan; untagged and tagged) built against the 2.3.3 library and against this build, dates and /ID masked: all 8 byte-identical. The probe printed 2.3.3+1c61fa6... for the old library and the build's own assembly path for the new one. Add(Row) has no 2.3.3 counterpart.

Tests (TableRowBackgroundTests, 42 cases)

Exact rg / re / f operators and rectangles per cell, the order fill, border, text, cell colour winning over row colour, per-row positions, a short row, a RowSpan, /Artifact wrapping in a tagged table, the header row repeated on every continuation page, a data row after a page break, the null background giving the bytes of AddRow(), reference semantics, an empty row, channels exactly 0 and 1, the overloads of AddRow, and the refusal theory (null; NaN, +inf, -inf, -1e-9, 1.000001 in each channel) with ParamName, ActualValue, the full message and an unchanged table. Oracles, files under a directory made with Directory.CreateDirectory: pdftoppm pixel probe (filled cell red, unfilled cell white), pdftotext, qpdf --check and veraPDF ua1 on a tagged table, veraPDF 2u. Each fixture asserts the construct is present before the verdict is read.

Full VellumPdf.Layout.Tests in Release with oracles required: net10.0 1378 total, 0 failed, 2 skipped; net11.0 1378 total, 0 failed, 2 skipped (both skips are Linux-only tests). Release solution build 0 warnings; dotnet format --verify-no-changes, clean-room check and generate-roadmap.py --check exit 0.

Mutations (each run in a detached worktree, each fails tests)

Mutant Failing tests
Add stores a copy without Background 36 cases, e.g. RowBackground_fillsEachCellRectangle_withTheRowColour, Add_holdsTheRowByReference
range check removed 16: Add_aBackgroundOutsideTheRange_*, Add_withTwoBadChannels_namesTheFirst
null check removed Add_aNullRow_throwsArgumentNullException_andLeavesTheTable
row appended before the check 15: Add_aBackgroundOutsideTheRange_*
upper bound exclusive 5: Add_acceptsChannelsAtTheRangeEnds, RowBackground_isVisible_inTheRenderedPage
range tested on the 5-decimal token 6: Add_aBackgroundOutsideTheRange_*
wrong ParamName 15: Add_aBackgroundOutsideTheRange_*
renderer ignores the row colour 20
row colour wins over cell colour CellBackground_winsOverRowBackground_forThatCellOnly
AddRow(bool) creates a row with a background 8, e.g. AddRow_overloads_areUnchanged
row fill one column wide on a spanning cell RowBackground_withAColSpan_fillsTheSpannedWidth

Not done

The fill is per cell, so a row shorter than the table is not filled across the missing columns; this is documented on Row.Background. Fill-versus-border order was tested but not mutated.

Row.Background was init-only and AddRow/AddHeaderRow build their own
rows, so no caller could set it. Add(Row) appends a caller-built row,
refusing null and a channel outside 0..1 at the call (ISO 32000-2,
8.6.4.3). AddRow and AddHeaderRow output is unchanged.
…an test

ColorRgb said no channel is ever checked at the call; Add(Row) now checks
a row background. Row.Background and TableRenderer.Draw describe a row
that reaches the table without Add(Row), the fill of a spanning cell, and
a cell pushed past the last column. Wrap the added comment lines.
@Tim81
Tim81 merged commit 7079efc into main Nov 21, 2026
4 checks passed
@Tim81
Tim81 deleted the fix/row-background branch November 26, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Layout: Row.Background can never take effect

1 participant