Repository navigation
fix(layout): report 207 only where a clamp or a move was skipped - #713
Merged
Merged
Conversation
Every list the document laid out as its twin and drew from its first entry reported 207 with a Count of at least 1. 207 is an Error, so StrictDiagnostics refused every such document, including one where the twin and the clamped and moved layout would have been identical. A twin now reports 207 only for an entry it left as it was that the new layout would have changed: an entry whose gutter the clamp would have narrowed, or an entry that does not fit what is left of a page and that the twin placed where it falls. Count is the number of those entries and a list with none reports nothing. A moved entry is counted by the piece that starts it, so a move on a later page is found when no header or footer makes the document lay out twice, and the diagnostic sink adds the pieces' counts. An entry in a font the document cannot draw is not counted, because the new layout leaves it as it was. The message of a twin placed by the continuation limit or by a document-wide cause now says an entry was left as it was. No PDF bytes change; only the reports, and so which strict saves succeed.
An entry the clamp would have narrowed was counted a second time as a move when its marker wrapped and was cut at the page end, because PartUnplaced reads the marker without the text. The twin now marks the entries BuildItems counted as clamps and the move count skips them. The move count's continuation-start guard is removed: a continuation is laid out at a page top, and no case of the Layout test project reaches the term. The strict sentences of the CHANGELOG and ListElement now name 208 as well as 207, and the code doc says a renderer built to start at a later entry can save under strict mode.
The undrawable-font exclusion now gives its true reason: narrowing or moving such an entry would draw text that makes the save throw. A list that does not report 207 is no longer said to report nothing where it reports 208, the entry-no-page-holds exception is in the summary, and the rule is worded as "left as it was an entry that the clamp or the moving would have changed". Tests: a child entry whose clamp and cut marker are counted once, a renamed later-start test, the strict 208 test described by what it builds, and a bool where a code number was read as a flag.
The 207 count skipped an entry when CanDrawEntry said the document cannot draw it. That check reads a run of white space alone, which the wrap draws no fragment for, so an entry such as "abc" followed by a space in an undrawable font lost its text with no report and a strict save succeeded where it had been refused. CanDrawEntry keeps choosing the layout the document uses, unchanged. The count calls the same predicate with skipWhitespaceRuns, so an entry is exempt only when drawing its marker or a run with text would make the save throw. The 207 remarks now list the exceptions as the code has them: a list a renderer of yours holds, a list built to start at a later entry, and a list with an entry no page holds, which reports 207 only when the limit or a document-wide cause also lays it out as its twin.
The exemption read a hand-written list of what the draw shows, and each version missed a case: a run of white space, then a line feed, in an undrawable font still lost its text with no report. It is now decided from the tokens ParagraphRenderer places for the entry's runs: an entry is exempt only when its marker, or a word the wrap draws, is in a font the document cannot draw. The tokenising step of WordWrap moves to a method both call, which measures nothing and so records no glyph. CanDrawEntry, which chooses the layout the document uses, keeps its body and takes no flag. The 207 remarks give the rule in one sentence and the three exceptions as the code has them. Tests cover spaces, tabs, line feeds and CRLF in both fonts at the clamp site, and a line feed at the move site and in a child, a no-break space that stays exempt, and the marker through the strict path and through a marker that does not fit the page end.
A page reference holds no text, so the tokenising step the exemption reads yields nothing for it and an entry whose reference is in a font the document cannot draw was counted, although the new layout would draw the label in that font and the save would throw. A reference is now read as a word in its own style. The label is not read: it is what the pagination makes it, differs between passes, and exists only inside a layout, and CanDrawEntry reads a reference the same way. Tests put a reference in an undrawable style at the clamp site, the move site and a child, and the same reference in a drawable style, which is counted. A child whose text is in an undrawable font is now pinned too, and a lone carriage return joins the white-space rows. The Tokenise comment now says that a tab token carries a style and draws no text.
A list that holds an entry no page holds reports 208 only for a part the twin placed and could not draw, and counts an entry the clamp would have narrowed under 207 instead. The same entries can report 208 alone, and 207 alone once a renderer of yours joins the document.
…thing The three sentences said such a document saves under strict mode. A list in a font the document cannot draw loses nothing to the twin and still throws, with or without strict mode, so they now say what strict mode does rather than how the save ends.
Tim81
force-pushed
the
fix/list-207-narrow
branch
from
November 27, 2026 07:43
6e498d2 to
d7e72a5
Compare
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.
Report
ListIndentClampSkipped(207) only where a clamp or a move was skipped.Since #682, every list with at least one entry that the document lays out as its twin (the layout it had before the clamp of #476 and the moving of #685) and draws from its first entry reported 207 with a
Countof at least 1. 207 is an Error, soStrictDiagnosticsrefused every such document, including one where the twin and the new layout would have been identical. A one-entry list with no indent, followed by a renderer of yours, an entry in a font the document cannot draw, or an element near the continuation limit, was refused under strict mode. Main (1dc734d) refuses all three; before #682 all three saved.The rule
A twin reports 207 only for an entry it left as it was that the new layout would have changed:
BuildItemsalready kept), orListRenderercounts these in the twin's own layout walk).Countis the number of those entries, and no entry is counted twice.BuildItemsmarks each entry it counts as a clamp (Entry.ClampCounted) and the move count skips marked entries. The mark is needed: the text of a clamped entry has no width in the twin, butPartUnplacedalso reads a marker that wraps and is cut at the page end, without looking at the text, so the first version of this change counted such an entry twice (a 40 pt marker in a 25 pt column at the end of a page: Count 3 for two entries, measured before the rebase at c6f07e9, now 5c3ce7a; the test pins 2). The same rule holds for every placement that reported 207: the continuation limit and the three document-wide causes.An entry counts unless drawing it in the new layout would draw text in a font the document cannot draw, which makes the save throw. The exemption is decided from what the wrap draws:
ParagraphRenderer.WordWrapis split so that its tokenising step, which places the word pieces and line breaks of the runs with the style each is drawn in, is one method that bothWordWrapand the count call. An entry is exempt when its marker, or a word that method places, is in such a font. A page reference holds no text and so yields no token; it is read as a word in its own style, because its label is what the pagination makes it, differs between passes and exists only inside a layout, andCanDrawEntryreads a reference the same way. The method measures nothing, so it records no glyph (an earlier attempt that laid the text out changed the bytes of an embedded font subset). The width the clamp gives the text does not change which styles the wrap places, so no width is needed.CanDrawEntry, which chooses the layout the document uses, keeps the body it has on the links branch (it skips a run byHoldsText). The count asks the question only for the entries it would otherwise count. Two earlier predicates read a hand-written list of what the draw shows and each missed a case (a run of white space, then a run of line feeds), which is why the exemption now reads the wrap itself. An entry whose marker alone is undrawable throws when the save draws the marker; strict mode publishes the diagnostics before the write, so a strict save shows it is not counted (the exception is the write's own, not a refusal for 207).Three lists depart from the definition, and
LayoutDiagnosticCode.ListIndentClampSkippedstates them as the code has them: a list a renderer of yours holds reports neither 207 nor 208; aListRendererbuilt to start at a later entry does not report 207 (it can report 208); a list that holds an entry no page holds reports 208 and not 207 on its own, and when the limit or a document-wide cause also lays it out as its twin it reports 207, counted as any other list's, and 208 only for a part it placed and could not draw (an entry whose text the clamp would have narrowed is counted under 207 instead).The rule is stated once, on
LayoutDiagnosticCode.ListIndentClampSkipped.ListElement,DocumentandListRendererpoint to it, and the CHANGELOG repeats it in short. The<b>Do/not</b>split and the "as that code describes" and empty-list sentences are rewritten with it.Where a move is found
A move is found only by the piece that reaches the entry. A document without a header, footer or dependents lays out in one pass and draws each piece before it lays out the next, so the start piece cannot know about a later page. Each piece therefore counts the moves among the entries it begins (
_moveSites, set by everyLayoutof the piece and read byDraw), the start piece adds the clamp count, andLayoutDiagnosticSinkadds the counts of one list's pieces: it keys on code, element kind, element index and subject, not on page, soCountsums and the first page stays (LayoutDiagnosticSink.ReportCore). A measuring pass and a drawing pass lay out new pieces, so a move is counted once per save.Message
The message names the causes that applied (
AllListsMessage, unchanged in that respect: a list twinned only by the near-limit rule does not name a font, pinned by a test) and now says an entry was left as it was, instead of saying the list was laid out as before. The limit's message says the same.Output
No PDF byte changes. Only the diagnostics and their
Countchange, and so which strict saves succeed.Preformatted), run on 1dc734d (the links branch) and on a7b878b: all three throwInvalidOperationException("StrictDiagnostics refused the save: ListIndentClampSkipped") on 1dc734d, and all three save under strict on a7b878b. The bytes are equal with and without strict, and equal on both (CD3C042260C62474,2A14935FA1E4A4E2,4A9DF37CB9A0C79A).VellumPdf.Layout2.3.3+1dc734d and 2.3.3+a7b878b (each probe prints the assembly path it loaded): 285,038 rows in the scripted sets, 284,457 rows equal. The other 581 are strict-mode rows that 1dc734d refused for 207 (127 save now, 126 are refused for 207 on another list, page or count, 55 for another code, 273 throw the exception the document raises without strict,IndexOutOfRangeException). No row without strict differs. The multi-line setx10chas the same 12 hashes on both. The Layout.Tests goldens pass at a7b878b (below).CHANGELOG
The #476 and #685 bullets (still under
[Unreleased]) are rewritten: the "or 1" count and the "with it, a 207 refuses the save" sentences are gone.Tests
ListSkippedReportTests(value-level: code,Count, page, element index, message, strict outcome) per cause (renderer of yours, undrawable font, element near the limit) and for the limit:Countis the entries narrowed, strict refuses;Countis the entries moved, strict refuses;Seven existing tests asserted the removed "1 when none" behaviour or a 207 for an undrawable entry and are updated.
Mutants at a7b878b on the whole
VellumPdf.Layout.Testsproject (4,035 cases, net10.0, Release, oracles required; 0 failed unmutated), each a one-edit diff toListRenderer.csorParagraphRenderer.cs:DrawsWordInStyle)AReferenceInAnUndrawableStyle_isNotCounted(3),AReferenceInAnUndrawableStyleAtAMoveSite_isNotCounted(2)!DrawingWouldThrowremoved)AChildWhoseTextIsInAnUndrawableFont_isNotCounted,AReferenceInAnUndrawableStyle_isNotCounted(child)AnEntryWhoseUndrawableRunIsANoBreakSpace_isNotCounted(2),AnEntryWhoseMarkerIsInAnUndrawableFont_isNotCounted(2),AReferenceInAnUndrawableStyle_isNotCounted(2),AnEntryWhoseTextIsInAnUndrawableFont_isNotCounted,AnEntryWithARunThatCannotBeDrawn_isNotClampedAReferenceInAnUndrawableStyleAtAMoveSite_isNotCounted(2),AMarkerInAnUndrawableFontThatDoesNotFit_isNotCountedAsAMove(2),AnEntryWithARunThatCannotBeDrawn_isNotMoved(2),OnlyTheListThatWouldHaveMovedAnEntry_reportsTheFallbackDrawsWordInStyleterm removed fromDrawingWouldThrow)AnEntryWhoseUndrawableRunIsANoBreakSpace_isNotCounted(2),AnEntryWithARunThatCannotBeDrawn_isNotMoved(2),AnEntryWhoseTextIsInAnUndrawableFont_isNotCounted,AChildWhoseTextIsInAnUndrawableFont_isNotCountedAnEntryWhoseOnlyUndrawableRunDrawsNothing_isCounted(14), the move-site rows (2), the child rows (2)DrawingWouldThrowAnEntryWhoseMarkerIsInAnUndrawableFont_isNotCounted(2),AMarkerInAnUndrawableFontThatDoesNotFit_isNotCountedAsAMove(2)AMoveOnALaterPiece_isCountedOnceAndKeepsItsPage(6),EachEntryTheNewLayoutWouldHaveMoved_isCounted(3),TheMovesOfSeveralPieces_addUpInOneReport(2), and othersAChildWhoseOnlyUndrawableRunDrawsNothing_isCounted(2),AReferenceInADrawableStyle_isCounted(child),AClampAndAMoveInOneList_areCountedTogether_andNoEntryTwice,TheFallbackCount_isTheEntriesTheClampWouldHaveNarrowed,Decision_agreesWithTheUnclampedPlacement_forSeededListsRows measured earlier in this change, on the commits before the rebase (1fc9de9, 94251be and ee4a126 there, now 1b8b090, 07891d5 and 98c9e22), for the other mutants, were not rerun at a7b878b: no clamp mark (1 before the rebase at 1fc9de9; 2 at 94251be with the child test), no child mark (1 at 94251be), report with
Countof at least 1 (25), moves from the start piece only (14), drop the clamp count (47 at 1fc9de9), count a move once per pass (2), count a move at a page top (3), report moves from a renderer built to start later (2).Gates at a7b878b: Release build, 0 warnings; VellumPdf.Layout.Tests in Release on net10.0 and net11.0 with the oracles required, 8,070 cases, 0 failed, 4 skipped (two Linux-only pipe tests per framework); dotnet format --verify-no-changes; eng/clean-room-check.ps1; generate-roadmap.py --check.
Cost
No extra layout pass. A twin that reports pays one
PartUnplacedcall (a text wrap if the entry's text has not been wrapped) and one font check per entry it finds placed where it does not fit, and nothing for an entry that fits. Measured on a document with a 40,000-entry twin list followed by a renderer of yours, 200 by 50 pt pages, one run per cell after the probe's own warm-up, release build, net10.0, on a machine that other builds shared; the output hashes are equal on both builds:The times go both ways between the two builds (10,000 entries all clamped 89 to 116 ms, 40,000 every second entry moves 880 to 638 ms) and one run per cell says nothing about their spread, so I do not read them. The allocation rises by 0.39% (40,000, all fit), 0.82% (40,000, all clamped) and 6.6% (40,000, every second entry moves; 21.5 MB over 20,000 moved entries, about 1.1 KB per moved entry for the tokenising step).
Not done, and why
LayoutDiagnosticCodesays so. On its own such a list reports only 208.AtPageTopis true and the page-top term covers it. I instrumented the old guard's condition (a continuation start, not at a page top,PartUnplacedtrue) and ran the 3,806 cases of the test project: 0 hits. The guard also did not match the new layout'smoves, which has no such term, so if it could fire it would under-report. It is deleted.Removed in 3.0
_moveSitesand_fromFirstEntryexist for the twin and go with it (#688), with the rest of the 207 reporting. Nothing in this change is public API.Where each figure was measured
The branch is rebased onto main (1dc734d). The figures below were measured at fa4aba4 on the links branch (1c6e44c), before a last rebase that changed no file: a7b878b and 1dc734d have the same trees, so the figures name those. The last commit, d7e72a5, changes three documentation sentences and nothing else. Nothing measured before the rebase is used here, except the mutation rows marked "earlier" under the table.
Strict mode also refuses a twin's 208: a document that holds a renderer of yours and a
ListRendererbuilt to start at a later entry (added separately: the renderer does not hold the list) is refused for 208 with no 207 (testAStrictSaveIsRefusedFor208_whenTheDocumentHoldsARendererOfYoursAndAListBuiltToStartLater), so the CHANGELOG andListElementsay "207 or 208". Such a list never reports 207, so strict can save a document whose list differs from the new layout;LayoutDiagnosticCodesays so.