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