Commit 506bde3
authored
[1/3] refactor(painter): consume only ResolvedLayout (SD-2836) (#3116)
* refactor(contracts): host expandRunsForInlineNewlines (SD-2836)
Move the inline-newline run expander from @superdoc/pm-adapter into
@superdoc/contracts. The function is a pure transformation on Run[]
shapes already defined here; relocating it lets painter-dom consume the
helper without depending on pm-adapter (per the SD-2836 acceptance
criterion: no painter-dom imports from pm-adapter or layout-bridge).
pm-adapter chains its public re-export through contracts, keeping the
import path stable until painter-dom is migrated to consume directly.
* refactor(contracts): host sliceRunsForLine (SD-2836)
Move the line-aware run slicer from @superdoc/layout-bridge into
@superdoc/contracts, alongside expandRunsForInlineNewlines. The function
is a pure transformation on Run/Line shapes already defined here;
relocating it lets painter-dom consume the helper without depending on
layout-bridge (per the SD-2836 acceptance criterion).
layout-bridge chains its public re-export through contracts, keeping
the import path stable until painter-dom is migrated to consume directly.
Also restore a TrackedChangeMeta import in pm-adapter's paragraph.test.ts
that the prior commit dropped; the type is still referenced outside the
migrated describe block.
* refactor(painter): consume run helpers from contracts (SD-2836)
Switch the painter's two cross-package run-helper imports
(expandRunsForInlineNewlines, sliceRunsForLine) to source from
@superdoc/contracts directly, then drop @superdoc/pm-adapter and
@superdoc/layout-bridge from painter-dom's runtime dependencies.
This closes the painter-dom -> pm-adapter / layout-bridge import edge
called out in the SD-2836 acceptance criteria. Architecture-boundary
guards added in [3/3] of this stack will prevent reintroduction.
* refactor(layout): add fragment back-pointer to resolved items (SD-2836)
Add a `fragment: Fragment` field to ResolvedFragmentItem,
ResolvedTableItem, ResolvedImageItem, and ResolvedDrawingItem, and
populate it from the corresponding resolve* helper. The reference is
shared, not copied: items now carry the same Fragment object that lives
on the source page.
This is the precondition for stopping painter iteration over
`page.fragments`. The next commit drops getResolvedFragmentItem and
switches the painter to iterate ResolvedPage.items, reading the source
fragment via `item.fragment` instead of indexing back into the legacy
fragments array.
Includes focused tests in resolveLayout.test.ts asserting back-pointer
identity for each kind.
* refactor(painter): drop getResolvedFragmentItem; iterate resolved items (SD-2836)
Replace the three `page.fragments.forEach((fragment, index) => ...)`
loops in renderPage / patchPage / initPage with iterations over
`resolvedItems` (the resolved page's items), reading the source
Fragment via the back-pointer added in the previous commit.
Removes:
- getResolvedFragmentItem (parallel-array index lookup into resolved items)
- direct iteration of `page.fragments` from the painter render path
Updates affected hand-rolled resolved-layout tests to populate the new
required `fragment` back-pointer; the painter now treats items without
a fragment as not-yet-renderable rather than indexing back into the
legacy fragments array.
* refactor(painter): paint() body reads ResolvedLayout (SD-2836)
Switch paint()'s top-level reads from input.sourceLayout to
input.resolvedLayout for: layoutEpoch, page count, and the mounted-page
indices.
The local `layout = input.sourceLayout` binding stays for one more
commit because the four legacy-Layout helpers (beginPaintSnapshot,
fullRender, patchLayout, renderHorizontal, renderBookMode,
renderVirtualized) still take a Layout argument. The next commit
migrates those signatures and removes the binding entirely.
* refactor(painter): drop fragments param from sdt+border helpers (SD-2836)
computeSdtBoundaries and computeBetweenBorderFlags previously took both
the raw `fragments` array and the parallel resolvedItems array. They
now take only resolvedItems and read each fragment via the back-pointer
added in [PR1#4]. Updates all four call sites in renderer.ts plus the
between-borders test fixture.
This eliminates the painter's lookup into `page.fragments` from the
helper-call layer, leaving only the deeper-method Layout dependency
(beginPaintSnapshot, fullRender, patchLayout, renderHorizontal,
renderBookMode, renderVirtualized) to migrate next.
* refactor(painter): migrate internals to ResolvedLayout (SD-2836)
Switch DomPainter's internal state and helpers from raw Layout/Page to
ResolvedLayout/ResolvedPage:
* The six top-level legacy-Layout methods (beginPaintSnapshot,
fullRender, patchLayout, renderHorizontal, renderBookMode,
renderVirtualized) take ResolvedLayout. paint() drops the
`const layout = input.sourceLayout` binding and calls every method
with input.resolvedLayout.
* The page-level helpers (renderPage, createPageState, patchPage,
renderDecorationsForPage, renderDecorationSection,
getDecorationAnchorPageOriginY, renderPageRuler,
renderColumnSeparators) take ResolvedPage and read width/height/
margins/numberText/etc. directly. Drops every redundant
`resolvedPage?: ResolvedPage | null` parameter.
* `currentLayout: Layout | null` -> `ResolvedLayout | null`. Strips
the `(page.size ?? layout.pageSize)` cascades inside virtualization
+ page-iteration code; uses ResolvedPage.width/.height directly.
* Lifts `columns` and `columnRegions` onto ResolvedPage so the
column-separator renderer can read them without falling back to
raw Page.
Couples PageDecorationProvider (planned PR2 work) since the painter
now passes ResolvedPage to the third callback argument:
* `PageDecorationProvider`'s `page?` parameter is `ResolvedPage`.
* `HeaderFooterSessionManager.rebuildRegions` takes ResolvedLayout.
`updateDecorationProviders(layout, resolvedLayout)` plumbed through
PresentationEditor.
* The provider closure body and internal helpers
(`#stripFootnoteReserveFromBottomMargin`, `#computeExpectedSectionType`)
now operate on ResolvedPage; `page?.size?.h` -> `page?.height`.
* `buildLegacyPaintInput` always calls `resolveLayout` so the legacy
paint(Layout) path produces ResolvedPages even when no body
blocks/measures are supplied (preserves page-level metadata).
Skips a "decoration item synthesis" describe block that exercises
`paint(Layout)` + `setData` + `setResolvedLayout`. Those legacy entry
points get deleted in the next commit; the block is being preserved as
.skip so the deletion is visible in diff.
* chore(deps): regenerate lockfile after painter-dom dep cleanup (SD-2836)
Drops the now-unused @superdoc/layout-bridge and @superdoc/pm-adapter
entries from pnpm-lock.yaml so CI's --frozen-lockfile install matches
package.json.
* test(super-editor): synthesize ResolvedLayout in PresentationEditor mock (SD-2836)
rebuildRegions now iterates resolvedLayout.pages (was layout.pages). The PresentationEditor test mocked resolveLayout to return empty pages, which caused the header/footer region tests to populate zero regions and bookmark navigation to fail. The mock now synthesizes a minimal ResolvedPage per source Layout page so region tests stay green.
* refactor(painter,super-editor): address PR review feedback (SD-2836)
- Drop redundant pageSize parameter from createPageState/patchPage; read
page.width/height directly from ResolvedPage.
- Migrate createDecorationProvider to ResolvedLayout; updateDecorationProviders
no longer needs the legacy Layout parameter.
- Add direct rebuildRegions(resolvedLayout) tests covering footnoteReserved>0,
per-page height variation, and sectionIndex>0.
- Assert columns and columnRegions forward through to ResolvedPage in
resolveLayout tests.1 parent 0132a97 commit 506bde3
25 files changed
Lines changed: 732 additions & 397 deletions
File tree
- packages
- layout-engine
- contracts/src
- layout-bridge/src
- layout-resolved/src
- painters/dom
- src
- features/paragraph-borders
- pm-adapter/src
- converters
- super-editor/src/editors/v1/core/presentation-editor
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2065 | 2065 | | |
2066 | 2066 | | |
2067 | 2067 | | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
2068 | 2072 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
2 | 4 | | |
3 | 5 | | |
4 | 6 | | |
| |||
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
69 | 75 | | |
70 | 76 | | |
71 | 77 | | |
| |||
111 | 117 | | |
112 | 118 | | |
113 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
114 | 124 | | |
115 | 125 | | |
116 | 126 | | |
| |||
257 | 267 | | |
258 | 268 | | |
259 | 269 | | |
| 270 | + | |
| 271 | + | |
260 | 272 | | |
261 | 273 | | |
262 | 274 | | |
| |||
318 | 330 | | |
319 | 331 | | |
320 | 332 | | |
| 333 | + | |
| 334 | + | |
321 | 335 | | |
322 | 336 | | |
323 | 337 | | |
| |||
371 | 385 | | |
372 | 386 | | |
373 | 387 | | |
| 388 | + | |
| 389 | + | |
374 | 390 | | |
375 | 391 | | |
376 | 392 | | |
| |||
Lines changed: 139 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
| 78 | + | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
| |||
0 commit comments