Bug 1340958 - Split get_animation_rules into get_animation_rule and get_transition_rule. r?heycam
If an element has only CSS animations we don't need to get transition rule,
and vice versa. This will be used when we implement eRestyle_CSSAnimations
and eRestyle_CSSTransitions.
MozReview-Commit-ID: 6Z9d9s1Fiar
--- a/servo/components/style/dom.rs
+++ b/servo/components/style/dom.rs
@@ -254,16 +254,28 @@ pub trait TElement : PartialEq + Debug +
/// Get this element's style attribute.
fn style_attribute(&self) -> Option<&Arc<RwLock<PropertyDeclarationBlock>>>;
/// Get this element's animation rules.
fn get_animation_rules(&self, _pseudo: Option<&PseudoElement>) -> AnimationRules {
AnimationRules(None, None)
}
+ /// Get this element's animation rule.
+ fn get_animation_rule(&self, _pseudo: Option<&PseudoElement>)
+ -> Option<Arc<RwLock<PropertyDeclarationBlock>>> {
+ None
+ }
+
+ /// Get this element's transition rule.
+ fn get_transition_rule(&self, _pseudo: Option<&PseudoElement>)
+ -> Option<Arc<RwLock<PropertyDeclarationBlock>>> {
+ None
+ }
+
/// Get this element's state, for non-tree-structural pseudos.
fn get_state(&self) -> ElementState;
/// Whether this element has an attribute with a given namespace.
fn has_attr(&self, namespace: &Namespace, attr: &LocalName) -> bool;
/// Whether an attribute value equals `value`.
fn attr_equals(&self, namespace: &Namespace, attr: &LocalName, value: &Atom) -> bool;
--- a/servo/components/style/gecko/wrapper.rs
+++ b/servo/components/style/gecko/wrapper.rs
@@ -411,22 +411,30 @@ impl<'le> TElement for GeckoElement<'le>
}
fn style_attribute(&self) -> Option<&Arc<RwLock<PropertyDeclarationBlock>>> {
let declarations = unsafe { Gecko_GetStyleAttrDeclarationBlock(self.0) };
declarations.map(|s| s.as_arc_opt()).unwrap_or(None)
}
fn get_animation_rules(&self, pseudo: Option<&PseudoElement>) -> AnimationRules {
+ AnimationRules(self.get_animation_rule(pseudo),
+ self.get_transition_rule(pseudo))
+ }
+
+ fn get_animation_rule(&self, pseudo: Option<&PseudoElement>)
+ -> Option<Arc<RwLock<PropertyDeclarationBlock>>> {
let atom_ptr = PseudoElement::ns_atom_or_null_from_opt(pseudo);
- unsafe {
- AnimationRules(
- Gecko_GetAnimationRule(self.0, atom_ptr, CascadeLevel::Animations).into_arc_opt(),
- Gecko_GetAnimationRule(self.0, atom_ptr, CascadeLevel::Transitions).into_arc_opt())
- }
+ unsafe { Gecko_GetAnimationRule(self.0, atom_ptr, CascadeLevel::Animations).into_arc_opt() }
+ }
+
+ fn get_transition_rule(&self, pseudo: Option<&PseudoElement>)
+ -> Option<Arc<RwLock<PropertyDeclarationBlock>>> {
+ let atom_ptr = PseudoElement::ns_atom_or_null_from_opt(pseudo);
+ unsafe { Gecko_GetAnimationRule(self.0, atom_ptr, CascadeLevel::Transitions).into_arc_opt() }
}
fn get_state(&self) -> ElementState {
unsafe {
ElementState::from_bits_truncate(Gecko_ElementState(self.0))
}
}