Files
moli/moli-layout/src/lib.rs
ldm0 09257c15cf refactor(fonts): extract system font matching crate
Move Fontconfig matching, substitution policy, and the Fontique lookup cache into moli-system-fonts. Keep CSS family adaptation in moli-layout, migrate tests and fixtures, and retain the Skia notice in source comments.
2026-09-12 04:13:15 +08:00

107 lines
4.6 KiB
Rust

//! One-shot CSS box construction, numeric layout, and owned paint projection.
//!
//! The crate knows Stylo and Taffy but never knows Moli's live DOM or V8
//! runtime. Renderer-owned adapters lend a canonical source view and resolve
//! styles; all source/style borrows and per-pass caches are gone before the
//! returned [`FrozenLayoutTree`] or [`PaintSnapshot`] crosses into a consumer.
/// Number of fixed layout subpixels in one CSS pixel, matching Blink's
/// `LayoutUnit` precision.
pub(crate) const LAYOUT_SUBPIXELS_PER_CSS_PIXEL: f32 = 64.0;
mod builder;
mod capture;
mod containment;
mod error;
mod form;
mod gradient;
mod grid;
mod inline;
mod intrinsic;
mod layout_tree;
mod list;
mod normalize;
mod normalize_source;
mod overflow;
mod paint;
mod pass;
mod positioned;
mod projection;
mod replaced;
mod scrollbar;
mod snapshot;
mod source;
mod stacking;
mod style;
mod stylo_to_parley;
mod table;
mod taffy_tree;
mod text;
mod world;
pub use builder::build_layout_world;
pub use capture::{
FULL_DOCUMENT_CAPTURE_CSS_DIMENSION_LIMIT, PaintCaptureRegion, PaintCaptureRequest,
PaintCaptureSurface,
};
pub use error::LayoutError;
pub use layout_tree::{
FrozenCoordinateSpace, FrozenEmbeddedFrame, FrozenLayoutBox, FrozenLayoutTree,
GeometryProvider, LayoutAnswers, LayoutBoxGeometry, LayoutBoxModel, LayoutCaretPosition,
LayoutClipChainId, LayoutClipNode, LayoutCoordinateSpaceId, LayoutCssImageReference,
LayoutDocumentMetrics, LayoutElementMetrics, LayoutFlushReason, LayoutFragment,
LayoutFragmentBoxModel, LayoutFragmentId, LayoutFragmentKind, LayoutHit,
LayoutIntersectionGeometry, LayoutNodeOutput, LayoutOutputBoxId, LayoutPaintedSurfaceHit,
LayoutPassMetrics, LayoutPassResult, LayoutPoint, LayoutQuad, LayoutQuery, LayoutQueryAnswer,
LayoutQueryBatch, LayoutRect, LayoutResolvedGridTrackList, LayoutResolvedGridTracks,
LayoutScrollContainerMetrics, LayoutScrollExtent, LayoutScrollIntoViewGeometry, LayoutSize,
LayoutTransform2D, LayoutTreeRetentionMetrics, LayoutUsedSize, LayoutViewport,
MAX_RETAINED_LAYOUT_BOXES, MAX_RETAINED_LAYOUT_FRAGMENTS, MAX_RETAINED_LAYOUT_TREE_BYTES,
};
pub use normalize::{NormalizedBoxNode, NormalizedBoxTree, NormalizedFormattingContext};
pub use normalize_source::{
NormalizedLayoutSourceNode, NormalizedLayoutSourceTree, normalize_layout_source,
};
pub use pass::{
EmbeddedFrameRenderer, EmbeddedFrameSnapshot, LayoutPassRequest, ScreenshotLayoutRequest,
build_layout_pass, build_layout_pass_with_embedded_frames, build_screenshot_snapshot,
};
pub use scrollbar::{
LayoutControlSurfaceHit, LayoutScrollbarAxis, LayoutScrollbarColors, LayoutScrollbarCornerHit,
LayoutScrollbarGeometry, LayoutScrollbarGutter, LayoutScrollbarHit, LayoutScrollbarPart,
LayoutScrollbarWidth,
};
pub use snapshot::{
PaintBlendMode, PaintBorderColors, PaintBorderStyle, PaintBorderStyles, PaintBoxShadow,
PaintBrush, PaintColor, PaintCompositeMode, PaintConicGradient, PaintCornerRadii,
PaintCornerRadius, PaintDiagnostic, PaintDiagnosticSeverity, PaintEdgeSizes, PaintFilter,
PaintFontId, PaintFontResource, PaintFragment, PaintGlyph, PaintGlyphRun,
PaintGradientColorSpace, PaintGradientExtend, PaintGradientHueDirection,
PaintGradientInterpolation, PaintGradientStop, PaintImage, PaintImageId, PaintImageResource,
PaintImageSampling, PaintLineCap, PaintLineJoin, PaintLinearGradient, PaintPath,
PaintPathElement, PaintPoint, PaintRadialGradient, PaintRect, PaintShape, PaintSize,
PaintSnapshot, PaintStroke, PaintSvgImage, PaintSvgImageId, PaintSvgImageResource,
PaintTextDecoration, PaintTextDecorationStyle, PaintTextShadow, PaintTransform2D,
PaintViewport, pixel_snap_paint_axis, pixel_snap_paint_axis_allowing_zero,
pixel_snap_paint_rect,
};
pub use source::{
LayoutElementCategory, LayoutElementMetadata, LayoutElementSemantics, LayoutFormControlData,
LayoutFormControlKind, LayoutImageResource, LayoutInputControlKind, LayoutListData,
LayoutListRole, LayoutNamespace, LayoutPseudo, LayoutReplacedKind, LayoutSource,
LayoutSourceKind, LayoutStyleResolver, LayoutTableData, LayoutTableRole, LayoutTextSelection,
ReplacedMetrics, ResolvedLayoutElementStyles, ResolvedLayoutPseudoStyle,
};
pub use style::{
LayoutDisplay, LayoutInlineAlignment, LayoutListMarkerPosition, LayoutListMarkerType,
LayoutPosition, ResolvedLayoutStyle,
};
pub use text::{
DocumentLayoutServices, SystemFontPolicy, WebFontFace, WebFontRegistration,
WebFontRegistrationError, WebFontRegistrationOutcome, WebFontStyle, WebFontUnicodeRange,
};
pub use world::{
LayoutAnonymousReason, LayoutBox, LayoutBoxId, LayoutBoxKind, LayoutCapabilityDiagnostic,
LayoutWorld,
};