Tree.Available_spaceSourceAvailable space constraints for layout computation.
Available space represents the amount of space available to a node in a given axis during CSS layout computation. It distinguishes between definite sizes (concrete pixel values) and intrinsic sizing constraints (min-content and max-content). See CSS Sizing Level 3.
Layout algorithms use these constraints to determine node dimensions. Definite specifies a fixed pixel count, Min_content instructs the node to shrink-wrap to its minimum intrinsic size, and Max_content instructs the node to expand to its maximum intrinsic size.
Operations on available space follow consistent semantics for constraint propagation:
add, sub) apply only to Definite values; constraints propagate unchanged.min operations convert constraints to Definite when combined with concrete values, as constraints represent unbounded space.max operations preserve constraints, as they remain unbounded after comparison.min_or_self, add_or_zero) treat None as a no-op.of_option opt converts an optional float to available space. Some value becomes Definite value; None becomes Max_content.
to_option t converts to an option. Definite value becomes Some value; constraints become None.
unwrap_or t default returns the definite value or default if indefinite.
unwrap t returns the definite value.
Raises Invalid_argument if t is not Definite.
unwrap_or_else t default_cb returns the definite value or the result of default_cb () if indefinite.
pp fmt t formats t for pretty-printing.
or_else t default_cb returns t if Definite, else default_cb ().
set_or_self t value returns Definite v if value is Some v, else t.
maybe_set t value is an alias for set_or_self.
map_definite_value t f applies f to the value if Definite, else returns t unchanged.
compute_free_space t used_space computes remaining free space after allocating used_space.
Returns Float.infinity for Max_content (unbounded expansion), 0.0 for Min_content (no free space for expansion), and available -. used_space for Definite available.
equal a b tests equality. Definite values are equal if their absolute difference is less than Float.epsilon. Constraints match only their own variant.
compare a b orders values. Definite values sort before constraints; Min_content sorts before Max_content.
is_roughly_equal t other tests approximate equality. Equivalent to equal.
These operations combine available space with concrete float values. Operations on Definite values apply standard arithmetic. Constraint handling varies by operation as documented.
min t rhs returns the minimum of t and rhs. Definite values use Float.min. Constraints become Definite rhs, as unbounded space is greater than any finite value.
max t rhs returns the maximum of t and rhs. Definite values use Float.max. Constraints remain unchanged, as they represent unbounded space greater than any finite value.
clamp t min_val max_val clamps t to the range [min_val, max_val]. Definite values are clamped. Constraints remain unchanged.
add t rhs adds rhs to t. Definite values are incremented. Constraints remain unchanged.
sub t rhs subtracts rhs from t. Definite values are decremented. Constraints remain unchanged.
These operations combine available space with optional float values. When the optional value is None, the operation returns t unchanged.
min_or_self t rhs returns the minimum of t and rhs. Returns t unchanged if rhs is None. Constraints become Definite when combined with Some value.
max_or_self t rhs returns the maximum of t and rhs. Returns t unchanged if rhs is None. Constraints remain unchanged when combined with Some value.
clamp_or_self t min_val max_val clamps t to the optional bounds. None bounds are ignored. Definite values are clamped; constraints remain unchanged.
add_or_zero t rhs adds rhs to t if Some, else returns t unchanged. Definite values are incremented; constraints remain unchanged.
sub_or_zero t rhs subtracts rhs from t if Some, else returns t unchanged. Definite values are decremented; constraints remain unchanged.
Operations on pairs of available space values for width and height.
size_to_options t converts to a size with optional components. Definite values become Some; constraints become None.
size_maybe_set t value updates dimensions where value has Some. None values leave the corresponding dimension unchanged.