diff options
Diffstat (limited to 'components/style/rule_tree/mod.rs')
-rw-r--r-- | components/style/rule_tree/mod.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/components/style/rule_tree/mod.rs b/components/style/rule_tree/mod.rs index 866eb9adab9..bb13836c2a6 100644 --- a/components/style/rule_tree/mod.rs +++ b/components/style/rule_tree/mod.rs @@ -16,6 +16,7 @@ use std::ptr; use std::sync::atomic::{AtomicPtr, AtomicUsize, Ordering}; use stylearc::Arc; use stylesheets::StyleRule; +use stylist::ApplicableDeclarationList; use thread_state; /// The rule tree, the structure servo uses to preserve the results of selector @@ -215,6 +216,18 @@ impl RuleTree { current } + /// Given a list of applicable declarations, insert the rules and return the + /// corresponding rule node. + pub fn compute_rule_node(&self, + applicable_declarations: &mut ApplicableDeclarationList, + guards: &StylesheetGuards) + -> StrongRuleNode + { + let rules = applicable_declarations.drain().map(|d| (d.source, d.level)); + let rule_node = self.insert_ordered_rules_with_important(rules, guards); + rule_node + } + /// Insert the given rules, that must be in proper order by specifity, and /// return the corresponding rule node representing the last inserted one. pub fn insert_ordered_rules<'a, I>(&self, iter: I) -> StrongRuleNode @@ -632,6 +645,8 @@ struct WeakRuleNode { /// A strong reference to a rule node. #[derive(Debug, PartialEq)] pub struct StrongRuleNode { + // TODO: Mark this as NonZero once stable to save space inside Option. + // https://github.com/rust-lang/rust/issues/27730 ptr: *mut RuleNode, } |