Repository navigation
fix(layout): lay a list out from the items it holds in this save - #697
Merged
Merged
Conversation
A ListRenderer built its entries at its first layout and kept them for every later one, so a renderer reused for a second document drew the lines an entry had in the first at a place where its layout in the second placed nothing, and an item added since was never read. The entries are now built from the items the list holds when a save first lays it out, once for the document's own calls and once for the calls a renderer of the caller's makes, and no other save or kind of call reads them. A child whose layout answers Nothing draws nothing. The adoption of earlier entries by the twin is removed.
…hangelog ListRenderer.Layout states which items a layout reads; ListElement, LayoutDiagnosticCode and Document.cs point to it or drop the sentences that described earlier layouts. The changelog entry lists the output, refusal and save changes with the documents they were measured on.
A document whose only refusal was a paragraph drawing an earlier layout's lines in an undefined font now saves, and the file holds no font resource for that value.
A piece a split returned keeps the entries of the layout that made it and never rebuilds, so the rule on ListRenderer.Layout says so and the other docs point to it. Two rows pin the piece for a layout made outside any save and for a piece a caller keeps across saves. The changelog entry drops its figures, and no longer names a foreign font handle among the documents that now save.
…691) Layouts made outside any save share one build, so the sentence that no save reads such a build was false; the rule now says what is shared and points the piece and outside-save cases to #696, which removes layout state, instead of #688. The CHANGELOG names the general class of saves that were refused only through an earlier layout's lines, counts the extra build of a list placed as its twin, and no longer says LayoutDiagnosticCode points to the rule. Two test comments are corrected.
#691) The sentence on layouts made outside any save was false when a save in between lays the list out through a renderer of yours. The remarks now tell a caller not to rely on what such a layout reads, which 3.0 removes with the layout state (#696). The CHANGELOG names the saved class for a reused list renderer, the case that was measured.
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 #691
Summary
A
ListRenderernow lays a list out from the items it holds in the save that lays it out.Before, it built a list's entries at its first layout, at that layout's width, and kept them for
every later one, whatever that layout was: another save, another document, a layout of yours
before the save, a renderer of yours that held the list. A paragraph that answers
Nothingkeepswhere its last layout put its lines, and
Drawreads that, so a reused renderer drew an entry'slines from an earlier document at a place where its layout now placed nothing (#691).
The rule, stated once on
ListRenderer.Layout, with its one exception: the entries are built for eachsave and each kind of call (the document's own calls, and the calls a renderer of yours makes), from
the items the list holds then, at the width of the first layout of that kind in that save. A piece a
split returned keeps the entries of the layout that made it and never rebuilds, as on 251adf8; two
rows pin that (
APieceOfALayoutMadeOutsideAnySave_...,APieceACallerKeepsAcrossSaves_...).A rebuild replaces the entries and the counts that belong to them. A child whose layout answers
Nothingdraws nothing. The other docs and the CHANGELOG point to the rule.Built) that holds the save number, not the run, so areused renderer no longer keeps the first document alive.
holds the list, so each kind reads its own entries and its own placement state.
(
ContinuationSession.Save) and is a renderer's call in the next one.ListRenderer.Drawcalls the newParagraphRenderer.ClearPlacementwhen a marker or textanswers
Nothingthere.Removed:
_earlier,AdoptEarlier,WithoutClamp,Entry.UnclampedGutter,BuiltByAnEarlierLayout,_builtUnder,_builtForCallerand theHeldroute reached only through history. Kept:IsCalledByDocument(it now decides the kind of call),_placementInherited, the twin for a contextthe document did not address, the whole-as-main twin and its placement restore, drawability, the
clamped-marker guard and the continuation-limit twin.
srcis +212/-223 lines against 251adf8.Rulings applied
251adf8 and are refused now (24,768 after an item in an undefined
Standard14value was added,8,256 after a child was added to an item of a list whose indent leaves its text no width, which a
new list of that shape is refused with on 2.3.3 too); a new renderer is refused identically in each.
since is placed (
ListReuseTests.AnAnchoredItemAddedSinceTheLastSave_isPlacedInTheNextOne).Measured against 251adf8
Per-kind oracle: the same document built with one new renderer for each kind of call, nothing laid
out before it, on the build under test.
Single-use documents. In the four generators each list renderer is placed once (most documents hold
several lists). With only the
Nothingrule left out of the build, all 110,000 generated documents,all 1,500 limit rows and the 2,304 matrix rows with no earlier layout that use one kind of call equal
251adf8, so no path where the twin took the list's own entries changes such a document in the sets
measured. The 139 and 20 byte differences and the saves below come from the
Nothingrule alone:lines of an earlier layout of the same save are no longer drawn (the mechanism of #691 inside one
save: two passes, a second placement, or a held and a direct use). Seven of the 139 also report fewer
encoding substitutions (601), because the stale line produced one. A document that uses both kinds of
call with one renderer reads two sets of entries, each at its first width, where 251adf8 read one;
that is the other source of byte differences in the matrix.
Documents that save now. In the four generators the class is an item in an undefined
Standard14value. 251adf8 threw
IndexOutOfRangeExceptionbecause a paragraph that placed nothing drew an earlier layout's lines inthat font. It has 12 seeds across the generator runs reviewed: the 9 of the first runs (variant 3
seeds 7862, 10053, 10938, 24672, 29247, 29288; variant 4 seeds 16088, 19765, 24029, built at commit
1055f5d) and 3 from the review's new ranges (variant 3 seed 115412; variant 4 seeds 107718, 124710).
With the undefined value replaced by Helvetica, 251adf8 saves all 12 (review measurement). The
general class is wider than these seeds: any document refused only because a reused list renderer drew an
earlier layout's lines now saves as a new renderer's save does. A second review measured it with a
font handle from another document in an entry whose text has no width in the second document: 251adf8
refuses with
ArgumentExceptionin 16 of 16 rows, this branch and a new renderer on either build save. Maintainerruling: accepted and documented in the CHANGELOG. The saved files of the first 9 pass
qpdf --check(12.4.2), none claims a PDF/A or PDF/UA level so veraPDF does not apply, and each writes only defined
fonts (no
/BaseFontfor the undefined value). 3.0 refuses an undefined font value where it is set(#696).
Row by row. All 139 single-use byte differences of the four generators and the 20 of the limit
generator were traced on 251adf8 and on a build of this branch that logs each placement it clears
(not committed). In every one, the new file draws a subset of what 251adf8 drew, per page stream and
position, adds nothing, and a cleared non-empty placement was logged: 251adf8 drew lines of an earlier
placement in the same save at a place where the marker or text answered Nothing. No row is another
kind of difference. The limit rows' traces reproduce the generator's hashes (40 of 40).
Residual cost. The entries are built for each save and each kind of call, and once more in a save that
places the list as its twin after it built them, so the cost is linear in the builds. net10.0 Release, 251adf8 against this branch (my runs, and the review's on a loaded
machine):
holds): 246 to 247 MB before, 293 to 294 MB now; my runs showed about the same time, the
review measured 693 to 786 ms before and 905 to 1,107 ms now;
build before, 258 MB and two builds now;
builds now;
84 MB).
Other containers. A paragraph, a keep-together paragraph, a table, and a paragraph held by a wrapper
of yours, reused across two documents (120 documents each, page 200x100), draw the same bytes as a
new renderer on 251adf8, so nothing outside
ListRendererchanged for theNothingrule.Removed in 3.0
The held twin (
HeldTwin) and the two-instance split are 2.x compatibility devices, removed with thetwin in 3.0 (#688).
ContinuationSession.Saveand the save check inIsCalledByDocumentgo withLayoutContext.Session(#688).Mutations
Each mutant ran in a detached worktree of its own over the list test classes (net10.0).
WhateverLaidTheListOutFirst_theDocumentLaysItOutFromWhatTheListHoldsNow,AReusedList_reportsTheFallbackOnlyWhereTheDocumentLaysEveryListOutAsItWas)AListLaidOutFromACallersDraw_andPlacedByTheDocument_readsEntriesForEachKindOfCall,WhateverLaidTheListOutFirst_...)AChildTheFirstDocumentsClampNarrowed_getsTheGutterTheSecondWidthGives, ...)TheClampSkippedCount_belongsToEachSave,AReusedRenderer_givesTheOutcomeAFreshRendererGives)Nothingis drawn, or only the markerOneRendererHeldTwice_drawsWhatARendererForEachPlacementDraws,ThePiecesOfAHeldList_reportNothingUnlessTheDocumentPlacesThem)_placementInheriteddroppedThePiecesOfAHeldList_reportNothingUnlessTheDocumentPlacesThem, ...)APageHeightThatChangesBetweenSaves_changesWhichEntriesNoPageHolds, ...)AnEntryNoPageHeldInTheFirstSave_isNotReportedWhereASecondSaveHoldsIt)AContextKeptFromAnEarlierSave_isACallersCallInTheNextOne)APieceOfALayoutMadeOutsideAnySave_keepsItsEntriesAfterTheListChanged,APieceACallerKeepsAcrossSaves_keepsTheEntriesOfTheSaveThatMadeIt)Tests flipped or deleted
Each pinned the entries or the stale lines of an earlier layout (#691). Old name to new name:
ListPlacementAdoptionTests:AListLaidOutBeforeTheSave_keepsTheEntriesThatCallBuiltto..._isClampedAsAFreshListIsAListLaidOutBeforeTheSaveAtAnotherWidth_isDrawnFromTheEntriesThatCallBuiltto..._isDrawnFromEntriesBuiltForTheSaveAListRendererReusedForASecondDocument_keepsTheEntriesTheFirstBuiltto..._drawsWhatAFreshRendererDrawsAListRendererReusedForASecondDocument_keepsTheGutterTheFirstWidthGaveto..._getsTheGutterTheSecondWidthGivesAListChangedBetweenTwoDocuments_isDrawnFromTheEntriesTheFirstBuiltto..._isDrawnFromTheItemsItHoldsNowAListChangedAfterTheClampNarrowedAnEntry_keepsTheEntryAsTheFirstDocumentBuiltItWithoutTheClampto..._isLaidOutFromTheListAsItIsAnEntryTheFirstDocumentsClampNarrowed_isNotHeldToTheClampsRuleInTheSecondto..._isBuiltAsANewRendererBuildsItInTheSecondAnEntryTheFirstDocumentsClampNarrowed_keepsItsLanguageInTheSecondtoAReusedEntry_keepsItsLanguageInTheSecondDocument(premise reworded, still passes)AReusedListInADocumentThatHoldsAnUndrawableEntry_reportsTheEntriesTheFirstClampNarrowedto..._reportsTheEntriesTheClampWouldNarrowInThatSaveAReusedListWhoseKeptEntryUsesTheFirstDocumentsFont_...toAReusedListWhoseItemUsesTheFirstDocumentsFont_...(premise reworded, still passes)AChildTheFirstDocumentsClampNarrowed_keepsItsGutterInTheSecondto..._getsTheGutterTheSecondWidthGivesARendererAddedAndThenHeldInOneDocument_laysTheHeldOneOutFromTheEntriesItBuiltto..._laysTheHeldOneOutFromEntriesOfItsOwnAListRendererReusedForASecondDocument_reportsNothingThereto..._reportsWhatAFreshRendererReportsAListChangedAfterTheFirstDocument_addsNoGlyphToTheSecondDocumentsSubset: deleted;ListReuseTests.AListChangedAfterTheFirstSave_putsTheGlyphsAFreshRendererPutsInTheSubsetreplaces it,because an item added since is measured by a new build too.
ListEarlierLayoutTests:WhateverLaidTheListOutFirst_theDocumentKeepsTheEntriesThatLayoutBuiltto..._theDocumentLaysItOutFromWhatTheListHoldsNow;AListHeldByACallersRendererAndThenAddedToTheDocument_isDrawnFromTheEntriesTheHeldLayoutBuiltto..._isDrawnFromEntriesBuiltAtThePagesWidth;AReusedList_reportsTheFallbackOnlyWhere...keeps itsname and now expects the clamp where the document does not keep every list as it was.
Gates
Release build 0 warnings. Layout.Tests 3,651 on each of net10.0 and net11.0 (2 skipped on each, 7,302
in all) and Barcodes.Tests 1,052 on each (2,104 in all), with REQUIRE_ORACLES and REQUIRE_VERAPDF, 0
failed.
dotnet format --verify-no-changes, the clean-room check andgenerate-roadmap.py --checkpass.