layout-cat 0.1.0

Box-model layout: cascade + block layout over a dom-cat tree using css-cat stylesheets. Produces a LayoutBox tree with positions and dimensions. No mut, no Rc/Arc, no interior mutability, no panics, exhaustive matches. Fourth sub-crate of a Servo-replacement webview runtime targeting Tauri.
docs.rs failed to build layout-cat-0.1.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

layout-cat

Box-model layout engine: cascade CSS rules over a DOM tree and compute a LayoutBox tree with positions and dimensions.

layout-cat is the fourth sub-crate of a comp-cat-rs Servo-replacement webview runtime targeting Tauri integration. It consumes a dom-cat document and a css-cat stylesheet, applies a simple cascade, and lays out block-level boxes. Same framework constraints: no mut, no Rc/Arc, no interior mutability, no panics.

Example

use layout_cat::{layout, Error, Viewport};

fn main() -> Result<(), Error> {
    let html_doc = html_cat::parse("<html><body><p>hi</p></body></html>")?;
    let dom = dom_cat::Document::from_html_doc(&html_doc);
    let sheet = css_cat::parse("p { width: 100px; padding: 8px; }")?;
    let tree = layout(&dom, &sheet, Viewport::new(800, 600));
    assert!(tree.root_box().is_some());
    Ok(())
}

v0 scope

  • Cascade: match css-cat rules to dom-cat elements (via dom-cat's matcher) and resolve declarations to a ComputedStyle.
  • Length resolution: px, em (multiplier on font-size), percentage (against containing-block width).
  • Box model: margin / border / padding / content per element.
  • Block layout: vertical stacking with width/height/margin/padding arithmetic.
  • LayoutTree of LayoutBox with positions, dimensions, and a back-reference to the originating dom_cat::NodeId.

Deferred to v0.2+

  • Inline layout, text shaping.
  • Flex / grid / floats / positioning (other than static).
  • Real font metrics; v0 uses 16px as the default font size.
  • Tables, transforms, logical properties.

License

MIT OR Apache-2.0