pub struct RuleTree {
root: StrongRuleNode,
}
Expand description
The rule tree, the structure servo uses to preserve the results of selector matching.
This is organized as a tree of rules. When a node matches a set of rules, they’re inserted in order in the tree, starting with the less specific one.
When a rule is inserted in the tree, other elements may share the path up to a given rule. If that’s the case, we don’t duplicate child nodes, but share them.
When the rule node refcount drops to zero, it doesn’t get freed. It gets instead put into a free list, and it is potentially GC’d after a while.
That way, a rule node that represents a likely-to-match-again rule (like a :hover rule) can be reused if we haven’t GC’d it yet.
Fields§
§root: StrongRuleNode
Implementations§
source§impl RuleTree
impl RuleTree
sourcepub fn root(&self) -> &StrongRuleNode
pub fn root(&self) -> &StrongRuleNode
Get the root rule node.
fn maybe_dump_stats(&self)
sourceunsafe fn swap_free_list_and_gc(&self, ptr: *mut RuleNode)
unsafe fn swap_free_list_and_gc(&self, ptr: *mut RuleNode)
Steals the free list and drops its contents.
source§impl RuleTree
impl RuleTree
fn dump<W: Write>(&self, guards: &StylesheetGuards<'_>, writer: &mut W)
sourcepub fn dump_stdout(&self, guards: &StylesheetGuards<'_>)
pub fn dump_stdout(&self, guards: &StylesheetGuards<'_>)
Dump the rule tree to stdout.
sourcepub fn insert_ordered_rules_with_important<'a, I>(
&self,
iter: I,
guards: &StylesheetGuards<'_>
) -> StrongRuleNodewhere
I: Iterator<Item = (StyleSource, CascadePriority)>,
pub fn insert_ordered_rules_with_important<'a, I>( &self, iter: I, guards: &StylesheetGuards<'_> ) -> StrongRuleNodewhere I: Iterator<Item = (StyleSource, CascadePriority)>,
Inserts the given rules, that must be in proper order by specifity, and returns the corresponding rule node representing the last inserted one.
!important rules are detected and inserted into the appropriate position in the rule tree. This allows selector matching to ignore importance, while still maintaining the appropriate cascade order in the rule tree.
sourcepub fn compute_rule_node(
&self,
applicable_declarations: &mut ApplicableDeclarationList,
guards: &StylesheetGuards<'_>
) -> StrongRuleNode
pub fn compute_rule_node( &self, applicable_declarations: &mut ApplicableDeclarationList, guards: &StylesheetGuards<'_> ) -> StrongRuleNode
Given a list of applicable declarations, insert the rules and return the corresponding rule node.
sourcepub fn insert_ordered_rules<'a, I>(&self, iter: I) -> StrongRuleNodewhere
I: Iterator<Item = (StyleSource, CascadePriority)>,
pub fn insert_ordered_rules<'a, I>(&self, iter: I) -> StrongRuleNodewhere I: Iterator<Item = (StyleSource, CascadePriority)>,
Insert the given rules, that must be in proper order by specifity, and return the corresponding rule node representing the last inserted one.
fn insert_ordered_rules_from<'a, I>( &self, from: StrongRuleNode, iter: I ) -> StrongRuleNodewhere I: Iterator<Item = (StyleSource, CascadePriority)>,
sourcepub fn update_rule_at_level(
&self,
level: CascadeLevel,
layer_order: LayerOrder,
pdb: Option<ArcBorrow<'_, Locked<PropertyDeclarationBlock>>>,
path: &StrongRuleNode,
guards: &StylesheetGuards<'_>,
important_rules_changed: &mut bool
) -> Option<StrongRuleNode>
pub fn update_rule_at_level( &self, level: CascadeLevel, layer_order: LayerOrder, pdb: Option<ArcBorrow<'_, Locked<PropertyDeclarationBlock>>>, path: &StrongRuleNode, guards: &StylesheetGuards<'_>, important_rules_changed: &mut bool ) -> Option<StrongRuleNode>
Replaces a rule in a given level (if present) for another rule.
Returns the resulting node that represents the new path, or None if the old path is still valid.
sourcepub fn remove_transition_rule_if_applicable(
&self,
path: &StrongRuleNode
) -> StrongRuleNode
pub fn remove_transition_rule_if_applicable( &self, path: &StrongRuleNode ) -> StrongRuleNode
Returns new rule nodes without Transitions level rule.
sourcepub fn remove_animation_rules(&self, path: &StrongRuleNode) -> StrongRuleNode
pub fn remove_animation_rules(&self, path: &StrongRuleNode) -> StrongRuleNode
Returns new rule node without rules from declarative animations.