fix: box-model padding/margin (#10, #12) + FlexRender.Xml release packaging#13
Merged
Conversation
…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.
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.
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).ContentInset.CalculateTotalHeight/Widthnow include trailing childMarginBottom/MarginRight, populated by the flex strategies.#12 — column-wrap collapses to zero height
direction: column+wrap: wrapwithout explicit height collapsed to ~0 and clipped all content (its main-axis auto-size was never computed).Wrap == NoWrap→node.Height == 0f, so column-wrap auto-height sizes to content (incl. trailing bottom margin). Row-wrap/no-wrap unchanged.Packaging
FlexRender.Xmladded to the NuGet release pack list (release.yml) — the new package would otherwise not publish.Verification
LeafPaddingInsetsContent(Skia + ImageSharp snapshots),SvgLeafPaddingInsetsContent,TextElement_WithMargin_TrailingBottomMarginIncludedInCanvasHeight,ComputeLayout_ColumnWrap_NoExplicitHeight_SizesToContentIncludingBottomMargin.Closes #10, closes #12.
🤖 Generated with Claude Code