package toffee
Build not yet checkedInstall
dune-project
Dependency
Authors
Maintainers
Sources
sha256=a92cbbcbe016fb19fb0a749222da0e459a9567aef3f4c7340d9bd6b71c53ed6f
sha512=6a7ab054605538bb31a2b73a1a6d093981a2704c9f0af5852221c05735290d74aca7c7282298c4d0f91e86a800e2ccd94b4918af883cd963449c758eb6b272b3
doc/toffee.tree/Toffee_tree/Sizing_mode/index.html
Module Toffee_tree.Sizing_modeSource
Sizing mode for layout computation.
Sizing mode controls whether inherent size styles (width, height, min/max constraints, aspect ratio) are considered during layout measurement. It is used in layout inputs to determine how a node's size should be computed.
In CSS layout, certain computations need to measure content size without applying explicit size constraints. For example, when computing intrinsic sizes for CSS Grid track sizing or Flexbox item sizing, the algorithm needs to know the content's natural size before applying width/height styles.
Usage
Use Content_size when measuring intrinsic content dimensions for track sizing algorithms. Use Inherent_size for normal layout computation where all style properties apply.
Example from CSS Grid track sizing:
(* Measure content size without applying width/height styles *)
let content_layout =
Tree.compute_child_layout tree node
(Layout_input.make
~run_mode:Run_mode.Compute_size
~sizing_mode:Sizing_mode.Content_size
~axis:Requested_axis.Both
~known_dimensions:Size.none
~parent_size:Size.none
~available_space:Size.max_content
~vertical_margins_are_collapsible:Line.false_)
in
(* Track size is based on content dimensions *)
let track_size = Layout_output.size content_layoutExample from final layout:
(* Apply all size styles during final layout *)
let final_layout =
Tree.compute_child_layout tree node
(Layout_input.make ~run_mode:Run_mode.Perform_layout
~sizing_mode:Sizing_mode.Inherent_size ~axis:Requested_axis.Both
~known_dimensions:final_size ~parent_size:container_size
~available_space:available
~vertical_margins_are_collapsible:Line.false_)type t = | Content_size(*Measure only content contributions, ignoring inherent size styles.
The node's explicit size properties (
width,height), size constraints (min_width,max_width,min_height,max_height), andaspect_ratioare not applied. Only the natural size of the content determines dimensions.Used during intrinsic sizing phases of CSS Grid track sizing and Flexbox item sizing, where the algorithm needs to measure content before applying size constraints.
*)| Inherent_size(*Measure content with all inherent size styles applied.
All size properties (
width,height), size constraints (min_width,max_width,min_height,max_height), andaspect_ratioare applied to constrain or set the node's dimensions.This is the standard sizing mode for normal layout computation and final layout passes.
*)
compare a b compares two sizing modes.
Returns a negative integer if a is less than b, zero if equal, and a positive integer if a is greater than b. The ordering is Content_size < Inherent_size.
pp fmt mode prints the sizing mode to the formatter.