Add an FFI to check that a given (pseudo-) element has any type of animations or not.

If an element has any type of animations in match_elements(), we need to call
UpdateEffectProperties() to update KeyframeEffectReadOnly::mProperties.
This commit is contained in:
Hiroyuki Ikezoe 2017-03-27 17:31:50 +09:00
parent 4aae0e29d6
commit 0c843d4b7d
4 changed files with 19 additions and 0 deletions

View file

@ -455,6 +455,10 @@ impl<'le> TElement for ServoLayoutElement<'le> {
panic!("this should be only called on gecko"); 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 { fn has_css_animations(&self, _pseudo: Option<&PseudoElement>) -> bool {
panic!("this should be only called on gecko"); panic!("this should be only called on gecko");
} }

View file

@ -370,6 +370,11 @@ pub trait TElement : PartialEq + Debug + Sized + Copy + Clone + ElementExt + Pre
/// Note: Gecko only. /// Note: Gecko only.
fn update_animations(&self, _pseudo: Option<&PseudoElement>); 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. /// Returns true if the element has a CSS animation.
fn has_css_animations(&self, _pseudo: Option<&PseudoElement>) -> bool; fn has_css_animations(&self, _pseudo: Option<&PseudoElement>) -> bool;

View file

@ -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_IsUnvisitedLink, Gecko_IsVisitedLink, Gecko_Namespace};
use gecko_bindings::bindings::{Gecko_SetNodeFlags, Gecko_UnsetNodeFlags}; use gecko_bindings::bindings::{Gecko_SetNodeFlags, Gecko_UnsetNodeFlags};
use gecko_bindings::bindings::Gecko_ClassOrClassList; use gecko_bindings::bindings::Gecko_ClassOrClassList;
use gecko_bindings::bindings::Gecko_ElementHasAnimations;
use gecko_bindings::bindings::Gecko_ElementHasCSSAnimations; use gecko_bindings::bindings::Gecko_ElementHasCSSAnimations;
use gecko_bindings::bindings::Gecko_GetAnimationRule; use gecko_bindings::bindings::Gecko_GetAnimationRule;
use gecko_bindings::bindings::Gecko_GetHTMLPresentationAttrDeclarationBlock; 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 { fn has_css_animations(&self, pseudo: Option<&PseudoElement>) -> bool {
let atom_ptr = PseudoElement::ns_atom_or_null_from_opt(pseudo); let atom_ptr = PseudoElement::ns_atom_or_null_from_opt(pseudo);
unsafe { Gecko_ElementHasCSSAnimations(self.0, atom_ptr) } unsafe { Gecko_ElementHasCSSAnimations(self.0, atom_ptr) }

View file

@ -612,6 +612,10 @@ extern "C" {
aParentComputedValues: aParentComputedValues:
ServoComputedValuesBorrowedOrNull); ServoComputedValuesBorrowedOrNull);
} }
extern "C" {
pub fn Gecko_ElementHasAnimations(aElement: RawGeckoElementBorrowed,
aPseudoTagOrNull: *mut nsIAtom) -> bool;
}
extern "C" { extern "C" {
pub fn Gecko_ElementHasCSSAnimations(aElement: RawGeckoElementBorrowed, pub fn Gecko_ElementHasCSSAnimations(aElement: RawGeckoElementBorrowed,
aPseudoTagOrNull: *mut nsIAtom) aPseudoTagOrNull: *mut nsIAtom)