package toffee
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=9e4e90d17f9b2af1b07071fe425bc2c519c849c4f1d1ab73cde512be2d874849
sha512=06e9c4a741590942e81a27738d0b5c0413fafec8cf3b7dae047ad69f155e7b718aa4223818dc161b7d028efffcfd3365905e264d6fd31d453910ddfa91dcf9b9
doc/toffee.tree/Tree/index.html
Module TreeSource
Tree 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.
Trait Hierarchy
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 trees
Layout 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 Flow
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.
Core Types
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 Signatures
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.
Tree Functions
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.