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.
§Supported CSS Features
The supported selectors can be found in StyleQuery docs.
The supported media features can be found in MediaQueryStatus docs.
The supported style properties can be found in SUPPORTED_CSS_PROPERTY_NAMES docs.
§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§
- length_
num - General length type utilities.
- parser
- The CSS parser module.
- property
- The list of supported CSS properties.
- query
- Utilities for style queries.
- sheet
- The style sheet data structures.
- typing
- CSS value types for each CSS property.
Macros§
Structs§
- Style
Sheet Group - A group of ordered style sheets.
- Style
Sheet Import Index - Import information of style sheet resources.
- Style
Sheet Resource - Resource manager to store style sheet files.
Constants§
- TEMP_
SHEET_ INDEX - The style sheet index for debugging.
Functions§
- compile_
style_ sheet_ to_ bincode - Serialize CSS to the binary format.
- style_
sheet_ from_ bincode - Deserialize bincode from the binary format.