TreeSourceTree abstractions for CSS layout computation.
This module defines signatures and types for layout trees in toffee. Layout algorithms operate on trees by calling trait methods to access children, styles, and storage.
Traits form a dependency hierarchy enabling different operations:
TRAVERSE_PARTIAL_TREE: Access immediate children of a nodeLAYOUT_PARTIAL_TREE: Run layout algorithms (Flexbox, Grid, Block)TRAVERSE_TREE: Guarantee full recursive tree accessCACHE_TREE: Enable layout result cachingROUND_TREE: Round float layouts to integer pixelsPRINT_TREE: Debug-print layout treesLayout algorithms require LAYOUT_PARTIAL_TREE. Pixel rounding and debug printing require TRAVERSE_TREE, which extends TRAVERSE_PARTIAL_TREE with a guarantee that child access methods can recurse infinitely.
Layout proceeds top-down: parents pass Layout_input constraints to children via compute_child_layout, and children return Layout_output with computed sizes and margins. Algorithms read styles via get_core_container_style and store results via set_unrounded_layout.
Sizing mode for layout computation.
Collapsible margin tracking for CSS Block layout.
Axis that layout algorithms can be requested to compute a size for.
Available space constraints for layout computation.
Layout input constraints passed from parent to child during layout computation.
Layout algorithm output for a single node.
Tree traversal for immediate children.
Tree traversal with full recursive access.
Tree interface for layout algorithms.
Tree interface for layout caching.
Tree interface for pixel rounding.
Tree interface for debug printing.
print_tree (module Tree) tree root prints a debug representation of the layout tree rooted at root to stdout.
Output format:
TREE
└── Flex [x: 0 y: 0 w: 800 h: 600 content_w: 780 content_h: 580 ...] (Node 0)
├── Block [x: 10 y: 10 w: 200 h: 100 ...] (Node 1)
└── Text [x: 10 y: 120 w: 150 h: 20 ...] (Node 2)Each line shows the node's label, location, size, content_size, border, padding, and node ID. Children are indented with tree drawing characters.