diff --git a/components/script/layout_wrapper.rs b/components/script/layout_wrapper.rs index aa93b38fd45..872cf913d9f 100644 --- a/components/script/layout_wrapper.rs +++ b/components/script/layout_wrapper.rs @@ -455,6 +455,10 @@ impl<'le> TElement for ServoLayoutElement<'le> { panic!("this should be only called on gecko"); } + fn has_animations(&self, _pseudo: Option<&PseudoElement>) -> bool { + panic!("this should be only called on gecko"); + } + fn has_css_animations(&self, _pseudo: Option<&PseudoElement>) -> bool { panic!("this should be only called on gecko"); } diff --git a/components/style/dom.rs b/components/style/dom.rs index cf64e2da6b8..4301c1d3b8e 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -370,6 +370,11 @@ pub trait TElement : PartialEq + Debug + Sized + Copy + Clone + ElementExt + Pre /// Note: Gecko only. fn update_animations(&self, _pseudo: Option<&PseudoElement>); + /// Returns true if the element has relevant animations. Relevant + /// animations are those animations that are affecting the element's style + /// or are scheduled to do so in the future. + fn has_animations(&self, _pseudo: Option<&PseudoElement>) -> bool; + /// Returns true if the element has a CSS animation. fn has_css_animations(&self, _pseudo: Option<&PseudoElement>) -> bool; diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index 3b0c5bf6cdb..ab58dd53fa1 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -30,6 +30,7 @@ use gecko_bindings::bindings::{Gecko_IsLink, Gecko_IsRootElement, Gecko_MatchesE use gecko_bindings::bindings::{Gecko_IsUnvisitedLink, Gecko_IsVisitedLink, Gecko_Namespace}; use gecko_bindings::bindings::{Gecko_SetNodeFlags, Gecko_UnsetNodeFlags}; use gecko_bindings::bindings::Gecko_ClassOrClassList; +use gecko_bindings::bindings::Gecko_ElementHasAnimations; use gecko_bindings::bindings::Gecko_ElementHasCSSAnimations; use gecko_bindings::bindings::Gecko_GetAnimationRule; use gecko_bindings::bindings::Gecko_GetHTMLPresentationAttrDeclarationBlock; @@ -587,6 +588,11 @@ impl<'le> TElement for GeckoElement<'le> { } } + fn has_animations(&self, pseudo: Option<&PseudoElement>) -> bool { + let atom_ptr = PseudoElement::ns_atom_or_null_from_opt(pseudo); + unsafe { Gecko_ElementHasAnimations(self.0, atom_ptr) } + } + fn has_css_animations(&self, pseudo: Option<&PseudoElement>) -> bool { let atom_ptr = PseudoElement::ns_atom_or_null_from_opt(pseudo); unsafe { Gecko_ElementHasCSSAnimations(self.0, atom_ptr) } diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index 75af7928a7f..ee9da0172d9 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -612,6 +612,10 @@ extern "C" { aParentComputedValues: ServoComputedValuesBorrowedOrNull); } +extern "C" { + pub fn Gecko_ElementHasAnimations(aElement: RawGeckoElementBorrowed, + aPseudoTagOrNull: *mut nsIAtom) -> bool; +} extern "C" { pub fn Gecko_ElementHasCSSAnimations(aElement: RawGeckoElementBorrowed, aPseudoTagOrNull: *mut nsIAtom)