Skip to main content

Module box_sizing

Module box_sizing 

Source
Expand description

Box sizing, box model constraints, intrinsic measurement, and numerical rules.

Provides:

  • Complete box model geometry (BoxDimensions: content, padding, border, margin boxes).
  • Min/max constraint resolution with strict floor precedence (min_size > max_size min wins).
  • Aspect ratio proportional resolution (width-to-height and height-to-width).
  • Inset and positioning calculations for Position::Relative and Position::Absolute.
  • Sizing units resolution (Dimension, LengthPercentage, LengthPercentageAuto).
  • Definite vs indefinite available space handling (indefinite percentages collapse to Auto/0.0).
  • Negative margin offsets.
  • Intrinsic measurement and text measurement caching with zero redundant calls.
  • Strict numerical invariants (finite f32, non-negative dimensions).

Structs§

BoxConstraints
Min, max, and aspect ratio constraints resolved against available space.
BoxDimensions
The four geometric regions of a box in the layout model: content box, padding box, border box, and margin box.
TextMeasurementCache
Cache and evaluator for intrinsic text measurements with call counting and constraint caching.

Constants§

MAX_LAYOUT_DEPTH
Maximum recursion depth allowed during layout to prevent infinite loops.
STRICT_TOLERANCE_PX
Numerical comparison tolerance for logical pixel layout.

Traits§

Measurer
Trait for intrinsic measurement providers.

Functions§

apply_relative_offset
Applies relative positioning offset to an in-flow item based on its inset.
compute_box_sizing
Computes the complete box dimensions for a node given its style, available space, and optional intrinsic content size.
resolve_absolute_position
Computes the layout position for an out-of-flow Position::Absolute child relative to the parent’s padding box.
resolve_box_constraints
Extracts and resolves min/max constraints and aspect ratio from a node’s style.
resolve_dimension
Resolves a Dimension against available space on that axis.
resolve_inset
Resolves insets (left, right, top, bottom) for positioned nodes.
resolve_margin
Resolves margins against available space. Negative margins are preserved (FIX-SIZ-009). Percentages against indefinite space resolve to 0.0. Auto resolves to 0.0.
resolve_padding
Resolves padding against available space. Indefinite space produces 0.0 for percentages.