Milky2018/css/cascade does not have a README file

    CSSRule

    pub struct CSSRule {
    selector_text : String
    selector :
    ComplexSelector

    declarations : Array[Declaration]
    source_order : Int
    media_query :
    MediaQueryList
    ?
    }

    A CSS rule: selector + declarations

    CascadedValues

    pub struct CascadedValues {
    values : Map[String, Declaration]
    }

    Cascaded values for an element Maps property names to their winning declaration

    CascadedValues::each

    fn CascadedValues::each(self : CascadedValues, f : (String, Declaration) -> Unit) -> Unit

    Iterate cascaded declarations without allocating an intermediate key array.

    CascadedValues::get

    fn CascadedValues::get(self : CascadedValues, property : String) -> Declaration?

    Get the cascaded value for a property

    CascadedValues::get_value

    fn CascadedValues::get_value(self : CascadedValues, property : String) -> String?

    Get the raw value string for a property

    CascadedValues::has

    fn CascadedValues::has(self : CascadedValues, property : String) -> Bool

    Check if a property has a cascaded value

    CascadedValues::new

    CascadedValues::properties

    fn CascadedValues::properties(self : CascadedValues) -> Array[String]

    Get all property names that have cascaded values

    Declaration

    pub(all) struct Declaration {
    property : String
    value : PropertyValue
    origin : Origin
    importance : Importance
    specificity :
    Specificity

    source_order : Int
    }

    A CSS declaration with cascade metadata
    impl Show for Declaration

    Declaration::from_inline

    fn Declaration::from_inline(property : String, value : String, importance : Importance) -> Declaration

    Create a declaration from inline style (highest specificity)

    Declaration::new

    fn Declaration::new(property : String, value : String) -> Declaration

    Create a new declaration with default values

    Declaration::output

    fn Declaration::output(self : Declaration, logger : &Logger) -> Unit

    Declaration::to_string

    fn Declaration::to_string(self : Declaration) -> String

    Declaration::with_metadata

    fn Declaration::with_metadata(property : String, value : PropertyValue, origin : Origin, importance : Importance, specificity :
    Specificity
    , source_order : Int) -> Declaration

    Create a declaration with full metadata

    ImportRule

    pub(all) struct ImportRule {
    href : String
    media : String
    }

    A parsed @import rule. Fetching and recursively parsing the referenced stylesheet remains the embedding application's responsibility.

    Importance

    pub(all) enum Importance {
    Normal
    Important
    }

    Importance of a declaration
    impl Show for Importance

    Importance::output

    fn Importance::output(self : Importance, logger : &Logger) -> Unit

    Importance::to_string

    fn Importance::to_string(self : Importance) -> String

    IndexedStylesheet

    pub struct IndexedStylesheet {
    stylesheet : Stylesheet
    index : SelectorIndex
    }

    Indexed stylesheet for fast matching

    IndexedStylesheet::match_element

    Match all rules against an element using the index

    IndexedStylesheet::match_element_with_media

    Match all rules against an element with media query evaluation using the index

    IndexedStylesheet::new

    KeyframeBlock

    pub(all) struct KeyframeBlock {
    offsets : Array[Double]
    declarations : Array[Declaration]
    }

    One keyframe block inside an @keyframes rule: a set of offsets (the from / to / <percentage> selectors, normalized to [0, 1]) sharing the same declarations.

    KeyframesRule

    pub(all) struct KeyframesRule {
    name : String
    blocks : Array[KeyframeBlock]
    }

    A parsed @keyframes at-rule.

    Origin

    pub(all) enum Origin {
    UserAgent
    User
    Author
    }

    Origin of a CSS declaration Ordered from lowest to highest precedence for normal declarations
    impl Show for Origin

    Origin::output

    fn Origin::output(self : Origin, logger : &Logger) -> Unit

    Origin::to_string

    fn Origin::to_string(self : Origin) -> String

    PropertyValue

    pub(all) enum PropertyValue {
    Value(String)
    Inherit
    Initial
    Unset
    Revert
    RevertLayer
    }

    A CSS property value that can be a specific value or a keyword

    PropertyValue::from_css_text

    fn PropertyValue::from_css_text(value : String) -> PropertyValue

    Parse a declaration value, preserving CSS-wide keywords for computed-value resolution instead of treating them as property-specific strings.

    PropertyValue::output

    fn PropertyValue::output(self : PropertyValue, logger : &Logger) -> Unit

    PropertyValue::to_string

    fn PropertyValue::to_string(self : PropertyValue) -> String

    RuleMatch

    pub(all) struct RuleMatch {
    specificity :
    Specificity

    declarations : Array[Declaration]
    source_order : Int
    }

    Collect declarations from matching rules for an element This is a helper to build the input for cascade()

    SelectorIndex

    pub(all) struct SelectorIndex {
    by_id : Map[String, Array[Int]]
    by_class : Map[String, Array[Int]]
    by_tag : Map[String, Array[Int]]
    universal : Array[Int]
    }

    Index for fast rule lookup Rules are indexed by the rightmost compound selector's:
    • ID selectors
    • Class selectors
    • Tag name
    • Universal selectors (matched against all elements)

    SelectorIndex::from_stylesheet

    fn SelectorIndex::from_stylesheet(stylesheet : Stylesheet) -> SelectorIndex

    Build index for a stylesheet

    SelectorIndex::get_candidates

    fn SelectorIndex::get_candidates(self : SelectorIndex, element :
    Element
    ) -> Array[Int]

    Get candidate rule indices for an element Returns indices of rules that might match (need full selector check)

    SelectorIndex::new

    Stylesheet

    pub struct Stylesheet {
    imports : Array[ImportRule]
    rules : Array[CSSRule]
    keyframes : Array[KeyframesRule]
    origin : Origin
    cached_index : SelectorIndex?
    }

    A stylesheet: collection of rules

    Stylesheet::add_import

    fn Stylesheet::add_import(self : Stylesheet, import_rule : ImportRule) -> Unit

    Stylesheet::add_keyframes

    fn Stylesheet::add_keyframes(self : Stylesheet, rule : KeyframesRule) -> Unit

    Add a parsed @keyframes rule to the stylesheet.

    Stylesheet::add_rule

    fn Stylesheet::add_rule(self : Stylesheet, selector_text : String, selector :
    ComplexSelector
    , declarations : Array[Declaration]) -> Unit

    Add a rule to the stylesheet

    Stylesheet::add_rule_with_media

    fn Stylesheet::add_rule_with_media(self : Stylesheet, selector_text : String, selector :
    ComplexSelector
    , declarations : Array[Declaration], media_query :
    MediaQueryList
    ) -> Unit

    Add a rule with a media query to the stylesheet

    Stylesheet::find_keyframes

    fn Stylesheet::find_keyframes(self : Stylesheet, name : String) -> KeyframesRule?

    Find the last @keyframes rule with the given name (later rules win, per the CSS cascade). Returns None if no such rule exists.

    Stylesheet::match_element

    Match all rules against an element and return matched rules

    Stylesheet::match_element_with_media

    Match all rules against an element with media query evaluation. Uses the stylesheet's cached selector index to prune rule candidates — large stylesheets see ~30× speedup vs scanning every rule.

    Stylesheet::new

    fn Stylesheet::new(origin : Origin) -> Stylesheet

    cascade

    fn cascade(declarations : Array[Declaration]) -> CascadedValues

    Cascade a list of declarations into final values Declarations should be for a single element

    cascade_element

    fn cascade_element(element :
    Element
    , stylesheets : Array[Stylesheet], inline_style : Array[Declaration]) -> CascadedValues

    Cascade styles for an element from multiple stylesheets

    cascade_element_indexed

    Cascade styles using indexed stylesheets for better performance

    cascade_element_with_forced_states

    Cascade styles for an element with forced pseudo-class states. This evaluates CSS rules as if the specified pseudo-class states (:hover, :focus, :active) were active on the element.

    cascade_element_with_media

    fn cascade_element_with_media(element :
    Element
    , stylesheets : Array[Stylesheet], inline_style : Array[Declaration], media_env :
    MediaEnvironment
    ?) -> CascadedValues

    Cascade styles for an element with media query evaluation

    cascade_element_with_media_and_validator

    fn cascade_element_with_media_and_validator(element :
    Element
    , stylesheets : Array[Stylesheet], inline_style : Array[Declaration], media_env :
    MediaEnvironment
    ?, declaration_is_valid : (String, PropertyValue) -> Bool) -> CascadedValues

    Cascade styles while allowing an embedding language to reject declarations for extension properties before they can win the cascade.

    cascade_element_with_media_forced_and_validator

    fn cascade_element_with_media_forced_and_validator(element :
    Element
    , stylesheets : Array[Stylesheet], inline_style : Array[Declaration], media_env :
    MediaEnvironment
    ?, forced :
    ForcedPseudoStates
    , declaration_is_valid : (String, PropertyValue) -> Bool) -> CascadedValues

    Cascade styles with media queries, a static pseudo-class state, and an embedding-language declaration validator.