Bug 1292432 part 9 - Change WebIDL interface of CSSStyleSheet to StyleSheet. r?heycam draft
authorXidorn Quan <me@upsuper.org>
Tue, 20 Sep 2016 20:49:54 +1000
changeset 423113 0aefe1edbe5caa55da24b6a7fbb103aa931f4404
parent 423112 f25e12685eb6d7952d644cd6482b9312b54cf3c2
child 423114 afab6e2e55a5fd4dfcf0f7f8662b17b9ef55b045
push id31799
push userxquan@mozilla.com
push dateMon, 10 Oct 2016 07:37:57 +0000
reviewersheycam
bugs1292432
milestone52.0a1
Bug 1292432 part 9 - Change WebIDL interface of CSSStyleSheet to StyleSheet. r?heycam MozReview-Commit-ID: 5AXhsuvvrwe
dom/base/ShadowRoot.cpp
dom/base/ShadowRoot.h
dom/base/StyleSheetList.h
dom/base/nsDocument.cpp
dom/base/nsDocument.h
dom/bindings/Bindings.conf
layout/inspector/inCSSValueSearch.cpp
layout/style/CSSStyleSheet.cpp
layout/style/CSSStyleSheet.h
layout/style/ServoStyleSheet.cpp
layout/style/ServoStyleSheet.h
layout/style/StyleSheet.cpp
layout/style/StyleSheet.h
layout/style/StyleSheetInlines.h
--- a/dom/base/ShadowRoot.cpp
+++ b/dom/base/ShadowRoot.cpp
@@ -740,33 +740,24 @@ ShadowRootStyleSheetList::ShadowRootStyl
   MOZ_COUNT_CTOR(ShadowRootStyleSheetList);
 }
 
 ShadowRootStyleSheetList::~ShadowRootStyleSheetList()
 {
   MOZ_COUNT_DTOR(ShadowRootStyleSheetList);
 }
 
-CSSStyleSheet*
+StyleSheet*
 ShadowRootStyleSheetList::IndexedGetter(uint32_t aIndex, bool& aFound)
 {
   aFound = aIndex < mShadowRoot->mProtoBinding->SheetCount();
-
   if (!aFound) {
     return nullptr;
   }
-
-  // XXXheycam Return null until ServoStyleSheet implements the right
-  // DOM interfaces.
-  StyleSheet* sheet = mShadowRoot->mProtoBinding->StyleSheetAt(aIndex);
-  if (sheet->IsServo()) {
-    NS_ERROR("stylo: can't return ServoStyleSheets to script yet");
-    return nullptr;
-  }
-  return sheet->AsGecko();
+  return mShadowRoot->mProtoBinding->StyleSheetAt(aIndex);
 }
 
 uint32_t
 ShadowRootStyleSheetList::Length()
 {
   return mShadowRoot->mProtoBinding->SheetCount();
 }
 
--- a/dom/base/ShadowRoot.h
+++ b/dom/base/ShadowRoot.h
@@ -197,18 +197,18 @@ public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ShadowRootStyleSheetList, StyleSheetList)
 
   virtual nsINode* GetParentObject() const override
   {
     return mShadowRoot;
   }
 
-  virtual uint32_t Length() override;
-  virtual CSSStyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) override;
+  uint32_t Length() override;
+  StyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) override;
 
 protected:
   virtual ~ShadowRootStyleSheetList();
 
   RefPtr<ShadowRoot> mShadowRoot;
 };
 
 } // namespace dom
--- a/dom/base/StyleSheetList.h
+++ b/dom/base/StyleSheetList.h
@@ -8,35 +8,35 @@
 #define mozilla_dom_StyleSheetList_h
 
 #include "nsIDOMStyleSheetList.h"
 #include "nsWrapperCache.h"
 
 class nsINode;
 
 namespace mozilla {
-class CSSStyleSheet;
+class StyleSheet;
 
 namespace dom {
 
 class StyleSheetList : public nsIDOMStyleSheetList
                      , public nsWrapperCache
 {
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(StyleSheetList)
   NS_DECL_NSIDOMSTYLESHEETLIST
 
   virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override final;
 
   virtual nsINode* GetParentObject() const = 0;
 
   virtual uint32_t Length() = 0;
-  virtual CSSStyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) = 0;
-  CSSStyleSheet* Item(uint32_t aIndex)
+  virtual StyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) = 0;
+  StyleSheet* Item(uint32_t aIndex)
   {
     bool dummy = false;
     return IndexedGetter(aIndex, dummy);
   }
 
 protected:
   virtual ~StyleSheetList() {}
 };
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -586,35 +586,25 @@ nsDOMStyleSheetList::Length()
   // observer notification to figure out if new ones have
   // been added or removed.
   if (-1 == mLength) {
     mLength = mDocument->GetNumberOfStyleSheets();
   }
   return mLength;
 }
 
-CSSStyleSheet*
+StyleSheet*
 nsDOMStyleSheetList::IndexedGetter(uint32_t aIndex, bool& aFound)
 {
   if (!mDocument || aIndex >= (uint32_t)mDocument->GetNumberOfStyleSheets()) {
     aFound = false;
     return nullptr;
   }
-
   aFound = true;
-  StyleSheet* sheet = mDocument->GetStyleSheetAt(aIndex);
-  NS_ASSERTION(sheet, "Must have a sheet");
-
-  // XXXheycam Return null until ServoStyleSheet implements the right DOM
-  // interfaces.
-  if (sheet->IsServo()) {
-    NS_ERROR("stylo: can't return a ServoStyleSheet to the DOM yet");
-    return nullptr;
-  }
-  return sheet->AsGecko();
+  return mDocument->GetStyleSheetAt(aIndex);
 }
 
 void
 nsDOMStyleSheetList::NodeWillBeDestroyed(const nsINode *aNode)
 {
   mDocument = nullptr;
 }
 
--- a/dom/base/nsDocument.h
+++ b/dom/base/nsDocument.h
@@ -300,19 +300,18 @@ public:
   // nsIMutationObserver
   NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
 
   virtual nsINode* GetParentObject() const override
   {
     return mDocument;
   }
 
-  virtual uint32_t Length() override;
-  virtual mozilla::CSSStyleSheet*
-  IndexedGetter(uint32_t aIndex, bool& aFound) override;
+  uint32_t Length() override;
+  mozilla::StyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) override;
 
 protected:
   virtual ~nsDOMStyleSheetList();
 
   int32_t       mLength;
   nsIDocument*  mDocument;
 };
 
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -303,17 +303,17 @@ DOMInterfaces = {
     'nativeType': 'nsROCSSPrimitiveValue',
 },
 
 'CSSStyleDeclaration': {
     'nativeType': 'nsICSSDeclaration'
 },
 
 'CSSStyleSheet': {
-    'nativeType': 'mozilla::CSSStyleSheet',
+    'nativeType': 'mozilla::StyleSheet',
     'binaryNames': { 'ownerRule': 'DOMOwnerRule' },
 },
 
 'CSSValue': {
     'concrete': False
 },
 
 'CSSValueList': {
@@ -935,17 +935,18 @@ DOMInterfaces = {
     'headerFile': 'mozilla/dom/WorkerScope.h',
 },
 
 'Storage': {
     'nativeType': 'mozilla::dom::DOMStorage',
 },
 
 'StyleSheet': {
-    'nativeType': 'mozilla::CSSStyleSheet',
+    'nativeType': 'mozilla::StyleSheet',
+    'headerFile': 'mozilla/StyleSheetInlines.h',
 },
 
 'SVGAnimatedLengthList': {
     'nativeType': 'mozilla::DOMSVGAnimatedLengthList',
     'headerFile': 'DOMSVGAnimatedLengthList.h',
 },
 
 'SVGAnimatedNumberList': {
--- a/layout/inspector/inCSSValueSearch.cpp
+++ b/layout/inspector/inCSSValueSearch.cpp
@@ -93,17 +93,17 @@ inCSSValueSearch::SearchSync()
 
   nsCOMPtr<nsIURI> baseURI = document->GetBaseURI();
 
   RefPtr<dom::StyleSheetList> sheets = document->StyleSheets();
   MOZ_ASSERT(sheets);
 
   uint32_t length = sheets->Length();
   for (uint32_t i = 0; i < length; ++i) {
-    RefPtr<CSSStyleSheet> sheet = sheets->Item(i);
+    RefPtr<StyleSheet> sheet = sheets->Item(i);
     SearchStyleSheet(sheet, baseURI);
   }
 
   // XXX would be nice to search inline style as well.
 
   return NS_OK;
 }
 
--- a/layout/style/CSSStyleSheet.cpp
+++ b/layout/style/CSSStyleSheet.cpp
@@ -1237,54 +1237,47 @@ CSSStyleSheet::TraverseInner(nsCycleColl
   const nsCOMArray<css::Rule>& rules = mInner->mOrderedRules;
   for (int32_t i = 0, count = rules.Count(); i < count; ++i) {
     NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mOrderedRules[i]");
     cb.NoteXPCOMChild(rules[i]->GetExistingDOMRule());
   }
 }
 
 // QueryInterface implementation for CSSStyleSheet
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CSSStyleSheet)
-  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
-  NS_INTERFACE_MAP_ENTRY(nsIDOMStyleSheet)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMCSSStyleSheet)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(CSSStyleSheet)
   NS_INTERFACE_MAP_ENTRY(nsICSSLoaderObserver)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMCSSStyleSheet)
   if (aIID.Equals(NS_GET_IID(CSSStyleSheet)))
     foundInterface = reinterpret_cast<nsISupports*>(this);
   else
-NS_INTERFACE_MAP_END
-
+NS_INTERFACE_MAP_END_INHERITING(StyleSheet)
 
-NS_IMPL_CYCLE_COLLECTING_ADDREF(CSSStyleSheet)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(CSSStyleSheet)
+NS_IMPL_ADDREF_INHERITED(CSSStyleSheet, StyleSheet)
+NS_IMPL_RELEASE_INHERITED(CSSStyleSheet, StyleSheet)
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(CSSStyleSheet)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(CSSStyleSheet)
   tmp->DropMedia();
   // We do not unlink mNext; our parent will handle that.  If we
   // unlinked it here, our parent would not be able to walk its list
   // of child sheets and null out the back-references to it, if we got
   // unlinked before it does.
   tmp->DropRuleCollection();
   tmp->UnlinkInner();
   tmp->mScopeElement = nullptr;
-  NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
-NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(CSSStyleSheet)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_END_INHERITED(StyleSheet)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(CSSStyleSheet, StyleSheet)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMedia)
   // We do not traverse mNext; our parent will handle that.  See
   // comments in Unlink for why.
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRuleCollection)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mScopeElement)
   tmp->TraverseInner(cb);
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
-NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(CSSStyleSheet)
 
 nsresult
 CSSStyleSheet::AddRuleProcessor(nsCSSRuleProcessor* aProcessor)
 {
   if (! mRuleProcessors) {
     mRuleProcessors = new AutoTArray<nsCSSRuleProcessor*, 8>();
     if (!mRuleProcessors)
       return NS_ERROR_OUT_OF_MEMORY;
@@ -2025,16 +2018,9 @@ CSSStyleSheet::ReparseSheet(const nsAStr
         continue; // notify when loaded (see StyleSheetLoaded)
       }
       mDocument->StyleRuleAdded(this, rule);
     }
   }
   return NS_OK;
 }
 
-/* virtual */
-JSObject*
-CSSStyleSheet::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
-{
-  return CSSStyleSheetBinding::Wrap(aCx, this, aGivenProto);
-}
-
 } // namespace mozilla
--- a/layout/style/CSSStyleSheet.h
+++ b/layout/style/CSSStyleSheet.h
@@ -20,17 +20,16 @@
 #include "nscore.h"
 #include "nsCOMPtr.h"
 #include "nsAutoPtr.h"
 #include "nsICSSLoaderObserver.h"
 #include "nsTArrayForwardDeclare.h"
 #include "nsString.h"
 #include "mozilla/CORSMode.h"
 #include "nsCycleCollectionParticipant.h"
-#include "nsWrapperCache.h"
 #include "mozilla/net/ReferrerPolicy.h"
 #include "mozilla/dom/SRIMetadata.h"
 
 class CSSRuleListImpl;
 class nsCSSRuleProcessor;
 class nsIPrincipal;
 class nsIURI;
 class nsMediaList;
@@ -102,29 +101,27 @@ private:
 // 7985c7ac-9ddc-444d-9899-0c86ec122f54
 #define NS_CSS_STYLE_SHEET_IMPL_CID     \
 { 0x7985c7ac, 0x9ddc, 0x444d, \
   { 0x98, 0x99, 0x0c, 0x86, 0xec, 0x12, 0x2f, 0x54 } }
 
 
 class CSSStyleSheet final : public StyleSheet
                           , public nsICSSLoaderObserver
-                          , public nsWrapperCache
 {
 public:
   typedef net::ReferrerPolicy ReferrerPolicy;
   CSSStyleSheet(css::SheetParsingMode aParsingMode,
                 CORSMode aCORSMode, ReferrerPolicy aReferrerPolicy);
   CSSStyleSheet(css::SheetParsingMode aParsingMode,
                 CORSMode aCORSMode, ReferrerPolicy aReferrerPolicy,
                 const dom::SRIMetadata& aIntegrity);
 
-  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(CSSStyleSheet,
-                                                         nsIDOMCSSStyleSheet)
+  NS_DECL_ISUPPORTS_INHERITED
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CSSStyleSheet, StyleSheet)
 
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_CSS_STYLE_SHEET_IMPL_CID)
 
   bool HasRules() const;
 
   /**
    * Set the stylesheet to be enabled.  This may or may not make it
    * applicable.  Note that this WILL inform the sheet's document of
@@ -218,19 +215,16 @@ public:
   nsMediaList* Media() final;
 
   // WebIDL CSSStyleSheet API
   // Can't be inline because we can't include ImportRule here.  And can't be
   // called GetOwnerRule because that would be ambiguous with the ImportRule
   // version.
   nsIDOMCSSRule* GetDOMOwnerRule() const final;
 
-  // WebIDL miscellaneous bits
-  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
-
   void WillDirty();
   void DidDirty();
 
 private:
   CSSStyleSheet(const CSSStyleSheet& aCopy,
                 CSSStyleSheet* aParentToUse,
                 css::ImportRule* aOwnerRuleToUse,
                 nsIDocument* aDocumentToUse,
--- a/layout/style/ServoStyleSheet.cpp
+++ b/layout/style/ServoStyleSheet.cpp
@@ -18,23 +18,22 @@ ServoStyleSheet::ServoStyleSheet(css::Sh
 {
 }
 
 ServoStyleSheet::~ServoStyleSheet()
 {
   DropSheet();
 }
 
-NS_INTERFACE_MAP_BEGIN(ServoStyleSheet)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMCSSStyleSheet)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMStyleSheet)
-NS_INTERFACE_MAP_END
+// QueryInterface implementation for ServoStyleSheet
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ServoStyleSheet)
+NS_INTERFACE_MAP_END_INHERITING(StyleSheet)
 
-NS_IMPL_ADDREF(ServoStyleSheet)
-NS_IMPL_RELEASE(ServoStyleSheet)
+NS_IMPL_ADDREF_INHERITED(ServoStyleSheet, StyleSheet)
+NS_IMPL_RELEASE_INHERITED(ServoStyleSheet, StyleSheet)
 
 bool
 ServoStyleSheet::HasRules() const
 {
   return mSheet && Servo_StyleSheet_HasRules(mSheet);
 }
 
 void
--- a/layout/style/ServoStyleSheet.h
+++ b/layout/style/ServoStyleSheet.h
@@ -8,32 +8,33 @@
 #define mozilla_ServoStyleSheet_h
 
 #include "mozilla/dom/SRIMetadata.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/ServoBindingHelpers.h"
 #include "mozilla/StyleSheet.h"
 #include "mozilla/StyleSheetInfo.h"
 #include "nsStringFwd.h"
+#include "nsCycleCollectionParticipant.h"
 
 namespace mozilla {
 
 /**
  * CSS style sheet object that is a wrapper for a Servo Stylesheet.
  */
 class ServoStyleSheet : public StyleSheet
                       , public StyleSheetInfo
 {
 public:
   ServoStyleSheet(css::SheetParsingMode aParsingMode,
                   CORSMode aCORSMode,
                   net::ReferrerPolicy aReferrerPolicy,
                   const dom::SRIMetadata& aIntegrity);
 
-  NS_DECL_ISUPPORTS
+  NS_DECL_ISUPPORTS_INHERITED
 
   bool HasRules() const;
 
   void SetOwningDocument(nsIDocument* aDocument);
 
   ServoStyleSheet* GetParentSheet() const;
   void AppendStyleSheet(ServoStyleSheet* aSheet);
 
@@ -59,17 +60,17 @@ public:
   // called GetOwnerRule because that would be ambiguous with the ImportRule
   // version.
   nsIDOMCSSRule* GetDOMOwnerRule() const final;
 
   void WillDirty() {}
   void DidDirty() {}
 
 protected:
-  ~ServoStyleSheet();
+  virtual ~ServoStyleSheet();
 
   // Internal methods which do not have security check and completeness check.
   dom::CSSRuleList* GetCssRulesInternal(ErrorResult& aRv);
   uint32_t InsertRuleInternal(const nsAString& aRule,
                               uint32_t aIndex, ErrorResult& aRv);
   void DeleteRuleInternal(uint32_t aIndex, ErrorResult& aRv);
 
 private:
--- a/layout/style/StyleSheet.cpp
+++ b/layout/style/StyleSheet.cpp
@@ -31,16 +31,28 @@ StyleSheet::StyleSheet(const StyleSheet&
   , mDocument(aDocumentToUse)
   , mOwningNode(aOwningNodeToUse)
   , mParsingMode(aCopy.mParsingMode)
   , mType(aCopy.mType)
   , mDisabled(aCopy.mDisabled)
 {
 }
 
+// QueryInterface implementation for StyleSheet
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(StyleSheet)
+  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
+  NS_INTERFACE_MAP_ENTRY(nsIDOMStyleSheet)
+  NS_INTERFACE_MAP_ENTRY(nsIDOMCSSStyleSheet)
+NS_INTERFACE_MAP_END
+
+NS_IMPL_CYCLE_COLLECTING_ADDREF(StyleSheet)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(StyleSheet)
+
+NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(StyleSheet)
+
 mozilla::dom::CSSStyleSheetParsingMode
 StyleSheet::ParsingModeDOM()
 {
 #define CHECK(X, Y) \
   static_assert(static_cast<int>(X) == static_cast<int>(Y),             \
                 "mozilla::dom::CSSStyleSheetParsingMode and mozilla::css::SheetParsingMode should have identical values");
 
   CHECK(mozilla::dom::CSSStyleSheetParsingMode::Agent, css::eAgentSheetFeatures);
@@ -285,9 +297,17 @@ StyleSheet::AreRulesAvailable(const Mayb
   //   style sheet can access rule collections.
   SubjectSubsumesInnerPrincipal(aSubjectPrincipal, aRv);
   if (NS_WARN_IF(aRv.Failed())) {
     return false;
   }
   return true;
 }
 
+// nsWrapperCache
+
+JSObject*
+StyleSheet::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
+{
+  return CSSStyleSheetBinding::Wrap(aCx, this, aGivenProto);
+}
+
 } // namespace mozilla
--- a/layout/style/StyleSheet.h
+++ b/layout/style/StyleSheet.h
@@ -9,16 +9,17 @@
 
 #include "mozilla/css/SheetParsingMode.h"
 #include "mozilla/dom/CSSStyleSheetBinding.h"
 #include "mozilla/net/ReferrerPolicy.h"
 #include "mozilla/StyleBackendType.h"
 #include "mozilla/CORSMode.h"
 
 #include "nsIDOMCSSStyleSheet.h"
+#include "nsWrapperCache.h"
 
 class nsIDocument;
 class nsINode;
 class nsMediaList;
 
 namespace mozilla {
 
 class CSSStyleSheet;
@@ -29,24 +30,29 @@ namespace dom {
 class SRIMetadata;
 class CSSRuleList;
 } // namespace dom
 
 /**
  * Superclass for data common to CSSStyleSheet and ServoStyleSheet.
  */
 class StyleSheet : public nsIDOMCSSStyleSheet
+                 , public nsWrapperCache
 {
 protected:
   StyleSheet(StyleBackendType aType, css::SheetParsingMode aParsingMode);
   StyleSheet(const StyleSheet& aCopy,
              nsIDocument* aDocumentToUse,
              nsINode* aOwningNodeToUse);
+  virtual ~StyleSheet() {}
 
 public:
+  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(StyleSheet)
+
   void SetOwningNode(nsINode* aOwningNode)
   {
     mOwningNode = aOwningNode;
   }
 
   css::SheetParsingMode ParsingMode() { return mParsingMode; }
   mozilla::dom::CSSStyleSheetParsingMode ParsingModeDOM();
 
@@ -71,19 +77,16 @@ public:
 
   // Only safe to call if the caller has verified that that |this| is of the
   // correct type.
   inline CSSStyleSheet* AsGecko();
   inline ServoStyleSheet* AsServo();
   inline const CSSStyleSheet* AsGecko() const;
   inline const ServoStyleSheet* AsServo() const;
 
-  inline MozExternalRefCountType AddRef();
-  inline MozExternalRefCountType Release();
-
   // Whether the sheet is for an inline <style> element.
   inline bool IsInline() const;
 
   inline nsIURI* GetSheetURI() const;
   /* Get the URI this sheet was originally loaded from, if any.  Can
      return null */
   inline nsIURI* GetOriginalURI() const;
   inline nsIURI* GetBaseURI() const;
@@ -151,16 +154,17 @@ public:
                       const Maybe<nsIPrincipal*>& aSubjectPrincipal,
                       ErrorResult& aRv);
   void DeleteRule(uint32_t aIndex,
                   const Maybe<nsIPrincipal*>& aSubjectPrincipal,
                   ErrorResult& aRv);
 
   // WebIDL miscellaneous bits
   inline dom::ParentObject GetParentObject() const;
+  JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
 
   // nsIDOMStyleSheet interface
   NS_IMETHOD GetType(nsAString& aType) final;
   NS_IMETHOD GetDisabled(bool* aDisabled) final;
   NS_IMETHOD SetDisabled(bool aDisabled) final;
   NS_IMETHOD GetOwnerNode(nsIDOMNode** aOwnerNode) final;
   NS_IMETHOD GetParentStyleSheet(nsIDOMStyleSheet** aParentStyleSheet) final;
   NS_IMETHOD GetHref(nsAString& aHref) final;
--- a/layout/style/StyleSheetInlines.h
+++ b/layout/style/StyleSheetInlines.h
@@ -69,28 +69,16 @@ StyleSheet::SheetInfo() const
                 "ServoStyleSheet should define its own " #method_); \
   if (IsServo()) { \
     return AsServo()->method_ servoargs_; \
   } \
   return AsGecko()->method_ geckoargs_;
 
 #define FORWARD(method_, args_) FORWARD_CONCRETE(method_, args_, args_)
 
-MozExternalRefCountType
-StyleSheet::AddRef()
-{
-  FORWARD(AddRef, ())
-}
-
-MozExternalRefCountType
-StyleSheet::Release()
-{
-  FORWARD(Release, ())
-}
-
 bool
 StyleSheet::IsInline() const
 {
   return !SheetInfo().mOriginalSheetURI;
 }
 
 nsIURI*
 StyleSheet::GetSheetURI() const
@@ -220,29 +208,11 @@ StyleSheet::List(FILE* aOut, int32_t aIn
 #endif
 
 void StyleSheet::WillDirty() { FORWARD(WillDirty, ()) }
 void StyleSheet::DidDirty() { FORWARD(DidDirty, ()) }
 
 #undef FORWARD
 #undef FORWARD_CONCRETE
 
-inline void
-ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
-                            RefPtr<StyleSheet>& aField,
-                            const char* aName,
-                            uint32_t aFlags = 0)
-{
-  if (aField && aField->IsGecko()) {
-    NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(aCallback, aName);
-    aCallback.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, aField->AsGecko()));
-  }
-}
-
-inline void
-ImplCycleCollectionUnlink(RefPtr<StyleSheet>& aField)
-{
-  aField = nullptr;
-}
-
 }
 
 #endif // mozilla_StyleSheetInlines_h