Expand description
CSS parser with a style sheet manager.
Note: it is not a full web-compatible CSS parser because it supports a subset of CSS selectors and properties.
§Main Workflow
The CSS parser is designed to be used in high-level UI frameworks. The main workflow:
- Create a
StyleSheetGroup
. - Parsing CSS text into a
StyleSheet
and added to theStyleSheetGroup
. - Create a
StyleQuery
. - Run the
StyleQuery
withStyleSheetGroup::query_matched_rules
and get aMatchedRuleList
. - Create a
NodeProperties
withNodeProperties::new
. - Merge the
MatchedRuleList
intoNodeProperties
withMatchedRuleList::merge_node_properties
.
The result NodeProperties
contains all supported CSS properties.
§The Binary Format
The StyleSheet
can be serialized into a specialized “bincode” format. (Note that it is not the same format as the bincode
crate.)
This binary format can be deserialized with great performance, so it can be used as the cache of static style sheet text.
It also has compatibilities across different versions of this crate.
Re-exports§
pub use sheet::LinkedStyleSheet;
pub use sheet::StyleSheet;
pub use query::EnvValues;
pub use query::MediaQueryStatus;
pub use query::StyleQuery;
pub use fixed;
pub use num_traits;
Modules§
- General length type utilities.
- The CSS parser module.
- The list of supported CSS properties.
- Utilities for style queries.
- The style sheet data structures.
- CSS value types for each CSS property.
Structs§
- A group of ordered style sheets.
- Import information of style sheet resources.
- Resource manager to store style sheet files.
Constants§
- The style sheet index for debugging.
Functions§
- Serialize CSS to the binary format.
- Deserialize bincode from the binary format.