From 652c2153a41fff590cfbf827f5c0b8b2a849549d Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Fri, 12 May 2017 11:56:18 +0900 Subject: [PATCH] Check ElementHasAnimations flag in rust side. We can bail out earlier before calling an FFI function. --- components/style/gecko/wrapper.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index 1aef3e325f7..65ca0f4427b 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -406,6 +406,12 @@ impl<'le> GeckoElement<'le> { }, } } + + fn may_have_animations(&self) -> bool { + use gecko_bindings::structs::nsINode_BooleanFlag; + self.as_node().bool_flags() & + (1u32 << nsINode_BooleanFlag::ElementHasAnimations as u32) != 0 + } } /// Converts flags from the layout used by rust-selectors to the layout used @@ -738,15 +744,15 @@ impl<'le> TElement for GeckoElement<'le> { } fn has_animations(&self) -> bool { - unsafe { Gecko_ElementHasAnimations(self.0) } + self.may_have_animations() && unsafe { Gecko_ElementHasAnimations(self.0) } } fn has_css_animations(&self) -> bool { - unsafe { Gecko_ElementHasCSSAnimations(self.0) } + self.may_have_animations() && unsafe { Gecko_ElementHasCSSAnimations(self.0) } } fn has_css_transitions(&self) -> bool { - unsafe { Gecko_ElementHasCSSTransitions(self.0) } + self.may_have_animations() && unsafe { Gecko_ElementHasCSSTransitions(self.0) } } fn get_css_transitions_info(&self)