From ba18c14b91573f1a16907655c00dfb394414001d Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Fri, 17 Mar 2017 12:28:37 +0900 Subject: [PATCH] Split get_animation_rules into get_animation_rule and get_transition_rule. 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. --- components/style/dom.rs | 12 ++++++++++++ components/style/gecko/wrapper.rs | 18 +++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/components/style/dom.rs b/components/style/dom.rs index d4f8d979309..612105c20e9 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -259,6 +259,18 @@ pub trait TElement : PartialEq + Debug + Sized + Copy + Clone + ElementExt + Pre AnimationRules(None, None) } + /// Get this element's animation rule. + fn get_animation_rule(&self, _pseudo: Option<&PseudoElement>) + -> Option>> { + None + } + + /// Get this element's transition rule. + fn get_transition_rule(&self, _pseudo: Option<&PseudoElement>) + -> Option>> { + None + } + /// Get this element's state, for non-tree-structural pseudos. fn get_state(&self) -> ElementState; diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index 86ac901e407..4182685ec49 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -416,12 +416,20 @@ impl<'le> TElement for GeckoElement<'le> { } 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>> { 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>> { + 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 {