Bug 1524480 - Make KeyframeEffect::CreateComputedStyleForAnimationValue handle a null elementForResolve; r=hiro
authorBrian Birtles <birtles@gmail.com>
Fri, 15 Feb 2019 05:54:10 +0000
changeset 459528 1625e825876ca6accdda4089532392e61a40d211
parent 459527 5dac0d4a3c4428a9e553ba7e1c47da7a81636c2a
child 459529 c6657979a1a6b0c5f856d43f4a039925c0febc6f
push id111964
push usercsabou@mozilla.com
push dateFri, 15 Feb 2019 18:54:44 +0000
treeherdermozilla-inbound@db3c4f905082 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershiro
bugs1524480
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1524480 - Make KeyframeEffect::CreateComputedStyleForAnimationValue handle a null elementForResolve; r=hiro This is unrelated to this bug (the assertion can already fail without the patches in this patch queue) but I uncovered it while writing the tests in the next patch which will trip the assertion that is removed in this patch. Differential Revision: https://phabricator.services.mozilla.com/D19885
dom/animation/KeyframeEffect.cpp
--- a/dom/animation/KeyframeEffect.cpp
+++ b/dom/animation/KeyframeEffect.cpp
@@ -433,16 +433,19 @@ void KeyframeEffect::EnsureBaseStyle(
 
   if (!hasAdditiveValues) {
     return;
   }
 
   if (!aBaseComputedStyle) {
     Element* animatingElement = EffectCompositor::GetElementToRestyle(
         mTarget->mElement, mTarget->mPseudoType);
+    if (!animatingElement) {
+      return;
+    }
     aBaseComputedStyle = aPresContext->StyleSet()->GetBaseContextForElement(
         animatingElement, aComputedStyle);
   }
   RefPtr<RawServoAnimationValue> baseValue =
       Servo_ComputedValues_ExtractAnimationValue(aBaseComputedStyle,
                                                  aProperty.mProperty)
           .Consume();
   mBaseValues.Put(aProperty.mProperty, baseValue);
@@ -1472,20 +1475,25 @@ void KeyframeEffect::SetPerformanceWarni
 already_AddRefed<ComputedStyle>
 KeyframeEffect::CreateComputedStyleForAnimationValue(
     nsCSSPropertyID aProperty, const AnimationValue& aValue,
     nsPresContext* aPresContext, const ComputedStyle* aBaseComputedStyle) {
   MOZ_ASSERT(aBaseComputedStyle,
              "CreateComputedStyleForAnimationValue needs to be called "
              "with a valid ComputedStyle");
 
-  ServoStyleSet* styleSet = aPresContext->StyleSet();
   Element* elementForResolve = EffectCompositor::GetElementToRestyle(
       mTarget->mElement, mTarget->mPseudoType);
-  MOZ_ASSERT(elementForResolve, "The target element shouldn't be null");
+  // The element may be null if, for example, we target a pseudo-element that no
+  // longer exists.
+  if (!elementForResolve) {
+    return nullptr;
+  }
+
+  ServoStyleSet* styleSet = aPresContext->StyleSet();
   return styleSet->ResolveServoStyleByAddingAnimation(
       elementForResolve, aBaseComputedStyle, aValue.mServo);
 }
 
 void KeyframeEffect::CalculateCumulativeChangeHint(
     const ComputedStyle* aComputedStyle) {
   mCumulativeChangeHint = nsChangeHint(0);
   mNeedsStyleData = false;