muskitty_cascade/lib.rs
1//! MusKitty Cascade — CSS Cascade Level 5 引擎。
2//!
3//! 实现 CSS Cascade Level 5 的核心算法:从 DOM 树 + 多源
4//! CSSStyleSheet 列表 → 每元素每属性的 computed value。
5//!
6//! # 数据流
7//!
8//! ```text
9//! DOM 树 + CssStyleSheet[] (带 origin 元数据)
10//! │ §5 Filtering
11//! ▼
12//! DeclaredValue[] (每元素每属性,无序)
13//! │ §6.1 Cascade 排序
14//! ▼
15//! DeclaredValue[] (有序,按 7 准则降序)
16//! │ 取首项 → §4.2 Cascaded Value
17//! ▼
18//! │ §4.3 + §7 Defaulting (initial/inherit/unset)
19//! ▼
20//! SpecifiedValue
21//! │ §4.4 Computed Value (相对单位解析、var() 求值)
22//! ▼
23//! ComputedValue
24//! ```
25//!
26//! # 规范依据
27//!
28//! - CSS Cascade Level 5: `d:\csswg\css-cascade-5\Overview.md`
29//! - CSS Variables Level 1: `d:\csswg\css-variables-1\Overview.md`
30//!
31//! # 快速上手
32//!
33//! ```no_run
34//! use muskitty_cascade::collect_declared_values;
35//! use muskitty_cssom::CssStyleSheet;
36//! use muskitty_selectors::matching::DomElement;
37//! use muskitty_dom::Node;
38//! use std::rc::Rc;
39//! use std::cell::RefCell;
40//!
41//! // let element = DomElement::new(Rc::clone(&node));
42//! // let sheets: Vec<CssStyleSheet> = Vec::new();
43//! // let declared = collect_declared_values(&element, &sheets);
44//! ```
45
46pub mod cascade;
47pub mod compute;
48pub mod custom_properties;
49pub mod defaulting;
50pub mod filter;
51pub mod origin;
52pub mod registry;
53pub mod style;
54pub mod style_tree;
55pub mod text_props;
56
57pub use cascade::{cascade_for_element, cascade_winner};
58pub use compute::{compute_value, compute_value_with, ComputeContext, CustomPropertySource};
59pub use custom_properties::collect_custom_properties;
60pub use defaulting::apply_defaulting;
61pub use filter::{
62 collect_declared_values, collect_declared_values_prepared, prepare_sheets,
63 prepare_sheets_with_context, MediaContext, PreparedSheets,
64};
65pub use origin::Origin;
66pub use registry::{lookup_property, PropertyDefinition, BUILTIN_PROPERTIES};
67pub use style::{ComputedStyle, ComputedValue, DeclaredValue};
68pub use style_tree::{compute_styles, StyleTreeOptions};
69pub use text_props::{
70 apply_text_transform, text_transform_keyword, used_line_height_px, NORMAL_LINE_HEIGHT,
71};