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
This commit is contained in:
Emilio Cobos Álvarez 2023-06-06 13:01:45 +02:00 committed by Oriol Brufau
parent 204317b1e6
commit 4904a97111
2 changed files with 10 additions and 10 deletions

View file

@ -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)
}

View file

@ -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)