Skip to main content

Crate cssbox_core

Crate cssbox_core 

Source
Expand description

cssbox-core — A standalone CSS layout engine.

This crate implements CSS layout algorithms: block, inline, float, positioning, flexbox, grid, and table. It takes a tree of styled nodes as input and produces computed positions and sizes as output.

§Usage

use cssbox_core::tree::BoxTreeBuilder;
use cssbox_core::style::ComputedStyle;
use cssbox_core::geometry::Size;
use cssbox_core::layout::{compute_layout, FixedWidthTextMeasure};

let mut builder = BoxTreeBuilder::new();
let root = builder.root(ComputedStyle::block());
// ... add children ...
let tree = builder.build();

let result = compute_layout(&tree, &FixedWidthTextMeasure, Size::new(800.0, 600.0));
let root_rect = result.bounding_rect(tree.root());

Modules§

block
Block formatting context layout.
box_model
Box model resolution: margin, border, padding computation.
flex
Flexbox layout algorithm.
float
Float layout per CSS 2.1 §9.5.1.
fragment
Fragment tree — the output of layout.
geometry
Geometric primitives for layout computation.
grid
CSS Grid Layout algorithm.
inline
Inline formatting context implementation.
layout
Layout entry point and dispatch.
position
CSS positioning: relative, absolute, fixed, sticky.
style
Computed CSS style types for layout.
table
CSS Table Layout algorithm.
tree
Box tree representation for layout.
values
CSS value types and resolution.