diff options
-rw-r--r-- | components/style/gecko/wrapper.rs | 71 | ||||
-rw-r--r-- | ports/geckolib/glue.rs | 2 |
2 files changed, 31 insertions, 42 deletions
diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index 8dd52eb4541..adac5713cb4 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -692,33 +692,14 @@ impl<'le> GeckoElement<'le> { unsafe { Gecko_GetDocumentLWTheme(node.owner_doc().0) } } - /// Only safe to call on the main thread, with exclusive access to the element and - /// its ancestors. - /// This function is also called after display property changed for SMIL animation. + /// Only safe to call on the main thread, with exclusive access to the + /// element and its ancestors. + /// + /// This function is also called after display property changed for SMIL + /// animation. /// /// Also this function schedules style flush. - unsafe fn maybe_restyle<'a>( - &self, - data: &'a mut ElementData, - animation_only: bool, - ) -> bool { - if !data.has_styles() { - return false; - } - - // Propagate the bit up the chain. - if animation_only { - bindings::Gecko_NoteAnimationOnlyDirtyElement(self.0); - } else { - bindings::Gecko_NoteDirtyElement(self.0); - } - - // Ensure and return the RestyleData. - true - } - - /// Set restyle and change hints to the element data. - pub fn note_explicit_hints( + pub unsafe fn note_explicit_hints( &self, restyle_hint: nsRestyleHint, change_hint: nsChangeHint, @@ -735,20 +716,25 @@ impl<'le> GeckoElement<'le> { restyle_hint.has_non_animation_hint()), "Animation restyle hints should not appear with non-animation restyle hints"); - let mut maybe_data = self.mutate_data(); - let should_restyle = maybe_data.as_mut().map_or(false, |d| unsafe { - self.maybe_restyle(d, restyle_hint.has_animation_hint()) - }); - if should_restyle { - maybe_data - .as_mut() - .unwrap() - .hint - .insert(restyle_hint.into()); - maybe_data.as_mut().unwrap().damage |= damage; + let mut data = match self.mutate_data() { + Some(d) => d, + None => { + debug!("(Element not styled, discarding hints)"); + return; + } + }; + + debug_assert!(data.has_styles(), "how?"); + + // Propagate the bit up the chain. + if restyle_hint.has_animation_hint() { + bindings::Gecko_NoteAnimationOnlyDirtyElement(self.0); } else { - debug!("(Element not styled, discarding hints)"); + bindings::Gecko_NoteDirtyElement(self.0); } + + data.hint.insert(restyle_hint); + data.damage |= damage; } /// This logic is duplicated in Gecko's nsIContent::IsRootOfAnonymousSubtree. @@ -1320,8 +1306,7 @@ impl<'le> TElement for GeckoElement<'le> { } /// Process various tasks that are a result of animation-only restyle. - fn process_post_animation(&self, - tasks: PostAnimationTasks) { + fn process_post_animation(&self, tasks: PostAnimationTasks) { use gecko_bindings::structs::nsChangeHint_nsChangeHint_Empty; use gecko_bindings::structs::nsRestyleHint_eRestyle_Subtree; @@ -1336,8 +1321,12 @@ impl<'le> TElement for GeckoElement<'le> { .map_or(true, |p| !p.is_before_or_after()), "display property animation shouldn't run on pseudo elements \ since it's only for SMIL"); - self.note_explicit_hints(nsRestyleHint_eRestyle_Subtree, - nsChangeHint_nsChangeHint_Empty); + unsafe { + self.note_explicit_hints( + nsRestyleHint_eRestyle_Subtree, + nsChangeHint_nsChangeHint_Empty, + ); + } } } diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 957264a38f5..143332ffa15 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -3565,7 +3565,7 @@ pub extern "C" fn Servo_CSSSupports(cond: *const nsACString) -> bool { } #[no_mangle] -pub extern "C" fn Servo_NoteExplicitHints( +pub unsafe extern "C" fn Servo_NoteExplicitHints( element: RawGeckoElementBorrowed, restyle_hint: nsRestyleHint, change_hint: nsChangeHint, |