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<'_>,
) -> StrongRuleNode
pub fn insert_ordered_rules_with_important<'a, I>( &self, iter: I, guards: &StylesheetGuards<'_>, ) -> StrongRuleNode
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) -> StrongRuleNode
pub fn insert_ordered_rules<'a, I>(&self, iter: I) -> StrongRuleNode
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, ) -> StrongRuleNode
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.
Trait Implementations§
source§impl MallocSizeOf for RuleTree
impl MallocSizeOf for RuleTree
source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Auto Trait Implementations§
impl Freeze for RuleTree
impl !RefUnwindSafe for RuleTree
impl Send for RuleTree
impl Sync for RuleTree
impl Unpin for RuleTree
impl !UnwindSafe for RuleTree
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more