mirror of
https://github.com/servo/servo.git
synced 2025-06-24 00:54:32 +01:00
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:
parent
96d6b30eff
commit
d30c4fe79d
3 changed files with 60 additions and 21 deletions
|
@ -6,12 +6,12 @@
|
||||||
|
|
||||||
use context::SharedStyleContext;
|
use context::SharedStyleContext;
|
||||||
use dom::TElement;
|
use dom::TElement;
|
||||||
use properties::ComputedValues;
|
use properties::{ComputedValues, PropertyDeclarationBlock};
|
||||||
use properties::longhands::display::computed_value as display;
|
use properties::longhands::display::computed_value as display;
|
||||||
use restyle_hints::{HintComputationContext, RestyleReplacements, RestyleHint};
|
use restyle_hints::{HintComputationContext, RestyleReplacements, RestyleHint};
|
||||||
use rule_tree::StrongRuleNode;
|
use rule_tree::StrongRuleNode;
|
||||||
use selector_parser::{EAGER_PSEUDO_COUNT, PseudoElement, RestyleDamage};
|
use selector_parser::{EAGER_PSEUDO_COUNT, PseudoElement, RestyleDamage};
|
||||||
use shared_lock::StylesheetGuards;
|
use shared_lock::{Locked, StylesheetGuards};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use stylearc::Arc;
|
use stylearc::Arc;
|
||||||
use traversal::TraversalFlags;
|
use traversal::TraversalFlags;
|
||||||
|
@ -558,4 +558,17 @@ impl ElementData {
|
||||||
pub fn restyle_mut(&mut self) -> &mut RestyleData {
|
pub fn restyle_mut(&mut self) -> &mut RestyleData {
|
||||||
self.get_restyle_mut().expect("Calling restyle_mut without RestyleData")
|
self.get_restyle_mut().expect("Calling restyle_mut without RestyleData")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns SMIL overriden value if exists.
|
||||||
|
pub fn get_smil_override(&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;
|
||||||
|
}
|
||||||
|
|
||||||
|
match self.get_styles() {
|
||||||
|
Some(s) => s.primary.rules.get_smil_animation_rule(),
|
||||||
|
None => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -736,30 +736,32 @@ pub trait MatchMethods : TElement {
|
||||||
|
|
||||||
let stylist = &context.shared.stylist;
|
let stylist = &context.shared.stylist;
|
||||||
let style_attribute = self.style_attribute();
|
let style_attribute = self.style_attribute();
|
||||||
let smil_override = self.get_smil_override();
|
{
|
||||||
let animation_rules = self.get_animation_rules();
|
let smil_override = data.get_smil_override();
|
||||||
let bloom = context.thread_local.bloom_filter.filter();
|
let animation_rules = self.get_animation_rules();
|
||||||
|
let bloom = context.thread_local.bloom_filter.filter();
|
||||||
|
|
||||||
|
|
||||||
let map = &mut context.thread_local.selector_flags;
|
let map = &mut context.thread_local.selector_flags;
|
||||||
let mut set_selector_flags = |element: &Self, flags: ElementSelectorFlags| {
|
let mut set_selector_flags = |element: &Self, flags: ElementSelectorFlags| {
|
||||||
self.apply_selector_flags(map, element, flags);
|
self.apply_selector_flags(map, element, flags);
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut matching_context =
|
let mut matching_context =
|
||||||
MatchingContext::new(MatchingMode::Normal, Some(bloom));
|
MatchingContext::new(MatchingMode::Normal, Some(bloom));
|
||||||
|
|
||||||
// Compute the primary rule node.
|
// Compute the primary rule node.
|
||||||
stylist.push_applicable_declarations(self,
|
stylist.push_applicable_declarations(self,
|
||||||
implemented_pseudo.as_ref(),
|
implemented_pseudo.as_ref(),
|
||||||
style_attribute,
|
style_attribute,
|
||||||
smil_override,
|
smil_override,
|
||||||
animation_rules,
|
animation_rules,
|
||||||
&mut applicable_declarations,
|
&mut applicable_declarations,
|
||||||
&mut matching_context,
|
&mut matching_context,
|
||||||
&mut set_selector_flags);
|
&mut set_selector_flags);
|
||||||
|
|
||||||
*relations = matching_context.relations;
|
*relations = matching_context.relations;
|
||||||
|
}
|
||||||
|
|
||||||
let primary_rule_node =
|
let primary_rule_node =
|
||||||
compute_rule_node::<Self>(stylist.rule_tree(),
|
compute_rule_node::<Self>(stylist.rule_tree(),
|
||||||
|
|
|
@ -1128,6 +1128,30 @@ impl StrongRuleNode {
|
||||||
}
|
}
|
||||||
result
|
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.
|
/// An iterator over a rule node and its ancestors.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue