From c09b204d5d91a2e77863fb4c638634f8a6993aac Mon Sep 17 00:00:00 2001 From: Boris Chiou Date: Tue, 24 Jan 2017 15:30:59 +0800 Subject: [PATCH] Bug 1317209 - Part 3: Add TElement::get_animation_rule. r=heycam We use TElement::get_animation_rule to get the animation rules from Gecko side, which contain the interpolated values of the specific element and the pseudo type. --- components/style/dom.rs | 6 ++++++ components/style/gecko/wrapper.rs | 7 +++++++ components/style/gecko_bindings/bindings.rs | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/components/style/dom.rs b/components/style/dom.rs index 90eacdf22bd..1019805cf2a 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -248,6 +248,12 @@ pub trait TElement : PartialEq + Debug + Sized + Copy + Clone + ElementExt + Pre /// Get this element's style attribute. fn style_attribute(&self) -> Option<&Arc>>; + /// Get this element's animation rule. + fn get_animation_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 8b74844590b..500dc92d7cc 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_GetAnimationRule; use gecko_bindings::bindings::Gecko_GetStyleContext; use gecko_bindings::structs; use gecko_bindings::structs::{RawGeckoElement, RawGeckoNode}; @@ -335,6 +336,12 @@ impl<'le> TElement for GeckoElement<'le> { declarations.map(|s| s.as_arc_opt()).unwrap_or(None) } + fn get_animation_rule(&self, pseudo: Option<&PseudoElement>) + -> Option>> { + let atom_ptr = pseudo.map(|p| p.as_atom().as_ptr()).unwrap_or(ptr::null_mut()); + unsafe { Gecko_GetAnimationRule(self.0, atom_ptr) }.into_arc_opt() + } + fn get_state(&self) -> ElementState { unsafe { ElementState::from_bits_truncate(Gecko_ElementState(self.0)) diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index e1190c2ca15..37d4654a049 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -501,6 +501,11 @@ extern "C" { pub fn Gecko_GetServoDeclarationBlock(element: RawGeckoElementBorrowed) -> RawServoDeclarationBlockStrongBorrowedOrNull; } +extern "C" { + pub fn Gecko_GetAnimationRule(element: RawGeckoElementBorrowed, + aAtom: *mut nsIAtom) + -> RawServoDeclarationBlockStrong; +} extern "C" { pub fn Gecko_Atomize(aString: *const ::std::os::raw::c_char, aLength: u32) -> *mut nsIAtom;