Repository navigation
Description
ListElement.Indent at negative infinity writes the literal token -Infinity into a text matrix
on a list with nested children. That token is not a PDF number, so the coordinate a reader needs
to place the item is not there.
Measured on docs/correct-layout-boundaries, Release, page 300x300pt at 10pt margins:
| list shape | Indent |
item text matrix |
|---|---|---|
| flat | -50 | 1 0 0 1 14.2 278 Tm |
| flat | negative infinity | 1 0 0 1 14.2 278 Tm (identical, 1,555 bytes) |
| nested | -50 | 1 0 0 1 -40 263.6 Tm and 1 0 0 1 -33.328 263.6 Tm — off-page, but numbers |
| nested | negative infinity | 1 0 0 1 **-Infinity** 263.6 Tm |
A flat list is unaffected because the gutter is Math.Max(indent, markerWidth), so any negative
indent collapses to the marker's own width. A nested child does not go through that:
ListRenderer.BuildItems sets the child marker paragraph's left inset to Indent directly, with
no LayoutValidation call on the way.
This is the same defect class as the NaN case the member already documents, and the same class
as #478 and #481: a non-finite value reaching the content stream as a token no reader can parse.
NaN and negative infinity are two separate inputs here and only one of them was known.
Nothing throws and nothing is reported, so a caller ships a file whose nested items have no
placeable coordinate.
Scope — corrected
An earlier revision of this issue said the flat path was correct. That is wrong, and the XML
documentation inherited the error from here.
A flat list is safe only while the gutter widens. ListRenderer.BuildItems computes
gutter = Math.Max(indent, markerWidth) and then, on the next statement, reverts it:
if (areaWidth - gutter < WidestWord(...)) gutter = indent;So a flat item whose longest word will not fit beside the marker takes the indent directly, exactly
as a nested child does. Measured with a single 40-character word, Indent negative infinity:
| page / margins | short word, -50 | long word, -50 | long word, negative infinity |
|---|---|---|---|
| 300x300, 10pt | 14.2 |
-40 |
-Infinity |
| 400x500, 20pt | 24.2 |
-30 |
-Infinity |
| 595x842, 72pt | 76.2 |
22 |
-Infinity |
| 200x400, 5pt | 9.2 |
-45 |
-Infinity |
Two paths reach it, then, not one: a nested child always, and a flat item whose longest word does
not fit. Positive infinity on a nested list still throws at the content-width boundary before it
can reach this, so it is unaffected.
Suggested fix
Route the child inset through the same validation the rest of the package uses, so a non-finite
indent is refused rather than emitted. That is a behaviour change: a document that saves today
would throw. Nothing it refuses could have rendered, since the coordinate it writes is
unparseable, so the usual objection does not apply here.
Found while reviewing #503's documentation. The XML doc records the current behaviour and should
be updated in the same commit that fixes it.
Activity
docs(layout): repair what the subtraction broke, one clause at a time
docs(layout): state the rule instead of enumerating what it produces