Expand description
Low-level access to the layout algorithms themselves. For a higher-level API, see the TakiaTree struct.
§Layout functions
The layout functions all take an &mut impl LayoutPartialTree parameter, which represents a single container node and it’s direct children.
| Function | Purpose |
|---|---|
compute_flexbox_layout | Layout a Flexbox container and it’s direct children |
compute_grid_layout | Layout a CSS Grid container and it’s direct children |
compute_block_layout | Layout a Block container and it’s direct children |
compute_leaf_layout | Applies common properties like padding/border/aspect-ratio to a node before deferring to a passed closure to determine it’s size. Can be applied to nodes like text or image nodes. |
compute_root_layout | Layout the root node of a tree (regardless of it’s layout mode). This function is typically called once to begin a layout run. |
compute_hidden_layout | Mark a node as hidden during layout (like Display::None) |
compute_cached_layout | Attempts to find a cached layout for the specified node and layout inputs. Uses the provided closure to compute the layout (and then stores the result in the cache) if no cached layout is found. |
§Other functions
| Function | Requires | Purpose |
|---|---|---|
round_layout | RoundTree | Round a tree of float-valued layouts to integer pixels |
print_tree | PrintTree | Print a debug representation of a node tree and it’s computed layout |
Modules§
- detailed_
info - A module for unified re-exports of detailed layout info structs, used by low level API
Structs§
- BfcSlot
float_layout - An empty “slot” that avoids floats that is suitable for a box that establishes
an independent formatting context (and therefore must not overlap floats) to be
laid out into. Unlike
ContentSlot, this accounts for the box’s own margins, which are resolved against the containing block’s edges (not float edges) and may therefore overlap floats. - Block
Context block_layout - Context for each individual Block within a Block Formatting Context
- Block
Formatting Context block_layout - Context for positioning Block and Float boxes within a Block Formatting Context
- Content
Slot float_layout - An empty “slot” that avoids floats that is suitable for non-floated content to be laid out into
- Float
Context float_layout - A context for placing floated boxes
- Float
Intrinsic Width Calculator float_layout - Context for computing the intrinsic width contribution of a set of floats
- Float
Mark block_layoutandfloat_layout - A mark of how many floats a Block Formatting Context held when it was taken.
See
BlockContext::float_mark. - OofLayout
Result - The result of laying out out-of-flow candidates against an explicit positioning area.
Functions§
- compute_
block_ align_ content_ offset block_layout - Compute the block-axis offset that
align-contentapplies to the in-flow content of a block container, given the free space between the container’s content box and its content. - compute_
block_ layout block_layout - Computes the layout of
LayoutPartialTreeaccording to the block layout algorithm - compute_
cached_ layout - Attempts to find a cached layout for the specified node and layout inputs.
- compute_
flexbox_ layout flexbox - Computes the layout of a box according to the flexbox algorithm
- compute_
grid_ layout grid - Grid layout algorithm This consists of a few phases:
- compute_
hidden_ layout - Creates a layout for this node and its children, recursively. Each hidden node has zero size and is placed at the origin
- compute_
leaf_ layout - Compute the size of a leaf node (node with no children)
- compute_
oof_ layout - Run the out-of-flow positioning pass for
node_idafter its layout algorithm has producedoutput: lay out the out-of-flow candidates inoutput.oof_candidatesfor which the node is the containing block, record them as the node’s hoisted children, and replaceoutput.oof_candidateswith the unclaimed remainder (which bubble further up the tree). The scrollable overflow contributed by the claimed boxes is merged intooutput.scrollable_overflow_rect. - compute_
oof_ layout_ for_ area - Lay out out-of-flow candidates against an explicit positioning area.
- compute_
root_ layout - Compute layout for the root node in the tree
- resolve_
static_ offset - Resolve the final static offset of an out-of-flow box from its static position, given the box’s final size and resolved margins.
- round_
layout - Rounds the calculated layout to exact pixel values