Crate float_pigment_css

Source
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:

  1. Create a StyleSheetGroup.
  2. Parsing CSS text into a StyleSheet and added to the StyleSheetGroup.
  3. Create a StyleQuery.
  4. Run the StyleQuery with StyleSheetGroup::query_matched_rules and get a MatchedRuleList.
  5. Create a NodeProperties with NodeProperties::new.
  6. Merge the MatchedRuleList into NodeProperties with MatchedRuleList::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§

check_null
raw_ptr_as_mut_ref

Structs§

StyleSheetGroup
A group of ordered style sheets.
StyleSheetImportIndex
Import information of style sheet resources.
StyleSheetResource
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.