build_layout_and_info

Function build_layout_and_info 

Source
pub fn build_layout_and_info(
    dom: &Rc<RefCell<TreeNode<HtmlNodeType>>>,
    resolved_styles: &ResolvedStyles,
    measurer: &dyn TextMeasurer<TextStyle>,
    parent_text_style: TextStyle,
    chain: ElementChain,
) -> (LayoutNode, InfoNode)
Expand description

Builds a layout tree (LayoutNode) and a render info tree (InfoNode) from the DOM.

§Overview

  • Recursively traverses the HTML DOM
  • Applies resolved CSS declarations
  • Computes layout-related styles
  • Collects render-time information (color, font size, text)

§Style resolution order (low → high priority)

  1. Inherited values from parent

    • text_style
  2. Resolved CSS declarations

    • Overrides inherited values when specified
  3. HTML defaults / semantics

    • display (block, inline, etc.)
    • Text measurement for text nodes

§Inherited properties

Only the following properties are inherited explicitly:

  • text_style

All other style fields are initialized per node and are not inherited.

§Parameters

  • parent_text_style

These values must be passed from the computed result of the parent when calling this function recursively.

§Returns

A tuple of:

  • LayoutNode: used by the layout engine
  • InfoNode: used for rendering (text, color, font size)