Skip to content

fix(layout-engine): remove remaining pm-adapter boundary leaks#2618

Merged
harbournick merged 2 commits intomainfrom
nick/sd-2401-clean-up-layout-engine-package-boundaries-after-the-pain
Mar 28, 2026
Merged

fix(layout-engine): remove remaining pm-adapter boundary leaks#2618
harbournick merged 2 commits intomainfrom
nick/sd-2401-clean-up-layout-engine-package-boundaries-after-the-pain

Conversation

@harbournick
Copy link
Copy Markdown
Collaborator

No description provided.

@harbournick harbournick self-assigned this Mar 28, 2026
@linear
Copy link
Copy Markdown

linear bot commented Mar 28, 2026

@harbournick harbournick merged commit 9a91465 into main Mar 28, 2026
47 checks passed
@harbournick harbournick deleted the nick/sd-2401-clean-up-layout-engine-package-boundaries-after-the-pain branch March 28, 2026 02:49
@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Mar 28, 2026

🎉 This PR is included in vscode-ext v1.1.0-next.32

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Mar 28, 2026

🎉 This PR is included in superdoc v1.24.0-next.31

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Mar 28, 2026

🎉 This PR is included in superdoc-cli v0.5.0-next.31

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Mar 28, 2026

🎉 This PR is included in superdoc-sdk v1.3.0-next.31

caio-pizzol added a commit that referenced this pull request Mar 28, 2026
layout-engine cannot import from pm-adapter (boundary removed in #2618).
Define PX_PER_PT locally, same as border-layer.ts does.
caio-pizzol added a commit that referenced this pull request Mar 28, 2026
* fix: correct spacing for paragraphs with borders/shades

* fix(layout): overlap border expansion with paragraph spacing (SD-2106)

Per ECMA-376 §17.3.1.42, paragraph border space is measured from
the text edge "ignoring any spacing above/below". This means border
expansion should overlap with spacingBefore/After, not stack on top.

- Reduce top border expansion by the amount spacingBefore already covers
- Reduce effective spacingAfter by the bottom border expansion
- Subtract border expansion from sliceLines available height to prevent
  page-bottom overflow
- Include border expansion in keepLines height calculation

* fix(layout): correct cursorY mismatch and continuation fragment overlap

Three fixes from self-review:

- fragment.y now uses extraTop (overlap-adjusted) instead of full
  borderExpansion.top, so cursorY reaches the visual bottom exactly
- Track spacingAppliedThisFragment to avoid under-counting border
  expansion on continuation fragments after page breaks
- keepLines fitsOnBlankPage uses overlap model (max instead of add)
  to avoid unnecessary page breaks for bordered paragraphs

* fix(layout): hoist borderExpansion to function scope

borderExpansion was declared inside the while loop but referenced
in the spacingAfter block outside it, causing a ReferenceError.
Move it before the loop so it's accessible in both places.

* fix(layout,renderer): between-border group detection and spacing

Layout engine:
- Detect between-border groups by comparing adjacent paragraph border
  hashes. When borders match, suppress top expansion and reclaim
  previous paragraph's bottom expansion.
- Border expansion is additive with spacing for non-grouped paragraphs
  (matches Word behavior).
- Add lastParagraphBorderHash to PageState for group tracking.

Renderer (group-analysis.ts):
- Remove requirement for `between` border element to be present for
  grouping. Per ECMA-376 §17.3.1.5, grouping occurs when all border
  properties are identical — a between border is optional.
- When no between border is defined, suppress bottom/top borders
  and render as a single continuous box.

* test(painter-dom): update between-border test for grouping without between element

The test expected no grouping when `between` border is absent. Updated
to expect grouping with suppressBottomBorder per ECMA-376 §17.3.1.5:
identical borders form a group regardless of whether a between border
is defined.

* fix(layout): use local PX_PER_PT constant instead of pm-adapter import

layout-engine cannot import from pm-adapter (boundary removed in #2618).
Define PX_PER_PT locally, same as border-layer.ts does.

---------

Co-authored-by: Johannes Wilm <mail@johanneswilm.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant