Function taffy::round_layout

source ยท
pub fn round_layout(tree: &mut impl RoundTree, node_id: NodeId)
Expand description

Rounds the calculated layout to exact pixel values

In order to ensure that no gaps in the layout are introduced we:

  • Always round based on the cumulative x/y coordinates (relative to the viewport) rather than parent-relative coordinates
  • Compute width/height by first rounding the top/bottom/left/right and then computing the difference rather than rounding the width/height directly

See https://github.com/facebook/yoga/commit/aa5b296ac78f7a22e1aeaf4891243c6bb76488e2 for more context

In order to prevent innacuracies caused by rounding already-rounded values, we read from unrounded_layout and write to final_layout.