Bug 1449103 part 1 - Make Rule::mParentRule not necessarily a GroupRule. r?emilio draft
authorXidorn Quan <me@upsuper.org>
Wed, 28 Mar 2018 12:20:41 +1100
changeset 773575 2186990e4f6712c8921b41425a0adc65f8ac7ef2
parent 773565 b7463f8a3ba8dd48dcdf6030f7bb1f4dd0d34be5
child 773576 7eb3b22f42fafcbea63316a35c5b60f331a7ea45
push id104251
push userxquan@mozilla.com
push dateWed, 28 Mar 2018 02:47:44 +0000
reviewersemilio
bugs1449103
milestone61.0a1
Bug 1449103 part 1 - Make Rule::mParentRule not necessarily a GroupRule. r?emilio For part 2, where CSSKeyframesRule will inherit directly from Rule while it is parent rule for its CSSKeyframeRules. It seems there is nothing relying on mParentRule being a GroupRule so we can just change it. MozReview-Commit-ID: Cyte6h3Q2LB
layout/style/Rule.h
--- a/layout/style/Rule.h
+++ b/layout/style/Rule.h
@@ -88,20 +88,29 @@ public:
   nsIDocument* GetDocument() const
   {
     StyleSheet* sheet = GetStyleSheet();
     return sheet ? sheet->GetAssociatedDocument() : nullptr;
   }
 
   virtual void SetStyleSheet(StyleSheet* aSheet);
 
-  void SetParentRule(GroupRule* aRule) {
-    // We don't reference count this up reference. The group rule
-    // will tell us when it's going away or when we're detached from
-    // it.
+  // We don't reference count this up reference. The rule will tell us
+  // when it's going away or when we're detached from it.
+  void SetParentRule(Rule* aRule) {
+#ifdef DEBUG
+    if (aRule) {
+      int16_t type = aRule->Type();
+      MOZ_ASSERT(type == dom::CSSRuleBinding::MEDIA_RULE ||
+                 type == dom::CSSRuleBinding::DOCUMENT_RULE ||
+                 type == dom::CSSRuleBinding::SUPPORTS_RULE ||
+                 (type == dom::CSSRuleBinding::KEYFRAMES_RULE &&
+                  Type() == dom::CSSRuleBinding::KEYFRAME_RULE));
+    }
+#endif
     mParentRule = aRule;
   }
 
   uint32_t GetLineNumber() const { return mLineNumber; }
   uint32_t GetColumnNumber() const { return mColumnNumber; }
 
   /**
    * Clones |this|. Never returns nullptr.
@@ -124,17 +133,17 @@ public:
 protected:
   // True if we're known-live for cycle collection purposes.
   bool IsKnownLive() const;
 
   // This is sometimes null (e.g., for style attributes).
   StyleSheet* mSheet;
   // When the parent GroupRule is destroyed, it will call SetParentRule(nullptr)
   // on this object. (Through SetParentRuleReference);
-  GroupRule* MOZ_NON_OWNING_REF mParentRule;
+  Rule* MOZ_NON_OWNING_REF mParentRule;
 
   // Keep the same type so that MSVC packs them.
   uint32_t          mLineNumber;
   uint32_t          mColumnNumber;
 };
 
 } // namespace css
 } // namespace mozilla