Skip to content

fix: box-model padding/margin (#10, #12) + FlexRender.Xml release packaging#13

Merged
RoboNET merged 4 commits into
mainfrom
fix/box-model-padding-margin
Jun 15, 2026
Merged

fix: box-model padding/margin (#10, #12) + FlexRender.Xml release packaging#13
RoboNET merged 4 commits into
mainfrom
fix/box-model-padding-margin

Conversation

@RoboNET

@RoboNET RoboNET commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Post-merge follow-ups to #11 (which was squash-merged before these commits landed). Targets main.

Fixes

#10 — Incorrect padding (box-model)

Leaf elements (text/image/qr/barcode/svg/separator) were drawn into the FULL layout box including padding, so left/top padding/border was ignored and the empty space appeared only on the right/bottom. Trailing child margin was also dropped from canvas auto-size (bottom clipped).

  • LayoutNode.ContentInset (padding+border per side) populated for all leaf types; flex containers stay zero (no double-apply).
  • All three renderers (Skia, ImageSharp, SVG) draw background/border on the full box but inset CONTENT by ContentInset.
  • CalculateTotalHeight/Width now include trailing child MarginBottom/MarginRight, populated by the flex strategies.

#12 — column-wrap collapses to zero height

direction: column + wrap: wrap without explicit height collapsed to ~0 and clipped all content (its main-axis auto-size was never computed).

  • Wrapped strategy stores resolved trailing margins on children.
  • Engine guard Wrap == NoWrapnode.Height == 0f, so column-wrap auto-height sizes to content (incl. trailing bottom margin). Row-wrap/no-wrap unchanged.

Packaging

  • FlexRender.Xml added to the NuGet release pack list (release.yml) — the new package would otherwise not publish.

Verification

  • New tests: LeafPaddingInsetsContent (Skia + ImageSharp snapshots), SvgLeafPaddingInsetsContent, TextElement_WithMargin_TrailingBottomMarginIncludedInCanvasHeight, ComputeLayout_ColumnWrap_NoExplicitHeight_SizesToContentIncludingBottomMargin.
  • All fixes reproduced before/after with real CLI renders (padding inset all sides; bottom margin no longer clipped; column-wrap no longer collapsed).
  • Full suite net10.0: 3316 passed, 0 failed. Build: 0 errors.

Closes #10, closes #12.

🤖 Generated with Claude Code

RoboNET added 4 commits June 15, 2026 08:28
…g margin in auto-size (#10)

Two box-model bugs are fixed:

- Leaf padding now insets content on all sides. Layout already sized the
  box as content + padding + border, but both renderers drew leaf content
  into the full box, leaving padding only on the right/bottom. LayoutNode
  now carries a ContentInset (padding + border per side) populated at each
  leaf layout site; the Skia and ImageSharp renderers keep background and
  border on the full box but draw content into the inset rect.

- A trailing child's bottom/right margin is now included in canvas/container
  auto-size. The flex strategies store each child's resolved outer Right and
  Bottom margins on LayoutNode, and CalculateTotalHeight/Width add them so
  the last child's trailing margin is no longer clipped.

Adds a layout regression test for the trailing-margin auto-height and Skia
and ImageSharp snapshot tests proving leaf padding insets content on all
four sides. Regenerated flex_with_margin and ndc_receipt_composite goldens
(now taller by the previously dropped trailing margin).
The SVG rendering backend (WithSvg) was missed in the box-model fix that
corrected the Skia and ImageSharp renderers. Leaf content was drawn into the
full box, so padding/border was only applied on the right/bottom edges for
SVG/PNG output via the SVG backend.

Compute the content inset from node.ContentInset (padding+border per side)
and pass the inset cx/cy/cw/ch to every content draw call (text, separator,
image, svg, qr, barcode), keeping background and borders on the full box.

Add svg_leaf_padding_insets_content snapshot test verifying the background
rect stays on the full box while text is inset on all sides.
…icit height

A flex container with direction: column + wrap: wrap and no explicit
height collapsed to ~0 height, clipping all content. The wrapped
strategy only set the cross-axis auto dimension (width for column-wrap),
never the main-axis (height), and the engine skipped fallback
height calculation for all wrap containers.

- WrappedFlexLayoutStrategy now records resolved trailing margins
  (MarginRight/MarginBottom) on wrap children so CalculateTotalHeight/
  Width account for them, matching the non-wrap strategies.
- LayoutEngine computes auto height whenever the strategy left
  node.Height unset (node.Height == 0f), covering no-wrap and
  column-wrap; row-wrap already sets height and is skipped.
@RoboNET RoboNET merged commit daa593f into main Jun 15, 2026
4 checks passed
@RoboNET RoboNET deleted the fix/box-model-padding-margin branch June 15, 2026 07:06
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.

flex-wrap containers drop trailing main-axis margin in auto-size Incorrect padding

1 participant