Bug 1535612 - CSSKeyframeList::RemoveRule should clear parent references when removed. r=heycam, a=pascalc
authorEmilio Cobos Álvarez <emilio@crisal.io>
Wed, 20 Mar 2019 09:50:51 +0000
changeset 525721 1b8d74f0b43fc23af67ea6528bf0deea40111666
parent 525720 d61382bfd4d8c47bdc8b5eb0784dad643fd6c2bc
child 525722 dab7eaf9899235d813e50b299508be269b167a19
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam, pascalc
bugs1535612
milestone67.0
Bug 1535612 - CSSKeyframeList::RemoveRule should clear parent references when removed. r=heycam, a=pascalc Differential Revision: https://phabricator.services.mozilla.com/D23729
layout/style/CSSKeyframesRule.cpp
--- a/layout/style/CSSKeyframesRule.cpp
+++ b/layout/style/CSSKeyframesRule.cpp
@@ -64,17 +64,25 @@ class CSSKeyframeList : public dom::CSSR
       return nullptr;
     }
     aFound = true;
     return GetRule(aIndex);
   }
 
   void AppendRule() { mRules.AppendObject(nullptr); }
 
-  void RemoveRule(uint32_t aIndex) { mRules.RemoveObjectAt(aIndex); }
+  void RemoveRule(uint32_t aIndex) {
+    if (aIndex >= mRules.Length()) {
+      return;
+    }
+    if (css::Rule* child = mRules[aIndex]) {
+      child->DropReferences();
+    }
+    mRules.RemoveObjectAt(aIndex);
+  }
 
   uint32_t Length() final { return mRules.Length(); }
 
   void DropReferences() {
     if (!mStyleSheet && !mParentRule) {
       return;
     }
     mStyleSheet = nullptr;