Skip to main content

strata_layout/
lib.rs

1//! Strata Layout: W3C Spec-compliant, Chromium-grade Box Model, Flexbox, and Grid solvers.
2//!
3//! # Examples
4//!
5//! ```rust
6//! use strata_layout::tree::LayoutNode;
7//! use strata_style::types::ComputedStyle;
8//!
9//! let mut root = LayoutNode::new(ComputedStyle::default());
10//! root.compute_layout(1024.0, 768.0);
11//! assert_eq!(root.geometry.border_box.width, 1024.0);
12//! ```
13
14#![forbid(unsafe_code)]
15
16pub mod box_model;
17pub mod exclusions;
18pub mod flexbox;
19pub mod geometry;
20pub mod grid;
21pub mod intrinsic;
22pub mod positioning;
23pub mod prof;
24pub mod table;
25pub mod text;
26pub mod tree;
27pub mod typography;
28pub mod wpt;
29
30pub use box_model::{
31    clamp_dimension, clamp_dimension_with_node, collapse_margins, resolve_dimension,
32    resolve_dimension_with_node,
33};
34pub use exclusions::{ExclusionKind, ExclusionRect, ExclusionSpace, LineOpportunity};
35pub use geometry::{LayoutGeometry, Point, Rect, Size};
36pub use intrinsic::{compute_min_max_sizes, MinMaxSizes};
37pub use positioning::{
38    solve_out_of_flow_box, solve_positioning, solve_positioning_children, ContainingBlock,
39};
40pub use table::{
41    border_style_priority, resolve_collapsed_border, solve_table, CollapsedBorderEdge,
42    ElementSource, TableBorderGrid,
43};
44pub use text::{
45    is_monospace_family, layout_inline_text, measure_text_bounds, measure_text_bounds_ext,
46    measure_text_bounds_styled_with_family, measure_text_bounds_with_family,
47    measure_text_bounds_with_white_space, text_measure_cache_stats,
48};
49pub use tree::{
50    clear_layout_overflow, last_layout_overflow, record_layout_overflow, set_on_layout_overflow,
51    solve_anchored_position, AnchorPlacement, FillRule, ImageResource, LayoutDepthGuard,
52    LayoutNode, PortalAnchorSpec, StrokeLineCap, StrokeLineJoin, SvgItem, SvgTextData,
53    ViewportSceneHandle, MAX_LAYOUT_DEPTH,
54};
55pub use typography::{
56    apply_small_caps, bidi_mirror, can_break_between_chars, classify_line_break, is_prohibited_end,
57    is_prohibited_start, AtomicFragment, BidiClass, BidiEngine, BidiRun, CssStrut, FontDatabase,
58    FontHeight, FontMetrics, InlineFormattingContext, InlineItem, InlineLayoutOptions,
59    InlineLayoutResult, InlineTextStyle, LineBox, LineBreakClass, LineBreaker, OpenTypeFeatures,
60    OpenTypeFont, OpenTypeParseError, ShapedGlyph, TextFragment, TextLine, TextShaper,
61    VerticalAlignment, WhiteSpaceMode,
62};
63pub use wpt::{
64    InternalLayoutRegressionSuite, SpecificationConformanceVector, WptSuite, WptTestVector,
65};
66
67pub mod prelude {
68    pub use crate::box_model::collapse_margins;
69    pub use crate::geometry::{LayoutGeometry, Point, Rect, Size};
70    pub use crate::intrinsic::{compute_min_max_sizes, MinMaxSizes};
71    pub use crate::text::{
72        is_monospace_family, layout_inline_text, measure_text_bounds, measure_text_bounds_ext,
73        measure_text_bounds_styled_with_family, measure_text_bounds_with_family,
74    };
75    pub use crate::tree::{solve_anchored_position, AnchorPlacement, LayoutNode, PortalAnchorSpec};
76    pub use crate::typography::*;
77    pub use crate::wpt::{
78        InternalLayoutRegressionSuite, SpecificationConformanceVector, WptSuite, WptTestVector,
79    };
80}