Bug 1307357 part 1 - Make css::Rule hold StyleSheet rather than CSSStyleSheet. r=heycam
authorXidorn Quan <me@upsuper.org>
Wed, 23 Nov 2016 10:26:20 +1100
changeset 323890 067fb417bb7bc51956941a495f4d6be271c832b4
parent 323880 3200aaa75fc28bafdbcaa5abdd3e511831b0035b
child 323891 7a9d6a3cdf1a68952f8fb88a0999db1f9486b921
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersheycam
bugs1307357
milestone53.0a1
Bug 1307357 part 1 - Make css::Rule hold StyleSheet rather than CSSStyleSheet. r=heycam MozReview-Commit-ID: JsJa4YqpCZy
layout/inspector/inDOMUtils.cpp
layout/style/CSSRuleList.h
layout/style/CSSStyleSheet.cpp
layout/style/FontFaceSet.cpp
layout/style/GroupRule.h
layout/style/Rule.h
layout/style/StyleRule.h
layout/style/nsCSSRules.cpp
layout/style/nsCSSRules.h
layout/style/nsDOMCSSDeclaration.cpp
--- a/layout/inspector/inDOMUtils.cpp
+++ b/layout/inspector/inDOMUtils.cpp
@@ -328,17 +328,17 @@ inDOMUtils::GetRelativeRuleLine(nsIDOMCS
   NS_ENSURE_ARG_POINTER(aRule);
 
   Rule* rule = aRule->GetCSSRule();
   if (!rule) {
     return NS_ERROR_FAILURE;
   }
 
   uint32_t lineNumber = rule->GetLineNumber();
-  CSSStyleSheet* sheet = rule->GetStyleSheet();
+  StyleSheet* sheet = rule->GetStyleSheet();
   if (sheet && lineNumber != 0) {
     nsINode* owningNode = sheet->GetOwnerNode();
     if (owningNode) {
       nsCOMPtr<nsIStyleSheetLinkingElement> link =
         do_QueryInterface(owningNode);
       if (link) {
         lineNumber -= link->GetLineNumber() - 1;
       }
--- a/layout/style/CSSRuleList.h
+++ b/layout/style/CSSRuleList.h
@@ -23,17 +23,17 @@ class CSSRuleList : public nsIDOMCSSRule
                   , public nsWrapperCache
 {
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICSSRULELIST_IID)
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(CSSRuleList)
 
-  virtual CSSStyleSheet* GetParentObject() = 0;
+  virtual StyleSheet* GetParentObject() = 0;
   virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override final;
 
   NS_IMETHOD
   GetLength(uint32_t* aLength) override final
   {
     *aLength = Length();
     return NS_OK;
   }
--- a/layout/style/CSSStyleSheet.cpp
+++ b/layout/style/CSSStyleSheet.cpp
@@ -1381,19 +1381,20 @@ CSSStyleSheet::FindOwningWindowInnerID()
     windowID = mDocument->InnerWindowID();
   }
 
   if (windowID == 0 && mOwningNode) {
     windowID = mOwningNode->OwnerDoc()->InnerWindowID();
   }
 
   if (windowID == 0 && mOwnerRule) {
-    RefPtr<CSSStyleSheet> sheet = static_cast<css::Rule*>(mOwnerRule)->GetStyleSheet();
+    RefPtr<StyleSheet> sheet =
+      static_cast<css::Rule*>(mOwnerRule)->GetStyleSheet();
     if (sheet) {
-      windowID = sheet->FindOwningWindowInnerID();
+      windowID = sheet->AsGecko()->FindOwningWindowInnerID();
     }
   }
 
   if (windowID == 0 && mParent) {
     windowID = mParent->FindOwningWindowInnerID();
   }
 
   return windowID;
--- a/layout/style/FontFaceSet.cpp
+++ b/layout/style/FontFaceSet.cpp
@@ -1259,17 +1259,17 @@ FontFaceSet::LogMessage(gfxUserFontEntry
   nsString href;
   nsString text;
   nsresult rv;
   uint32_t line = 0;
   uint32_t column = 0;
   if (rule) {
     rv = rule->GetCssText(text);
     NS_ENSURE_SUCCESS(rv, rv);
-    CSSStyleSheet* sheet = rule->GetStyleSheet();
+    StyleSheet* sheet = rule->GetStyleSheet();
     // if the style sheet is removed while the font is loading can be null
     if (sheet) {
       nsCString spec = sheet->GetSheetURI()->GetSpecOrDefault();
       CopyUTF8toUTF16(spec, href);
     } else {
       NS_WARNING("null parent stylesheet for @font-face rule");
       href.AssignLiteral("unknown");
     }
--- a/layout/style/GroupRule.h
+++ b/layout/style/GroupRule.h
@@ -17,17 +17,17 @@
 #include "mozilla/css/Rule.h"
 #include "nsCycleCollectionParticipant.h"
 
 class nsPresContext;
 class nsMediaQueryResultCacheKey;
 
 namespace mozilla {
 
-class CSSStyleSheet;
+class StyleSheet;
 
 namespace css {
 
 class GroupRuleRuleList;
 
 // inherits from Rule so it can be shared between
 // MediaRule and DocumentRule
 class GroupRule : public Rule
@@ -41,17 +41,17 @@ public:
   NS_DECL_CYCLE_COLLECTION_CLASS(GroupRule)
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
 
   // implement part of Rule
   DECL_STYLE_RULE_INHERIT_NO_DOMRULE
 #ifdef DEBUG
   virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
 #endif
-  virtual void SetStyleSheet(CSSStyleSheet* aSheet) override;
+  virtual void SetStyleSheet(StyleSheet* aSheet) override;
 
 public:
   void AppendStyleRule(Rule* aRule);
 
   int32_t StyleRuleCount() const { return mRules.Count(); }
   Rule* GetStyleRuleAt(int32_t aIndex) const;
 
   typedef IncrementalClearCOMRuleArray::nsCOMArrayEnumFunc RuleEnumFunc;
--- a/layout/style/Rule.h
+++ b/layout/style/Rule.h
@@ -75,26 +75,26 @@ public:
     DOCUMENT_RULE,
     SUPPORTS_RULE,
     FONT_FEATURE_VALUES_RULE,
     COUNTER_STYLE_RULE
   };
 
   virtual int32_t GetType() const = 0;
 
-  CSSStyleSheet* GetStyleSheet() const { return mSheet; }
+  StyleSheet* GetStyleSheet() const { return mSheet; }
 
   // Return the document the rule lives in, if any
   nsIDocument* GetDocument() const
   {
-    CSSStyleSheet* sheet = GetStyleSheet();
+    StyleSheet* sheet = GetStyleSheet();
     return sheet ? sheet->GetDocument() : nullptr;
   }
 
-  virtual void SetStyleSheet(CSSStyleSheet* aSheet);
+  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.
     mParentRule = aRule;
   }
 
@@ -120,17 +120,17 @@ public:
 
   // This is pure virtual because all of Rule's data members are non-owning and
   // thus measured elsewhere.
   virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
     const MOZ_MUST_OVERRIDE = 0;
 
 protected:
   // This is sometimes null (e.g., for style attributes).
-  CSSStyleSheet*    mSheet;
+  StyleSheet* mSheet;
   // When the parent GroupRule is destroyed, it will call SetParentRule(nullptr)
   // on this object. (Through SetParentRuleReference);
   GroupRule* MOZ_NON_OWNING_REF mParentRule;
 
   // Keep the same type so that MSVC packs them.
   uint32_t          mLineNumber;
   uint32_t          mColumnNumber;
 };
--- a/layout/style/StyleRule.h
+++ b/layout/style/StyleRule.h
@@ -332,16 +332,22 @@ public:
   // hooks for DOM rule
   void GetCssText(nsAString& aCssText);
   void SetCssText(const nsAString& aCssText);
   void GetSelectorText(nsAString& aSelectorText);
   void SetSelectorText(const nsAString& aSelectorText);
 
   virtual int32_t GetType() const override;
 
+  CSSStyleSheet* GetStyleSheet() const
+  {
+    StyleSheet* sheet = Rule::GetStyleSheet();
+    return sheet ? sheet->AsGecko() : nullptr;
+  }
+
   virtual already_AddRefed<Rule> Clone() const override;
 
   virtual nsIDOMCSSRule* GetDOMRule() override;
 
   virtual nsIDOMCSSRule* GetExistingDOMRule() override;
 
 #ifdef DEBUG
   virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
--- a/layout/style/nsCSSRules.cpp
+++ b/layout/style/nsCSSRules.cpp
@@ -51,17 +51,17 @@ using namespace mozilla::dom;
 IMPL_STYLE_RULE_INHERIT_GET_DOM_RULE_WEAK(class_, super_)
 
 // base class for all rule types in a CSS style sheet
 
 namespace mozilla {
 namespace css {
 
 /* virtual */ void
-Rule::SetStyleSheet(CSSStyleSheet* aSheet)
+Rule::SetStyleSheet(StyleSheet* aSheet)
 {
   // We don't reference count this up reference. The style sheet
   // will tell us when it's going away or when we're detached from
   // it.
   mSheet = aSheet;
 }
 
 nsresult
@@ -127,18 +127,18 @@ GroupRuleRuleList::~GroupRuleRuleList()
 }
 
 CSSStyleSheet*
 GroupRuleRuleList::GetParentObject()
 {
   if (!mGroupRule) {
     return nullptr;
   }
-
-  return mGroupRule->GetStyleSheet();
+  StyleSheet* sheet = mGroupRule->GetStyleSheet();
+  return sheet ? sheet->AsGecko() : nullptr;
 }
 
 uint32_t
 GroupRuleRuleList::Length()
 {
   if (!mGroupRule) {
     return 0;
   }
@@ -384,18 +384,17 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(GroupRul
 NS_IMPL_CYCLE_COLLECTING_RELEASE(GroupRule)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(GroupRule)
 NS_INTERFACE_MAP_END
 
 static bool
 SetStyleSheetReference(Rule* aRule, void* aSheet)
 {
-  CSSStyleSheet* sheet = (CSSStyleSheet*)aSheet;
-  aRule->SetStyleSheet(sheet);
+  aRule->SetStyleSheet(reinterpret_cast<StyleSheet*>(aSheet));
   return true;
 }
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(GroupRule)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(GroupRule)
   tmp->mRules.EnumerateForwards(SetParentRuleReference, nullptr);
   // If tmp does not have a stylesheet, neither do its descendants.  In that
@@ -419,17 +418,17 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(
   for (int32_t i = 0, count = rules.Count(); i < count; ++i) {
     NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mRules[i]");
     cb.NoteXPCOMChild(rules[i]->GetExistingDOMRule());
   }
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRuleCollection)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 /* virtual */ void
-GroupRule::SetStyleSheet(CSSStyleSheet* aSheet)
+GroupRule::SetStyleSheet(StyleSheet* aSheet)
 {
   // Don't set the sheet on the kids if it's already the same as the sheet we
   // already have.  This is needed to avoid O(N^2) behavior in group nesting
   // depth when seting the sheet to null during unlink, if we happen to unlin in
   // order from most nested rule up to least nested rule.
   if (aSheet != GetStyleSheet()) {
     mRules.EnumerateForwards(SetStyleSheetReference, aSheet);
     Rule::SetStyleSheet(aSheet);
@@ -445,21 +444,21 @@ GroupRule::List(FILE* out, int32_t aInde
   }
 }
 #endif
 
 void
 GroupRule::AppendStyleRule(Rule* aRule)
 {
   mRules.AppendObject(aRule);
-  CSSStyleSheet* sheet = GetStyleSheet();
+  StyleSheet* sheet = GetStyleSheet();
   aRule->SetStyleSheet(sheet);
   aRule->SetParentRule(this);
   if (sheet) {
-    sheet->SetModifiedByChildRule();
+    sheet->AsGecko()->SetModifiedByChildRule();
   }
 }
 
 Rule*
 GroupRule::GetStyleRuleAt(int32_t aIndex) const
 {
   return mRules.SafeObjectAt(aIndex);
 }
@@ -530,41 +529,41 @@ GroupRule::GetCssRules(nsIDOMCSSRuleList
 
   NS_ADDREF(*aRuleList = mRuleCollection);
   return NS_OK;
 }
 
 nsresult
 GroupRule::InsertRule(const nsAString & aRule, uint32_t aIndex, uint32_t* _retval)
 {
-  CSSStyleSheet* sheet = GetStyleSheet();
+  StyleSheet* sheet = GetStyleSheet();
   NS_ENSURE_TRUE(sheet, NS_ERROR_FAILURE);
   
   if (aIndex > uint32_t(mRules.Count()))
     return NS_ERROR_DOM_INDEX_SIZE_ERR;
 
   NS_ASSERTION(uint32_t(mRules.Count()) <= INT32_MAX,
                "Too many style rules!");
 
-  return sheet->InsertRuleIntoGroup(aRule, this, aIndex, _retval);
+  return sheet->AsGecko()->InsertRuleIntoGroup(aRule, this, aIndex, _retval);
 }
 
 nsresult
 GroupRule::DeleteRule(uint32_t aIndex)
 {
-  CSSStyleSheet* sheet = GetStyleSheet();
+  StyleSheet* sheet = GetStyleSheet();
   NS_ENSURE_TRUE(sheet, NS_ERROR_FAILURE);
 
   if (aIndex >= uint32_t(mRules.Count()))
     return NS_ERROR_DOM_INDEX_SIZE_ERR;
 
   NS_ASSERTION(uint32_t(mRules.Count()) <= INT32_MAX,
                "Too many style rules!");
 
-  return sheet->DeleteRuleFromGroup(this, aIndex);
+  return sheet->AsGecko()->DeleteRuleFromGroup(this, aIndex);
 }
 
 /* virtual */ size_t
 GroupRule::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
 {
   size_t n = mRules.ShallowSizeOfExcludingThis(aMallocSizeOf);
   for (size_t i = 0; i < mRules.Length(); i++) {
     n += mRules[i]->SizeOfIncludingThis(aMallocSizeOf);
@@ -611,22 +610,24 @@ NS_INTERFACE_MAP_BEGIN(MediaRule)
   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSGroupingRule)
   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSConditionRule)
   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSMediaRule)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, mozilla::css::Rule)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSMediaRule)
 NS_INTERFACE_MAP_END_INHERITING(GroupRule)
 
 /* virtual */ void
-MediaRule::SetStyleSheet(CSSStyleSheet* aSheet)
+MediaRule::SetStyleSheet(StyleSheet* aSheet)
 {
   if (mMedia) {
     // Set to null so it knows it's leaving one sheet and joining another.
     mMedia->SetStyleSheet(nullptr);
-    mMedia->SetStyleSheet(aSheet);
+    if (aSheet) {
+      mMedia->SetStyleSheet(aSheet->AsGecko());
+    }
   }
 
   GroupRule::SetStyleSheet(aSheet);
 }
 
 #ifdef DEBUG
 /* virtual */ void
 MediaRule::List(FILE* out, int32_t aIndent) const
@@ -2126,20 +2127,18 @@ nsCSSKeyframeRule::SetKeyText(const nsAS
     return NS_OK;
   }
 
   nsIDocument* doc = GetDocument();
   MOZ_AUTO_DOC_UPDATE(doc, UPDATE_STYLE, true);
 
   newSelectors.SwapElements(mKeys);
 
-  CSSStyleSheet* sheet = GetStyleSheet();
-  if (sheet) {
-    sheet->SetModifiedByChildRule();
-
+  if (StyleSheet* sheet = GetStyleSheet()) {
+    sheet->AsGecko()->SetModifiedByChildRule();
     if (doc) {
       doc->StyleRuleChanged(sheet, this);
     }
   }
 
   return NS_OK;
 }
 
@@ -2163,20 +2162,18 @@ nsCSSKeyframeRule::ChangeDeclaration(css
   MOZ_AUTO_DOC_UPDATE(doc, UPDATE_STYLE, true);
 
   if (aDeclaration != mDeclaration) {
     mDeclaration->SetOwningRule(nullptr);
     mDeclaration = aDeclaration;
     mDeclaration->SetOwningRule(this);
   }
 
-  CSSStyleSheet* sheet = GetStyleSheet();
-  if (sheet) {
-    sheet->SetModifiedByChildRule();
-
+  if (StyleSheet* sheet = GetStyleSheet()) {
+    sheet->AsGecko()->SetModifiedByChildRule();
     if (doc) {
       doc->StyleRuleChanged(sheet, this);
     }
   }
 }
 
 /* virtual */ size_t
 nsCSSKeyframeRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
@@ -2312,20 +2309,18 @@ nsCSSKeyframesRule::SetName(const nsAStr
     return NS_OK;
   }
 
   nsIDocument* doc = GetDocument();
   MOZ_AUTO_DOC_UPDATE(doc, UPDATE_STYLE, true);
 
   mName = aName;
 
-  CSSStyleSheet* sheet = GetStyleSheet();
-  if (sheet) {
-    sheet->SetModifiedByChildRule();
-
+  if (StyleSheet* sheet = GetStyleSheet()) {
+    sheet->AsGecko()->SetModifiedByChildRule();
     if (doc) {
       doc->StyleRuleChanged(sheet, this);
     }
   }
 
   return NS_OK;
 }
 
@@ -2347,20 +2342,18 @@ nsCSSKeyframesRule::AppendRule(const nsA
   RefPtr<nsCSSKeyframeRule> rule =
     parser.ParseKeyframeRule(aRule, nullptr, 0);
   if (rule) {
     nsIDocument* doc = GetDocument();
     MOZ_AUTO_DOC_UPDATE(doc, UPDATE_STYLE, true);
 
     AppendStyleRule(rule);
 
-    CSSStyleSheet* sheet = GetStyleSheet();
-    if (sheet) {
-      sheet->SetModifiedByChildRule();
-
+    if (StyleSheet* sheet = GetStyleSheet()) {
+      sheet->AsGecko()->SetModifiedByChildRule();
       if (doc) {
         doc->StyleRuleChanged(sheet, this);
       }
     }
   }
 
   return NS_OK;
 }
@@ -2395,19 +2388,18 @@ nsCSSKeyframesRule::DeleteRule(const nsA
 {
   uint32_t index = FindRuleIndexForKey(aKey);
   if (index != RULE_NOT_FOUND) {
     nsIDocument* doc = GetDocument();
     MOZ_AUTO_DOC_UPDATE(doc, UPDATE_STYLE, true);
 
     mRules.RemoveObjectAt(index);
 
-    CSSStyleSheet* sheet = GetStyleSheet();
-    if (sheet) {
-      sheet->SetModifiedByChildRule();
+    if (StyleSheet* sheet = GetStyleSheet()) {
+      sheet->AsGecko()->SetModifiedByChildRule();
 
       if (doc) {
         doc->StyleRuleChanged(sheet, this);
       }
     }
   }
   return NS_OK;
 }
@@ -2648,19 +2640,18 @@ void
 nsCSSPageRule::ChangeDeclaration(css::Declaration* aDeclaration)
 {
   if (aDeclaration != mDeclaration) {
     mDeclaration->SetOwningRule(nullptr);
     mDeclaration = aDeclaration;
     mDeclaration->SetOwningRule(this);
   }
 
-  CSSStyleSheet* sheet = GetStyleSheet();
-  if (sheet) {
-    sheet->SetModifiedByChildRule();
+  if (StyleSheet* sheet = GetStyleSheet()) {
+    sheet->AsGecko()->SetModifiedByChildRule();
   }
 }
 
 /* virtual */ size_t
 nsCSSPageRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
 {
   return aMallocSizeOf(this);
 }
@@ -2964,19 +2955,18 @@ nsCSSCounterStyleRule::SetName(const nsA
   nsCSSParser parser;
   nsAutoString name;
   if (parser.ParseCounterStyleName(aName, nullptr, name)) {
     nsIDocument* doc = GetDocument();
     MOZ_AUTO_DOC_UPDATE(doc, UPDATE_STYLE, true);
 
     mName = name;
 
-    CSSStyleSheet* sheet = GetStyleSheet();
-    if (sheet) {
-      sheet->SetModifiedByChildRule();
+    if (StyleSheet* sheet = GetStyleSheet()) {
+      sheet->AsGecko()->SetModifiedByChildRule();
       if (doc) {
         doc->StyleRuleChanged(sheet, this);
       }
     }
   }
   return NS_OK;
 }
 
@@ -3010,19 +3000,18 @@ nsCSSCounterStyleRule::SetDesc(nsCSSCoun
              "descriptor ID out of range");
 
   nsIDocument* doc = GetDocument();
   MOZ_AUTO_DOC_UPDATE(doc, UPDATE_STYLE, true);
 
   mValues[aDescID] = aValue;
   mGeneration++;
 
-  CSSStyleSheet* sheet = GetStyleSheet();
-  if (sheet) {
-    sheet->SetModifiedByChildRule();
+  if (StyleSheet* sheet = GetStyleSheet()) {
+    sheet->AsGecko()->SetModifiedByChildRule();
     if (doc) {
       doc->StyleRuleChanged(sheet, this);
     }
   }
 }
 
 NS_IMETHODIMP
 nsCSSCounterStyleRule::GetSystem(nsAString& aSystem)
@@ -3240,20 +3229,19 @@ nsCSSCounterStyleRule::CheckDescValue(in
 }
 
 nsresult
 nsCSSCounterStyleRule::SetDescriptor(nsCSSCounterDesc aDescID,
                                      const nsAString& aValue)
 {
   nsCSSParser parser;
   nsCSSValue value;
-  CSSStyleSheet* sheet = GetStyleSheet();
   nsIURI* baseURL = nullptr;
   nsIPrincipal* principal = nullptr;
-  if (sheet) {
+  if (StyleSheet* sheet = GetStyleSheet()) {
     baseURL = sheet->GetBaseURI();
     principal = sheet->Principal();
   }
   if (parser.ParseCounterDescriptor(aDescID, aValue, nullptr,
                                     baseURL, principal, value)) {
     if (CheckDescValue(GetSystem(), aDescID, value)) {
       SetDesc(aDescID, value);
     }
--- a/layout/style/nsCSSRules.h
+++ b/layout/style/nsCSSRules.h
@@ -54,17 +54,22 @@ private:
 public:
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // Rule methods
 #ifdef DEBUG
   virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
 #endif
-  virtual void SetStyleSheet(mozilla::CSSStyleSheet* aSheet) override; //override GroupRule
+  virtual void SetStyleSheet(mozilla::StyleSheet* aSheet) override; //override GroupRule
+  mozilla::CSSStyleSheet* GetStyleSheet() const
+  {
+    mozilla::StyleSheet* sheet = GroupRule::GetStyleSheet();
+    return sheet ? sheet->AsGecko() : nullptr;
+  }
   virtual int32_t GetType() const override;
   virtual already_AddRefed<Rule> Clone() const override;
   virtual nsIDOMCSSRule* GetDOMRule() override
   {
     return this;
   }
   virtual nsIDOMCSSRule* GetExistingDOMRule() override
   {
--- a/layout/style/nsDOMCSSDeclaration.cpp
+++ b/layout/style/nsDOMCSSDeclaration.cpp
@@ -256,17 +256,17 @@ nsDOMCSSDeclaration::RemoveProperty(cons
   NS_ENSURE_SUCCESS(rv, rv);
   return RemovePropertyInternal(aPropertyName);
 }
 
 /* static */ void
 nsDOMCSSDeclaration::GetCSSParsingEnvironmentForRule(css::Rule* aRule,
                                                      CSSParsingEnvironment& aCSSParseEnv)
 {
-  CSSStyleSheet* sheet = aRule ? aRule->GetStyleSheet() : nullptr;
+  StyleSheet* sheet = aRule ? aRule->GetStyleSheet() : nullptr;
   if (!sheet) {
     aCSSParseEnv.mPrincipal = nullptr;
     return;
   }
 
   nsIDocument* document = sheet->GetOwningDocument();
   aCSSParseEnv.mSheetURI = sheet->GetSheetURI();
   aCSSParseEnv.mBaseURI = sheet->GetBaseURI();