Backed out changeset 02d0214c5e37 (bug 738196)
authorEd Morley <emorley@mozilla.com>
Thu, 10 Apr 2014 15:47:57 +0100
changeset 178005 60541caee1d7f46e9f25c39193ce489305f88643
parent 178004 329d3187bca84a51b125d2dd7e0a947dd89b33ed
child 178006 f3eec266cf22b6eb824ce9578e1f43fa0601388c
push id26569
push userryanvm@gmail.com
push dateFri, 11 Apr 2014 04:11:36 +0000
treeherdermozilla-central@783c5013dbec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs738196
milestone31.0a1
backs out02d0214c5e376eed361db12ed8678bebc60525cc
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 02d0214c5e37 (bug 738196)
content/base/public/nsIDocument.h
content/base/src/ShadowRoot.cpp
content/base/src/ShadowRoot.h
content/base/src/StyleSheetList.cpp
content/base/src/StyleSheetList.h
content/base/src/moz.build
content/base/src/nsDocument.cpp
content/base/src/nsDocument.h
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfo.h
dom/base/nsDOMClassInfoClasses.h
dom/bindings/Bindings.conf
dom/interfaces/stylesheets/nsIDOMStyleSheetList.idl
dom/webidl/Document.webidl
dom/webidl/StyleSheetList.webidl
dom/webidl/moz.build
layout/inspector/inCSSValueSearch.cpp
--- a/content/base/public/nsIDocument.h
+++ b/content/base/public/nsIDocument.h
@@ -107,17 +107,16 @@ class EventTarget;
 class FrameRequestCallback;
 class HTMLBodyElement;
 struct LifecycleCallbackArgs;
 class Link;
 class GlobalObject;
 class NodeFilter;
 class NodeIterator;
 class ProcessingInstruction;
-class StyleSheetList;
 class Touch;
 class TouchList;
 class TreeWalker;
 class UndoManager;
 class XPathEvaluator;
 template<typename> class OwningNonNull;
 template<typename> class Sequence;
 
@@ -2172,17 +2171,17 @@ public:
   {
     return mVisibilityState;
   }
   mozilla::dom::VisibilityState MozVisibilityState()
   {
     WarnOnceAbout(ePrefixedVisibilityAPI);
     return VisibilityState();
   }
-  virtual mozilla::dom::StyleSheetList* StyleSheets() = 0;
+  virtual nsIDOMStyleSheetList* StyleSheets() = 0;
   void GetSelectedStyleSheetSet(nsAString& aSheetSet);
   virtual void SetSelectedStyleSheetSet(const nsAString& aSheetSet) = 0;
   virtual void GetLastStyleSheetSet(nsString& aSheetSet) = 0;
   void GetPreferredStyleSheetSet(nsAString& aSheetSet);
   virtual mozilla::dom::DOMStringList* StyleSheetSets() = 0;
   virtual void EnableStyleSheetsForSet(const nsAString& aSheetSet) = 0;
   Element* ElementFromPoint(float aX, float aY);
 
--- a/content/base/src/ShadowRoot.cpp
+++ b/content/base/src/ShadowRoot.cpp
@@ -479,17 +479,17 @@ ShadowRoot::SetApplyAuthorStyles(bool aA
   nsIPresShell* shell = OwnerDoc()->GetShell();
   if (shell) {
     OwnerDoc()->BeginUpdate(UPDATE_STYLE);
     shell->RestyleShadowRoot(this);
     OwnerDoc()->EndUpdate(UPDATE_STYLE);
   }
 }
 
-StyleSheetList*
+nsIDOMStyleSheetList*
 ShadowRoot::StyleSheets()
 {
   if (!mStyleSheetList) {
     mStyleSheetList = new ShadowRootStyleSheetList(this);
   }
 
   return mStyleSheetList;
 }
@@ -650,56 +650,65 @@ ShadowRoot::ContentRemoved(nsIDocument* 
 
   // Watch for node that is removed from the pool because
   // it may need to be removed from an insertion point.
   if (IsPooledNode(aChild, aContainer, mPoolHost)) {
     RemoveDistributedNode(aChild);
   }
 }
 
-NS_IMPL_CYCLE_COLLECTION_INHERITED_1(ShadowRootStyleSheetList, StyleSheetList,
-                                     mShadowRoot)
+NS_IMPL_CYCLE_COLLECTION_1(ShadowRootStyleSheetList, mShadowRoot)
 
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ShadowRootStyleSheetList)
-NS_INTERFACE_MAP_END_INHERITING(StyleSheetList)
+NS_INTERFACE_TABLE_HEAD(ShadowRootStyleSheetList)
+  NS_INTERFACE_TABLE1(ShadowRootStyleSheetList, nsIDOMStyleSheetList)
+  NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(ShadowRootStyleSheetList)
+  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(StyleSheetList)
+NS_INTERFACE_MAP_END
 
-NS_IMPL_ADDREF_INHERITED(ShadowRootStyleSheetList, StyleSheetList)
-NS_IMPL_RELEASE_INHERITED(ShadowRootStyleSheetList, StyleSheetList)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(ShadowRootStyleSheetList)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(ShadowRootStyleSheetList)
 
 ShadowRootStyleSheetList::ShadowRootStyleSheetList(ShadowRoot* aShadowRoot)
   : mShadowRoot(aShadowRoot)
 {
   MOZ_COUNT_CTOR(ShadowRootStyleSheetList);
 }
 
 ShadowRootStyleSheetList::~ShadowRootStyleSheetList()
 {
   MOZ_COUNT_DTOR(ShadowRootStyleSheetList);
 }
 
 nsCSSStyleSheet*
-ShadowRootStyleSheetList::IndexedGetter(uint32_t aIndex, bool& aFound)
+ShadowRootStyleSheetList::GetItemAt(uint32_t aIndex)
 {
   nsTArray<nsRefPtr<nsCSSStyleSheet>>* sheets =
     mShadowRoot->mProtoBinding->GetStyleSheets();
 
   if (!sheets) {
-    aFound = false;
     return nullptr;
   }
 
-  aFound = aIndex < sheets->Length();
   return sheets->SafeElementAt(aIndex);
 }
 
-uint32_t
-ShadowRootStyleSheetList::Length()
+NS_IMETHODIMP
+ShadowRootStyleSheetList::Item(uint32_t aIndex, nsIDOMStyleSheet** aReturn)
+{
+  NS_IF_ADDREF(*aReturn = GetItemAt(aIndex));
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+ShadowRootStyleSheetList::GetLength(uint32_t* aLength)
 {
   nsTArray<nsRefPtr<nsCSSStyleSheet> >* sheets =
     mShadowRoot->mProtoBinding->GetStyleSheets();
 
-  if (!sheets) {
-    return 0;
+  if (sheets) {
+    *aLength = sheets->Length();
+  } else {
+    *aLength = 0;
   }
 
-  return sheets->Length();
+  return NS_OK;
 }
 
--- a/content/base/src/ShadowRoot.h
+++ b/content/base/src/ShadowRoot.h
@@ -48,17 +48,17 @@ public:
   virtual ~ShadowRoot();
 
   void AddToIdTable(Element* aElement, nsIAtom* aId);
   void RemoveFromIdTable(Element* aElement, nsIAtom* aId);
   void InsertSheet(nsCSSStyleSheet* aSheet, nsIContent* aLinkingContent);
   void RemoveSheet(nsCSSStyleSheet* aSheet);
   bool ApplyAuthorStyles();
   void SetApplyAuthorStyles(bool aApplyAuthorStyles);
-  StyleSheetList* StyleSheets();
+  nsIDOMStyleSheetList* StyleSheets();
   HTMLShadowElement* GetShadowElement() { return mShadowElement; }
 
   /**
    * Sets the current shadow insertion point where the older
    * ShadowRoot will be projected.
    */
   void SetShadowElement(HTMLShadowElement* aShadowElement);
 
@@ -171,26 +171,23 @@ protected:
 };
 
 class ShadowRootStyleSheetList : public StyleSheetList
 {
 public:
   ShadowRootStyleSheetList(ShadowRoot* aShadowRoot);
   virtual ~ShadowRootStyleSheetList();
 
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ShadowRootStyleSheetList, StyleSheetList)
+  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+  NS_DECL_CYCLE_COLLECTION_CLASS(ShadowRootStyleSheetList)
 
-  virtual nsINode* GetParentObject() const MOZ_OVERRIDE
-  {
-    return mShadowRoot;
-  }
+  // nsIDOMStyleSheetList
+  NS_DECL_NSIDOMSTYLESHEETLIST
 
-  virtual uint32_t Length() MOZ_OVERRIDE;
-  virtual nsCSSStyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) MOZ_OVERRIDE;
+  virtual nsCSSStyleSheet* GetItemAt(uint32_t aIndex) MOZ_OVERRIDE;
 
 protected:
   nsRefPtr<ShadowRoot> mShadowRoot;
 };
 
 } // namespace dom
 } // namespace mozilla
 
deleted file mode 100644
--- a/content/base/src/StyleSheetList.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "mozilla/dom/StyleSheetList.h"
-
-#include "mozilla/dom/StyleSheetListBinding.h"
-#include "nsCSSStyleSheet.h"
-
-namespace mozilla {
-namespace dom {
-
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(StyleSheetList)
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(StyleSheetList)
-  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
-  NS_INTERFACE_MAP_ENTRY(nsIDOMStyleSheetList)
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
-NS_INTERFACE_MAP_END
-
-NS_IMPL_CYCLE_COLLECTING_ADDREF(StyleSheetList)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(StyleSheetList)
-
-/* virtual */ JSObject*
-StyleSheetList::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
-{
-  return StyleSheetListBinding::Wrap(aCx, aScope, this);
-}
-
-NS_IMETHODIMP
-StyleSheetList::GetLength(uint32_t* aLength)
-{
-  *aLength = Length();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-StyleSheetList::SlowItem(uint32_t aIndex, nsIDOMStyleSheet** aItem)
-{
-  NS_IF_ADDREF(*aItem = Item(aIndex));
-  return NS_OK;
-}
-
-} // namespace dom
-} // namespace mozilla
--- a/content/base/src/StyleSheetList.h
+++ b/content/base/src/StyleSheetList.h
@@ -2,48 +2,40 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_StyleSheetList_h
 #define mozilla_dom_StyleSheetList_h
 
 #include "nsIDOMStyleSheetList.h"
-#include "nsWrapperCache.h"
 
 class nsCSSStyleSheet;
-class nsINode;
 
 namespace mozilla {
 namespace dom {
 
 class StyleSheetList : public nsIDOMStyleSheetList
-                     , public nsWrapperCache
 {
 public:
-  StyleSheetList()
+  static StyleSheetList* FromSupports(nsISupports* aSupports)
   {
-    SetIsDOMBinding();
-  }
-  virtual ~StyleSheetList() {}
-
-  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(StyleSheetList)
-  NS_DECL_NSIDOMSTYLESHEETLIST
+    nsIDOMStyleSheetList* list = static_cast<nsIDOMStyleSheetList*>(aSupports);
+#ifdef DEBUG
+    {
+      nsCOMPtr<nsIDOMStyleSheetList> list_qi = do_QueryInterface(aSupports);
 
-  virtual JSObject*
-  WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE MOZ_FINAL;
-
-  virtual nsINode* GetParentObject() const = 0;
+      // If this assertion fires the QI implementation for the object in
+      // question doesn't use the nsIDOMStyleSheetList pointer as the
+      // nsISupports pointer. That must be fixed, or we'll crash...
+      MOZ_ASSERT(list_qi == list, "Uh, fix QI!");
+    }
+#endif
+    return static_cast<StyleSheetList*>(list);
+  }
 
-  virtual uint32_t Length() = 0;
-  virtual nsCSSStyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) = 0;
-  nsCSSStyleSheet* Item(uint32_t aIndex)
-  {
-    bool dummy = false;
-    return IndexedGetter(aIndex, dummy);
-  }
+  virtual nsCSSStyleSheet* GetItemAt(uint32_t aIndex) = 0;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_StyleSheetList_h
--- a/content/base/src/moz.build
+++ b/content/base/src/moz.build
@@ -157,17 +157,16 @@ UNIFIED_SOURCES += [
     'nsTraversal.cpp',
     'nsTreeSanitizer.cpp',
     'nsViewportInfo.cpp',
     'nsXHTMLContentSerializer.cpp',
     'nsXMLContentSerializer.cpp',
     'nsXMLHttpRequest.cpp',
     'nsXMLNameSpaceMap.cpp',
     'ShadowRoot.cpp',
-    'StyleSheetList.cpp',
     'Text.cpp',
     'ThirdPartyUtil.cpp',
     'TreeWalker.cpp',
     'WebSocket.cpp',
 ]
 
 # These files cannot be built in unified mode because they use FORCE_PR_LOG
 SOURCES += [
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -718,60 +718,88 @@ nsDOMStyleSheetList::nsDOMStyleSheetList
 
 nsDOMStyleSheetList::~nsDOMStyleSheetList()
 {
   if (mDocument) {
     mDocument->RemoveObserver(this);
   }
 }
 
-NS_IMPL_ISUPPORTS_INHERITED2(nsDOMStyleSheetList, StyleSheetList,
-                             nsIDocumentObserver,
-                             nsIMutationObserver)
-
-uint32_t
-nsDOMStyleSheetList::Length()
-{
-  if (!mDocument) {
-    return 0;
-  }
-
-  // XXX Find the number and then cache it. We'll use the
-  // observer notification to figure out if new ones have
-  // been added or removed.
-  if (-1 == mLength) {
-    mLength = mDocument->GetNumberOfStyleSheets();
+DOMCI_DATA(StyleSheetList, nsDOMStyleSheetList)
+
+// XXX couldn't we use the GetIIDs method from CSSStyleSheetList here?
+// QueryInterface implementation for nsDOMStyleSheetList
+NS_INTERFACE_TABLE_HEAD(nsDOMStyleSheetList)
+  NS_INTERFACE_TABLE3(nsDOMStyleSheetList,
+                      nsIDOMStyleSheetList,
+                      nsIDocumentObserver,
+                      nsIMutationObserver)
+  NS_INTERFACE_TABLE_TO_MAP_SEGUE
+  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(StyleSheetList)
+NS_INTERFACE_MAP_END
+
+
+NS_IMPL_ADDREF(nsDOMStyleSheetList)
+NS_IMPL_RELEASE(nsDOMStyleSheetList)
+
+
+NS_IMETHODIMP
+nsDOMStyleSheetList::GetLength(uint32_t* aLength)
+{
+  if (mDocument) {
+    // XXX Find the number and then cache it. We'll use the
+    // observer notification to figure out if new ones have
+    // been added or removed.
+    if (-1 == mLength) {
+      mLength = mDocument->GetNumberOfStyleSheets();
 
 #ifdef DEBUG
-    int32_t i;
-    for (i = 0; i < mLength; i++) {
-      nsIStyleSheet *sheet = mDocument->GetStyleSheetAt(i);
-      nsCOMPtr<nsIDOMStyleSheet> domss(do_QueryInterface(sheet));
-      NS_ASSERTION(domss, "All \"normal\" sheets implement nsIDOMStyleSheet");
-    }
+      int32_t i;
+      for (i = 0; i < mLength; i++) {
+        nsIStyleSheet *sheet = mDocument->GetStyleSheetAt(i);
+        nsCOMPtr<nsIDOMStyleSheet> domss(do_QueryInterface(sheet));
+        NS_ASSERTION(domss, "All \"normal\" sheets implement nsIDOMStyleSheet");
+      }
 #endif
-  }
-  return mLength;
+    }
+    *aLength = mLength;
+  }
+  else {
+    *aLength = 0;
+  }
+
+  return NS_OK;
 }
 
 nsCSSStyleSheet*
-nsDOMStyleSheetList::IndexedGetter(uint32_t aIndex, bool& aFound)
+nsDOMStyleSheetList::GetItemAt(uint32_t aIndex)
 {
   if (!mDocument || aIndex >= (uint32_t)mDocument->GetNumberOfStyleSheets()) {
-    aFound = false;
     return nullptr;
   }
 
-  aFound = true;
   nsIStyleSheet *sheet = mDocument->GetStyleSheetAt(aIndex);
   NS_ASSERTION(sheet, "Must have a sheet");
 
   return static_cast<nsCSSStyleSheet*>(sheet);
 }
 
+NS_IMETHODIMP
+nsDOMStyleSheetList::Item(uint32_t aIndex, nsIDOMStyleSheet** aReturn)
+{
+  nsIStyleSheet *sheet = GetItemAt(aIndex);
+  if (!sheet) {
+      *aReturn = nullptr;
+
+      return NS_OK;
+  }
+
+  return CallQueryInterface(sheet, aReturn);
+}
+
 void
 nsDOMStyleSheetList::NodeWillBeDestroyed(const nsINode *aNode)
 {
   mDocument = nullptr;
 }
 
 void
 nsDOMStyleSheetList::StyleSheetAdded(nsIDocument *aDocument,
@@ -6075,17 +6103,17 @@ nsDocument::Load(const nsAString& aUrl, 
 
 NS_IMETHODIMP
 nsDocument::GetStyleSheets(nsIDOMStyleSheetList** aStyleSheets)
 {
   NS_ADDREF(*aStyleSheets = StyleSheets());
   return NS_OK;
 }
 
-StyleSheetList*
+nsIDOMStyleSheetList*
 nsDocument::StyleSheets()
 {
   if (!mDOMStyleSheets) {
     mDOMStyleSheets = new nsDOMStyleSheetList(this);
   }
   return mDOMStyleSheets;
 }
 
--- a/content/base/src/nsDocument.h
+++ b/content/base/src/nsDocument.h
@@ -437,32 +437,28 @@ public:
 
 class nsDOMStyleSheetList : public mozilla::dom::StyleSheetList,
                             public nsStubDocumentObserver
 {
 public:
   nsDOMStyleSheetList(nsIDocument *aDocument);
   virtual ~nsDOMStyleSheetList();
 
-  NS_DECL_ISUPPORTS_INHERITED
+  NS_DECL_ISUPPORTS
+
+  NS_DECL_NSIDOMSTYLESHEETLIST
 
   // nsIDocumentObserver
   NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETADDED
   NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETREMOVED
 
   // nsIMutationObserver
   NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
 
-  virtual nsINode* GetParentObject() const MOZ_OVERRIDE
-  {
-    return mDocument;
-  }
-
-  virtual uint32_t Length() MOZ_OVERRIDE;
-  virtual nsCSSStyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) MOZ_OVERRIDE;
+  virtual nsCSSStyleSheet* GetItemAt(uint32_t aIndex) MOZ_OVERRIDE;
 
 protected:
   int32_t       mLength;
   nsIDocument*  mDocument;
 };
 
 class nsOnloadBlocker MOZ_FINAL : public nsIRequest
 {
@@ -1223,17 +1219,17 @@ public:
 
   // WebIDL bits
   virtual mozilla::dom::DOMImplementation*
     GetImplementation(mozilla::ErrorResult& rv) MOZ_OVERRIDE;
   virtual JSObject*
     RegisterElement(JSContext* aCx, const nsAString& aName,
                     const mozilla::dom::ElementRegistrationOptions& aOptions,
                     mozilla::ErrorResult& rv) MOZ_OVERRIDE;
-  virtual mozilla::dom::StyleSheetList* StyleSheets() MOZ_OVERRIDE;
+  virtual nsIDOMStyleSheetList* StyleSheets() MOZ_OVERRIDE;
   virtual void SetSelectedStyleSheetSet(const nsAString& aSheetSet) MOZ_OVERRIDE;
   virtual void GetLastStyleSheetSet(nsString& aSheetSet) MOZ_OVERRIDE;
   virtual mozilla::dom::DOMStringList* StyleSheetSets() MOZ_OVERRIDE;
   virtual void EnableStyleSheetsForSet(const nsAString& aSheetSet) MOZ_OVERRIDE;
   using nsIDocument::CreateElement;
   using nsIDocument::CreateElementNS;
   virtual already_AddRefed<Element> CreateElement(const nsAString& aTagName,
                                                   const nsAString& aTypeExtension,
@@ -1430,17 +1426,17 @@ public:
                                     mozilla::ErrorResult& rv);
 
   static bool IsRegisterElementEnabled(JSContext* aCx, JSObject* aObject);
 
   // The "registry" from the web components spec.
   nsRefPtr<mozilla::dom::Registry> mRegistry;
 
   nsRefPtr<mozilla::EventListenerManager> mListenerManager;
-  nsRefPtr<mozilla::dom::StyleSheetList> mDOMStyleSheets;
+  nsCOMPtr<nsIDOMStyleSheetList> mDOMStyleSheets;
   nsRefPtr<nsDOMStyleSheetSetList> mStyleSheetSetList;
   nsRefPtr<nsScriptLoader> mScriptLoader;
   nsDocHeaderData* mHeaderData;
   /* mIdentifierMap works as follows for IDs:
    * 1) Attribute changes affect the table immediately (removing and adding
    *    entries as needed).
    * 2) Removals from the DOM affect the table immediately
    * 3) Additions to the DOM always update existing entries for names, and add
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -80,16 +80,17 @@
 #include "nsIDOMXULCheckboxElement.h"
 #include "nsIDOMXULPopupElement.h"
 
 // Event related includes
 #include "nsIDOMEventTarget.h"
 
 // CSS related includes
 #include "nsCSSRules.h"
+#include "nsIDOMStyleSheetList.h"
 #include "nsIDOMCSSRule.h"
 #include "nsICSSRuleList.h"
 #include "nsAutoPtr.h"
 #include "nsMemory.h"
 
 // Tranformiix
 #include "nsIXSLTProcessor.h"
 #include "nsIXSLTProcessorPrivate.h"
@@ -313,16 +314,18 @@ static nsDOMClassInfoData sClassInfoData
   NS_DEFINE_CLASSINFO_DATA(CSSImportRule, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(CSSMediaRule, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(CSSNameSpaceRule, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(CSSRuleList, nsCSSRuleListSH,
                            ARRAY_SCRIPTABLE_FLAGS)
+  NS_DEFINE_CLASSINFO_DATA(StyleSheetList, nsStyleSheetListSH,
+                           ARRAY_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(CSSStyleSheet, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   // XUL classes
 #ifdef MOZ_XUL
   NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(XULCommandDispatcher, nsDOMGenericSH,
                                       DOM_DEFAULT_SCRIPTABLE_FLAGS)
 #endif
@@ -940,16 +943,20 @@ nsDOMClassInfo::Init()
   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(CSSNameSpaceRule, nsIDOMCSSRule)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSRule)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(CSSRuleList, nsIDOMCSSRuleList)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSRuleList)
   DOM_CLASSINFO_MAP_END
 
+  DOM_CLASSINFO_MAP_BEGIN(StyleSheetList, nsIDOMStyleSheetList)
+    DOM_CLASSINFO_MAP_ENTRY(nsIDOMStyleSheetList)
+  DOM_CLASSINFO_MAP_END
+
   DOM_CLASSINFO_MAP_BEGIN(CSSStyleSheet, nsIDOMCSSStyleSheet)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleSheet)
   DOM_CLASSINFO_MAP_END
 
 #ifdef MOZ_XUL
   DOM_CLASSINFO_MAP_BEGIN(XULCommandDispatcher, nsIDOMXULCommandDispatcher)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULCommandDispatcher)
   DOM_CLASSINFO_MAP_END
@@ -3668,16 +3675,28 @@ nsArraySH::GetProperty(nsIXPConnectWrapp
       rv = NS_SUCCESS_I_DID_SOMETHING;
     }
   }
 
   return rv;
 }
 
 
+// StyleSheetList helper
+
+nsISupports*
+nsStyleSheetListSH::GetItemAt(nsISupports *aNative, uint32_t aIndex,
+                              nsWrapperCache **aCache, nsresult *rv)
+{
+  StyleSheetList* list = StyleSheetList::FromSupports(aNative);
+  nsIDOMStyleSheet* item = list->GetItemAt(aIndex);
+  return item;
+}
+
+
 // CSSRuleList scriptable helper
 
 nsISupports*
 nsCSSRuleListSH::GetItemAt(nsISupports *aNative, uint32_t aIndex,
                            nsWrapperCache **aCache, nsresult *aResult)
 {
   nsICSSRuleList* list = static_cast<nsICSSRuleList*>(aNative);
 #ifdef DEBUG
--- a/dom/base/nsDOMClassInfo.h
+++ b/dom/base/nsDOMClassInfo.h
@@ -363,16 +363,40 @@ public:
                          JSObject *obj, jsid id, JS::Value *vp, bool *_retval) MOZ_OVERRIDE;
 
 private:
   // Not implemented, nothing should create an instance of this class.
   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData);
 };
 
 
+// StyleSheetList helper
+
+class nsStyleSheetListSH : public nsArraySH
+{
+protected:
+  nsStyleSheetListSH(nsDOMClassInfoData* aData) : nsArraySH(aData)
+  {
+  }
+
+  virtual ~nsStyleSheetListSH()
+  {
+  }
+
+  virtual nsISupports* GetItemAt(nsISupports *aNative, uint32_t aIndex,
+                                 nsWrapperCache **aCache, nsresult *aResult) MOZ_OVERRIDE;
+
+public:
+  static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
+  {
+    return new nsStyleSheetListSH(aData);
+  }
+};
+
+
 // CSSRuleList helper
 
 class nsCSSRuleListSH : public nsArraySH
 {
 protected:
   nsCSSRuleListSH(nsDOMClassInfoData* aData) : nsArraySH(aData)
   {
   }
--- a/dom/base/nsDOMClassInfoClasses.h
+++ b/dom/base/nsDOMClassInfoClasses.h
@@ -11,16 +11,17 @@ DOMCI_CLASS(DOMConstructor)
 
 // CSS classes
 DOMCI_CLASS(CSSStyleRule)
 DOMCI_CLASS(CSSCharsetRule)
 DOMCI_CLASS(CSSImportRule)
 DOMCI_CLASS(CSSMediaRule)
 DOMCI_CLASS(CSSNameSpaceRule)
 DOMCI_CLASS(CSSRuleList)
+DOMCI_CLASS(StyleSheetList)
 DOMCI_CLASS(CSSStyleSheet)
 
 // XUL classes
 #ifdef MOZ_XUL
 DOMCI_CLASS(XULCommandDispatcher)
 #endif
 DOMCI_CLASS(XULControllers)
 DOMCI_CLASS(BoxObject)
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -1900,16 +1900,17 @@ addExternalIface('nsIDocShell', nativeTy
 addExternalIface('nsIEditor', nativeType='nsIEditor', notflattened=True)
 addExternalIface('nsIVariant', nativeType='nsIVariant', notflattened=True)
 addExternalIface('OutputStream', nativeType='nsIOutputStream',
                  notflattened=True)
 addExternalIface('Principal', nativeType='nsIPrincipal',
                  headerFile='nsIPrincipal.h', notflattened=True)
 addExternalIface('StackFrame', nativeType='nsIStackFrame',
                  headerFile='nsIException.h', notflattened=True)
+addExternalIface('StyleSheetList')
 addExternalIface('SVGLength')
 addExternalIface('SVGNumber')
 addExternalIface('URI', nativeType='nsIURI', headerFile='nsIURI.h',
                  notflattened=True)
 addExternalIface('UserDataHandler')
 addExternalIface('XPathResult', nativeType='nsISupports')
 addExternalIface('XPathExpression')
 addExternalIface('XPathNSResolver')
--- a/dom/interfaces/stylesheets/nsIDOMStyleSheetList.idl
+++ b/dom/interfaces/stylesheets/nsIDOMStyleSheetList.idl
@@ -12,11 +12,10 @@
  * For more information on this interface please see
  * http://www.w3.org/TR/DOM-Level-2-Style
  */
 
 [scriptable, uuid(a6cf9081-15b3-11d2-932e-00805f8add32)]
 interface nsIDOMStyleSheetList : nsISupports
 {
   readonly attribute unsigned long    length;
-  [binaryname(SlowItem)]
   nsIDOMStyleSheet         item(in unsigned long index);
 };
--- a/dom/webidl/Document.webidl
+++ b/dom/webidl/Document.webidl
@@ -10,16 +10,17 @@
  * http://dvcs.w3.org/hg/pointerlock/raw-file/default/index.html#extensions-to-the-document-interface
  * http://dvcs.w3.org/hg/webperf/raw-file/tip/specs/PageVisibility/Overview.html#sec-document-interface
  * http://dev.w3.org/csswg/cssom/#extensions-to-the-document-interface
  * http://dev.w3.org/csswg/cssom-view/#extensions-to-the-document-interface
  *
  * http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/core/nsIDOMDocument.idl
  */
 
+interface StyleSheetList;
 interface WindowProxy;
 interface nsISupports;
 interface URI;
 interface nsIDocShell;
 
 enum VisibilityState { "hidden", "visible" };
 
 /* http://dom.spec.whatwg.org/#interface-document */
deleted file mode 100644
--- a/dom/webidl/StyleSheetList.webidl
+++ /dev/null
@@ -1,8 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-interface StyleSheetList {
-  readonly attribute unsigned long length;
-  getter StyleSheet? item(unsigned long index);
-};
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -298,17 +298,16 @@ WEBIDL_FILES = [
     'ShadowRoot.webidl',
     'SharedWorker.webidl',
     'SharedWorkerGlobalScope.webidl',
     'SimpleGestureEvent.webidl',
     'SourceBuffer.webidl',
     'SourceBufferList.webidl',
     'StorageType.webidl',
     'StyleSheet.webidl',
-    'StyleSheetList.webidl',
     'SVGAElement.webidl',
     'SVGAltGlyphElement.webidl',
     'SVGAngle.webidl',
     'SVGAnimatedAngle.webidl',
     'SVGAnimatedBoolean.webidl',
     'SVGAnimatedEnumeration.webidl',
     'SVGAnimatedInteger.webidl',
     'SVGAnimatedLength.webidl',
--- a/layout/inspector/inCSSValueSearch.cpp
+++ b/layout/inspector/inCSSValueSearch.cpp
@@ -1,16 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "inCSSValueSearch.h"
 
-#include "mozilla/dom/StyleSheetList.h"
-#include "nsCSSStyleSheet.h"
 #include "nsIComponentManager.h"
 #include "nsIServiceManager.h"
 #include "nsVoidArray.h"
 #include "nsReadableUtils.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMStyleSheetList.h"
 #include "nsIDOMCSSStyleSheet.h"
 #include "nsIDOMCSSRuleList.h"
@@ -18,18 +16,16 @@
 #include "nsIDOMCSSStyleDeclaration.h"
 #include "nsIDOMCSSImportRule.h"
 #include "nsIDOMCSSMediaRule.h"
 #include "nsIDOMCSSSupportsRule.h"
 #include "nsIURI.h"
 #include "nsIDocument.h"
 #include "nsNetUtil.h"
 
-using namespace mozilla;
-
 ///////////////////////////////////////////////////////////////////////////////
 inCSSValueSearch::inCSSValueSearch()
   : mResults(nullptr),
     mProperties(nullptr),
     mResultCount(0),
     mPropertyCount(0),
     mIsActive(false),
     mHoldResults(true),
@@ -84,28 +80,34 @@ NS_IMETHODIMP
 inCSSValueSearch::SearchSync()
 {
   InitSearch();
 
   if (!mDocument) {
     return NS_OK;
   }
 
-  nsCOMPtr<nsIDocument> document = do_QueryInterface(mDocument);
-  MOZ_ASSERT(document);
-
-  nsCOMPtr<nsIURI> baseURI = document->GetBaseURI();
+  nsCOMPtr<nsIURI> baseURI;
+  nsCOMPtr<nsIDocument> idoc = do_QueryInterface(mDocument);
+  if (idoc) {
+    baseURI = idoc->GetBaseURI();
+  }
 
-  nsRefPtr<dom::StyleSheetList> sheets = document->StyleSheets();
-  MOZ_ASSERT(sheets);
+  nsCOMPtr<nsIDOMStyleSheetList> sheets;
+  nsresult rv = mDocument->GetStyleSheets(getter_AddRefs(sheets));
+  NS_ENSURE_SUCCESS(rv, NS_OK);
 
-  uint32_t length = sheets->Length();
+  uint32_t length;
+  sheets->GetLength(&length);
   for (uint32_t i = 0; i < length; ++i) {
-    nsRefPtr<nsCSSStyleSheet> sheet = sheets->Item(i);
-    SearchStyleSheet(sheet, baseURI);
+    nsCOMPtr<nsIDOMStyleSheet> sheet;
+    sheets->Item(i, getter_AddRefs(sheet));
+    nsCOMPtr<nsIDOMCSSStyleSheet> cssSheet = do_QueryInterface(sheet);
+    if (cssSheet)
+      SearchStyleSheet(cssSheet, baseURI);
   }
 
   // XXX would be nice to search inline style as well.
 
   return NS_OK;
 }
 
 NS_IMETHODIMP