Skip to content

refactor(layout): extract the inline token model out of TextFlowSupport#346

Merged
DemchaAV merged 1 commit into
2.0-devfrom
refactor/extract-inline-tokens
Jul 9, 2026
Merged

refactor(layout): extract the inline token model out of TextFlowSupport#346
DemchaAV merged 1 commit into
2.0-devfrom
refactor/extract-inline-tokens

Conversation

@DemchaAV

@DemchaAV DemchaAV commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Why

TextFlowSupport is the largest file in document.layout (~1877 LOC). This is the first of two byte-identical steps that pull the inline paragraph wrapping subsystem out of it. Step 1 moves the leaf of that subsystem — the inline token model — so the follow-up wrapping-loop extraction has a clean dependency to build on.

What

  • New package-private file InlineLayoutToken.java: the sealed InlineLayoutToken and its InlineTextToken / InlineImageToken / InlineShapeToken / InlineSvgToken record variants (including InlineSvgToken.toResolvedSvgLayer, the SVG-layer → engine-span lowering).
  • The types were private nested in TextFlowSupport; as top-level package-private types the wrapping loops reference them by simple name unchanged (same package) — the modified file only loses code (−200: the token block + 6 now-unused imports).
  • Pure type move, no logic edits, no public API change (document.layout is @Internal).

Tests

  • Core suite (395) and the qa byte-identity gate (642 — InlineHighlightRenderTest, InlineSvgRenderTest, InlineShapeRenderTest, UnicodeFallbackDemoTest, TableCellInlineCodeWrapTest, PdfVisualRegressionTest, all *VisualParityTest, LayoutSnapshotRegressionDemoTest) green: renders are byte-identical.
  • No new unit test: the move is a mechanical type relocation with zero behaviour change, guarded by the parity/visual suites above. A focused ParagraphWrappingTest lands with the wrapping-loop extraction (step 2).

Follow-up

Step 2 extracts the wrap loops + tokenize/trim/indent helpers + ParagraphIndentSpec into a ParagraphWrapping collaborator (rewiring the prepareParagraphLayout call sites).

Move the inline layout tokens — the sealed InlineLayoutToken and its
InlineText / Image / Shape / Svg record variants (with the SVG-layer lowering)
— out of the TextFlowSupport god-class into their own package-private file.
The types were private nested; as top-level package-private types the wrapping
loops reference them by simple name unchanged. Pure type move, no behaviour
change; the paragraph wrapping loops that build and consume them follow next.
@DemchaAV DemchaAV merged commit 531f0d1 into 2.0-dev Jul 9, 2026
12 checks passed
@DemchaAV DemchaAV deleted the refactor/extract-inline-tokens branch July 9, 2026 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant