Luccas/sd 2838 unify nested tables rendering#3367
Open
luccas-harbour wants to merge 11 commits into
Open
Conversation
…ntracts Move getCellLines, getEmbeddedRowLines, describeCellRenderBlocks, and the cell-slice cursor/height utilities into @superdoc/contracts so the DOM painter and layout engine share a single source of truth for nested table rendering. Replace the painter's duplicated segment counters and even-split height approximations with calls into the shared module, and extract embedded table fragment assembly into a dedicated embeddedTableFragment helper.
Pull the table branch of DomPainter.renderFragment out of renderer.ts into dedicated modules under painters/dom/src/table/: - renderResolvedTableFragment: the former renderTableFragment method plus its resolveTableRenderData helper, taking renderLine, snapshot capture, frame application, and SDT helpers as dependencies - fragmentKey: tableFragmentKey() with the partial-row-aware cache key - snapshot: getTableSnapshotFlags() for the inTableFragment/inTableParagraph closest() checks used during paint-snapshot capture Each extraction has a co-located test. DomPainter now dispatches table fragments through renderResolvedTableFragment and delegates fragmentKey / snapshot-flag work to the new helpers, shrinking renderer.ts by ~150 lines.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fa69af7b08
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Contributor
Author
|
I deleted codex' comment as it related to the removal of rendering of |
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.
Summary
Continuation of the SD-2838 unification effort, focused on nested table rendering. The painter and the layout engine had grown two parallel implementations of cell-segment expansion, partial-row pricing, and table fragment height math — slightly out of sync, and both living inside large
renderer.ts/layout-table.tsfiles. This PR collapses them onto a single source of truth in@superdoc/contractsand breaks the painter's table branch out into co-located modules.Shared cell-slice + fragment-height helpers (
contracts/)table-cell-slice.ts(moved fromlayout-engine/): ownsgetCellLines,getEmbeddedRowLines,describeCellRenderBlocks,createCellSliceCursor,computeFullCellContentHeight, andcomputeCellSliceContentHeight. Exposed via the contracts barrel and marked internal in JSDoc.table-fragment-height.ts:computeTableFragmentHeight()is the single formula for adding header rows + body rows (with partial-row substitution) + cell-spacing gutters + outer borders whenborder-collapse: separate.layout-table.tsand the DOM painter both call into these helpers; the painter's even-split height approximation for embedded rows is gone — slice heights now come from the same recursive walk the layout engine uses.DomPainter.renderFragment(table branch) decompositionCarved out of
renderer.tsintopainters/dom/src/table/:renderResolvedTableFragment.ts— the formerrenderTableFragmentmethod plus itsresolveTableRenderDatahelper. TakesrenderLine, snapshot capture, frame application, and SDT helpers as injected deps.fragmentKey.ts—tableFragmentKey()with the partial-row-aware cache key.snapshot.ts—getTableSnapshotFlags()for theinTableFragment/inTableParagraph.closest()checks used during paint-snapshot capture.embeddedTableFragment.ts—createEmbeddedTableFragment,mapEmbeddedTableRowSlice,computeRenderedTableFragmentHeight, andgetEmbeddedTableSegmentCount, replacing the duplicated segment counters, visible-height loops, and partial-row computation insiderenderTableCell.Each new module has a co-located test.
renderer.tsshrinks by ~150 lines and no longer carries table-specific helper closures.Bug fixes uncovered along the way
fix(layout-engine): price embedded table slice height— partial embedded table slices now report their actual visible height instead of the full table height when computing whether they fit on the page.fix(layout-engine): price partial embedded table slices— pricing now uses the shared cell-slice cursor so deeply nested partial rows are sized consistently with the splitter's decisions.table-cell-slice.tsshim inlayout-engine/now thatcontracts/owns the implementation.Tests
contracts/:table-cell-slice.test.ts(132 lines),table-fragment-height.test.ts(51 lines).renderResolvedTableFragment.test.ts,embeddedTableFragment.test.ts,fragmentKey.test.ts,snapshot.test.ts.renderTableCell.test.tscovers embedded-row slice mapping.renderer-dispatch.test.tsupdated for the new dispatch path.