Struct style::rule_tree::RuleTree
[−]
[src]
pub struct RuleTree { /* fields omitted */ }
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 in a single-threaded fashion.
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.
See the discussion at https://github.com/servo/servo/pull/15562 and the IRC logs at http://logs.glob.uno/?c=mozilla%23servo&s=3+Apr+2017&e=3+Apr+2017 logs from http://logs.glob.uno/?c=mozilla%23servo&s=3+Apr+2017&e=3+Apr+2017#c644094 to se a discussion about the different memory orderings used here.
Methods
impl RuleTree
[src]
pub fn new() -> Self
[src]
Construct a new rule tree.
pub fn root(&self) -> &StrongRuleNode
[src]
Get the root rule node.
pub fn dump_stdout(&self, guards: &StylesheetGuards)
[src]
Dump the rule tree to stdout.
pub fn insert_ordered_rules_with_important<'a, I>(
&self,
iter: I,
guards: &StylesheetGuards
) -> StrongRuleNode where
I: Iterator<Item = (StyleSource, CascadeLevel)>,
[src]
&self,
iter: I,
guards: &StylesheetGuards
) -> StrongRuleNode where
I: Iterator<Item = (StyleSource, CascadeLevel)>,
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.
pub fn compute_rule_node(
&self,
applicable_declarations: &mut ApplicableDeclarationList,
guards: &StylesheetGuards
) -> StrongRuleNode
[src]
&self,
applicable_declarations: &mut ApplicableDeclarationList,
guards: &StylesheetGuards
) -> StrongRuleNode
Given a list of applicable declarations, insert the rules and return the corresponding rule node.
pub fn insert_ordered_rules<'a, I>(&self, iter: I) -> StrongRuleNode where
I: Iterator<Item = (StyleSource, CascadeLevel)>,
[src]
I: Iterator<Item = (StyleSource, CascadeLevel)>,
Insert the given rules, that must be in proper order by specifity, and return the corresponding rule node representing the last inserted one.
pub unsafe fn gc(&self)
[src]
This can only be called when no other threads is accessing this tree.
pub unsafe fn maybe_gc(&self)
[src]
This can only be called when no other threads is accessing this tree.
pub fn update_rule_at_level(
&self,
level: CascadeLevel,
pdb: Option<ArcBorrow<Locked<PropertyDeclarationBlock>>>,
path: &StrongRuleNode,
guards: &StylesheetGuards,
important_rules_changed: &mut bool
) -> Option<StrongRuleNode>
[src]
&self,
level: CascadeLevel,
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.
pub fn remove_transition_rule_if_applicable(
&self,
path: &StrongRuleNode
) -> StrongRuleNode
[src]
&self,
path: &StrongRuleNode
) -> StrongRuleNode
Returns new rule nodes without Transitions level rule.
pub fn remove_animation_rules(&self, path: &StrongRuleNode) -> StrongRuleNode
[src]
Returns new rule node without rules from declarative animations.
pub fn add_animation_rules_at_transition_level(
&self,
path: &StrongRuleNode,
pdb: Arc<Locked<PropertyDeclarationBlock>>,
guards: &StylesheetGuards
) -> StrongRuleNode
[src]
&self,
path: &StrongRuleNode,
pdb: Arc<Locked<PropertyDeclarationBlock>>,
guards: &StylesheetGuards
) -> StrongRuleNode
Returns new rule node by adding animation rules at transition level. The additional rules must be appropriate for the transition level of the cascade, which is the highest level of the cascade. (This is the case for one current caller, the cover rule used for CSS transitions.)
Trait Implementations
impl Debug for RuleTree
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl MallocSizeOf for RuleTree
[src]
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
[src]
Measure the heap usage of all descendant heap-allocated structures, but not the space taken up by the value itself. Read more