aboutsummaryrefslogtreecommitdiffstats
path: root/components/style/rule_tree/mod.rs
diff options
context:
space:
mode:
authorBobby Holley <bobbyholley@gmail.com>2017-02-08 15:38:35 -0800
committerBobby Holley <bobbyholley@gmail.com>2017-02-10 10:34:28 -0800
commit0e3aeac9222262ce33d20ad0f2311e49d7dd59af (patch)
tree11c23aed0ad9188c28d47a46e8f070b0585abc5b /components/style/rule_tree/mod.rs
parent5873de3fb670bdcf38af0375a217b888d92220b2 (diff)
downloadservo-0e3aeac9222262ce33d20ad0f2311e49d7dd59af.tar.gz
servo-0e3aeac9222262ce33d20ad0f2311e49d7dd59af.zip
Stop returning rule nodes from match_element and overhaul style calculation logic.
Diffstat (limited to 'components/style/rule_tree/mod.rs')
-rw-r--r--components/style/rule_tree/mod.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/components/style/rule_tree/mod.rs b/components/style/rule_tree/mod.rs
index c93ff94a841..77cf7d17697 100644
--- a/components/style/rule_tree/mod.rs
+++ b/components/style/rule_tree/mod.rs
@@ -183,12 +183,13 @@ impl RuleTree {
/// Replaces a rule in a given level (if present) for another rule.
///
- /// Returns the resulting node that represents the new path.
+ /// Returns the resulting node that represents the new path, or None if
+ /// the old path is still valid.
pub fn update_rule_at_level(&self,
level: CascadeLevel,
pdb: Option<&Arc<RwLock<PropertyDeclarationBlock>>>,
- path: StrongRuleNode)
- -> StrongRuleNode {
+ path: &StrongRuleNode)
+ -> Option<StrongRuleNode> {
debug_assert!(level.is_unique_per_element());
// TODO(emilio): Being smarter with lifetimes we could avoid a bit of
// the refcount churn.
@@ -231,7 +232,7 @@ impl RuleTree {
if is_here_already {
debug!("Picking the fast path in rule replacement");
- return path;
+ return None;
}
}
current = current.parent().unwrap().clone();
@@ -262,7 +263,7 @@ impl RuleTree {
// Now the rule is in the relevant place, push the children as
// necessary.
- self.insert_ordered_rules_from(current, children.into_iter().rev())
+ Some(self.insert_ordered_rules_from(current, children.into_iter().rev()))
}
}
@@ -501,7 +502,7 @@ struct WeakRuleNode {
}
/// A strong reference to a rule node.
-#[derive(Debug)]
+#[derive(Debug, PartialEq)]
pub struct StrongRuleNode {
ptr: *mut RuleNode,
}