Skip to main content

compute_root_layout

Function compute_root_layout 

Source
pub fn compute_root_layout(
    tree: &mut (impl LayoutContainingBlock + CacheTree),
    root: NodeId,
    available_space: Size<AvailableSpace>,
)
Expand description

Compute layout for the root node in the tree

The root’s containing block is the initial containing block (ICB), which has the dimensions of the viewport (available_space) and is anchored at the canvas origin. The root’s position and inset styles are resolved against it:

  • A position: absolute/fixed root is laid out by the out-of-flow positioning routine used for every other out-of-flow box (insets, shrink-to-fit sizing, auto margins, …), with its static position at the ICB origin. This requires a definite available_space in both axes: otherwise there is no ICB to resolve against and the root is laid out as if it were in flow.
  • A position: relative root is laid out in flow and then offset by its insets.