mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Add a function that returns new rules by removing transition and animation level rules.
This will be used for additive animations and SMIL.
This commit is contained in:
parent
959f1c8360
commit
aa6433b6d6
1 changed files with 28 additions and 0 deletions
|
@ -249,6 +249,27 @@ impl RuleTree {
|
||||||
|
|
||||||
path.parent().unwrap().clone()
|
path.parent().unwrap().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns new rule node without Animations and Transitions level rules.
|
||||||
|
pub fn remove_animation_and_transition_rules(&self, path: &StrongRuleNode) -> StrongRuleNode {
|
||||||
|
// Return a clone if there is neither animation nor transition level.
|
||||||
|
if !path.has_animation_or_transition_rules() {
|
||||||
|
return path.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
let iter = path.self_and_ancestors().take_while(|node| node.cascade_level() >= CascadeLevel::Animations);
|
||||||
|
let mut last = path;
|
||||||
|
let mut children = vec![];
|
||||||
|
for node in iter {
|
||||||
|
if node.cascade_level() != CascadeLevel::Animations &&
|
||||||
|
node.cascade_level() != CascadeLevel::Transitions {
|
||||||
|
children.push((node.get().source.clone().unwrap(), node.cascade_level()));
|
||||||
|
}
|
||||||
|
last = node;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.insert_ordered_rules_from(last.parent().unwrap().clone(), children.into_iter().rev())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The number of RuleNodes added to the free list before we will consider
|
/// The number of RuleNodes added to the free list before we will consider
|
||||||
|
@ -738,6 +759,13 @@ impl StrongRuleNode {
|
||||||
self.gc();
|
self.gc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns true if there is either animation or transition level rule.
|
||||||
|
pub fn has_animation_or_transition_rules(&self) -> bool {
|
||||||
|
self.self_and_ancestors()
|
||||||
|
.take_while(|node| node.cascade_level() >= CascadeLevel::Animations)
|
||||||
|
.any(|node| matches!(node.cascade_level(), CascadeLevel::Animations | CascadeLevel::Transitions))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An iterator over a rule node and its ancestors.
|
/// An iterator over a rule node and its ancestors.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue