Use SMIL override value that has been processed during animation-only restyles for normal restyle.

In the case where we process an element which has SMIL animations in normal travesal
the SMIL styles must have been computed in animation-only restyles. So we
have only to pick the computed styles instead of recomputing it.
This commit is contained in:
Hiroyuki Ikezoe 2017-05-24 11:11:25 +09:00
parent 96d6b30eff
commit d30c4fe79d
3 changed files with 60 additions and 21 deletions

View file

@ -1128,6 +1128,30 @@ impl StrongRuleNode {
}
result
}
/// Returns PropertyDeclarationBlock for this node.
/// This function must be called only for animation level node.
fn get_animation_style(&self) -> &Arc<Locked<PropertyDeclarationBlock>> {
debug_assert!(self.cascade_level().is_animation(),
"The cascade level should be an animation level");
match *self.style_source().unwrap() {
StyleSource::Declarations(ref block) => block,
StyleSource::Style(_) => unreachable!("animating style should not be a style rule"),
}
}
/// Returns SMIL override declaration block if exists.
pub fn get_smil_animation_rule(&self) -> Option<&Arc<Locked<PropertyDeclarationBlock>>> {
if cfg!(feature = "servo") {
// Servo has no knowledge of a SMIL rule, so just avoid looking for it.
return None;
}
self.self_and_ancestors()
.take_while(|node| node.cascade_level() >= CascadeLevel::SMILOverride)
.find(|node| node.cascade_level() == CascadeLevel::SMILOverride)
.map(|node| node.get_animation_style())
}
}
/// An iterator over a rule node and its ancestors.