Repository navigation
fix(layout): read tabs, line breaks and form feeds in cells and bands - #679
Merged
Merged
Conversation
A table cell split its text on U+0020 only, so a tab reached glyph lookup as glyph 0 (embedded font) or a raw 0x09 byte (Standard 14), and a line feed was one line holding glyph 0 or a string-escaped newline. A running band passed a form feed to the font as it was. A cell now breaks lines as a paragraph does (CR LF, CR and LF each end a line) and draws every other white-space control character as a space. Automatic columns are sized from the widest line. A band draws those characters as spaces and measures them as spaces. Header rows and RowSpan groups are never cut between lines, so honouring breaks there could turn a table that saved into a too-tall refusal. A cell of such rows that would do so keeps the unbroken layout, with each break drawn as a space, and is listed as the new warning CellBreakDrawnAsSpace (301). Closes #611
…awing A cell laid out unbroken was wrapped with its tabs and line breaks at their own width, zero in Helvetica, but drawn with each as a space, so its lines came out wider than measured and crossed borders and the page edge. They are now left out of the drawing, so a line is as wide as it was measured. Also limit the third fallback step to the cells that can change the rows that do not fit, end a pass after the header step so a group is judged by the header's new height, read other Unicode space separators as a space, and decide the fallback once per width instead of once per page.
Cover the fallback drawing no wider than it measured, a header step that ends its pass, a tab that tips a group without reaching a fixed column's rows, a header that gives up only its breaks, a RowSpan chain read as one group, a report per table, one report for a cut row, and a minimum column width taken from each line's words.
… at a time
Drop the reading of Unicode space separators as spaces: two tables that
saved are refused with it, and a paragraph's rule for them is a change for
a later major. A group step that adds a cell now ends its pass, so the next
group is judged by heights taken after the change. The text a page label
prints for {page} is read as the template's own text is. The cached decision
is keyed on the width and the boxes' heights, not their x, so mirrored
margins reuse it.
State what Count counts, scope the claim that nothing crosses a cell, describe the random tables accurately and give the exact page boundary: 2,350,047 words save and 2,350,048 are refused.
A group that gave up its breaks ended the pass, so a table with many such groups took one full measurement per group. A step that adds only cells of the group's own rows in fixed-width columns changes no height another group reads, so the pass goes on. A step that touches a header row or an automatic column still ends it. Also pins the header's no-room rule for a later row, a fallback cell after a ColSpan, the all-header table, and U+0085, U+2028, U+2029 in a band template, and says in the runtime message that the rows were left no room, not that they were taller than a page.
A tab-tipped group in fixed columns must also be judged in one pass, and a tab in the last header row must reach the group's third step.
A header that gives up its tab also changes the heights the next group is judged by, which one more case pins.
The tab pin allocates 1.03 times its baseline when groups are judged together and 1.93 times that when each ends the pass; a bound of five missed it.
A header falls back when it leaves the row below no room for a line, and a group when it exceeds what a page leaves under the header, so 'taller than a page' was false for both. A table of nothing but header rows repeats none. Corrects the qpdf and cell-border claim for the six refused-then-saved tables, the CR LF band sentence, and states that RunningBand.Resolve returns control characters as given.
A group that gave up a cell in a fixed-width column let the pass go on to the next group, which was then judged against a header that a later pass relieved. With that header the next group would have had room, so its breaks were dropped for nothing. Only this group's rows are measured again now, and the group is judged once more before the next one. Each group that gives up a cell in an automatic column still ends the pass, and each pass measures the whole table, so a table with many such groups took time and allocation that grew with the square of their number. After 8 measurements the groups not yet judged are judged together. A table that needs at most 8 is decided as before; beyond that a later group can give up cells it would have kept. Tests pin the groups the cap leaves alone, the boundary at 7 and 8 measurements, the allocation of 400 groups in automatic columns, and the decision key, the column reach of a spanning cell, a column past the width array and a RowSpan inside the header.
The rule for which table cells are laid out unbroken was copied into six places, and each copy drifted from the others: one said every step ends its pass, one said the cause was line breaks, though a tab alone can tip a table with none. Cell.Content now holds the rule in full, including the bound on measurements and what it changes. TableElement, LayoutDiagnosticCode, TableRenderer.Layout, the runtime message and the CHANGELOG say what they add and point there. Also fixes the running band note that a carriage return and line feed pair is two spaces, and replaces the CHANGELOG sentence about identical bytes with what was measured.
The limit of 8 measurements ends passes that stop at the first shared step. A table in which each group's fallback changes the column widths the next group is judged against still takes one measurement per group, and above the limit a later group can give up more cells or fewer than group-by-group judging would. Say so in the XML docs, comments and CHANGELOG, and pin the batch-mode branches of the group loop with tests.
The chapter token added a second copy of the predicate and the replacement that LayoutText already holds. A table cell, a page label and a bookmark title now read control white space through the one helper.
A decision that reads cells unbroken measured every cell's longest word and widest line again on each pass, though both depend only on the cell's text and mode. They are kept for the decision and dropped with it, so a table edited between saves is measured from nothing.
Measuring a row wrapped every cell again, though a cell's line count only changes when the column width crosses one of the comparisons the wrap made. The count is kept with the interval of widths over which every comparison comes out the same; a word that was broken at its characters pins it to that width. A test probe can check each hit against a fresh wrap.
After eight measurements a pass judged all the groups it reached on the heights it started with, so a group could give up more cells than judging it on the heights its predecessors left would. The limit goes, and a table decides the same cells however many groups it holds. The commits after this one keep what each cell measures, which is what made the limit unnecessary.
A group that gave up cells in an automatic column ended the pass, because the width of that column can change other rows. When the widths come out bit for bit as they were, and every cell given up lies in the group's own rows, no other row measures differently, so the pass goes on with the next group instead of starting again from the first.
Every page of a table resolved the grid again, though the renderer that carries the table over holds the grid, the heights and the decision for the same width and fresh page. The checks of the cells and the border width ran on the page that made the decision, so a later page keeps them as they were.
Allocations are counted, not time, so a loaded machine does not move the pins. The shapes are groups that give up a cell in a column other rows share, groups that each widen that column, and a chain in which each group changes the width the next is judged by.
The pass limit and its cost paragraph are gone from the changelog and the XML documentation, which now state the rule once on Cell.Content. A test pins the interval of a cached line count as closed below and open above.
A table the previous release saved was refused when an automatic column's cell, in a row of no group, held a line break: reading it per line took the column's minimum from its widest line, the explicit columns were scaled down to what that left, and the group's own cells held no control white space for any step to give up. When a header or a group still has no room after the three steps, a last step reads every control-white-space cell that spans an automatic column unbroken. Those cells alone decide every column's width, so the widths, and the header and group heights, come out as when every cell was one line. A test hook measures a table that way, for the property test.
The widths kept for the pass, raised by a step, decide whether the step moves a column. A step that ends the pass is followed by a measurement of the whole table from what the cells kept, and a fixed column's step computes none.
The bound on a table's page continuations counted two for every unit, so a table of 26,000 ordinary rows was placed twice to find out that it takes a few thousand pages. When no row is cut, two pieces in a row are taller together than what a page leaves under the header, so the bound also follows from the rows' heights, and the check runs only for tables that can reach the limit.
The three renderers a layout hands on each copied the decision field by field, and a copy that missed one went unnoticed. The continuation verdict is asked again rather than kept: it depends on where the element starts, and a key that said so had no test that could tell it from a wrong one. The refusal property now draws tall header rows too.
Header rows that do not fit a page leave every run of rows without room, so the refusal check needs no test of its own for them; no test could tell the two apart.
This was referenced Nov 22, 2026
Takes the shared continuation-limit mechanism (#686). The table's own limit check in DocumentRenderer goes: the merge keeps the mechanism's placement loop and drops the guard, the probe and the two fields the table added.
…nism The table now reports a bound to the document and the document decides, instead of the table running its own placement. The bound is the larger of the grid that keeps the breaks and the grid that reads every cell unbroken, so a table whose unbroken layout alone reaches the limit stays refused with the message that layout gives, as it was in 2.3.3. A table laid out under a context the document did not address to it (a caller's renderer that forwards here, WithArea, the public constructor) is its own twin: it reads every cell unbroken and reports nothing, so the document's limit holds however the table is reached. Its Draw and ReportPlacements forward to the twin that laid it out, and the fallback is reported only for a twin the document chose. The guard interface, the probe and the two fields in DocumentRenderer are gone; the mechanism's limit and verdict memo replace them. The public XML documentation of IRenderer.Layout, TableRenderer.Layout, TableElement, Cell.Content and LayoutContext.WithArea says what a table you lay out yourself does. The Kernel method that measures without registering has a direct test, and four comment lines are rewrapped.
…ntity A table that keeps its breaks keeps them in the drawing pass of a document with a footer, which lays the table out a second time from the decision the first one carried. The twin is one object for the life of the renderer. A delegating table no longer forwards its anchor: the document reports one only for a renderer it placed, so the forward was never reached.
…rt row A table whose bound with its breaks read is within the limit and whose unbroken layout reaches it is refused as before, which only holds when the reported bound covers the unbroken grid. A wrapped table that fits one page is drawn by its twin. A table started at a row, under a context the caller built, is its twin from that row.
Each comment that belongs to the twin, the report and the delegation names 3.0 and #688, as the shared mechanism's own comments do.
… starts it The stack-depth probes counted PlaceRenderer frames. PlaceRenderer is now a small method that starts PlaceLoop, and the JIT inlines it once it is hot, so on net11.0 a run that placed 50,000 pages before the probes (the table limit tests do) read zero frames. PlaceLoop holds the loop, is not inlined, and is on the stack exactly once per Layout call.
…t it The stack-depth probes counted PlaceRenderer frames, and in a full run of the suite in sequence the count read 0, so both probes failed with Expected: 1, Actual: 0. PlaceRenderer only starts the placement loop and is small enough for the JIT to inline into its caller. PlaceLoop is the method that recurses if the loop regresses, and a recursion into it puts a second frame on the stack. Marking it NoInlining keeps the frame the probes count, and the count stays 1 for a renderer that does not report.
…pace emptied A cell the table lays out unbroken leaves its tabs and line breaks out of what it draws, so a line made only of them came out empty and was written as an empty string shown with Tj, which draws nothing. A blank line between two line breaks in a cell that keeps its breaks was written the same way. Neither writes a show now. A cell that holds no control white space is not touched, so a table without any keeps its bytes, an empty cell and a cell of spaces alone included. A table reports its bound whether or not a cell holds control white space, and a test pins why: with no report the document lays the rest of the placement out as the twin, a new renderer without the lines a cut row carries, and the row is drawn again from its first line. The message for a cell given up for the continuation limit and the test hook that measures every cell unbroken now say that 3.0 removes them.
…refusal A tab, a line break or another control white-space character in a cell reaches no font, so the save lists no NotdefGlyph or UnencodableCharacter for it and StrictDiagnostics does not refuse the cell. That holds for a table the document lays out and for one a caller's renderer holds, which draws the character as nothing, and a PDF/A-2u file made that way passes veraPDF. A control character that is not white space is still refused. The XML documentation of Cell.Content and TableRenderer.Layout and the CHANGELOG now say so, and list the output change of a table a caller's renderer holds, which leaves the control characters out of the drawing, and the position of a centred band that holds a tab.
The comment gave one run's result as the general one. State the runs: both probes failed in four sequential runs on main, on net10.0 and on net11.0, and one net11.0 run passed. The inlining cause stays a likely cause, not an established one.
…kips The skip covers every empty line of a cell that holds control white space, a line of spaces alone included, not only a line the control characters emptied.
…efusal A tab, line break or form feed in a band template or a page label is drawn as a space, so StrictDiagnostics has nothing to refuse. A PDF/A-2u band passes veraPDF, and U+0001 in a band is still refused.
…ble wrote before RunningBand.Template and the CHANGELOG now say a control white-space character in a band no longer reports NotdefGlyph or UnencodableCharacter. The CHANGELOG also names what a table wrote for such a character before: glyph 0, a raw byte, ? or the font's own glyph.
Tim81
added a commit
that referenced
this pull request
Nov 23, 2026
Three conflicts, all in documentation and the reserved-code comment. IRenderer.Layout keeps main's table paragraph ahead of the list paragraphs. WithArea names both built-in renderers that lay out the earlier way under the copy. The reserved list drops 203 and 301, which the two changes now define.
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.
Closes #611
What changed
A table cell split its text on U+0020 only. A tab reached glyph lookup as glyph 0 in an embedded font (the ToUnicode map held
<0000> <0009>, and veraPDF failed PDF/A-2u clause 6.2.11.8) and as a raw 0x09 byte in a Standard 14 font. A line feed stayed inside the word: glyph 0 in the middle of one line, or the string escape\n. #613 item 34 is the same path for a form feed in a cell or a running band.A cell reads its text by one rule. CR LF, a lone CR and a lone LF each end a line. An empty line between two of them is a blank line one leading tall, and so is the one after a trailing break (
a<LF>is two lines in a cell; a paragraph draws one). Runs of spaces are kept as written (a paragraph collapses them). Every other white-space control character (tab, form feed, line tabulation, next-line, U+2028, U+2029) is one space, so none reachesGetGlyphIdsorShowText. The no-break spaces and the other Unicode space separators (U+2003 and so on) are written as before; a paragraph reads the separators as spaces, and that parity is left for a later major (see below).An automatic column takes its minimum from the widest word and its maximum from the widest line, each line measured by itself where 2.3.3 measured the whole text. The width it is given is shared out as before and can be more than the maximum or less than the minimum.
A running band draws a tab, a line feed, a carriage return or a form feed as one space, in its template and in the text a page label prints for
{page}(aPageLabelRangeprefix with a tab or line break wrote raw control bytes in Helvetica and glyph 0 in DejaVu under PDF/A-2u; both are tested, veraPDF included). The band measures and cuts the text it draws. This covers Tracking: defects found while doing the v2.4 work (not yet fixed) #613 item 34.Rows that cannot be cut keep the unbroken layout of their cells when reading the cells' breaks would refuse them. A header row and rows joined by a
RowSpanare never cut between lines. When a cell's line breaks, or its other control white space read as spaces, would leave such rows no room on a page, 2.3.3 saved and the new layout would throw. The cause is not only a line break: a tab is one space wide where 2.3.3 measured the raw character at its own width, so a tab can tip a table with no line break in it (ATabThatWouldTipARowSpanGroupOverThePageIsLaidOutUnbroken:a,ab<TAB>ab, 46 words). The cells concerned are wrapped at spaces alone and sized from their whole text, as before, with each tab and break measured at its font's width and then left out of what is drawn. The save lists each as the newLayoutDiagnosticCode.CellWhiteSpaceDropped(301, a warning;StrictDiagnosticssaves). The rule is stated once, in the XML documentation ofCell.Content: when the header rows and a group have no room, the order in which they are judged and relieved, the cells each step reaches, and the all-header table. The other members (TableElement,LayoutDiagnosticCode,TableRenderer.Layout, the runtime message, the CHANGELOG) say what they add and point there.A group is judged again after its own step. A step that adds only cells of the group's own rows in fixed-width columns changes no height another group reads, so only that group's rows are measured again and the group is judged once more before the next one. A step that adds a header cell or a cell in an automatic column ends the pass, because it can change other rows' heights. It does not when the cells all lie in the group's own rows and every column width comes out bit for bit as it was. This is group-by-group judging: each group is judged on the heights the earlier decisions leave. Judging the next group on the header as it stood before a later pass relieved it gave a different answer (
AGroupIsJudgedAgainAfterItsOwnStepBeforeTheNextOneIsJudged).Every group is judged in order, however many there are, and the decision keeps what each cell measures. There is no limit on the number of measurements. A cell's longest word and widest line are kept per mode, and its line count with the interval of column widths over which it holds, a word broken at its characters included, because each comparison that decides where it breaks bounds the interval like the others. After a step the column widths come from the per-column widths kept for the pass, raised by what the step's cells contribute unbroken; when a cell would contribute less, the table is measured again. A step that gives up only cells in the group's own rows, and leaves every column width bit for bit as it was, does not end the pass, and a table resolves its grid once for all its pages. A cell is still measured again when a column width leaves the interval its count holds over, so "once" would be false; "Cost of the fallback" has the counts.
A last step relieves a header or group that a cell outside it narrowed. The width of every column follows from the cells of the automatic columns, whichever rows they are in, so a cell in a column that no cell of the group is in can make the group's columns too narrow, and no step reached it. When a header or a group still has no room after the first three steps, every cell that holds control white space and spans an automatic column is laid out unbroken. The widths are then the ones 2.3.3 measured, and so are the heights of each header or group that still had no room; a group that fits keeps its breaks, so it can be taller than that. Each cell given up is reported as 301 where it is drawn. The rule is stated once, in
Cell.Content;TableElementandTableRenderer.Layoutsay that a cell in an automatic column can be among those given up. The review of an earlier head found three of 3,000 random long tables (seeds 366, 1482, 2461) that 2.3.3 and origin/main saved and this branch refused, and a minimal one: a 400 x 300pt page, Helvetica 10, columns 100, 100 and automatic; rows 0 and 1 joined by aRowSpanover a 38-character text; row 2 holding, in the automatic column, 37W, a line feed and 4W. Its group was 424pt tall with 280pt left, and is 100pt.A table reads its cells' breaks only where the document lays it out. The document addresses each context it builds to the renderer it calls (the mechanism of Keep the continuation limit's verdict for elements that lay out differently from 2.3.3 #686, merged as feat(layout): add one shared continuation-limit mechanism #690). A
TableRendererthat a caller's renderer holds and forwardsLayoutto, or that is laid out underWithAreaor the public constructor, is laid out by its twin: every cell unbroken, nothing reported, so its pages, and what it refuses for room or for the continuation limit, are those of the table as main lays it out, and the continuation limit holds however the table is reached. ItsDrawleaves the control characters out of the drawing, as the document's own fallback does. Main wrote glyph 0, a raw control byte,?or the font's own glyph for them and, for glyph 0 and?, reportedNotdefGlyphorUnencodableCharacter; this build does neither (see "For the maintainer" and "Differential underStrictDiagnostics"). A wrapper'sDrawhas to forward to the table, because the document draws the instance it called. The public XML documentation ofIRenderer.Layout,TableRenderer.Layout,TableElement,Cell.ContentandLayoutContext.WithAreasays so.The fallback is decided once per width and set of page heights and carried to the renderers for later pages, with the grid and heights it was made with, which those pages do not resolve again. The key leaves out the boxes' x, which mirrored margins move on every other page.
XML docs:
Cell.Content,Row.AddCell(string),TableElement,TableRenderer.Layout,RunningBand.Template,LayoutDiagnosticCode,Document.Diagnostics; the one existing test that pinned "a cell and a band hand the raw 0x0C to the font" now pins a space.New internal
Core/LayoutText.csholds the line-split and control-space rule.ParagraphRendereris untouched.A table that is refused when every cell is measured as one line stays refused. The decision gives up a cell's breaks only where a header or group has no room, which could leave a table that main refuses saving with its breaks read. After the decision, when some cell that holds control white space still keeps its breaks, the table is measured once more with every cell unbroken, from the same cache. The trial is a check of what the layout would do on a fresh page: the header rows must fit, and so must every run of rows the layout never splits (
BuildRowspanBlockedSet), unless the run is one row that can be cut. If the trial is refused, the table is laid out that way and the save throws what main throws. Otherwise the decision's widths and heights are put back. The trial measures embedded text without adding any of it to the font's subset: without that, the control characters of cells that keep their breaks were added to the subset of an embedded font although none is drawn (found when 1,196 of 4,439 saved tables of generator X came out with another subset tag than before the check; none does now).A table whose breaks would take more than 50,000 page continuations is laid out with every cell unbroken, and a table whose unbroken layout would is refused as before. The limit stays. The table reports to the document, through the shared mechanism, an upper bound on the continuations of its placement in either layout: the larger of the bound over the grid that keeps the breaks and the bound over the grid that reads every cell unbroken (twice its units less one, or
3 + 4H / Awhen no row is cut; the argument is in the XML doc ofContinuationBoundOf). The earlier head bounded only the layout that keeps the breaks, and asked only whether that one reached the limit, so a table whose unbroken layout alone reaches it was saved where main and 2.3.3 refuse it (the limit table below). Where the bound is within what is left of the limit nothing more runs. Above it the document places the table twice without drawing, the unbroken layout first: if that reaches the limit or throws, the table is that layout and the save throws what main throws; if the layout that keeps the breaks reaches it, the table is laid out unbroken from its first page, main's measurement, so it saves what main saves in main's pages; otherwise it keeps its breaks. The verdict is kept for each place the table starts, so each start is probed once however many passes and simulations of the keep rules ask. Each cell the fallback leaves unbroken is reported as 301 with a message that names the limit, and only where the document chose the fallback.A span declared in a header row makes no group of the rows under it. The layout breaks between those rows (
BuildRowspanBlockedSetstarts at the first data row), so the decision judged them as a group the layout never keeps whole and gave up breaks that fit. Each of those rows is now judged by its own height, and a span declared in a data row is still a group. The mismatch on main, whereInSpanGroupand the refusal messages count a header-declared span and the layout does not, is not changed; it belongs with Tracking: defects found while doing the v2.4 work (not yet fixed) #613.Deliberate output changes
A<TAB>Bin a cell of a table the document lays out:(A B)in Standard 14, a space glyph (glyph 3 in DejaVu Sans) between the letters in an embedded font, no<0000>ToUnicode entry.line1<LF>line2,cr1<CR><LF>cr2,a<LF>: one show string per line, the next baseline one leading lower, rows taller (12pt: 2 x 14.4 + 8 = 36.8). Automatic columns take their width from the widest line.A+ 120 tabs +Bin Helvetica 10 on a 300pt page saved with no truncation on origin/main and now draws 1 of 122 characters and listsBandTruncated, whichStrictDiagnosticsrefuses. A band that holds a tab is also placed by that width: a centred one moves by half the difference between the width its font gave the tab and the width of a space, a right-aligned one by the whole difference, a left-aligned one not at all. The shift comes from this change to the band and not from main:Page {page}<TAB>of {total}at 8pt starts 1.112pt further left when centred and 2.224pt further left when right-aligned in Helvetica (main measured the tab at 0; 278/1000 x 8 = 2.224pt), and 1.128pt and 2.256pt further right in DejaVu Sans (the glyph 0 main wrote for the tab is wider than a space). Measured on origin/main and on this build with one header and no table.RowSpangroup that has no room on a page, when its cells' breaks or other control white space are read, keeps the 2.3.3 geometry, with the tabs and breaks left out of the drawing (see above).WithAreaor the public constructor, keeps main's layout and pages and leaves its control characters out of the drawing:A<TAB>Bis(AB), andA<U+2028>Bis(AB)in Helvetica where main wrote the tab as a raw byte and U+2028 as?. A DejaVu Sans cell holds no glyph 0 and the ToUnicode map no<0000> <FFFD>entry for it. The save lists noNotdefGlyph(102) orUnencodableCharacter(103) for these characters.StrictDiagnosticson, a control white-space character in a cell, in a table the document lays out or one a caller's renderer holds, no longer makes the save throw (see below and "Differential underStrictDiagnostics").StrictDiagnosticson, a control white-space character in a running band's template or a page label's text no longer makes the save throw either. Main reported it asNotdefGlyphorUnencodableCharacter; the band now draws it as a space and reports nothing.With
StrictDiagnosticsoff, no table that main refuses saves here, and none that main saves is refused: a table that main refuses is refused with main's message, a table whose breaks would pass the 50,000-continuation limit is laid out as main measures it and reported as 301, and a table that a caller's renderer holds is laid out as main lays it out (0 of 26,000 documents differ in what saves or in the refusal message, in each of four contexts, and none in the page count in the three contexts a caller builds: pass-through,WithAreaand the public constructor. In the direct context 10,634 of the documents both builds save have another page count than main (Y 1,330, X 4,157, A 1,938, G 2,487, P 722), because a cell's breaks are read there (deliberate change 2); see "Differential with the shared limit mechanism").With
StrictDiagnosticson, one class of documents changes: those whose only error items were the reports of a control white-space character in a cell or in a running band. Such a character reaches no font now, so the save lists noNotdefGlyphorUnencodableCharacterfor it. A document that main refuses for those reports alone saves here. Main's refusal was its own report of the #611 defect (glyph 0, or?, written for a control white-space character), the defect is gone, and the output that now saves passes veraPDF: a PDF/A-2u file made this way is compliant, and main's own file for the same table fails clause 6.2.11.8 (see "Differential underStrictDiagnostics"). A control character that is not white space, such as U+0001, is still reported and refused in a cell. Every other strict-mode result is main's, measured over the same 26,000 documents in four contexts. The refusal is not restored: it would make a table or a band refuse the input that this change corrects.A table whose cells hold none of tab, CR, LF, form feed, line tabulation, next-line character, U+2028 and U+2029 saves to the same bytes as before (differential below). A paragraph is unchanged: no byte of
ParagraphRenderermoved.ISO 19005-2, 6.1.13: this change shortens show strings (one per line) and writes no
qorQ.For the maintainer
Three choices are provisional. All are implemented as stated and are cheap to change.
A fallback cell draws its control characters as nothing. The cell is wrapped with each at its own width (zero in Helvetica) and, drawn as spaces, came out wider than measured: 60 LF-joined
abin a 100pt column drew 102.86pt in an 88pt box, and on a 400pt page with automatic columns the first line ran from x=16 to 446.9. Leaving them out makes the drawn width equal the measured one. Measured now: 0 lines past their cell on those two fixtures, andpdftotext -rawreturns all 120 letters in order (they run together in the extraction as they do in the drawing). The alternative is to wrap the fallback with each control character as a space. Heights then differ from 2.3.3, so a table 2.3.3 saved can be refused: built and measured on the 20,000 tables with control characters, wrapping alone with each as a space refuses 16 that origin/main saved, and wrapping and sizing the automatic columns that way refuses 26, against none now.Other Unicode space separators in a cell are left as written; paragraph parity for them is left for 3.0. A cell read them as one space in an earlier revision of this branch, as a paragraph does. That revision changed 9,408 of 20,000 tables whose texts hold no tab or line break (the one text with a separator there is the U+2003 one), turned two tables that saved into refusals (seeds 12243 and 4668; both save again with the rule off), and it changed 1,846 of 4,000 valid tables in DejaVu Sans, where U+2003 is a real glyph. With the rule off, none of the 40,000 Helvetica tables goes from saved to refused, and the 20,000 without control characters are byte-identical to origin/main. Cell, paragraph and band still differ on these characters;
Cell.Contentsays so.The pass limit is gone, and every group is judged on the heights the groups before it leave. An earlier revision of this branch stopped passes from ending at the first shared step after 8 measurements, which made a table of many groups cheaper and changed which cells a later group gave up. With the measurements kept per cell, and with a step that moves no column not ending the pass, every table in "Cost of the fallback" takes less time and less allocation than 2.3.3 and than origin/main on the same table, in the single run measured. The decision is exact at any size. Had the cost stayed far from origin/main I would have kept the limit; it did not. The cost of groups that each widen an automatic column still grows with the square of their number: 1,000 of them allocate 6.5 times what 400 do.
A table a caller's renderer holds draws without its control characters, where main drew them. The pages, the cell rectangles and the refusals are main's: over 26,000 documents with every table behind a forwarding renderer, 0 differ in what saves, in the refusal message or in the page count. The bytes differ where a cell holds a control character, because the twin is the same layout the document's fallback uses and that layout leaves them out, where main wrote a glyph, an escape or a raw byte for each (
<0000>and(lorem\n\niii)in the lines I opened). Making the twin draw them would reproduce Layout: a tab or newline inside a table cell is written as glyph 0 (.notdef) with an embedded font, and as a raw control byte with a standard-14 font #611 for a caller's renderer:<0000>in the ToUnicode map and a PDF/A-2u failure. Of the first 40 documents of each of the five sets, 123 were saved by both. In each of them every show string that differs is main's string with its control characters removed, or with the glyph 0,?or U+2028 and U+2029 glyph written for them; a line that holds only control characters is not written at all. 12 of the 123 also differ in the x of a text origin, and all 12 are the running headerPage {page}<TAB>of {total}, not a table: that shift is deliberate change 4 (the header is centred and its tab is now measured as a space), 1.112pt in Helvetica 8. In 166 documents saved by both under a context built with the public constructor (seeds 40 to 99), 16 differ in an origin, all of them band lines. No table origin differs in either sample. The ToUnicode map and the subset also lose the entries for glyph 0. Say if main's bytes are wanted here instead; keeping the characters would restoreNotdefGlyphandUnencodableCharacterfor a caller's renderer too, and with them the PDF/A-2u failure.2.3.3 against this build
Page 2000x600, 10pt margins (580pt content), Helvetica 10 (12pt leading, 8pt padding), one column 1900pt wide unless stated; a cell is n two-letter words joined by LF.
10 570 1930.09932 20,1940.09932 570 49.90068 20Differential against origin/main (4dd521f)
Run on an earlier revision of this branch. Its "refused before, saves now" figures no longer hold: this revision refuses those tables, as the final differential below shows.
20,000 random tables per set (1 to 3 columns, up to 11 rows, header rows,
RowSpan,ColSpan, fixed or automatic widths, tagged or not, two page heights, Helvetica), saved on origin/main and on this branch; dates, /ID and XMP ids normalised. The first set draws texts from 17 kinds: letters, words, spaces, an accented letter, U+0001, U+007F, a no-break space and a text with U+2003, and none has a tab, line break, form feed, line tabulation or next-line character. The second adds ten kinds that do.In DejaVu Sans (the same generator, seeds 0 to 3,999), the 4,000 tables without those characters are byte-identical to origin/main (259 refused on both). Of the 4,000 with them, 3,576 change, 9 are refused on origin/main and save here (seeds 496, 793, 1069, 1138, 1372, 2166, 2683, 2723, 3033), none is saved there and refused here, and 182 are refused on both.
Line past a cell border (a show string that ends beyond the right edge of the smallest cell rectangle holding its start, counted on saved documents of the second set): 149 documents on origin/main and 178 here; 41 cross here and not there. In 38 of the 41 the crossing show string is one character long and none carries a fallback report; I read the other three: seed 9086 is one glyph and a space, seed 13766 (3 characters) is a text drawn below its row, and seed 16449 is a ColSpan cell measured at one column and drawn at another under a RowSpan, a mismatch origin/main has. Of the 206 saved documents that carry a fallback report, 8 have a line past a border, the crossing show strings being 1 to 14 characters long; I did not trace them.
Differential of the caches
Run on an earlier revision of this branch. Its "refused before, saves now" figures no longer hold: this revision refuses those tables, as the final differential below shows.
The same seeds saved by three builds, with
TimestampandDocumentIdpinned and the SHA-256 taken over the whole file: origin/main (fc2b248), this branch at 574806c with the pass limit set toint.MaxValue(exact group-by-group judging, no caches), and this build. The sets are the 20,000 Helvetica tables without and with control characters, the same generator in DejaVu Sans (4,000 each), and three generators of tables with manyRowSpangroups and header rows (3,000, 2,000 and 2,000; pages 300 to 2,000pt wide).55,000 tables, 0 differences between the exact build and this one, saved or refused. This run had the verification hook on: each cached line count that was used (568,866 of them) was checked against a fresh wrap of the same cell at the same width, and none differed. The caches answered 1,081,581 width lookups, 9,151 steps kept a pass going, and 42,320 layouts kept the grid of an earlier page. Origin/main is the fc2b248 build, before the chapter token of #681.
Cost of the fallback
Release, net10.0, a 2000 x 600pt page, Helvetica 10, one process per row, one run each on a shared machine, so read the times to a factor of two. The MB are cumulative allocation (
GC.GetTotalAllocatedBytes), not memory in use: the peak working set was 71MB or less in every run. Diagnostics are capped at 1,000. "Fillers" are groups of two rows: two short cells in 36pt columns and a cell of 60 lines withRowSpan = 2in an automatic column. "Fillers, spaces" is the same table with spaces between the lines, which has nothing to give up. "Grow n" has n groups whose cell has 48 + i lines, in three automatic columns, so each step widens a column. "Cascade 400" is 400 groups that each tip the next (columns 1980 and automatic). 2.3.3 and origin/main (a34a281) measure each cell as one line; 72330b7 is the previous head.Where it stops. What the fillers cost over the same table with spaces is 3, 4, 9, 15 and 30MB at 400 to 6,400 groups, so the decision itself no longer grows with the square on that shape; what is left in both is the document's own cost, which also grows faster than the row count (9MB to 468MB over a sixteenfold increase of the spaces table). Grow still does: 1,000 groups allocate 6.5 times what 400 do (2.5 times the groups; quadratic would be 6.25) and take 3.0 times as long. Every step of that table moves a column width, so each ends the pass and the next pass visits every cell again; a line count is measured again when a width leaves the interval it holds over, 13,103 times at 400 groups and 37,730 at 1,000, against 135,397 and 768,035 on 72330b7. Three exact remedies the review named (per-column interval endpoints, measuring a row only when the group judged needs it, never judging again a group that cannot change) are not implemented: they change how the pass is organised, not how a cell is measured, and I stopped here.
How the cost was found. The decision was timed by phase in an instrumented build. At 1,600 fillers, deciding whether a step moves a column took 1,490 of 2,100ms and 232 of 278MB, because each step copied the set of cells read unbroken and resolved the whole grid. At 1,000 grow groups, 19.7 of 25.1s and 12.5 of 13.3GB went to line counts of a word broken at its characters, which were held for one exact width, so each new width measured every such cell again, with a string allocated per character. Both fixes are exact, not caps: a step raises the kept widths, and the interval is bounded by the comparisons that cut the word. The allocation left per pass was the owner text built for each cell's font-size check and an enumerator per row; both are gone.
Pins, by allocation: fillers at 400 and 1,600 groups stay under 1.5 times the same table with spaces (1.2 measured at both); 300 grow groups allocate under 60MB (32.6MB measured); a chain of 60 groups that each tip the next, under 30MB; counting the lines of a 3,000-character broken word allocates under 4KB. They replace two ratio pins: the fillers one held only near 400 groups (the ratio went 2.7, 3.9, 5.5, 7.3 and 9.0 from 400 to 6,400 on 72330b7), and the grow one passed with all four caches off because the baseline it divided by grew with them.
Differential, last step and incremental widths
Run on an earlier revision of this branch. Its "refused before, saves now" figures no longer hold: this revision refuses those tables, as the final differential below shows.
Generators A (8,000 mixed tables), G (3,000 tables with many
RowSpangroups near the page height) and P (3,000 long multi-page tables with mirrored margins, bands and repeated headers).TimestampandDocumentIdpinned, SHA-256 over each file, refusals compared by type and message. The builds are this branch, 72330b7, origin/main a34a281 and 2.3.3 (1c61fa6, whoseDocumenthas no pins and noMirrorMargins: its run uses the same generators without them and compares saved against refused only, so its row is not byte-for-byte the same documents).The first 16 hex digits of
sha256sumover the per-seed result lines (seed, saved or refused, SHA-256 of the file or the exception) of this build and of 72330b7: A 2164c7a534f20823 and 2164c7a534f20823, G 61ac3191c64f05db and 61ac3191c64f05db, P a84e2a96b9726b97 and 92eb2080639bd9ed. Against 72330b7 the only differences are the three tables it refused (P seeds 366, 1482, 2461); every other table saves to the same bytes or is refused with the same message. The commit that made the steps cheaper (2a1ffaa) changes no byte of any of the 14,000 tables against the commit before it. With the verification hook on, no cached line count differed from a fresh wrap, and every step that raised the kept column widths (3,949 in A, 36,478 in G, 6,108 in P) gave the widths of measuring the table again, bit for bit; 634 steps in A and 335 in P measured the table again because a cell would have contributed less, none in G. A separate probe checked the line-count intervals against a fresh wrap over 1,746,192 (text, width) cases, among them every fragment sum a broken word compares and each width's neighbours one unit in the last place apart, and the interval ends: 9,499,974 comparisons, 0 differences.Differential, final
Generators X (6,000 tables, driven by the limit mechanism), A (8,000 mixed), G (3,000 with many
RowSpangroups near the page height) and P (3,000 long, with mirrored margins, bands and repeated headers).TimestampandDocumentIdpinned, SHA-256 over each file, refusals compared by type and the whole message. Builds: this head, 329d10a (the previous head), origin/main a34a281 and 2.3.3 (1c61fa6, saved or refused only: itsDocumenthas neither pin nor mirrored margins).RowSpandeclared in a header row, where the rows under it now keep breaks that fit (one run of the earlier commit 7583406 alone, 43, 217 and 22, before the refusals).Verifyhook checked every cached line count and every raised column width against a fresh measurement, and none differed (X: 8,181 raises, 28 measured again; A: 3,999 and 613; G: 36,478 and 0; P: 5,849 and 321).The continuation limit, built on this head (page 2000 x 40pt, one line of the cell per page; one cell of
abwords joined by LF): 50,001 words keep their breaks and take 50,001 pages; 50,002 words are laid out unbroken, 295 pages, one report. On a 2000 x 600pt page: 2,350,047 words keep their breaks (50,001 pages), 2,350,048 take 295 pages and 2,500,000 take 314, as on main. A table (rows ofa<LF>bon a 400 x 40pt page, 20pt of content) keeps its breaks at 25,000 rows (50,000 pages) and is laid out unbroken at 25,001 rows (25,001 pages, 1,000 reports and the sink's own entry for the reports it dropped) and at 30,000 (30,000 pages); main saves 25,000 rows in 25,000 pages, and the review found the previous head throwing at 30,000.Differential with the shared limit mechanism
Generators X (6,000), A (8,000), G (3,000), P (3,000) and Y (6,000: PDF/A-2u, PDF/A-2b and PDF/UA-1 claims with DejaVu only, tagged documents, Times, Courier, Symbol, Helvetica and DejaVu, U+202F, U+2007, U+4E00 (no glyph) and NBSP, header rows and spans, data spans, tall LF cells near the page, mixed widths, keep rules, anchors, mirrored margins, bands).
TimestampandDocumentIdpinned, SHA-256 over each file, refusals compared by type and the whole message. Builds: this head (built at b4a698c; 8e90128 changes one test file), origin/main c44a516 (the mechanism without this PR) and 2.3.3 (saved or refused only). Four more runs of this head: with theVerifyhook (every cached line count and raised column width checked against a fresh measurement), with every cell measured as one line, and each of those documents with every table behind a forwardingIRenderer(Fwd, whoseLayoutandDrawforward to a publicTableRenderer) on this head and on main. The head runs were repeated after the last source change and are byte-for-byte the same as before it.StrictDiagnosticsoff. Their bytes differ where a cell holds a control character, which is item 4 under "For the maintainer". With it on, see the next section.Differential under
StrictDiagnosticsThe same 26,000 documents (Y, X, A, G, P), each saved with
StrictDiagnostics = trueby this head and by origin/main c44a516, in four contexts (direct, behind a pass-throughIRenderer, underWithArea, under the public constructor). A refused strict save leaves the items it found inDocument.Diagnostics, so each document's error items were read from both builds, ignoring their counts.WithAreaNotdefGlyphorUnencodableCharacternaming U+0009, U+000A, U+000B, U+000C, U+000D, U+0085, U+2028 or U+2029: 0 documents had an error item of another code or character, and 0 had none. This head reports no error item that main lacks in any document.Tableonly, 170HeaderorFooteronly, and 10 both (4,483 under the public constructor: 4,305, 168 and 10). Of the documents where both throw, 239 differ because main lists a band item that this head does not (238 under the constructor); the band items areNotdefGlyphorUnencodableCharacterfor a tab, a line break or a form feed in a band template or page label, which the band now draws as a space. Every item main lists that this head does not names one of the eight characters (0 items name another), in all four contexts, and this head lists no item that main lacks. The band's oracle isAStrictPdfA2uDocumentWithControlWhiteSpaceInABand_passesVeraPdfandABandWithAControlSpaceInAPageLabelIsPdfA2uClean(veraPDF 1.30.4, flavour 2u, compliant).StrictDiagnosticsoff, status and message equal main's in all four contexts.a<TAB>b,line1<LF>line2andc<TAB>d,StrictDiagnosticson): origin/main throwsNotdefGlyph (ISO 19005-2:2011, 6.2.11.8) ... U+0009 has no glyph in DejaVuSans, both directly and behind a pass-through renderer; this head saves both, and veraPDF 1.30.4--flavour 2ureports both compliant (146 rules passed, 0 failed). With the switch off, main's file for the direct table fails veraPDF clause 6.2.11.8 and carries two error items, and this head's passes.qpdf --checkis clean on both of this head's files, andpdftotext -layoutreturnsline1andline2on separate lines for the direct table andline1line2for the one a caller's renderer holds, where the words the characters separated run together as the twin draws them. The testAStrictPdfA2uDocumentWithControlWhiteSpaceInACell_passesVeraPdfpins this for both.A table at the real limit (page 400 x 60pt, margins 10, Helvetica 10, two automatic columns; row 0 six
mmmmmmmmjoined by LF ands; then n rows ofaandlorem lorem):InvalidOperationException(2,590s)The previous head saved n = 50,001 in 25,004 pages, where main and 2.3.3 refuse. A wrapper (one cell of 50,002
abwords joined by LF, 2000 x 40pt page, 1900pt column, behind a forwardingIRenderer) is pinned at a limit of 300 byATableAWrapperHolds_isLaidOutAsBeforeItsBreaksWereRead; at the real limit the previous head threw where main saved 295 pages.Cost of the new checks
Release, net10.0, one run each on a shared machine, so read the times to a factor of two.
a<LF>bon a 400 x 40pt page (24,000 pages)The one-line trial costs 1% to 20% of time on tables that keep every break (the smallest tables show the larger shares) and 1.5% to 11% of allocation. It does not run for a table whose control-space cells have all given up their breaks. The continuation check is kept off tables far below the limit by the bound: the 26,000-row table is placed once, and an earlier bound of twice the rows placed it twice (13.9s and 5.0GB against 7.7s and 2.8GB). Near the limit it costs more layouts: 25,000 one-row pages took 55.7s where an earlier head took 30.0s, and the rows of "Cost with the shared limit mechanism" below are the head with the shared mechanism. Most of both is a cost per page that grows with the number of rows (
BuildRowspanBlockedSetis rebuilt for every page); caching it for the table made the same run 22.4s in a scratch build, with more per-page work left. That is not in this branch.Cost with the shared limit mechanism
Release, net10.0, one process per row, one run each on a shared machine, so read the times to a factor of two. Allocation is cumulative (
GC.GetTotalAllocatedBytes). Main is c44a516. The shapes are those of "Cost of the fallback" and "Cost of the new checks".a<LF>b, 400 x 40pt (50,000 pages, keeps its breaks)The last row is the exact limit: this head keeps the breaks of a cell that takes 50,001 pages and main lays it out unbroken in 295. The allocations are within 1MB of the earlier head's (fillers 499MB against 498MB, grow 378MB, cascade 68MB, 20,000 rows 1,793MB against 1,793MB in an independent run).
Tests
TableMainRefusalTests(18 cases, new),TableLastStepTests(7 new cases),TableContinuationLimitTests(21 cases, new) andTableStrictDiagnosticsTests(11 cases, new) withTableCellBreakTestsandTableMeasureCacheTests. On the final commit, Release, withREQUIRE_ORACLES=1,REQUIRE_VERAPDF=1, veraPDF 1.30.4, qpdf 12.4.2 and poppler fromC:\msys64\mingw64:Layout.Testsnet10.0 and net11.0 each 2,461 run, 2,459 passed, 0 failed, 2 skipped (the two Linux-only pipe tests);Kernel.Testseach 2,666 run, 2,666 passed. The sameLayout.Testsrun in sequence (-parallel none) passes on net10.0 and on net11.0 with the stack-depth probes in it. Release build ofVellumPdf.slnx0 warnings;dotnet format --verify-no-changes,eng/clean-room-check.ps1andgenerate-roadmap.py --checkclean. The Kernel method that measures without registering has its own test now (MeasureStringWithoutRegistering_equalsMeasureString_andRegistersNothing, two fonts).PaginationDepthTestscountsPlaceLoopframes, andPlaceLoopcarries[MethodImpl(MethodImplOptions.NoInlining)]. One commit changes only that test and that attribute line, so PR #682 can take it as it is. The probes countedPlaceRendererframes, and origin/main c44a516 fails them: in full runs of its own suite in sequence (-parallel none) both probes readExpected: 1, Actual: 0in four runs, two on net10.0 and two on net11.0. One further run on net11.0 passed (2,298 run, 0 failed). The likely cause is that the JIT inlinedPlaceRendererinto its caller; I did not confirm that with a JIT dump. What the probe counts is true for the test's own renderer, which never reports: onePlaceLoopframe perLayoutcall. A renderer that reports puts two on the stack during a continuation probe, because the probe callsPlaceLoopfrom insidePlaceLoop. The attribute rules out a false failure from inliningPlaceLoopintoPlaceRenderer; it does not guarantee that the JIT never turns a recursion into a loop. Mutants, each failing both probes on net10.0 and on net11.0:PlaceLoopcalls itself for the overflow, in tail position or not, andPlaceLoopcallsPlaceRendererfor it, in tail position or not.The limit tests, at a limit of 300 page continuations (
ContinuationSupport.Run): a table whose unbroken layout reaches the limit is refused with the message the one-line measurement gives (the shape of the limit table above), and one continuation fewer keeps its breaks; a table whose bound with its breaks read is within the limit and whose unbroken layout reaches it is refused (page 400 x 200pt, a bound of 153 against 301 continuations); a cell of 302 lines is laid out unbroken in the bytes of the one-line measurement and reported as 301 with the limit's message; a forwarding renderer in three ways (pass-through,WithArea, results cached by area) around a table of 302 lines saves in the bytes of the one-line measurement with no report and no probe, and around a table that reaches the limit is refused with that message; a forwarding renderer that lays the table out under a context it builds with the public constructor cuts no row, so a cell that does not fit a page is refused as too tall; a table that fits one page behind a forwarding renderer is drawn; under a context the caller built a table cuts no row and starts at its start row; a table within the limit keeps its breaks in the drawing pass of a document with a footer; the twin is one object.TheContinuationBoundIsNeverBelowTheContinuationsATableTakesreads the bound from the session the document makes.Tests for the header spans, the one-line measurement and the limit: a header-span table at n = 18, 24, 26 and 34 (no cell is reported), a header span over two rows that fit alone, a row under a header span that has no room, and a span declared in a data row that still holds its rows; a table that is refused measured as one line, refused with the same message (three widths), its neighbours saved with their reports, a property over 600 shaped tables (tall header rows among them) and 250 long ones that every table refused measured as one line is refused with the same message, and a DejaVu table whose dropped measurement leaves no
<0000> <FFFD>in the file; the limit exactly (50,001 pages keep their breaks), one over (the bytes of the one-line measurement, with and without a footer, and after a paragraph that makes the table move a page), a refusal by the limit's message measured as one line, the 2,350,048-word cell of the earlier body, and the bound (a property over 500 tables on short pages and 500 on tall ones that it is never below the continuations taken, and that 30,000 short rows have a bound under 50,000).Mutations
Each applied in a detached worktree, built, and run against
TableCellBreakTestsandPageBreakTests(121 tests). The comment-only baseline fails none. The first group of rows below ran on an earlier build of this branch; the rows for the caches and the early cutoff ran on the final one, against the whole ofLayout.Tests, and each fails at least one test.ARelievedGroupIsMeasuredAgainBeforeTheNextGroupIsJudgedAFallbackHeaderLeavesAnUnrelatedRowItsBreaks(automatic columns)AHeaderThatTakesTheRoomOfAGroupGivesUpOnlyItsBreaksAHeaderThatATabTipsIsLaidOutUnbrokenARowThatCanBeCutKeepsItsBreaksWhenATabTipsAGroupACutRowWithAFallbackCellIsReportedOnceARowThatCanBeCutKeepsItsBreaksWhenATabTipsAGroupAControlSpaceThatIsNotABreakIsNotTheFirstStepACutRowWithAFallbackCellIsReportedOnceACutRowWithAFallbackCellIsReportedOnceAnAutoColumn_hasItsMinimumFromTheWordsOfEachLine,ACutRowWithAFallbackCellIsReportedOnceARowSpanChainIsOneGroupTwoTablesReportTheirOwnFallbackCellsABandDrawsAControlSpaceInAPageLabelAsASpace,ABandWithAControlSpaceInAPageLabelIsPdfA2uCleanAFallbackCellIsDrawnNoWiderThanItWasMeasuredStandard14_anEmptyHardLineIsABlankLineAHeaderThatWouldLeaveNoRoomForTheRowBelowIsLaidOutUnbroken(47)TheCostOfGivingUpBreaksInFixedColumnsDoesNotGrowWithEachGroupTheCostOfGivingUpTabsInFixedColumnsDoesNotGrowWithEachGroupARelievedGroupIsMeasuredAgainBeforeTheNextGroupIsJudged(both cases)AGroupAfterARelievedHeaderIsJudgedByTheHeaderThatRemainsARelievedGroupIsMeasuredAgainBeforeTheNextGroupIsJudged(zeroWidths: true)ABandDrawsAControlSpaceAsASpacecasesAFallbackCellAfterAColSpanIsMeasuredAsItIsDrawnATabInTheLastHeaderRowThatTipsAGroupIsLaidOutUnbroken,AGroupAfterARelievedHeaderIsJudgedByTheHeaderThatRemainsAHeaderIsRelievedWhenALaterRowHasNoRoomForALineAGroupCellSpanningAnAutoColumnEndsThePassEvenWhenItStartsInAFixedOneAColumnPastTheWidthArrayIsAnAutoColumnRowSpaninside the header counts as a groupARowSpanInsideTheHeaderIsNotAGroupTheThirdStepReachesAnAutoColumnThatOnlyTheHeaderIsInADecisionIsNotReusedForAFreshPageOfAnotherHeightAGroupIsJudgedAgainAfterItsOwnStepBeforeTheNextOneIsJudged; on the previous head the test reports row 3, cell 0 as wellAControlSpaceThatIsNotABreakIsNotTheFirstStepAGroupAfterARelievedHeaderIsJudgedByTheHeaderThatRemainsEveryRowOfAGroupIsMeasuredAgainAfterItGivesUpItsBreaks(3)/ both casesY + (Bottom - Y)and deflated by the table's own margins, so for one table it equals the first except for rounding in the last bit of the bottom edge, and the decision reads both only throughFitsFresh, whose tolerance is 0.001pt. Two calls would have to agree in the first box and differ in the second by more than rounding, which no page rectangle does. The document offers one content area for every page and moves only its x.Layout.Tests)<=)AnIntervalIsClosedBelowAndOpenAbove<)AnIntervalIsClosedBelowAndOpenAboveAColumnPastTheWidthArrayIsAnAutoColumnandAControlSpaceThatIsNotABreakIsNotTheFirstStepACertificateCountsLikeTheWrapItStandsForAcrossItsInterval,ACertificateHoldsOverARangeUnlessAWordWasBrokenACertificateCountsLikeTheWrapItStandsForAcrossItsIntervalACertificateCountsLikeTheWrapItStandsForAcrossItsInterval,TheCostOfAChainOfTippedGroupsStaysUnderAFixedBoundAnIntervalIsClosedBelowAndOpenAboveAStepThatMovesAColumnWidthStillEndsThePassAGroupAfterARelievedHeaderIsJudgedByTheHeaderThatRemainsADecisionIsNotReusedForAFreshPageOfAnotherHeight,ALaterPageOfAnotherWidthResolvesTheGridAgainRefusalMessageTests.Table_colSpanBelowOne_namesTheCellTheCallerWroteTableLastStepTests,TableCellBreakTests,TableMeasureCacheTests, net10.0)AGroupThatACellOutsideItNarrowedIsRelievedByThatCell,AHeaderThatACellOutsideItNarrowedIsRelievedByThatCell,TheLastStepLeavesTheOtherCellsTheirBreaks,ALongRandomTableThatTheThreeStepsCouldNotRelieveIsSaved(3 seeds),ADocumentThatSavesMeasuredAsOneLineSavesADocumentThatSavesMeasuredAsOneLineSavesAStepRaisesTheKeptColumnWidthsAndMeasuresNoOtherCell,TheCostOfGivingUpBreaksInASharedAutoColumnStaysAFixedMultipleOfNotGivingThemUpAStepThatNarrowsAColumnMeasuresTheTableAgainACertificateCountsLikeTheWrapItStandsForAcrossItsInterval,ACertificateHoldsOverARangeWhenAWordWasBrokenALongRandomTableThatTheThreeStepsCouldNotRelieveIsSavedandADocumentThatSavesMeasuredAsOneLineSavesCountingABrokenWordAllocatesNothingPerCharacterEveryCachedLineCountEqualsAFreshWrapand the three cost pinsAStepThatLeavesEveryColumnWidthAsItWasDoesNotEndThePassand 3 more, among them the fillers pinATableOverManyPagesResolvesItsGridOnceand the three cost pinsTheCostOfGroupsThatEachWidenTheColumnStaysUnderAFixedBound, run alone: it fails after 361 seconds;TableCellBreakTests.TheCostOfGivingUpBreaksInFixedColumnsDoesNotGrowWithEachGroupand...TabsInFixedColumns...fail too. The whole class under this mutant did not finish in 15 minutes, so I stopped it.| header spans and main refusals (detached worktree of an earlier head,
TableMainRefusalTestsandTableLastStepTests, net10.0) | || a span declared in a header row is a group again |
ARowUnderAHeaderSpanThatHasNoRoomGivesUpItsBreaks,ASpanInTheLastHeaderRowIsNotAGroupOverTheRowsItReaches,RowsUnderAHeaderSpanAreJudgedOneAtATime(6 cases) || rows under a header span are not judged |
ARowUnderAHeaderSpanThatHasNoRoomGivesUpItsBreaks,ADocumentThatSavesMeasuredAsOneLineSaves,ADocumentThatIsRefusedMeasuredAsOneLineIsRefused|| the one-line trial never refuses |
ATableThatIsRefusedMeasuredAsOneLineIsRefusedWithTheSameMessage(3 cases),ADocumentThatIsRefusedMeasuredAsOneLineIsRefused|| the one-line trial measures into the subset |
AMeasurementThatIsDroppedAddsNothingToAnEmbeddedFont|| the one-line trial splits inside a
RowSpangroup |ADocumentThatIsRefusedMeasuredAsOneLineIsRefused|| the one-line trial lets any single row be cut |
ATableThatTakesExactlyTheLimitKeepsItsBreaks,ATableThatWouldTakeOneContinuationTooManyIsLaidOutAsOneLine(4 cases) || the one-line trial tests the header rows alone | none, and none is possible: the run check refuses whatever the header test would, because header rows that do not fit leave every run without room. The test is removed. |
| the bound is zero | 7 cases, among them
TheContinuationBoundIsNeverBelowTheContinuationsATableTakesandTheBoundOfAManyRowTableThatTakesFewPagesIsBelowTheLimit; see the mutations of the shared limit mechanism below || the bound counts the units less one |
ATableThatWouldTakeOneContinuationTooManyIsLaidOutAsOneLine|| the height bound uses 1H in place of 4H |
TheContinuationBoundIsNeverBelowTheContinuationsATableTakes,TheBoundOfAManyRowTableThatTakesFewPagesIsBelowTheLimit|| the reason is not carried to later pages |
ATableThatWouldTakeOneContinuationTooManyIsLaidOutAsOneLine(3 cases) || the fallback reports the room reason |
ATableThatWouldTakeOneContinuationTooManyIsLaidOutAsOneLine(3 cases) |Mutations of the shared limit mechanism
Each applied in a detached worktree at c78522d (the table code is that of the head, whose later commits change comments and one test), built, and run against
TableContinuationLimitTests,TableMainRefusalTestsandTableCellBreakTests(110 to 114 tests, net10.0, Release); the Kernel row againstPeekGlyphIdTests. The first sweep ran at e8944ec; three mutants survived it and one did not build, and the tests that kill them were added, so those four rows are from the second sweep at c78522d. Every mutant below fails at least one test.ATableThatKeepsItsBreaks_keepsThemInEveryPass,ACellThatWouldTakeMoreThanTheLimitIsLaidOutUnbroken_andReportedand the wrapper casesATableWhoseBreaksBoundIsWithinTheLimit_butWhoseUnbrokenLayoutReachesIt_isRefused(survived the first sweep)ACellThatWouldTakeMoreThanTheLimitIsLaidOutUnbroken_andReportedandTheContinuationBoundIsNeverBelowTheContinuationsATableTakesATableWhoseUnbrokenLayoutReachesTheLimit_isRefusedWithTheMessageThatLayoutGivesTheSameTableWithoutAWrapperKeepsItsBreaksDrawATableAWrapperHolds_thatFitsOnePage_isDrawnByItsTwin(survived the first sweep: every wrapped table in it took several pages, so the table's own first call was never the one that drew)DrawTheTwinIsTheSameObjectOnEveryCall(did not build in the first sweep: an unused field)TheTwinIsTheSameObjectOnEveryCallATableStartedAtARow_laidOutUnderAContextTheCallerBuilt_startsThere(survived the first sweep)ACellThatWouldTakeMoreThanTheLimitIsLaidOutUnbroken_andReportedATableThatWouldTakeOneContinuationTooManyIsLaidOutAsOneLine(3 cases)MeasureStringWithoutRegistering_equalsMeasureString_andRegistersNothingMutations of the empty show, the strict-mode rule and the depth probes
The band row was applied in the worktree of this branch and then restored; the others each in a detached worktree at 55b7403 (its tree differs from the final commit in one test comment), built in Release, and run against
TableContinuationLimitTests,TableStrictDiagnosticsTestsandTableCellBreakTests(107 tests, net10.0) or, for the depth probes, against*stackDepthStaysFlat(2 tests, net10.0 and net11.0). The baseline fails none. Every mutant below fails at least one test.ALineThatIsEmptyBecauseOfControlWhiteSpace_writesNoEmptyShowATableWithNoControlWhiteSpace_drawsEachLineOfARowCutBetweenItsLinesOnceAnEmbeddedCellWithControlWhiteSpace_saves_underStrictDiagnostics(direct),AStrictPdfA2uDocumentWithControlWhiteSpaceInACell_passesVeraPdf(direct) andStandard14_aTabIsOneSpaceTableStrictDiagnosticsTestsand the wrapper case of the empty-show testAStandard14CellWithControlWhiteSpace_saves_underStrictDiagnosticsand 4 moreACellWithAControlCharacterThatIsNotWhiteSpace_isStillRefused_underStrictDiagnosticsandEmbedded_noControlWhiteSpaceIsGlyphZero_andOtherControlsStillAreBandTemplateswitched off)*Band*filter, net10.0: both new band cases ofTableStrictDiagnosticsTestsand the existing band cases ofTableCellBreakTestsandPageBreakTests(ABandDrawsAControlSpaceAsASpace,ABandCutsAtTheSpaceAFormFeedBecame)PlaceLoopcalls itself for the overflow, not in tail positionPlaceLoopcallsPlaceRendererfor the overflow, not in tail positionA first version of the twin mutant, one that made
RemoveControlSpacesreturn its argument, hung the test process instead of failing a named test, and was replaced by the one above.Removed in 3.0 (#688)
3.0 lays a table out one way under every context, so every compatibility device this PR adds goes. Each carries a comment naming 3.0 and #688.
TableRenderer: theIContinuationTwinimplementation (Twin()), the fields_readsUnbrokenForTheLimit,_twin,_laidOutBy,_placedAsTwinand_reportBound, the delegation to the twin at the top ofLayout, the report to the session at the end of the decision, the bound over the unbroken grid, the forward inDraw, and the_placedAsTwincondition on the 301 report with itsDroppedForTheLimitmessage.IRenderer.Layout,TableRenderer.Layout,TableElement,Cell.ContentandLayoutContext.WithAreaabout a table you lay out yourself, and the CHANGELOG entry "A table is laid out with its breaks read only where the document lays it out".TableMeasureProbe.ReadEveryCellUnbroken, which the tests use to measure a table as it was before breaks were honoured, and the tests that pin the twin: the wrapper cases ofTableContinuationLimitTests,TheTwinIsTheSameObjectOnEveryCall,ATableStartedAtARow_laidOutUnderAContextTheCallerBuilt_startsThere.Residual costs, for 3.0 to close with an exact technique:
a<LF>bon a 400 x 40pt page (the twin is chosen) took 42.9s and 119,640MB here against 141.5s and 314,639MB on main, in one run each of net10.0 on a shared machine. I did not time the phases. The exact remedy is to keep the pieces the twin's probe placed and replay them when the twin is chosen.aon a 400 x 40pt page (a bound of 50,003, above the limit) took 24.5s and 71,859MB here, three placements, against 135.4s and 309,888MB on main (the same bytes, sha-256 prefix 73DE1E2F8374); 25,000 such rows (a bound of 49,999, no probe) took 10.2s and 24,114MB. The report cannot be dropped for such a table. A call that reports nothing makes the document lay out the rest of the placement as the twin, a new renderer that holds none of the lines a cut row carried, and the cut row is drawn again from its first line. Measured with the report made only for a table that holds control white space, on a 400 x 100pt page, one row of 80 wordsw0tow79in a 100pt column and no control character: 5 pages and 106 word shows, where this build and main write 4 pages and 80 (3,014 bytes on both).ATableWithNoControlWhiteSpace_drawsEachLineOfARowCutBetweenItsLinesOncepins it. The exact remedy is a report that carries the cut row to the twin, or a bound the document can trust without probing when the two layouts are one. One candidate, unproven and not measured here: keep the report but give a bound of 0 when no cell holds control white space, so the document takes the bound branch with no probe. A review tried it on a few shapes and the table test classes passed; nobody ran the differential or the limit tests at the real limit on it, and it stretches what a bound means, so 3.0 would be better served by a flag that says the two layouts are one.BuildRowspanBlockedSetand the header scan still run for every page (see "Not done").Other open PRs
#680 and #681 are merged into this branch. The three list conflicts with #680 are unions, and its reserved-numbers comment no longer names
301 ControlCharacterInCell, which this PR defines asCellWhiteSpaceDropped. #681's copy of the control-space predicate inBandTextis removed: bands, page labels, bookmark titles and cells read it throughLayoutText.Not done
RowSpandeclared in a header row in two ways (found by the review; to be filed with Tracking: defects found while doing the v2.4 work (not yet fixed) #613).InSpanGroup,CanCut,SpanGroupOfand the refusal messages count it as holding the data rows under it, andBuildRowspanBlockedSetstarts at the first data row, so the layout still ends a page between them. This change judges those rows one at a time and leaves the layout alone.BuildRowspanBlockedSetand the header scan run for every page) makes a 25,000-row table of one-row pages take 30s on main. The continuation check doubles it near the limit; see "Cost of the new checks".NotdefGlyphreports them.RowSpan(origin/main, found while checking this change; to be filed separately).ResolveGridmeasures a row's cells in consecutive columns from the left, andDrawRowskips a column that a span from an earlier row occupies, so a cell can be measured at one column's width and drawn in another. On origin/main, tables whose texts hold no tab, line break or form feed draw text outside their row: seeds 47, 118, 212 and 221 of the first set above draw 45, 36, 10 and 51 shows outside the row they belong to (counted by the same probe on origin/main). Three of the six refused-then-saved tables above show the same thing. This change leaves it as it was.