From 4904a9711182d6eaef2dd6b1f8b017e3323a3a45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Tue, 6 Jun 2023 13:01:45 +0200 Subject: [PATCH] style: Correctly report animation status of pseudo-elements that are not stored in the parent element We allow animating pseudo-elements like ::-moz-progress-bar (and we treat them like regular elements). Ideally we should store animations for these in the parent element as well, so they survive reframes and such. But treating them as regular elements right now means that we do animate them, but we never update animations for them correctly because wrapper.rs assumed them to be non-animatable. Since it seems reasonable to keep allowing the animations to happen, let's just correct the update code and add a test. Differential Revision: https://phabricator.services.mozilla.com/D131794 --- components/style/gecko/pseudo_element.rs | 5 +++-- components/style/gecko/wrapper.rs | 15 +++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/components/style/gecko/pseudo_element.rs b/components/style/gecko/pseudo_element.rs index 5a9b955b1c8..be8d0def121 100644 --- a/components/style/gecko/pseudo_element.rs +++ b/components/style/gecko/pseudo_element.rs @@ -93,9 +93,10 @@ impl PseudoElement { EAGER_PSEUDOS[i].clone() } - /// Whether the current pseudo element is animatable. + /// Whether animations for the current pseudo element are stored in the + /// parent element. #[inline] - pub fn is_animatable(&self) -> bool { + pub fn animations_stored_in_parent(&self) -> bool { matches!(*self, Self::Before | Self::After | Self::Marker) } diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index c41d2ff1e85..27f3eefe62e 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -1390,15 +1390,14 @@ impl<'le> TElement for GeckoElement<'le> { #[inline] fn may_have_animations(&self) -> bool { if let Some(pseudo) = self.implemented_pseudo_element() { - if !pseudo.is_animatable() { - return false; + if pseudo.animations_stored_in_parent() { + // FIXME(emilio): When would the parent of a ::before / ::after + // pseudo-element be null? + return self.parent_element().map_or(false, |p| { + p.as_node() + .get_bool_flag(nsINode_BooleanFlag::ElementHasAnimations) + }); } - // FIXME(emilio): When would the parent of a ::before / ::after - // pseudo-element be null? - return self.parent_element().map_or(false, |p| { - p.as_node() - .get_bool_flag(nsINode_BooleanFlag::ElementHasAnimations) - }); } self.as_node() .get_bool_flag(nsINode_BooleanFlag::ElementHasAnimations)