From 137044a3db7683d412b90d2ca3a7b230c0f57f77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Tue, 16 Jul 2019 15:42:08 +0000 Subject: [PATCH] style: Update animations when a pseudo-element had animations but no longer has, and has been re-framed in the meantime. This is the easy fix. The hard fix (outlined in the comment) would be nice, but I don't think this bug alone justifies it. Differential Revision: https://phabricator.services.mozilla.com/D38184 --- components/style/matching.rs | 25 ++++++++++++++++++----- components/style/properties/gecko.mako.rs | 7 ++++++- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/components/style/matching.rs b/components/style/matching.rs index dfc5685098c..2c6b16d964d 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -240,16 +240,31 @@ trait PrivateMatchMethods: TElement { let new_box_style = new_style.get_box(); let new_style_specifies_animations = new_box_style.specifies_animations(); - let old_style = match old_style { - Some(old) => old, - None => return new_style_specifies_animations, - }; - let has_animations = self.has_css_animations(); if !new_style_specifies_animations && !has_animations { return false; } + let old_style = match old_style { + Some(old) => old, + // If we have no old style but have animations, we may be a + // pseudo-element which was re-created without style changes. + // + // This can happen when we reframe the pseudo-element without + // restyling it (due to content insertion on a flex container or + // such, for example). See bug 1564366. + // + // FIXME(emilio): The really right fix for this is keeping the + // pseudo-element itself around on reframes, but that's a bit + // harder. If we do that we can probably remove quite a lot of the + // EffectSet complexity though, since right now it's stored on the + // parent element for pseudo-elements given we need to keep it + // around... + None => { + return new_style_specifies_animations || new_style.is_pseudo_style(); + } + }; + let old_box_style = old_style.get_box(); let keyframes_could_have_changed = context diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 11bd30136d7..32db1b5d47c 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -117,9 +117,14 @@ impl ComputedValues { ).to_outer(None) } + #[inline] + pub fn is_pseudo_style(&self) -> bool { + self.0.mPseudoType != PseudoStyleType::NotPseudo + } + #[inline] pub fn pseudo(&self) -> Option { - if self.0.mPseudoType == PseudoStyleType::NotPseudo { + if !self.is_pseudo_style() { return None; } PseudoElement::from_pseudo_type(self.0.mPseudoType)