From f2c547aaaf09c1af9e6e416fd77166d99890e4b5 Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Fri, 10 Mar 2017 11:30:57 +0900 Subject: [PATCH] Call UpdateAnimations even if the element has no computed values. --- components/style/gecko/wrapper.rs | 12 +++++++++--- components/style/gecko_bindings/bindings.rs | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index 4c3fd1e9b76..d4d0c2dd3db 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -511,8 +511,14 @@ impl<'le> TElement for GeckoElement<'le> { fn update_animations(&self, pseudo: Option<&PseudoElement>) { let atom_ptr = PseudoElement::ns_atom_or_null_from_opt(pseudo); - let computed_data = self.borrow_data().unwrap(); - let computed_values = computed_data.styles().primary.values(); + // We have to update animations even if the element has no computed style + // since it means the element is in a display:none subtree, we should destroy + // all CSS animations in display:none subtree. + let computed_data = self.borrow_data(); + let computed_values = computed_data.as_ref().map(|d| d.styles().primary.values()); + let computed_values_opt = computed_values.map(|v| + *HasArcFFI::arc_as_borrowed(v) + ); let parent_element = self.parent_element(); let parent_data = parent_element.as_ref().and_then(|e| e.borrow_data()); @@ -523,7 +529,7 @@ impl<'le> TElement for GeckoElement<'le> { unsafe { Gecko_UpdateAnimations(self.0, atom_ptr, - HasArcFFI::arc_as_borrowed(&computed_values), + computed_values_opt, parent_values_opt); } } diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index 2079ad8aa20..f468ec94ab8 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -545,7 +545,7 @@ extern "C" { pub fn Gecko_UpdateAnimations(aElement: RawGeckoElementBorrowed, aPseudoTagOrNull: *mut nsIAtom, aComputedValues: - ServoComputedValuesBorrowed, + ServoComputedValuesBorrowedOrNull, aParentComputedValues: ServoComputedValuesBorrowedOrNull); }