layout

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Kite Layout Engine

The layout package implements Kite's high-performance, LayoutNG-inspired layout engine. Its primary responsibility is to take a tree of style-resolved nodes and compute their exact physical dimensions and positions, outputting an Immutable Fragment Tree.

Intent and Philosophy

Unlike traditional layout engines that mutate the state of logical DOM nodes or render objects during measurement, this engine adheres to strict separation of constraints and immutability:

  1. No Mutations During Layout: Layout algorithms never modify the incoming Node or its styles.
  2. Immutable Outputs: The result of a layout operation is a Fragment. Once created, a Fragment is strictly read-only.
  3. Stateless Positioning: A Fragment does not know its absolute position on the screen, nor does it contain a pointer to its parent. Its position (offset) is stored in the parent's FragmentLink. This allows identical fragments to be cached and reused in entirely different positions.
  4. Cache-Driven: If a node's constraints (available space) and styles have not changed, the engine instantly returns the cached Fragment, skipping the subtree walk.

Core Data Structures

  • Node: An interface representing the input to the layout engine (implemented by render.Box and render.Text). It provides access to computed styles and an iterator over its children.
  • ConstraintSpace: The input parameters for a layout operation. It defines the available size (width/height) and specifies whether those dimensions are fixed or flexible (e.g., shrink-to-fit).
  • Fragment: The physical, read-only output. It contains a geom.Size and a slice of FragmentLinks (children fragments and their X/Y offsets).
  • BoxFragmentBuilder: A mutable builder used by algorithms to accumulate inline size, block size, and child fragments. Calling builder.ToFragment() seals it into an immutable Fragment.
  • FlexLineBuilder: A specialized builder for the flex algorithm that manages item collection, line breaking, space distribution, and alignment state.
  • MinMaxSizes: Represents the intrinsic minimum (shrink-wrapped) and maximum (fully expanded) sizes of a node before flex or percentage rules are applied.

The Layout Flow

Every layout operation broadly follows these steps:

  1. Cache Check: If the Node is clean and the ConstraintSpace exactly matches the previous run, return the cached Fragment.
  2. Measurement Pass (Intrinsic Sizing): The algorithm calculates the minimum and maximum sizes of its children to determine how to distribute space (crucial for Flexbox and Auto-sized blocks).
  3. Constraint Resolution: The algorithm resolves percentage sizes and auto margins against the ConstraintSpace.
  4. Child Layout: The algorithm loops over its children, creates a new ConstraintSpace for each, and calls Layout() on them.
  5. Assembly: Children fragments are placed at specific X/Y coordinates via builder.AddChild().
  6. Finalization: The builder is sealed into a Fragment, cached on the Node, and returned.

Layout Algorithms

The engine routes nodes to specific formatting context algorithms based on their style.Display property.

Block Algorithm (block.go)

The Block Formatting Context (BFC) algorithm implements standard vertical stacking, the default behavior for display: block elements.

Detailed Flow
  1. Width Resolution: The algorithm first resolves the block's inline size (width). If the width is Auto and the ConstraintSpace permits, the block stretches to fill the available inline space, minus any margins, borders, or padding.
  2. Child Traversal: It iterates over its children in DOM sequence.
  3. Child Constraint Generation: For each child, a new ConstraintSpace is built. The child's available width is locked to the parent's resolved content width.
  4. Layout & Positioning: The child's Layout() method is invoked, yielding an immutable Fragment. The Block algorithm calculates the child's X offset (handling margins and text alignment) and Y offset (tracking the accumulated block height of all preceding siblings).
  5. Height Resolution: After all children are laid out, the Block algorithm determines its own final block size (height). If the height is explicitly set, it uses that; otherwise, it shrink-wraps to the bottom edge of the last child (plus padding and borders).
  6. Margin Collapsing: (Note: Terminal UI margin collapsing rules are simpler than web CSS, often just resolving explicit cell gaps).
Flex Algorithm (flex.go, flex_builder.go)

The Flex Formatting Context handles 1D layouts with advanced alignment, wrapping, and distribution of space. It is designed to be agnostic of the FlexDirection (Row vs. Column) by operating on Main and Cross axes using a geometry abstraction (flexGeometry). All mutable state for the algorithm is encapsulated in the FlexLineBuilder.

Detailed Flow

The flex algorithm is heavily optimized to avoid exponential ($O(n^2)$) layout times by strictly caching intermediate results across its two-pass system.

Pass 1: Intrinsic Measurement & Line Generation
  1. Item Collection: All flex children are gathered. If display: inline children are found alongside blocks, they are bundled into an AnonymousBlock to participate as a single flex item.
  2. Order Sorting: Items are reordered based on their CSS order property.
  3. Base Size Calculation: The intrinsic MinMaxSizes of each item are measured. The item's BaseSize and HypotheticalMainSize (its size before any growing or shrinking) are calculated based on the available main-axis space.
  4. Line Breaking: Using FlexLineBuilder.ComputeLines(), the algorithm accumulates items into logical FlexLine groupings. When the sum of HypotheticalMainSizes exceeds the available main space, a new line is started (if flex-wrap is enabled).
Pass 2: Flexible Length Resolution

For each logical line, the FlexLineBuilder distributes the remaining free space (or shrinks items if they overflow) using ResolveFlexibleLengths():

  1. Determine Free Space: Available Space - Sum(HypotheticalMainSize).
  2. Freeze Inflexible Items: Items with flex-grow: 0 (when there's extra space) or flex-shrink: 0 (when overflowing) are "frozen" at their hypothetical sizes.
  3. Distribute Space: The remaining space is distributed proportionally among the unfrozen items based on their flex-grow or flex-shrink factors.
  4. Min/Max Clamping Loop (Freeze and Restart): If a stretched/shrunk item hits its min-width or max-width, it is clamped, marked as "frozen", and the algorithm loops again to redistribute the leftover space among the remaining unfrozen items.
Final Layout & Alignment
  1. Forced Child Layout: Every child is laid out again. This time, the parent builds a ConstraintSpace with strict, fixed dimensions based on the resolved flexible sizes. The child must obey these constraints, returning its final immutable Fragment.
  2. Main-Axis Alignment: Using FlexLineBuilder.AlignLine(), the algorithm calculates the exact X (or Y for columns) coordinate for each item on the line based on justify-content.
  3. Cross-Axis Alignment: Using FlexLineBuilder.AlignCrossAxis(), the algorithm handles align-content (for multiple lines) and align-items/align-self, calculating the perpendicular coordinate for each item.
Inline Algorithm (inline.go)

The Inline Formatting Context (IFC) is highly specialized for text handling, operating very differently from Block and Flex contexts. It uses a flat-list architecture to maximize memory locality and line-breaking performance.

Detailed Flow
  1. Anonymous Wrapping: The engine enforces that inline elements cannot be direct children of Flex or standard Block contexts without an intermediary. The parent engine creates an AnonymousBlock, which then delegates entirely to the Inline algorithm.
  2. Pre-Layout Collection: Instead of walking a deep tree recursively during layout, the algorithm flattens all inline children (<span>, <text>, <icon>) into an array of InlineItems.
  3. Whitespace Collapsing: Based on white-space rules, consecutive spaces, tabs, and newlines are collapsed or preserved.
  4. Shaping & Measurement: Text runs are sent to the uniseg shaper. The shaper determines exactly how many terminal cells each grapheme cluster requires. The results are heavily cached to prevent recalculating static text on every frame.
  5. Line Breaking: The algorithm iterates through the InlineItems, accumulating their cell widths.
    • When the accumulated width exceeds the ConstraintSpace.AvailableSize, the algorithm looks backwards for the nearest valid "soft break" opportunity (usually a space or hyphen).
    • The line is split at that index.
  6. Line Box Construction: For each broken line, a LineBox fragment is generated. The text elements inside are aligned vertically (handling varying font heights or inline-block vertical alignment, like baseline or middle).
  7. Bidi Reordering (UAX#9): If RTL (Right-to-Left) text is present, the physical order of the fragments inside the LineBox is reversed or shuffled according to the Unicode Bidirectional Algorithm before final fragment assembly.
List Algorithm (list.go)

The List Formatting Context (LFC) implements the layout for display: list-item elements. It specializes in rendering markers (bullets, numbers) using a virtual, layout-driven strategy that avoids phantom render objects.

Detailed Flow
  1. Virtual Marker Synthesis: Unlike web engines that inject anonymous boxes for list markers, the ListAlgorithm synthesizes the marker as a transient, physical text fragment directly during the layout phase. This adheres to the "Unified Render Box" principle and prevents architectural leaks.
  2. Two-Column Row Layout: The algorithm formats the list item as a logical two-column row:
    • Column 1: Contains the synthesized marker fragment (e.g., "• " or "1. "), measured to its exact cell width using the text shaper.
    • Column 2: Contains the actual child content of the list item, laid out using standard Block layout rules.
  3. Ordinal Calculation: For numbered lists (ListStyleDecimal), the algorithm computes the ordinal by walking the previous logical siblings of the node to count consecutive display: list-item elements.
  4. Content Wrapping: Multi-line content in Column 2 is constrained to the remaining available inline space, ensuring that text wraps cleanly adjacent to the marker rather than underneath it.
Table Algorithm (table.go, table_builder.go)

The Table Formatting Context (DisplayTable) implements a rigorous two-pass layout algorithm to resolve intrinsic grid column dimensions and handle complex cell spanning (ColSpan, RowSpan). All mutable state for the two-pass process is managed by a dedicated TableFragmentBuilder.

TableFragmentBuilder (table_builder.go)

The TableFragmentBuilder is the central state-management object for a single table layout run. It is created by TableAlgorithm and threaded through to TableSectionAlgorithm and TableRowAlgorithm. Its responsibilities are:

  1. Section Grouping: Collects thead, tbody, and tfoot children via AddHeaderChild, AddBodyChild, and AddFooterChild. Direct row or non-row children are wrapped into anonymous section and row nodes automatically.
  2. Grid Construction (BuildGrid): Builds a logical 2D grid (tableGrid) by walking all rows and cells. The grid records each cell's ColStart, ColSpan, and RowSpan, resolving overlapping cells due to RowSpan. It also pre-computes per-column-junction border-overlap flags (see below).
  3. Column Sizing (DistributeSpan): Populates colMinMax []MinMaxSizes — one entry per column. Single-span cells are measured first, then multi-span cells distribute any excess width proportionally across the spanned columns.
  4. Width Resolution (ResolveWidths): Resolves the final per-column pixel widths (colWidths) given the table's total resolved inline size. The distributable budget is widened by the number of actual collapsed junctions (not all junctions unconditionally).
  5. Implicit Border-Collapse Math: Provides AdjustRowOffset and GetCellShift to TableSectionAlgorithm and TableRowAlgorithm so they can apply the -1 coordinate adjustments for overlapping borders.
Border-Collapse Coordinate Model

Kite uses implicit border collapse for table elements. The key rules are:

Horizontal (X-axis) — cell-to-cell:

  • Cells are placed at X = 0 within the row (no left-border inset). This ensures that a cell's left border physically overlaps with the row's own left border at the same terminal column, allowing the paint engine's junction resolver to merge them.
  • When a cell at column j has a right border and the cell at column j+1 has a left border, GetCellShift returns 1. The calling row algorithm subtracts this from the next cell's X offset, causing the two borders to share the same terminal column.
  • For spanning cells (ColSpan > 1), each internal collapsed junction within the span is subtracted from the cell's total width (cellWidth-- for each ColJunctionOverlap[j] == true in the span range). The junction column does not exist inside a spanning cell.

Vertical (Y-axis) — row-to-row:

  • Cells are placed at Y = 0 within the row (the BoxFragmentBuilder's automatic border.Top inset is explicitly reset to 0). This ensures that a cell's top border shares the same terminal row as the row's own top border.
  • The row's block size is set to maxCellHeight only (no extra border.Bottom added). The row's bottom border is therefore drawn at Y = maxCellHeight - 1, coinciding exactly with the cells' bottom borders.
  • When the previous row has a bottom border and the next row has a top border, AdjustRowOffset returns -1. The section algorithm subtracts this from the next row's Y offset, making the two rows share that single border terminal row.
  • TableFragmentBuilder is initialized with lastRowBorderBottom = table.border.Edges.Top so the very first row also collapses against the table's own top border when applicable.

Table-edge overlaps (X-axis):

  • tableGrid.ColJunctionOverlap[j] is true when any row has both a right-bordered cell ending at column j and a left-bordered cell starting at column j+1.
  • tableGrid.LeftEdgeHasOverlap / RightEdgeHasOverlap are true when the table's own left/right border intersects with the first/last column's cell borders.
  • These flags drive two things:
    1. Table width: tableMinMax is reduced by 1 for each actual overlap (not unconditionally for every junction).
    2. Section placement: when LeftEdgeHasOverlap is true, sections are placed at X = padding.Left (instead of X = border.Left + padding.Left), and childAvailWidth is expanded by border.Left (and border.Right for RightEdgeHasOverlap), so that column 0's left border shares the table's left border column.
Detailed Flow
Pass 1: Grid Sizing & Measurement
  1. Section Grouping: TableAlgorithm walks its children and calls the appropriate builder.Add*Child method to populate the three section buckets (header, bodies, footer). Anonymous wrappers are created for stray rows or cells.
  2. Grid Construction (BuildGrid): Flattens all rows from all sections and builds tableGrid, including ColJunctionOverlap, LeftEdgeHasOverlap, and RightEdgeHasOverlap.
  3. Column Sizing: Single-span cells are measured first (IntrinsicMinMaxSizes), then multi-span cells run DistributeSpan to push any excess width into the spanned columns.
  4. Table Width Resolution: tableMinMax sums the per-column min/max values, then subtracts 1 for each genuinely collapsed border (junctions and table edges). parentDecorX (table borders + padding) is added back.
  5. Column Width Distribution (ResolveWidths): The distributable pixel budget is resolvedInlineSize - parentDecorX + overlaps_added_back. This is distributed proportionally to max-content sizes, then evenly for any remainder.
Pass 2: Row & Cell Layout
  1. Section Invocation: For each section (in header → body → footer order), TableAlgorithm builds a ConstraintSpace whose width is childAvailWidthBase (accounting for edge overlaps) and passes it to TableSectionAlgorithm, along with the relevant slice of tableGrid.Rows and the resolved colWidths.
  2. Row Invocation: TableSectionAlgorithm iterates over its rows, calling TableRowAlgorithm for each. Before placing each row, it calls builder.AdjustRowOffset to apply the -1 vertical collapse shift where row borders overlap.
  3. Cell Layout: TableRowAlgorithm resets its builder's currentBlockOffset to 0 (overriding the automatic border inset), then iterates over the row's cells from tableGrid. For each cell it: a. Sums colWidths across the spanned columns, then subtracts 1 for each internal collapsed junction. b. Calls builder.GetCellShift to obtain the horizontal -1 collapse shift. c. Lays the cell out as a standard BlockAlgorithm within a fixed-width ConstraintSpace. d. Places the cell at the adjusted (X, 0) offset.
  4. Row Height: The row's height is set to maxCellHeight + padding.Bottom (no extra border.Bottom). The table aggregates row heights via AdjustRowOffset to arrive at its final block size.

Documentation

Overview

Package layout computes a fragment tree from render nodes, computed styles, and available space. Its block, inline, flex, grid, list, table, and overlay algorithms measure and position content in terminal cells. The resulting fragments provide geometry for painting and hit testing.

Index

Constants

View Source
const InfiniteBlockSize = math.MaxInt32 / 2

InfiniteBlockSize is the height used when probing a node's intrinsic block size. It represents an unconstrained vertical axis: the node should size to its content, not to the available height. math.MaxInt32/2 avoids overflow when arithmetic is performed on top of it.

Variables

This section is empty.

Functions

func AbsoluteBounds

func AbsoluteBounds(root *Fragment, target Node) (geometry.Rect, bool)

AbsoluteBounds traverses the fragment tree starting at root and computes the absolute bounding rectangle of the target node. Returns the rect and true if found, or a zero rect and false if the node is not present in the tree.

func ClampHeight

func ClampHeight(node Node, height int, parentSpace ConstraintSpace) int

ClampHeight clamps the height according to the node's style min/max constraints.

func ClampWidth

func ClampWidth(node Node, width int, parentSpace ConstraintSpace) int

ClampWidth clamps the width according to the node's style min/max constraints.

func InfiniteRect

func InfiniteRect() geometry.Rect

InfiniteRect returns a rectangle that covers the entire signed integer coordinate space.

func IntrinsicBlockSize

func IntrinsicBlockSize(ctx *Context, node Node, availableWidth int) int

IntrinsicBlockSize returns the intrinsic block size (height) of a node given an available inline size (width).

func IsInlineLevel

func IsInlineLevel(node Node) bool

func MaxScroll

func MaxScroll(frag *Fragment) (x, y int)

MaxScroll calculates the maximum horizontal and vertical scroll offsets for a fragment, clamped to its content extent.

func ReleaseFlexLineBuilder

func ReleaseFlexLineBuilder(b *FlexLineBuilder)

ReleaseFlexLineBuilder returns a builder to the pool.

func ReleaseGridBuilder

func ReleaseGridBuilder(b *GridBuilder)

ReleaseGridBuilder returns a builder to the pool.

func ReleaseInlineItemsBuilder

func ReleaseInlineItemsBuilder(b *InlineItemsBuilder)

ReleaseInlineItemsBuilder returns a builder to the pool.

func ReleaseLineBreaker

func ReleaseLineBreaker(l *LineBreaker)

func ReleaseTableFragmentBuilder

func ReleaseTableFragmentBuilder(b *TableFragmentBuilder)

ReleaseTableFragmentBuilder returns a builder to the pool.

func ResolveTrackSizes

func ResolveTrackSizes(templates []style.GridTrackSize, available int, gap int) []int

ResolveTrackSizes resolves fixed and percentage track sizes against the available space.

func ScrolledAbsoluteBounds

func ScrolledAbsoluteBounds(root *Fragment, target Node) (rect geometry.Rect, clip geometry.Rect, found bool)

ScrolledAbsoluteBounds returns the absolute bounding box of target, shifted by all ancestor scroll offsets and clipped by all ancestor overflow regions.

It returns:

  • rect: the absolute border-box of target (scrolled).
  • clip: the absolute content-box clip rectangle of the nearest clipping ancestor (intersected with all further clipping ancestors).
  • found: true if target was found in the subtree.

func ScrolledAbsoluteBoundsPath

func ScrolledAbsoluteBoundsPath(root *Fragment, target Node, path []Node) (rect geometry.Rect, clip geometry.Rect, found bool)

func ShouldReserveScrollbar

func ShouldReserveScrollbar(s *style.Computed) (x, y bool)

ShouldReserveScrollbar returns true if space for a scrollbar must be reserved regardless of content size (i.e. style is OverflowScroll).

Types

type Algorithm

type Algorithm interface {
	// Layout computes and returns an immutable Fragment based on the underlying node and constraints.
	Layout(ctx *Context, node Node, space ConstraintSpace) *Fragment

	// ComputeMinMaxSizes calculates the intrinsic minimum and maximum sizes of the node.
	ComputeMinMaxSizes(ctx *Context, node Node) MinMaxSizes
}

Algorithm is the interface that all LayoutNG-inspired layout formatters must implement.

func GetAlgorithm

func GetAlgorithm(node Node) Algorithm

GetAlgorithm returns the appropriate layout algorithm for the given node.

func NewAlgorithm

func NewAlgorithm(node Node, space ConstraintSpace) Algorithm

NewAlgorithm is deprecated: use GetAlgorithm instead.

type AnonymousBlock

type AnonymousBlock struct {
	// contains filtered or unexported fields
}

AnonymousBlock represents an anonymous box created to wrap contiguous runs of inline content.

func (*AnonymousBlock) CachedBlockSize

func (a *AnonymousBlock) CachedBlockSize(width int) (int, bool)

func (*AnonymousBlock) CachedLayout

func (a *AnonymousBlock) CachedLayout(space ConstraintSpace) *Fragment

func (*AnonymousBlock) CachedMinMaxSizes

func (a *AnonymousBlock) CachedMinMaxSizes() (MinMaxSizes, bool)

func (*AnonymousBlock) ClearDirtyLayout

func (a *AnonymousBlock) ClearDirtyLayout()

func (*AnonymousBlock) ComputeMinMaxSizes

func (a *AnonymousBlock) ComputeMinMaxSizes(ctx *Context) MinMaxSizes

func (*AnonymousBlock) FirstLayoutChild

func (a *AnonymousBlock) FirstLayoutChild() Node

func (*AnonymousBlock) Fragment

func (a *AnonymousBlock) Fragment() *Fragment

func (*AnonymousBlock) HasChildNeedsPaint

func (a *AnonymousBlock) HasChildNeedsPaint() bool

func (*AnonymousBlock) IsAnonymous

func (a *AnonymousBlock) IsAnonymous() bool

func (*AnonymousBlock) IsDirtyLayout

func (a *AnonymousBlock) IsDirtyLayout() bool

func (*AnonymousBlock) IsDirtyPaint

func (a *AnonymousBlock) IsDirtyPaint() bool

func (*AnonymousBlock) Layout

func (a *AnonymousBlock) Layout(ctx *Context) *Fragment

func (*AnonymousBlock) LogicalNode

func (a *AnonymousBlock) LogicalNode() dom.Node

func (*AnonymousBlock) NextLayoutSibling

func (a *AnonymousBlock) NextLayoutSibling(child Node) Node

func (*AnonymousBlock) SetCachedBlockSize

func (a *AnonymousBlock) SetCachedBlockSize(width, height int)

func (*AnonymousBlock) SetCachedLayout

func (a *AnonymousBlock) SetCachedLayout(space ConstraintSpace, frag *Fragment)

func (*AnonymousBlock) SetCachedMinMaxSizes

func (a *AnonymousBlock) SetCachedMinMaxSizes(sizes MinMaxSizes)

func (*AnonymousBlock) SetOffset

func (a *AnonymousBlock) SetOffset(p geometry.Point)

func (*AnonymousBlock) Style

func (a *AnonymousBlock) Style() *style.Computed

type BlockAlgorithm

type BlockAlgorithm struct{}

BlockAlgorithm implements the Block formatting context layout. It stacks children vertically (in the block-flow direction) and calculates its own intrinsic size based on the accumulated height of its children.

func (*BlockAlgorithm) ComputeMinMaxSizes

func (a *BlockAlgorithm) ComputeMinMaxSizes(ctx *Context, node Node) MinMaxSizes

ComputeMinMaxSizes calculates the intrinsic minimum and maximum sizes of the node.

func (*BlockAlgorithm) Layout

func (a *BlockAlgorithm) Layout(ctx *Context, node Node, space ConstraintSpace) *Fragment

Layout executes the block layout algorithm and returns an immutable Fragment.

type BoxFragmentBuilder

type BoxFragmentBuilder struct {
	// contains filtered or unexported fields
}

BoxFragmentBuilder manages the state of a box fragment being built.

func AcquireBoxFragmentBuilder

func AcquireBoxFragmentBuilder(node Node, space ConstraintSpace) *BoxFragmentBuilder

AcquireBoxFragmentBuilder gets a builder from the pool and initializes it.

func NewBoxFragmentBuilder

func NewBoxFragmentBuilder(node Node, space ConstraintSpace) *BoxFragmentBuilder

NewBoxFragmentBuilder creates a new builder for the given node and constraint space.

func (*BoxFragmentBuilder) AddChild

func (b *BoxFragmentBuilder) AddChild(frag *Fragment, offset geometry.Point)

AddChild adds a child fragment at the specified offset.

func (*BoxFragmentBuilder) AdvanceBlockOffset

func (b *BoxFragmentBuilder) AdvanceBlockOffset(delta int)

AdvanceBlockOffset increases the block-direction offset (Y).

func (*BoxFragmentBuilder) CurrentBlockOffset

func (b *BoxFragmentBuilder) CurrentBlockOffset() int

CurrentBlockOffset returns the current block-direction offset (Y).

func (*BoxFragmentBuilder) SetBlockOffset

func (b *BoxFragmentBuilder) SetBlockOffset(offset int)

SetBlockOffset sets the current block-direction offset (Y).

func (*BoxFragmentBuilder) SetBlockSize

func (b *BoxFragmentBuilder) SetBlockSize(height int)

SetBlockSize sets the final block size (height) of the fragment.

func (*BoxFragmentBuilder) SetBreakToken

func (b *BoxFragmentBuilder) SetBreakToken(token *BreakToken)

SetBreakToken sets the break token for the fragment.

func (*BoxFragmentBuilder) SetHasScrollbarX

func (b *BoxFragmentBuilder) SetHasScrollbarX(v bool)

SetHasScrollbarX sets whether the fragment has a horizontal scrollbar.

func (*BoxFragmentBuilder) SetHasScrollbarY

func (b *BoxFragmentBuilder) SetHasScrollbarY(v bool)

SetHasScrollbarY sets whether the fragment has a vertical scrollbar.

func (*BoxFragmentBuilder) SetInlineSize

func (b *BoxFragmentBuilder) SetInlineSize(width int)

SetInlineSize sets the final inline size (width) of the fragment.

func (*BoxFragmentBuilder) ToFragment

func (b *BoxFragmentBuilder) ToFragment() *Fragment

ToFragment finalizes the builder and returns an immutable Fragment. It also returns the builder to the pool.

type BreakToken

type BreakToken struct {
	Node        Node
	ChildIndex  int
	InlineToken any // For resuming text layout
}

BreakToken represents the state needed to resume layout of a node in a new fragmentainer (e.g., the next page or column).

type ConstraintSpace

type ConstraintSpace struct {
	// AvailableSize is the ideal size the node should consume, provided by the parent.
	AvailableSize geometry.Size

	// ContainingSpace is the parent's resolved border-box dimensions.
	ContainingSpace geometry.Size

	// ContainerSpace is the parent's content-box dimensions
	// (ContainingSpace minus border minus padding).
	// KindPercent resolution and per-child AvailableSize derive from this field.
	ContainerSpace geometry.Size

	// IsFixedInlineSize indicates the inline size (width) is pre-determined.
	IsFixedInlineSize bool

	// IsFixedBlockSize indicates the block size (height) is pre-determined.
	IsFixedBlockSize bool

	// BreakToken is the token to resume layout from.
	BreakToken *BreakToken
}

ConstraintSpace defines the inputs for a layout operation. It encapsulates the physical size constraints alongside any additional context required during the layout walk (e.g., parent reference sizes, break tokens).

The three size fields serve distinct roles (ADR-018):

  • AvailableSize: per-child space after subtracting margins (or an explicit size).
  • ContainerSpace: parent's content-box (ContainingSpace − border − padding). KindPercent dimensions resolve against this field, and it is the base for computing per-child AvailableSize. In CSS, percentage widths/heights always resolve against the containing block's content area.
  • ContainingSpace: parent's resolved border-box. Carries the parent's total outer size for algorithms that require it (e.g. intrinsic sizing, positioning).

func BuildChildSpace

func BuildChildSpace(child Node, containerSpace geometry.Size, containingSpace geometry.Size, parentSpace ConstraintSpace) ConstraintSpace

BuildChildSpace constructs a ConstraintSpace for a block-level child element.

Parameters:

  • child: the child layout node (for computed style access).
  • containerSpace: the parent's content-box dimensions, pre-adjusted for the current block offset so that Height reflects the remaining vertical space.
  • containingSpace: the parent's border-box dimensions, used as the base for KindPercent resolution (ADR-018).
  • parentSpace: the parent's own ConstraintSpace (for IsFixedBlockSize and BreakToken).

This function centralises the child constraint generation that was previously duplicated across BlockAlgorithm and ListAlgorithm (ADR-018).

type ConstraintSpaceBuilder

type ConstraintSpaceBuilder struct {
	// contains filtered or unexported fields
}

ConstraintSpaceBuilder is a helper to construct a ConstraintSpace.

func NewConstraintSpaceBuilder

func NewConstraintSpaceBuilder(availableSize geometry.Size) *ConstraintSpaceBuilder

NewConstraintSpaceBuilder creates a new builder initialized with the available size. ContainingSpace and ContainerSpace default to zero and must be set explicitly by the caller.

func (*ConstraintSpaceBuilder) SetContainerSpace

func (b *ConstraintSpaceBuilder) SetContainerSpace(size geometry.Size) *ConstraintSpaceBuilder

SetContainerSpace sets the parent's content-box size (the available space for children before per-child margins are subtracted) (ADR-018).

func (*ConstraintSpaceBuilder) SetContainingSpace

func (b *ConstraintSpaceBuilder) SetContainingSpace(size geometry.Size) *ConstraintSpaceBuilder

SetContainingSpace sets the parent's border-box size (ADR-018). KindPercent resolution uses ContainerSpace (content-box), not this field.

func (*ConstraintSpaceBuilder) SetIsFixedBlockSize

func (b *ConstraintSpaceBuilder) SetIsFixedBlockSize(fixed bool) *ConstraintSpaceBuilder

SetIsFixedBlockSize sets whether the block size is fixed.

func (*ConstraintSpaceBuilder) SetIsFixedInlineSize

func (b *ConstraintSpaceBuilder) SetIsFixedInlineSize(fixed bool) *ConstraintSpaceBuilder

SetIsFixedInlineSize sets whether the inline size is fixed.

func (*ConstraintSpaceBuilder) ToConstraintSpace

func (b *ConstraintSpaceBuilder) ToConstraintSpace() ConstraintSpace

ToConstraintSpace returns the constructed ConstraintSpace.

type Constraints

type Constraints struct {
	Min, Max geometry.Size
}

Constraints defines the minimum and maximum dimensions allowed for a box.

type Context

type Context struct {
	Tracer       *trace.Tracer
	InlineBuffer []Node
}

Context carries state and utilities through the layout tree.

func (*Context) Begin

func (c *Context) Begin(name string) func()

Begin is a helper to start a trace span.

type FlexAlgorithm

type FlexAlgorithm struct{}

FlexAlgorithm implements the CSS Flexbox formatting context layout.

func (*FlexAlgorithm) ComputeMinMaxSizes

func (a *FlexAlgorithm) ComputeMinMaxSizes(ctx *Context, node Node) MinMaxSizes

ComputeMinMaxSizes calculates the intrinsic minimum and maximum sizes of the node.

func (*FlexAlgorithm) Layout

func (a *FlexAlgorithm) Layout(ctx *Context, node Node, space ConstraintSpace) *Fragment

Layout executes the flex layout algorithm and returns an immutable Fragment.

type FlexItem

type FlexItem struct {
	Node Node

	// Flex base size (initial main size before growing/shrinking).
	BaseSize int

	// Hypothetical main size (base size clamped by min/max constraints).
	HypotheticalMainSize int

	// Final resolved sizes.
	MainSize  int
	CrossSize int

	// Frozen indicates the item's main size has been fixed.
	Frozen bool

	// Style shortcuts.
	Grow   int
	Shrink int
	Order  int

	// Min/Max constraints in main axis.
	MinMainSize int
	MaxMainSize int

	// Cached measurement result.
	Fragment *Fragment

	// AlignSelf override for this item.
	AlignSelf style.Align

	// Physical offset relative to container content box.
	Offset geometry.Point
}

FlexItem represents a transient layout state for a flex child.

type FlexLine

type FlexLine struct {
	Items     []*FlexItem
	MainSize  int
	CrossSize int
}

FlexLine represents a group of flex items that fit on a single line.

type FlexLineBuilder

type FlexLineBuilder struct {
	// contains filtered or unexported fields
}

FlexLineBuilder encapsulates the mutable state required for resolving flex lines. It acts as the state machine for the flex layout algorithm, handling item collection, line breaking, space distribution (growing/shrinking), and alignment.

func AcquireFlexLineBuilder

func AcquireFlexLineBuilder(geom flexGeometry, mainGap, crossGap int) *FlexLineBuilder

AcquireFlexLineBuilder gets a builder from the pool and initializes it.

func NewFlexLineBuilder

func NewFlexLineBuilder(geom flexGeometry, mainGap, crossGap int) *FlexLineBuilder

func (*FlexLineBuilder) AddItem

func (b *FlexLineBuilder) AddItem(node Node, baseSize, minSize, maxSize, grow, shrink, order int)

func (*FlexLineBuilder) AlignCrossAxis

func (b *FlexLineBuilder) AlignCrossAxis(containerCrossSize int, alignContent style.Align, alignItems style.Align)

AlignCrossAxis handles cross-axis alignment (align-content and align-items).

func (*FlexLineBuilder) AlignLine

func (b *FlexLineBuilder) AlignLine(lineIndex int, containerMainSize int, justifyContent style.Justify, isReverse bool)

AlignLine handles main-axis alignment (justify-content) for a single line.

func (*FlexLineBuilder) ComputeLines

func (b *FlexLineBuilder) ComputeLines(availableMainSize int, wrap bool)

ComputeLines groups the items into lines based on the available main size.

func (*FlexLineBuilder) Lines

func (b *FlexLineBuilder) Lines() []*FlexLine

Lines returns the computed lines.

func (*FlexLineBuilder) ResolveFlexibleLengths

func (b *FlexLineBuilder) ResolveFlexibleLengths(lineIndex int, availableMain int)

ResolveFlexibleLengths distributes free space among items in a line.

func (*FlexLineBuilder) ReverseItems

func (b *FlexLineBuilder) ReverseItems()

ReverseItems reverses the order of items (used for row-reverse/column-reverse).

func (*FlexLineBuilder) SortItems

func (b *FlexLineBuilder) SortItems()

SortItems sorts items by their Order property.

type Fragment

type Fragment struct {
	// Size is the computed physical dimensions of this fragment in terminal cells.
	Size geometry.Size

	// Node is the layout node that generated this fragment.
	Node Node

	// Children contains the positioned child fragments relative to this fragment.
	Children []FragmentLink

	// Text contains the shaped clusters if this fragment represents a text run.
	Text []text.Cluster

	// ParentNode is the containing inline element for text fragments (for style inheritance).
	ParentNode Node

	// BreakToken is the token to resume layout in the next fragmentainer.
	BreakToken *BreakToken

	// HasScrollbarX indicates that a horizontal scrollbar was reserved during layout.
	HasScrollbarX bool
	// HasScrollbarY indicates that a vertical scrollbar was reserved during layout.
	HasScrollbarY bool
}

Fragment represents the immutable output of a layout algorithm. Once created, a Fragment's fields must never be modified. This immutability allows fragments to be cached and reused across layout passes.

func (*Fragment) ChildViewport

func (frag *Fragment) ChildViewport(origin geometry.Point, currentClip geometry.Rect) (geometry.Point, geometry.Rect)

ChildViewport returns the scrolled origin and clip for a fragment's children.

type FragmentLink struct {
	// Offset is the physical position of the child relative to the parent fragment's origin.
	Offset geometry.Point

	// Fragment is the immutable child fragment.
	Fragment *Fragment
}

FragmentLink connects a child Fragment to its parent at a specific physical offset. Positioning information is stored here rather than inside the Fragment itself, allowing the exact same Fragment to be reused in different positions.

type GridAlgorithm

type GridAlgorithm struct{}

GridAlgorithm implements the CSS Grid formatting context layout.

func (*GridAlgorithm) ComputeMinMaxSizes

func (a *GridAlgorithm) ComputeMinMaxSizes(ctx *Context, node Node) MinMaxSizes

func (*GridAlgorithm) Layout

func (a *GridAlgorithm) Layout(ctx *Context, node Node, space ConstraintSpace) *Fragment

Layout executes the grid layout algorithm and returns an immutable Fragment.

type GridBuilder

type GridBuilder struct {
	// contains filtered or unexported fields
}

GridBuilder handles the auto-placement algorithm and track sizing for CSS Grid.

func AcquireGridBuilder

func AcquireGridBuilder(node Node, space ConstraintSpace) *GridBuilder

AcquireGridBuilder gets a builder from the pool and initializes it.

func NewGridBuilder

func NewGridBuilder(node Node, space ConstraintSpace) *GridBuilder

NewGridBuilder creates a new GridBuilder for the given node and space.

func (*GridBuilder) Init

func (b *GridBuilder) Init(node Node, space ConstraintSpace)

Init initializes the GridBuilder for the given node and space. This allows for stack allocation or reuse.

func (*GridBuilder) PlaceItems

func (b *GridBuilder) PlaceItems()

type InlineItem

type InlineItem struct {
	Type InlineItemType

	// Text contains the shaped clusters for InlineText items.
	Text []text.Cluster

	// Node is the layout node that generated this item.
	// For InlineAtomic, this is the element itself.
	// For Tags, this is the element providing the styles.
	Node Node

	// ParentNode is the containing inline element for text items.
	ParentNode Node
}

InlineItem is the atomic unit of the flattened inline representation.

type InlineItemType

type InlineItemType uint8

InlineItemType identifies the role of an item in the inline flow.

const (
	// InlineText represents a contiguous run of shaped text.
	InlineText InlineItemType = iota
	// InlineAtomic represents an opaque block element (inline-block).
	InlineAtomic
	// InlineOpenTag marks the start of a styled range.
	InlineOpenTag
	// InlineCloseTag marks the end of a styled range.
	InlineCloseTag
	// InlineBr represents a <br> element that forces a mandatory line break.
	// It contributes zero bytes and zero visual width but terminates the
	// current line immediately, similar to a \n cluster with BreakMandatory.
	InlineBr
	// InlineBrPlaceholder represents a trailing placeholder <br> that forces
	// a line break (so the textarea always has height for an empty last line)
	// but contributes ZERO bytes to the cursor byte-offset model. This maps
	// to the browser model where the placeholder break is not part of the
	// buffer value.
	InlineBrPlaceholder
)

type InlineItemsBuilder

type InlineItemsBuilder struct {
	// contains filtered or unexported fields
}

InlineItemsBuilder flattens a tree of layout nodes into a 1D array of InlineItems.

func AcquireInlineItemsBuilder

func AcquireInlineItemsBuilder(shaper *text.Shaper, block Node) *InlineItemsBuilder

AcquireInlineItemsBuilder gets a builder from the pool and initializes it.

func NewInlineItemsBuilder

func NewInlineItemsBuilder(shaper *text.Shaper, block Node) *InlineItemsBuilder

func (*InlineItemsBuilder) Build

func (b *InlineItemsBuilder) Build(root Node) []InlineItem

func (*InlineItemsBuilder) Reset

func (b *InlineItemsBuilder) Reset()

type InlineLever

type InlineLever interface {
	IsInlineLevel() bool
}

type LineBox

type LineBox struct {
	Size     geometry.Size
	Children []FragmentLink
}

LineBox represents a single horizontal line of positioned inline fragments.

func (*LineBox) ToFragment

func (lb *LineBox) ToFragment() *Fragment

type LineBreaker

type LineBreaker struct {
	// contains filtered or unexported fields
}

LineBreaker packs InlineItems into physical lines.

func AcquireLineBreaker

func AcquireLineBreaker(items []InlineItem, width int, textAlign style.TextAlign, verticalAlign style.Align, textOverflow style.TextOverflow) *LineBreaker

func (*LineBreaker) NextLine

func (l *LineBreaker) NextLine(ctx *Context) (*LineBox, bool)

type ListAlgorithm

type ListAlgorithm struct{}

ListAlgorithm implements the layout for list items with markers. It formats the list item as a two-column row: Column 1 is the marker, and Column 2 contains the children laid out using Block layout rules.

func (*ListAlgorithm) ComputeMinMaxSizes

func (a *ListAlgorithm) ComputeMinMaxSizes(ctx *Context, node Node) MinMaxSizes

func (*ListAlgorithm) Layout

func (a *ListAlgorithm) Layout(ctx *Context, node Node, space ConstraintSpace) *Fragment

type MeasureResult

type MeasureResult struct {
	Size geometry.Size
}

MeasureResult is the output of a node's Measure method.

type MinMaxSizes

type MinMaxSizes struct {
	Min, Max int
}

MinMaxSizes represents the intrinsic minimum and maximum widths of a node.

func ComputeInlineMinMaxSizes

func ComputeInlineMinMaxSizes(ctx *Context, items []InlineItem) MinMaxSizes

func IntrinsicMinMaxSizes

func IntrinsicMinMaxSizes(ctx *Context, node Node) MinMaxSizes

IntrinsicMinMaxSizes computes the intrinsic min/max widths for a node by selecting the correct algorithm based on its display style.

func (MinMaxSizes) Add

func (m MinMaxSizes) Add(value int) MinMaxSizes

Add shifts both min and max sizes simultaneously.

func (MinMaxSizes) Constrain

func (m MinMaxSizes) Constrain(value int) MinMaxSizes

Constrain caps the boundaries (min/max) to a specific value.

func (*MinMaxSizes) Encompass

func (m *MinMaxSizes) Encompass(other MinMaxSizes)

Encompass expands the min/max bounds to fit another MinMaxSizes.

func (*MinMaxSizes) EncompassSize

func (m *MinMaxSizes) EncompassSize(value int)

EncompassSize expands the min/max bounds to fit an explicit value.

func (MinMaxSizes) Subtract

func (m MinMaxSizes) Subtract(value int) MinMaxSizes

Subtract shifts both min and max sizes simultaneously.

type Node

type Node interface {
	// Style returns the node's fully-resolved computed style.
	// Must not return nil for nodes that participate in layout.
	Style() *style.Computed

	// FirstLayoutChild returns the first layout-visible child of this node.
	FirstLayoutChild() Node

	// NextLayoutSibling returns the next layout-visible sibling of the given child.
	NextLayoutSibling(child Node) Node

	// LogicalNode returns the logical DOM node that owns this render object.
	// May be nil.
	LogicalNode() dom.Node

	// IsDirtyLayout reports whether this node's layout is stale. The engine
	// uses this signal to decide whether cached intrinsic sizes are still
	// valid.
	IsDirtyLayout() bool

	// IsDirtyPaint reports whether this node's paint is stale.
	IsDirtyPaint() bool

	// HasChildNeedsPaint reports whether any descendant needs paint.
	HasChildNeedsPaint() bool

	// ClearDirtyLayout clears the DirtyLayout flag on this node. Called by
	// the layout engine after successfully measuring the node so that
	// subsequent cache lookups are valid.
	ClearDirtyLayout()

	// Fragment returns the most recent LayoutNG fragment generated for this node.
	// It is used by paint, hit testing, and spatial navigation to retrieve the
	// physical representation of the element.
	Fragment() *Fragment

	// CachedLayout returns a previously computed fragment if the node is clean
	// and the constraints match. Returns nil if a re-layout is required.
	CachedLayout(space ConstraintSpace) *Fragment

	// SetCachedLayout stores the computed fragment and the constraints that generated it.
	// Implementing this should implicitly clear the DirtyLayout flag.
	SetCachedLayout(space ConstraintSpace, frag *Fragment)

	// CachedMinMaxSizes returns the intrinsic minimum and maximum sizes if they are still valid.
	CachedMinMaxSizes() (MinMaxSizes, bool)

	// SetCachedMinMaxSizes stores the computed intrinsic minimum and maximum sizes.
	SetCachedMinMaxSizes(sizes MinMaxSizes)

	// CachedBlockSize returns the intrinsic block size (height) for a given inline size (width).
	CachedBlockSize(width int) (int, bool)

	// SetCachedBlockSize stores the computed intrinsic block size for a given inline size.
	SetCachedBlockSize(width, height int)

	// SetOffset updates the physical offset of this node.
	SetOffset(geom.Point)

	// IsAnonymous reports whether this node is a virtual layout-only node
	// (like flex's AnonymousBlock) that should trigger shrink-wrap for auto width.
	IsAnonymous() bool
}

Node is the layout engine's view of a render object. It provides the style, tree-walk, and bounds-mutation interface required by formatting-context algorithms without importing the render package.

Any render object that participates in layout must implement this interface.

type NoneAlgorithm

type NoneAlgorithm struct{}

NoneAlgorithm is a layout formatter for nodes with display: none. It always returns an empty fragment.

func (*NoneAlgorithm) ComputeMinMaxSizes

func (a *NoneAlgorithm) ComputeMinMaxSizes(ctx *Context, node Node) MinMaxSizes

func (*NoneAlgorithm) Layout

func (a *NoneAlgorithm) Layout(ctx *Context, node Node, space ConstraintSpace) *Fragment

type OverlayAlgorithm

type OverlayAlgorithm struct{}

OverlayAlgorithm implements anchored positioning and smart flipping for overlays.

func (*OverlayAlgorithm) ComputeMinMaxSizes

func (a *OverlayAlgorithm) ComputeMinMaxSizes(ctx *Context, node Node) MinMaxSizes

func (*OverlayAlgorithm) Layout

func (a *OverlayAlgorithm) Layout(ctx *Context, node Node, space ConstraintSpace) *Fragment

type OverlayLever

type OverlayLever interface {
	Anchor() dom.Node
	Placement() geom.Placement
	Flip() bool
}

type ResolvedDecorations

type ResolvedDecorations struct {
	// Insets is the total space consumed by decorations on each side.
	// This is the sum of Border + Padding + (if present) Scrollbar.
	Insets style.EdgeValues[int]

	// HasScrollbarX indicates if a horizontal scrollbar is active.
	HasScrollbarX bool
	// HasScrollbarY indicates if a vertical scrollbar is active.
	HasScrollbarY bool
}

ResolvedDecorations contains the computed sizes and visibility flags for an element's non-content area (borders, padding, and scrollbars).

func ResolveDecorations

func ResolveDecorations(node Node, scrollX, scrollY bool) ResolvedDecorations

ResolveDecorations computes the decoration sizes for a node based on its style and whether scrollbars have been requested/forced by the layout algorithm.

func (ResolvedDecorations) ViewportSize

func (d ResolvedDecorations) ViewportSize(outer geometry.Size) geometry.Size

ViewportSize returns the available content area for a fragment of the given outer size, accounting for decorations.

type ShapedTextCache

type ShapedTextCache interface {
	CachedText() string
	CachedClusters() []text.Cluster
	SetCachedClusters(text string, clusters []text.Cluster)
}

type TableAlgorithm

type TableAlgorithm struct{}

TableAlgorithm implements the DisplayTable layout.

func (*TableAlgorithm) ComputeMinMaxSizes

func (a *TableAlgorithm) ComputeMinMaxSizes(ctx *Context, node Node) MinMaxSizes

func (*TableAlgorithm) Layout

func (a *TableAlgorithm) Layout(ctx *Context, node Node, space ConstraintSpace) *Fragment

Layout executes the two-pass table layout algorithm and returns an immutable Fragment.

type TableCellLever

type TableCellLever interface {
	ColSpan() int
	RowSpan() int
}

type TableFragmentBuilder

type TableFragmentBuilder struct {
	// contains filtered or unexported fields
}

TableFragmentBuilder manages the mutable state during the two-pass table layout algorithm. It handles section grouping, column matrix math, and implicit border overlapping calculations.

func AcquireTableFragmentBuilder

func AcquireTableFragmentBuilder(node Node, space ConstraintSpace) *TableFragmentBuilder

AcquireTableFragmentBuilder gets a builder from the pool and initializes it.

func NewTableFragmentBuilder

func NewTableFragmentBuilder(node Node, space ConstraintSpace) *TableFragmentBuilder

func (*TableFragmentBuilder) AddBodyChild

func (b *TableFragmentBuilder) AddBodyChild(node Node)

func (*TableFragmentBuilder) AddFooterChild

func (b *TableFragmentBuilder) AddFooterChild(node Node)

func (*TableFragmentBuilder) AddHeaderChild

func (b *TableFragmentBuilder) AddHeaderChild(node Node)

func (*TableFragmentBuilder) AddNonRowChild

func (b *TableFragmentBuilder) AddNonRowChild(node Node)

func (*TableFragmentBuilder) AddRowChild

func (b *TableFragmentBuilder) AddRowChild(node Node)

func (*TableFragmentBuilder) AdjustRowOffset

func (b *TableFragmentBuilder) AdjustRowOffset(hasTopBorder, hasBottomBorder bool) int

AdjustRowOffset handles the -1 Y coordinate adjustment for intersecting row borders.

func (*TableFragmentBuilder) AdvanceBlockOffset

func (b *TableFragmentBuilder) AdvanceBlockOffset(amount int)

func (*TableFragmentBuilder) BuildGrid

func (b *TableFragmentBuilder) BuildGrid(ctx *Context)

func (*TableFragmentBuilder) CurrentBlockOffset

func (b *TableFragmentBuilder) CurrentBlockOffset() int

func (*TableFragmentBuilder) DistributeSpan

func (b *TableFragmentBuilder) DistributeSpan(ctx *Context, cell Node, colIndex int, colSpan int)

DistributeSpan handles the complex math of stretching minimum widths across multiple columns.

func (*TableFragmentBuilder) ResolveWidths

func (b *TableFragmentBuilder) ResolveWidths(resolvedInlineSize int, parentDecorX int)

func (*TableFragmentBuilder) Sections

func (b *TableFragmentBuilder) Sections() []Node

func (*TableFragmentBuilder) SetBlockSize

func (b *TableFragmentBuilder) SetBlockSize(size int)

func (*TableFragmentBuilder) ToFragment

func (b *TableFragmentBuilder) ToFragment() *Fragment

type TableRowAlgorithm

type TableRowAlgorithm struct{}

TableRowAlgorithm implements the DisplayTableRow layout.

func (*TableRowAlgorithm) ComputeMinMaxSizes

func (a *TableRowAlgorithm) ComputeMinMaxSizes(ctx *Context, node Node) MinMaxSizes

func (*TableRowAlgorithm) Layout

func (a *TableRowAlgorithm) Layout(ctx *Context, node Node, space ConstraintSpace) *Fragment

func (*TableRowAlgorithm) LayoutWithData

func (a *TableRowAlgorithm) LayoutWithData(ctx *Context, node Node, space ConstraintSpace, tableBuilder *TableFragmentBuilder, colWidths []int, rowData *tableRowGrid) *Fragment

type TableSectionAlgorithm

type TableSectionAlgorithm struct{}

TableSectionAlgorithm implements the layout for table header, body, and footer groups.

func (*TableSectionAlgorithm) ComputeMinMaxSizes

func (a *TableSectionAlgorithm) ComputeMinMaxSizes(ctx *Context, node Node) MinMaxSizes

func (*TableSectionAlgorithm) Layout

func (a *TableSectionAlgorithm) Layout(ctx *Context, node Node, space ConstraintSpace) *Fragment

func (*TableSectionAlgorithm) LayoutWithData

func (a *TableSectionAlgorithm) LayoutWithData(ctx *Context, node Node, space ConstraintSpace, tableBuilder *TableFragmentBuilder, colWidths []int, rowsData []*tableRowGrid) *Fragment

Directories

Path Synopsis
Package text shapes strings into grapheme clusters with terminal-cell widths and line-break opportunities for inline layout.
Package text shapes strings into grapheme clusters with terminal-cell widths and line-break opportunities for inline layout.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL