Backout revision 308e51eae10c for build bustage.
authorMs2ger <ms2ger@gmail.com>
Fri, 20 Jun 2014 13:00:08 +0200
changeset 211680 3bf0b88186bf6eb6461a1b59f922f5ee906e2576
parent 211679 a03ae2d574c27be6f136219760f13136b01cbb98
child 211681 77f59b3856545de416d405975945bf8fb147e775
push idunknown
push userunknown
push dateunknown
milestone33.0a1
backs out308e51eae10c244ffdf0e38c4fe983f1248ef473
Backout revision 308e51eae10c for build bustage.
chrome/src/nsChromeRegistry.cpp
content/base/public/nsIDocument.h
content/base/public/nsIStyleSheetLinkingElement.h
content/base/src/ShadowRoot.cpp
content/base/src/ShadowRoot.h
content/base/src/StyleSheetList.cpp
content/base/src/StyleSheetList.h
content/base/src/nsContentSink.cpp
content/base/src/nsContentSink.h
content/base/src/nsDocument.cpp
content/base/src/nsDocument.h
content/base/src/nsStyleLinkElement.cpp
content/base/src/nsStyleLinkElement.h
content/base/src/nsTreeSanitizer.cpp
content/html/content/src/HTMLLinkElement.cpp
content/html/content/src/HTMLStyleElement.cpp
content/html/document/src/nsHTMLDocument.cpp
content/svg/document/src/SVGDocument.cpp
content/xml/document/src/nsXMLContentSink.cpp
content/xml/document/src/nsXMLContentSink.h
content/xul/document/src/XULDocument.cpp
content/xul/document/src/XULDocument.h
content/xul/document/src/nsXULPrototypeCache.cpp
content/xul/document/src/nsXULPrototypeCache.h
dom/bindings/Bindings.conf
dom/xbl/nsBindingManager.cpp
dom/xbl/nsBindingManager.h
dom/xbl/nsXBLPrototypeBinding.cpp
dom/xbl/nsXBLPrototypeBinding.h
dom/xbl/nsXBLPrototypeResources.cpp
dom/xbl/nsXBLPrototypeResources.h
dom/xbl/nsXBLResourceLoader.cpp
dom/xbl/nsXBLResourceLoader.h
dom/xslt/xslt/txMozillaXMLOutput.cpp
dom/xslt/xslt/txMozillaXMLOutput.h
editor/idl/nsIEditorStyleSheets.idl
editor/libeditor/base/nsEditor.cpp
editor/libeditor/base/nsEditor.h
editor/libeditor/base/nsStyleSheetTxns.cpp
editor/libeditor/base/nsStyleSheetTxns.h
editor/libeditor/html/nsHTMLEditor.cpp
editor/libeditor/html/nsHTMLEditor.h
js/xpconnect/src/event_impl_gen.conf.in
layout/base/nsDocumentViewer.cpp
layout/base/nsPresContext.cpp
layout/base/nsPresShell.cpp
layout/base/nsPresShell.h
layout/base/nsStyleSheetService.cpp
layout/inspector/inCSSValueSearch.cpp
layout/inspector/inDOMUtils.cpp
layout/style/CSSRuleList.h
layout/style/CSSStyleSheet.cpp
layout/style/CSSStyleSheet.h
layout/style/ErrorReporter.cpp
layout/style/ErrorReporter.h
layout/style/GroupRule.h
layout/style/ImportRule.h
layout/style/Loader.cpp
layout/style/Loader.h
layout/style/Rule.h
layout/style/StyleRule.cpp
layout/style/StyleRule.h
layout/style/moz.build
layout/style/nsCSSParser.cpp
layout/style/nsCSSParser.h
layout/style/nsCSSRuleProcessor.cpp
layout/style/nsCSSRuleProcessor.h
layout/style/nsCSSRules.cpp
layout/style/nsCSSRules.h
layout/style/nsCSSStyleSheet.cpp
layout/style/nsCSSStyleSheet.h
layout/style/nsCSSValue.cpp
layout/style/nsCSSValue.h
layout/style/nsDOMCSSDeclaration.cpp
layout/style/nsICSSLoaderObserver.h
layout/style/nsIMediaList.h
layout/style/nsIStyleSheet.h
layout/style/nsLayoutStylesheetCache.cpp
layout/style/nsLayoutStylesheetCache.h
layout/style/nsStyleSet.cpp
layout/style/nsStyleSet.h
layout/style/test/ParseCSS.cpp
--- a/chrome/src/nsChromeRegistry.cpp
+++ b/chrome/src/nsChromeRegistry.cpp
@@ -11,32 +11,30 @@
 #include "prprf.h"
 
 #include "nsCOMPtr.h"
 #include "nsError.h"
 #include "nsEscape.h"
 #include "nsNetUtil.h"
 #include "nsString.h"
 
-#include "mozilla/CSSStyleSheet.h"
-#include "mozilla/dom/URL.h"
+#include "nsCSSStyleSheet.h"
 #include "nsIConsoleService.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMLocation.h"
 #include "nsIDOMWindowCollection.h"
 #include "nsIDOMWindow.h"
 #include "nsIObserverService.h"
 #include "nsIPresShell.h"
 #include "nsIScriptError.h"
 #include "nsIWindowMediator.h"
+#include "mozilla/dom/URL.h"
 
 nsChromeRegistry* nsChromeRegistry::gChromeRegistry;
-
-using namespace mozilla;
 using mozilla::dom::IsChromeURI;
 
 ////////////////////////////////////////////////////////////////////////////////
 
 void
 nsChromeRegistry::LogMessage(const char* aMsg, ...)
 {
   nsCOMPtr<nsIConsoleService> console 
@@ -412,17 +410,17 @@ nsresult nsChromeRegistry::RefreshWindow
     nsCOMArray<nsIStyleSheet> newAgentSheets;
     for (int32_t l = 0; l < agentSheets.Count(); ++l) {
       nsIStyleSheet *sheet = agentSheets[l];
 
       nsIURI* uri = sheet->GetSheetURI();
 
       if (IsChromeURI(uri)) {
         // Reload the sheet.
-        nsRefPtr<CSSStyleSheet> newSheet;
+        nsRefPtr<nsCSSStyleSheet> newSheet;
         rv = document->LoadChromeSheetSync(uri, true,
                                            getter_AddRefs(newSheet));
         if (NS_FAILED(rv)) return rv;
         if (newSheet) {
           rv = newAgentSheets.AppendObject(newSheet) ? NS_OK : NS_ERROR_FAILURE;
           if (NS_FAILED(rv)) return rv;
         }
       }
@@ -451,22 +449,22 @@ nsresult nsChromeRegistry::RefreshWindow
     if (!oldSheets.AppendObject(styleSheet)) {
       return NS_ERROR_OUT_OF_MEMORY;
     }
   }
 
   // Iterate over our old sheets and kick off a sync load of the new
   // sheet if and only if it's a chrome URL.
   for (i = 0; i < count; i++) {
-    nsRefPtr<CSSStyleSheet> sheet = do_QueryObject(oldSheets[i]);
+    nsRefPtr<nsCSSStyleSheet> sheet = do_QueryObject(oldSheets[i]);
     nsIURI* uri = sheet ? sheet->GetOriginalURI() : nullptr;
 
     if (uri && IsChromeURI(uri)) {
       // Reload the sheet.
-      nsRefPtr<CSSStyleSheet> newSheet;
+      nsRefPtr<nsCSSStyleSheet> newSheet;
       // XXX what about chrome sheets that have a title or are disabled?  This
       // only works by sheer dumb luck.
       document->LoadChromeSheetSync(uri, false, getter_AddRefs(newSheet));
       // Even if it's null, we put in in there.
       newSheets.AppendObject(newSheet);
     }
     else {
       // Just use the same sheet.
--- a/content/base/public/nsIDocument.h
+++ b/content/base/public/nsIDocument.h
@@ -24,16 +24,17 @@
 #include "mozilla/WeakPtr.h"
 #include "Units.h"
 #include "nsExpirationTracker.h"
 #include "nsClassHashtable.h"
 
 class imgIRequest;
 class nsAString;
 class nsBindingManager;
+class nsCSSStyleSheet;
 class nsIDocShell;
 class nsDocShell;
 class nsDOMNavigationTiming;
 class nsFrameLoader;
 class nsHTMLCSSStyleSheet;
 class nsHTMLDocument;
 class nsHTMLStyleSheet;
 class nsIAtom;
@@ -77,17 +78,16 @@ class nsTextNode;
 class nsWindowSizes;
 class nsSmallVoidArray;
 class nsDOMCaretPosition;
 class nsViewportInfo;
 class nsIGlobalObject;
 struct nsCSSSelectorList;
 
 namespace mozilla {
-class CSSStyleSheet;
 class ErrorResult;
 class EventStates;
 
 namespace css {
 class Loader;
 class ImageLoader;
 } // namespace css
 
@@ -774,17 +774,17 @@ public:
    * This function prepends the given style sheet to the document's style set
    * in order to make sure that it does not override user-agent style sheets
    * supplied by add-ons or by the app (Firefox OS or Firefox Mobile, for
    * example), since their sheets should override built-in sheets.
    *
    * TODO We can get rid of the whole concept of delayed loading if we fix
    * bug 77999.
    */
-  virtual void EnsureOnDemandBuiltInUASheet(mozilla::CSSStyleSheet* aSheet) = 0;
+  virtual void EnsureOnDemandBuiltInUASheet(nsCSSStyleSheet* aSheet) = 0;
 
   /**
    * Get the number of (document) stylesheets
    *
    * @return the number of stylesheets
    * @throws no exceptions
    */
   virtual int32_t GetNumberOfStyleSheets() const = 0;
@@ -1831,17 +1831,17 @@ public:
    * Called by the chrome registry to load style sheets.  Can be put
    * back there if and when when that module is merged with libgklayout.
    *
    * This always does a synchronous load.  If aIsAgentSheet is true,
    * it also uses the system principal and enables unsafe rules.
    * DO NOT USE FOR UNTRUSTED CONTENT.
    */
   virtual nsresult LoadChromeSheetSync(nsIURI* aURI, bool aIsAgentSheet,
-                                       mozilla::CSSStyleSheet** aSheet) = 0;
+                                       nsCSSStyleSheet** aSheet) = 0;
 
   /**
    * Returns true if the locale used for the document specifies a direction of
    * right to left. For chrome documents, this comes from the chrome registry.
    * This is used to determine the current state for the :-moz-locale-dir pseudoclass
    * so once can know whether a document is expected to be rendered left-to-right
    * or right-to-left.
    */
--- a/content/base/public/nsIStyleSheetLinkingElement.h
+++ b/content/base/public/nsIStyleSheetLinkingElement.h
@@ -11,33 +11,30 @@
 class nsICSSLoaderObserver;
 class nsIURI;
 
 #define NS_ISTYLESHEETLINKINGELEMENT_IID          \
 { 0xd753c84a, 0x17fd, 0x4d5f, \
  { 0xb2, 0xe9, 0x63, 0x52, 0x8c, 0x87, 0x99, 0x7a } }
 
 class nsIStyleSheet;
-
-namespace mozilla {
-class CSSStyleSheet;
-} // namespace mozilla
+class nsCSSStyleSheet;
 
 class nsIStyleSheetLinkingElement : public nsISupports {
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISTYLESHEETLINKINGELEMENT_IID)
 
   /**
    * Used to make the association between a style sheet and
    * the element that linked it to the document.
    *
    * @param aStyleSheet the style sheet associated with this
    *                    element.
    */
-  NS_IMETHOD SetStyleSheet(mozilla::CSSStyleSheet* aStyleSheet) = 0;
+  NS_IMETHOD SetStyleSheet(nsCSSStyleSheet* aStyleSheet) = 0;
 
   /**
    * Used to obtain the style sheet linked in by this element.
    *
    * @param aStyleSheet out parameter that returns the style
    *                    sheet associated with this element.
    */
   NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aStyleSheet) = 0;
--- a/content/base/src/ShadowRoot.cpp
+++ b/content/base/src/ShadowRoot.cpp
@@ -132,17 +132,17 @@ ShadowRoot::StyleSheetChanged()
   if (shell) {
     OwnerDoc()->BeginUpdate(UPDATE_STYLE);
     shell->RecordShadowStyleChange(this);
     OwnerDoc()->EndUpdate(UPDATE_STYLE);
   }
 }
 
 void
-ShadowRoot::InsertSheet(CSSStyleSheet* aSheet,
+ShadowRoot::InsertSheet(nsCSSStyleSheet* aSheet,
                         nsIContent* aLinkingContent)
 {
   nsCOMPtr<nsIStyleSheetLinkingElement>
     linkingElement = do_QueryInterface(aLinkingContent);
   MOZ_ASSERT(linkingElement, "The only styles in a ShadowRoot should come "
                              "from <style>.");
 
   linkingElement->SetStyleSheet(aSheet); // This sets the ownerNode on the sheet
@@ -163,17 +163,17 @@ ShadowRoot::InsertSheet(CSSStyleSheet* a
   }
 
   if (aSheet->IsApplicable()) {
     StyleSheetChanged();
   }
 }
 
 void
-ShadowRoot::RemoveSheet(CSSStyleSheet* aSheet)
+ShadowRoot::RemoveSheet(nsCSSStyleSheet* aSheet)
 {
   mProtoBinding->RemoveStyleSheet(aSheet);
 
   if (aSheet->IsApplicable()) {
     StyleSheetChanged();
   }
 }
 
@@ -714,17 +714,17 @@ ShadowRootStyleSheetList::ShadowRootStyl
   MOZ_COUNT_CTOR(ShadowRootStyleSheetList);
 }
 
 ShadowRootStyleSheetList::~ShadowRootStyleSheetList()
 {
   MOZ_COUNT_DTOR(ShadowRootStyleSheetList);
 }
 
-CSSStyleSheet*
+nsCSSStyleSheet*
 ShadowRootStyleSheetList::IndexedGetter(uint32_t aIndex, bool& aFound)
 {
   aFound = aIndex < mShadowRoot->mProtoBinding->SheetCount();
 
   if (!aFound) {
     return nullptr;
   }
 
--- a/content/base/src/ShadowRoot.h
+++ b/content/base/src/ShadowRoot.h
@@ -43,18 +43,18 @@ public:
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
 
   ShadowRoot(nsIContent* aContent, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
              nsXBLPrototypeBinding* aProtoBinding);
   virtual ~ShadowRoot();
 
   void AddToIdTable(Element* aElement, nsIAtom* aId);
   void RemoveFromIdTable(Element* aElement, nsIAtom* aId);
-  void InsertSheet(CSSStyleSheet* aSheet, nsIContent* aLinkingContent);
-  void RemoveSheet(CSSStyleSheet* aSheet);
+  void InsertSheet(nsCSSStyleSheet* aSheet, nsIContent* aLinkingContent);
+  void RemoveSheet(nsCSSStyleSheet* aSheet);
   bool ApplyAuthorStyles();
   void SetApplyAuthorStyles(bool aApplyAuthorStyles);
   StyleSheetList* StyleSheets();
   HTMLShadowElement* GetShadowElement() { return mShadowElement; }
 
   /**
    * Sets the current shadow insertion point where the older
    * ShadowRoot will be projected.
@@ -182,17 +182,17 @@ public:
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ShadowRootStyleSheetList, StyleSheetList)
 
   virtual nsINode* GetParentObject() const MOZ_OVERRIDE
   {
     return mShadowRoot;
   }
 
   virtual uint32_t Length() MOZ_OVERRIDE;
-  virtual CSSStyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) MOZ_OVERRIDE;
+  virtual nsCSSStyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) MOZ_OVERRIDE;
 
 protected:
   nsRefPtr<ShadowRoot> mShadowRoot;
 };
 
 } // namespace dom
 } // namespace mozilla
 
--- a/content/base/src/StyleSheetList.cpp
+++ b/content/base/src/StyleSheetList.cpp
@@ -1,17 +1,17 @@
 /* -*- 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/CSSStyleSheet.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
--- a/content/base/src/StyleSheetList.h
+++ b/content/base/src/StyleSheetList.h
@@ -4,21 +4,20 @@
  * 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 {
-class CSSStyleSheet;
-
 namespace dom {
 
 class StyleSheetList : public nsIDOMStyleSheetList
                      , public nsWrapperCache
 {
 public:
   StyleSheetList()
   {
@@ -30,18 +29,18 @@ public:
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(StyleSheetList)
   NS_DECL_NSIDOMSTYLESHEETLIST
 
   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE MOZ_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 nsCSSStyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) = 0;
+  nsCSSStyleSheet* Item(uint32_t aIndex)
   {
     bool dummy = false;
     return IndexedGetter(aIndex, dummy);
   }
 };
 
 } // namespace dom
 } // namespace mozilla
--- a/content/base/src/nsContentSink.cpp
+++ b/content/base/src/nsContentSink.cpp
@@ -202,17 +202,17 @@ nsContentSink::Init(nsIDocument* aDoc,
     mDynamicLowerValue = sEnablePerfMode == 1;
     FavorPerformanceHint(!mDynamicLowerValue, 0);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsContentSink::StyleSheetLoaded(CSSStyleSheet* aSheet,
+nsContentSink::StyleSheetLoaded(nsCSSStyleSheet* aSheet,
                                 bool aWasAlternate,
                                 nsresult aStatus)
 {
   NS_ASSERTION(!mRunsToCompletion, "How come a fragment parser observed sheets?");
   if (!aWasAlternate) {
     NS_ASSERTION(mPendingSheetCount > 0, "How'd that happen?");
     --mPendingSheetCount;
 
--- a/content/base/src/nsContentSink.h
+++ b/content/base/src/nsContentSink.h
@@ -81,18 +81,17 @@ class nsContentSink : public nsICSSLoade
 {
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsContentSink,
                                            nsICSSLoaderObserver)
     // nsITimerCallback
   NS_DECL_NSITIMERCALLBACK
 
   // nsICSSLoaderObserver
-  NS_IMETHOD StyleSheetLoaded(mozilla::CSSStyleSheet* aSheet,
-                              bool aWasAlternate,
+  NS_IMETHOD StyleSheetLoaded(nsCSSStyleSheet* aSheet, bool aWasAlternate,
                               nsresult aStatus) MOZ_OVERRIDE;
 
   virtual nsresult ProcessMETATag(nsIContent* aContent);
 
   // nsIContentSink implementation helpers
   nsresult WillParseImpl(void);
   nsresult WillInterruptImpl(void);
   nsresult WillResumeImpl(void);
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -756,29 +756,29 @@ nsDOMStyleSheetList::Length()
       nsCOMPtr<nsIDOMStyleSheet> domss(do_QueryInterface(sheet));
       NS_ASSERTION(domss, "All \"normal\" sheets implement nsIDOMStyleSheet");
     }
 #endif
   }
   return mLength;
 }
 
-CSSStyleSheet*
+nsCSSStyleSheet*
 nsDOMStyleSheetList::IndexedGetter(uint32_t aIndex, bool& aFound)
 {
   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<CSSStyleSheet*>(sheet);
+  return static_cast<nsCSSStyleSheet*>(sheet);
 }
 
 void
 nsDOMStyleSheetList::NodeWillBeDestroyed(const nsINode *aNode)
 {
   mDocument = nullptr;
 }
 
@@ -3965,29 +3965,29 @@ nsDocument::RemoveChildAt(uint32_t aInde
     DestroyElementMaps();
   }
 
   doRemoveChildAt(aIndex, aNotify, oldKid, mChildren);
   mCachedRootElement = nullptr;
 }
 
 void
-nsDocument::EnsureOnDemandBuiltInUASheet(CSSStyleSheet* aSheet)
+nsDocument::EnsureOnDemandBuiltInUASheet(nsCSSStyleSheet* aSheet)
 {
   // Contains() takes nsISupport*, so annoyingly we have to cast here
   if (mOnDemandBuiltInUASheets.Contains(static_cast<nsIStyleSheet*>(aSheet))) {
     return;
   }
   BeginUpdate(UPDATE_STYLE);
   AddOnDemandBuiltInUASheet(aSheet);
   EndUpdate(UPDATE_STYLE);
 }
 
 void
-nsDocument::AddOnDemandBuiltInUASheet(CSSStyleSheet* aSheet)
+nsDocument::AddOnDemandBuiltInUASheet(nsCSSStyleSheet* aSheet)
 {
   // Contains() takes nsISupport*, so annoyingly we have to cast here
   MOZ_ASSERT(!mOnDemandBuiltInUASheets.Contains(static_cast<nsIStyleSheet*>(aSheet)));
 
   // Prepend here so that we store the sheets in mOnDemandBuiltInUASheets in
   // the same order that they should end up in the style set.
   mOnDemandBuiltInUASheets.InsertElementAt(0, aSheet);
 
@@ -4275,17 +4275,17 @@ nsDocument::LoadAdditionalStyleSheet(add
 
   // Checking if we have loaded this one already.
   if (FindSheet(mAdditionalSheets[aType], aSheetURI) >= 0)
     return NS_ERROR_INVALID_ARG;
 
   // Loading the sheet sync.
   nsRefPtr<mozilla::css::Loader> loader = new mozilla::css::Loader();
 
-  nsRefPtr<CSSStyleSheet> sheet;
+  nsRefPtr<nsCSSStyleSheet> sheet;
   nsresult rv = loader->LoadSheetSync(aSheetURI, aType == eAgentSheet,
     true, getter_AddRefs(sheet));
   NS_ENSURE_SUCCESS(rv, rv);
 
   mAdditionalSheets[aType].AppendObject(sheet);
   sheet->SetOwningDocument(this);
   MOZ_ASSERT(sheet->IsApplicable());
 
@@ -9326,17 +9326,17 @@ namespace {
 
 /**
  * Stub for LoadSheet(), since all we want is to get the sheet into
  * the CSSLoader's style cache
  */
 class StubCSSLoaderObserver MOZ_FINAL : public nsICSSLoaderObserver {
 public:
   NS_IMETHOD
-  StyleSheetLoaded(CSSStyleSheet*, bool, nsresult)
+  StyleSheetLoaded(nsCSSStyleSheet*, bool, nsresult)
   {
     return NS_OK;
   }
   NS_DECL_ISUPPORTS
 };
 NS_IMPL_ISUPPORTS(StubCSSLoaderObserver, nsICSSLoaderObserver)
 
 }
@@ -9352,17 +9352,17 @@ nsDocument::PreloadStyle(nsIURI* uri, co
   CSSLoader()->LoadSheet(uri, NodePrincipal(),
                          NS_LossyConvertUTF16toASCII(charset),
                          obs,
                          Element::StringToCORSMode(aCrossOriginAttr));
 }
 
 nsresult
 nsDocument::LoadChromeSheetSync(nsIURI* uri, bool isAgentSheet,
-                                CSSStyleSheet** sheet)
+                                nsCSSStyleSheet** sheet)
 {
   return CSSLoader()->LoadSheetSync(uri, isAgentSheet, isAgentSheet, sheet);
 }
 
 class nsDelayedEventDispatcher : public nsRunnable
 {
 public:
   nsDelayedEventDispatcher(nsTArray<nsCOMPtr<nsIDocument> >& aDocuments)
@@ -9701,37 +9701,37 @@ nsIDocument::CreateStaticClone(nsIDocShe
       clonedDoc = static_cast<nsDocument*>(tmp.get());
       if (IsStaticDocument()) {
         clonedDoc->mOriginalDocument = mOriginalDocument;
       } else {
         clonedDoc->mOriginalDocument = this;
       }
       int32_t sheetsCount = GetNumberOfStyleSheets();
       for (int32_t i = 0; i < sheetsCount; ++i) {
-        nsRefPtr<CSSStyleSheet> sheet = do_QueryObject(GetStyleSheetAt(i));
+        nsRefPtr<nsCSSStyleSheet> sheet = do_QueryObject(GetStyleSheetAt(i));
         if (sheet) {
           if (sheet->IsApplicable()) {
-            nsRefPtr<CSSStyleSheet> clonedSheet =
+            nsRefPtr<nsCSSStyleSheet> clonedSheet =
               sheet->Clone(nullptr, nullptr, clonedDoc, nullptr);
             NS_WARN_IF_FALSE(clonedSheet, "Cloning a stylesheet didn't work!");
             if (clonedSheet) {
               clonedDoc->AddStyleSheet(clonedSheet);
             }
           }
         }
       }
 
       sheetsCount = thisAsDoc->mOnDemandBuiltInUASheets.Count();
       // Iterate backwards to maintain order
       for (int32_t i = sheetsCount - 1; i >= 0; --i) {
-        nsRefPtr<CSSStyleSheet> sheet =
+        nsRefPtr<nsCSSStyleSheet> sheet =
           do_QueryObject(thisAsDoc->mOnDemandBuiltInUASheets[i]);
         if (sheet) {
           if (sheet->IsApplicable()) {
-            nsRefPtr<CSSStyleSheet> clonedSheet =
+            nsRefPtr<nsCSSStyleSheet> clonedSheet =
               sheet->Clone(nullptr, nullptr, clonedDoc, nullptr);
             NS_WARN_IF_FALSE(clonedSheet, "Cloning a stylesheet didn't work!");
             if (clonedSheet) {
               clonedDoc->AddOnDemandBuiltInUASheet(clonedSheet);
             }
           }
         }
       }
--- a/content/base/src/nsDocument.h
+++ b/content/base/src/nsDocument.h
@@ -452,18 +452,17 @@ public:
   NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
 
   virtual nsINode* GetParentObject() const MOZ_OVERRIDE
   {
     return mDocument;
   }
 
   virtual uint32_t Length() MOZ_OVERRIDE;
-  virtual mozilla::CSSStyleSheet*
-  IndexedGetter(uint32_t aIndex, bool& aFound) MOZ_OVERRIDE;
+  virtual nsCSSStyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) MOZ_OVERRIDE;
 
 protected:
   int32_t       mLength;
   nsIDocument*  mDocument;
 };
 
 class nsOnloadBlocker MOZ_FINAL : public nsIRequest
 {
@@ -776,17 +775,17 @@ public:
   virtual mozilla::dom::AnimationTimeline* Timeline() MOZ_OVERRIDE;
 
   virtual nsresult SetSubDocumentFor(Element* aContent,
                                      nsIDocument* aSubDoc) MOZ_OVERRIDE;
   virtual nsIDocument* GetSubDocumentFor(nsIContent* aContent) const MOZ_OVERRIDE;
   virtual Element* FindContentForSubDocument(nsIDocument *aDocument) const MOZ_OVERRIDE;
   virtual Element* GetRootElementInternal() const MOZ_OVERRIDE;
 
-  virtual void EnsureOnDemandBuiltInUASheet(mozilla::CSSStyleSheet* aSheet) MOZ_OVERRIDE;
+  virtual void EnsureOnDemandBuiltInUASheet(nsCSSStyleSheet* aSheet) MOZ_OVERRIDE;
 
   /**
    * Get the (document) style sheets owned by this document.
    * These are ordered, highest priority last
    */
   virtual int32_t GetNumberOfStyleSheets() const MOZ_OVERRIDE;
   virtual nsIStyleSheet* GetStyleSheetAt(int32_t aIndex) const MOZ_OVERRIDE;
   virtual int32_t GetIndexOfStyleSheet(nsIStyleSheet* aSheet) const MOZ_OVERRIDE;
@@ -928,17 +927,17 @@ public:
 
   // for radio group
   nsRadioGroupStruct* GetRadioGroup(const nsAString& aName) const;
   nsRadioGroupStruct* GetOrCreateRadioGroup(const nsAString& aName);
 
   virtual nsViewportInfo GetViewportInfo(const mozilla::ScreenIntSize& aDisplaySize) MOZ_OVERRIDE;
 
 private:
-  void AddOnDemandBuiltInUASheet(mozilla::CSSStyleSheet* aSheet);
+  void AddOnDemandBuiltInUASheet(nsCSSStyleSheet* aSheet);
   nsRadioGroupStruct* GetRadioGroupInternal(const nsAString& aName) const;
   void SendToConsole(nsCOMArray<nsISecurityConsoleMessage>& aMessages);
 
 public:
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE_OVERRIDABLE
 
   // nsIDOMDocument
@@ -1076,17 +1075,17 @@ public:
 
   virtual void MaybePreLoadImage(nsIURI* uri,
                                  const nsAString &aCrossOriginAttr) MOZ_OVERRIDE;
 
   virtual void PreloadStyle(nsIURI* uri, const nsAString& charset,
                             const nsAString& aCrossOriginAttr) MOZ_OVERRIDE;
 
   virtual nsresult LoadChromeSheetSync(nsIURI* uri, bool isAgentSheet,
-                                       mozilla::CSSStyleSheet** sheet) MOZ_OVERRIDE;
+                                       nsCSSStyleSheet** sheet) MOZ_OVERRIDE;
 
   virtual nsISupports* GetCurrentContentSink() MOZ_OVERRIDE;
 
   virtual mozilla::EventStates GetDocumentState() MOZ_OVERRIDE;
 
   virtual void RegisterHostObjectUri(const nsACString& aUri) MOZ_OVERRIDE;
   virtual void UnregisterHostObjectUri(const nsACString& aUri) MOZ_OVERRIDE;
 
--- a/content/base/src/nsStyleLinkElement.cpp
+++ b/content/base/src/nsStyleLinkElement.cpp
@@ -7,22 +7,22 @@
 /*
  * A base class which implements nsIStyleSheetLinkingElement and can
  * be subclassed by various content nodes that want to load
  * stylesheets (<style>, <link>, processing instructions, etc).
  */
 
 #include "nsStyleLinkElement.h"
 
-#include "mozilla/CSSStyleSheet.h"
 #include "mozilla/css/Loader.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/FragmentOrElement.h"
 #include "mozilla/dom/ShadowRoot.h"
 #include "mozilla/Preferences.h"
+#include "nsCSSStyleSheet.h"
 #include "nsIContent.h"
 #include "nsIDocument.h"
 #include "nsIDOMComment.h"
 #include "nsIDOMNode.h"
 #include "nsIDOMStyleSheet.h"
 #include "nsNetUtil.h"
 #include "nsUnicharUtils.h"
 #include "nsCRT.h"
@@ -55,17 +55,17 @@ nsStyleLinkElement::Unlink()
 void
 nsStyleLinkElement::Traverse(nsCycleCollectionTraversalCallback &cb)
 {
   nsStyleLinkElement* tmp = this;
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStyleSheet);
 }
 
 NS_IMETHODIMP 
-nsStyleLinkElement::SetStyleSheet(CSSStyleSheet* aStyleSheet)
+nsStyleLinkElement::SetStyleSheet(nsCSSStyleSheet* aStyleSheet)
 {
   if (mStyleSheet) {
     mStyleSheet->SetOwningNode(nullptr);
   }
 
   mStyleSheet = aStyleSheet;
   if (mStyleSheet) {
     nsCOMPtr<nsINode> node = do_QueryObject(this);
@@ -257,17 +257,17 @@ UpdateIsElementInStyleScopeFlagOnSubtree
       n = n->GetNextNode(aElement);
     }
   }
 }
 
 static Element*
 GetScopeElement(nsIStyleSheet* aSheet)
 {
-  nsRefPtr<CSSStyleSheet> cssStyleSheet = do_QueryObject(aSheet);
+  nsRefPtr<nsCSSStyleSheet> cssStyleSheet = do_QueryObject(aSheet);
   if (!cssStyleSheet) {
     return nullptr;
   }
 
   return cssStyleSheet->GetScopeElement();
 }
 
 nsresult
--- a/content/base/src/nsStyleLinkElement.h
+++ b/content/base/src/nsStyleLinkElement.h
@@ -9,21 +9,21 @@
  * be subclassed by various content nodes that want to load
  * stylesheets (<style>, <link>, processing instructions, etc).
  */
 
 #ifndef nsStyleLinkElement_h___
 #define nsStyleLinkElement_h___
 
 #include "mozilla/Attributes.h"
-#include "mozilla/CORSMode.h"
-#include "mozilla/CSSStyleSheet.h"
 #include "nsCOMPtr.h"
 #include "nsIStyleSheetLinkingElement.h"
+#include "nsCSSStyleSheet.h"
 #include "nsTArray.h"
+#include "mozilla/CORSMode.h"
 
 class nsIDocument;
 class nsIURI;
 
 namespace mozilla {
 namespace dom {
 class ShadowRoot;
 } // namespace dom
@@ -32,20 +32,20 @@ class ShadowRoot;
 class nsStyleLinkElement : public nsIStyleSheetLinkingElement
 {
 public:
   nsStyleLinkElement();
   virtual ~nsStyleLinkElement();
 
   NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) MOZ_OVERRIDE = 0;
 
-  mozilla::CSSStyleSheet* GetSheet() const { return mStyleSheet; }
+  nsCSSStyleSheet* GetSheet() const { return mStyleSheet; }
 
   // nsIStyleSheetLinkingElement  
-  NS_IMETHOD SetStyleSheet(mozilla::CSSStyleSheet* aStyleSheet) MOZ_OVERRIDE;
+  NS_IMETHOD SetStyleSheet(nsCSSStyleSheet* aStyleSheet) MOZ_OVERRIDE;
   NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aStyleSheet) MOZ_OVERRIDE;
   NS_IMETHOD InitStyleLinkElement(bool aDontLoadStyle) MOZ_OVERRIDE;
   NS_IMETHOD UpdateStyleSheet(nsICSSLoaderObserver* aObserver,
                               bool* aWillNotify,
                               bool* aIsAlternate) MOZ_OVERRIDE;
   NS_IMETHOD SetEnableUpdates(bool aEnableUpdates) MOZ_OVERRIDE;
   NS_IMETHOD GetCharset(nsAString& aCharset) MOZ_OVERRIDE;
 
@@ -117,17 +117,17 @@ private:
    */
   nsresult DoUpdateStyleSheet(nsIDocument* aOldDocument,
                               mozilla::dom::ShadowRoot* aOldShadowRoot,
                               nsICSSLoaderObserver* aObserver,
                               bool* aWillNotify,
                               bool* aIsAlternate,
                               bool aForceUpdate);
 
-  nsRefPtr<mozilla::CSSStyleSheet> mStyleSheet;
+  nsRefPtr<nsCSSStyleSheet> mStyleSheet;
 protected:
   bool mDontLoadStyle;
   bool mUpdatesEnabled;
   uint32_t mLineNumber;
 };
 
 #endif /* nsStyleLinkElement_h___ */
 
--- a/content/base/src/nsTreeSanitizer.cpp
+++ b/content/base/src/nsTreeSanitizer.cpp
@@ -1,24 +1,24 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set sw=2 ts=2 et tw=80: */
 /* 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 "nsTreeSanitizer.h"
+#include "mozilla/ArrayUtils.h"
 
-#include "mozilla/ArrayUtils.h"
-#include "mozilla/CSSStyleSheet.h"
+#include "nsTreeSanitizer.h"
+#include "nsCSSParser.h"
+#include "nsCSSProperty.h"
 #include "mozilla/css/Declaration.h"
 #include "mozilla/css/StyleRule.h"
 #include "mozilla/css/Rule.h"
-#include "nsCSSParser.h"
-#include "nsCSSProperty.h"
 #include "nsUnicharInputStream.h"
+#include "nsCSSStyleSheet.h"
 #include "nsIDOMCSSRule.h"
 #include "nsAttrName.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsNetUtil.h"
 #include "nsComponentManagerUtils.h"
 #include "nsNullPrincipal.h"
 #include "nsContentUtils.h"
 #include "nsIParserUtils.h"
@@ -1093,17 +1093,17 @@ nsTreeSanitizer::SanitizeStyleSheet(cons
                                     nsIURI* aBaseURI)
 {
   nsresult rv;
   aSanitized.Truncate();
   // aSanitized will hold the permitted CSS text.
   // -moz-binding is blacklisted.
   bool didSanitize = false;
   // Create a sheet to hold the parsed CSS
-  nsRefPtr<CSSStyleSheet> sheet = new CSSStyleSheet(CORS_NONE);
+  nsRefPtr<nsCSSStyleSheet> sheet = new nsCSSStyleSheet(CORS_NONE);
   sheet->SetURIs(aDocument->GetDocumentURI(), nullptr, aBaseURI);
   sheet->SetPrincipal(aDocument->NodePrincipal());
   // Create the CSS parser, and parse the CSS text.
   nsCSSParser parser(nullptr, sheet);
   rv = parser.ParseSheet(aOriginal, aDocument->GetDocumentURI(), aBaseURI,
                          aDocument->NodePrincipal(), 0, false);
   NS_ENSURE_SUCCESS(rv, true);
   // Mark the sheet as complete.
--- a/content/html/content/src/HTMLLinkElement.cpp
+++ b/content/html/content/src/HTMLLinkElement.cpp
@@ -76,34 +76,35 @@ NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION
 NS_INTERFACE_TABLE_TAIL_INHERITING(nsGenericHTMLElement)
 
 
 NS_IMPL_ELEMENT_CLONE(HTMLLinkElement)
 
 bool
 HTMLLinkElement::Disabled()
 {
-  CSSStyleSheet* ss = GetSheet();
+  nsCSSStyleSheet* ss = GetSheet();
   return ss && ss->Disabled();
 }
 
 NS_IMETHODIMP
 HTMLLinkElement::GetMozDisabled(bool* aDisabled)
 {
   *aDisabled = Disabled();
   return NS_OK;
 }
 
 void
 HTMLLinkElement::SetDisabled(bool aDisabled)
 {
-  CSSStyleSheet* ss = GetSheet();
+  nsCSSStyleSheet* ss = GetSheet();
   if (ss) {
     ss->SetDisabled(aDisabled);
   }
+
 }
 
 NS_IMETHODIMP
 HTMLLinkElement::SetMozDisabled(bool aDisabled)
 {
   SetDisabled(aDisabled);
   return NS_OK;
 }
--- a/content/html/content/src/HTMLStyleElement.cpp
+++ b/content/html/content/src/HTMLStyleElement.cpp
@@ -64,31 +64,31 @@ HTMLStyleElement::GetMozDisabled(bool* a
 
   *aDisabled = Disabled();
   return NS_OK;
 }
 
 bool
 HTMLStyleElement::Disabled()
 {
-  CSSStyleSheet* ss = GetSheet();
+  nsCSSStyleSheet* ss = GetSheet();
   return ss && ss->Disabled();
 }
 
 NS_IMETHODIMP
 HTMLStyleElement::SetMozDisabled(bool aDisabled)
 {
   SetDisabled(aDisabled);
   return NS_OK;
 }
 
 void
 HTMLStyleElement::SetDisabled(bool aDisabled)
 {
-  CSSStyleSheet* ss = GetSheet();
+  nsCSSStyleSheet* ss = GetSheet();
   if (ss) {
     ss->SetDisabled(aDisabled);
   }
 }
 
 NS_IMPL_STRING_ATTR(HTMLStyleElement, Media, media)
 NS_IMPL_BOOL_ATTR(HTMLStyleElement, Scoped, scoped)
 NS_IMPL_STRING_ATTR(HTMLStyleElement, Type, type)
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -2751,17 +2751,17 @@ nsHTMLDocument::EditingStateChanged()
     nsCOMArray<nsIStyleSheet> agentSheets;
     rv = presShell->GetAgentStyleSheets(agentSheets);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIURI> uri;
     rv = NS_NewURI(getter_AddRefs(uri), NS_LITERAL_STRING("resource://gre/res/contenteditable.css"));
     NS_ENSURE_SUCCESS(rv, rv);
 
-    nsRefPtr<CSSStyleSheet> sheet;
+    nsRefPtr<nsCSSStyleSheet> sheet;
     rv = LoadChromeSheetSync(uri, true, getter_AddRefs(sheet));
     NS_ENSURE_TRUE(sheet, rv);
 
     bool result = agentSheets.AppendObject(sheet);
     NS_ENSURE_TRUE(result, NS_ERROR_OUT_OF_MEMORY);
 
     // Should we update the editable state of all the nodes in the document? We
     // need to do this when the designMode value changes, as that overrides
--- a/content/svg/document/src/SVGDocument.cpp
+++ b/content/svg/document/src/SVGDocument.cpp
@@ -138,29 +138,29 @@ SVGDocument::EnsureNonSVGUserAgentStyleS
           catMan->GetCategoryEntry("agent-style-sheets", name.get(),
                                    getter_Copies(spec));
 
           mozilla::css::Loader* cssLoader = CSSLoader();
           if (cssLoader->GetEnabled()) {
             nsCOMPtr<nsIURI> uri;
             NS_NewURI(getter_AddRefs(uri), spec);
             if (uri) {
-              nsRefPtr<CSSStyleSheet> cssSheet;
+              nsRefPtr<nsCSSStyleSheet> cssSheet;
               cssLoader->LoadSheetSync(uri, true, true, getter_AddRefs(cssSheet));
               if (cssSheet) {
                 EnsureOnDemandBuiltInUASheet(cssSheet);
               }
             }
           }
         }
       }
     }
   }
 
-  CSSStyleSheet* sheet = nsLayoutStylesheetCache::NumberControlSheet();
+  nsCSSStyleSheet* sheet = nsLayoutStylesheetCache::NumberControlSheet();
   if (sheet) {
     // number-control.css can be behind a pref
     EnsureOnDemandBuiltInUASheet(sheet);
   }
   EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::FormsSheet());
   EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::CounterStylesSheet());
   EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::HTMLSheet());
   EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::UASheet());
--- a/content/xml/document/src/nsXMLContentSink.cpp
+++ b/content/xml/document/src/nsXMLContentSink.cpp
@@ -15,17 +15,17 @@
 #include "nsNetUtil.h"
 #include "nsIDocShell.h"
 #include "nsIStyleSheetLinkingElement.h"
 #include "nsIDOMComment.h"
 #include "nsIDOMCDATASection.h"
 #include "DocumentType.h"
 #include "nsHTMLParts.h"
 #include "nsCRT.h"
-#include "mozilla/CSSStyleSheet.h"
+#include "nsCSSStyleSheet.h"
 #include "mozilla/css/Loader.h"
 #include "nsGkAtoms.h"
 #include "nsContentUtils.h"
 #include "nsIScriptContext.h"
 #include "nsNameSpaceManager.h"
 #include "nsIServiceManager.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIContentViewer.h"
@@ -58,17 +58,16 @@
 #include "nsHtml5SVGLoadDispatcher.h"
 #include "nsTextNode.h"
 #include "mozilla/dom/CDATASection.h"
 #include "mozilla/dom/Comment.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/HTMLTemplateElement.h"
 #include "mozilla/dom/ProcessingInstruction.h"
 
-using namespace mozilla;
 using namespace mozilla::dom;
 
 // XXX Open Issues:
 // 1) what's not allowed - We need to figure out which HTML tags
 //    (prefixed with a HTML namespace qualifier) are explicitly not
 //    allowed (if any).
 // 2) factoring code with nsHTMLContentSink - There's some amount of
 //    common code between this and the HTML content sink. This will
@@ -410,17 +409,17 @@ nsXMLContentSink::OnTransformDone(nsresu
   ScrollToRef();
 
   originalDocument->EndLoad();
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsXMLContentSink::StyleSheetLoaded(CSSStyleSheet* aSheet,
+nsXMLContentSink::StyleSheetLoaded(nsCSSStyleSheet* aSheet,
                                    bool aWasAlternate,
                                    nsresult aStatus)
 {
   if (!mPrettyPrinting) {
     return nsContentSink::StyleSheetLoaded(aSheet, aWasAlternate, aStatus);
   }
 
   if (!mDocument->CSSLoader()->HasPendingLoads()) {
--- a/content/xml/document/src/nsXMLContentSink.h
+++ b/content/xml/document/src/nsXMLContentSink.h
@@ -78,18 +78,17 @@ public:
   virtual bool IsScriptExecuting() MOZ_OVERRIDE;
   virtual void ContinueInterruptedParsingAsync() MOZ_OVERRIDE;
 
   // nsITransformObserver
   NS_IMETHOD OnDocumentCreated(nsIDocument *aResultDocument) MOZ_OVERRIDE;
   NS_IMETHOD OnTransformDone(nsresult aResult, nsIDocument *aResultDocument) MOZ_OVERRIDE;
 
   // nsICSSLoaderObserver
-  NS_IMETHOD StyleSheetLoaded(mozilla::CSSStyleSheet* aSheet,
-                              bool aWasAlternate,
+  NS_IMETHOD StyleSheetLoaded(nsCSSStyleSheet* aSheet, bool aWasAlternate,
                               nsresult aStatus) MOZ_OVERRIDE;
   static bool ParsePIData(const nsString &aData, nsString &aHref,
                           nsString &aTitle, nsString &aMedia,
                           bool &aIsAlternate);
 
 protected:
 
   nsIParser* GetParser();
--- a/content/xul/document/src/XULDocument.cpp
+++ b/content/xul/document/src/XULDocument.cpp
@@ -66,17 +66,17 @@
 #include "nsIScriptGlobalObject.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsNodeInfoManager.h"
 #include "nsContentCreatorFunctions.h"
 #include "nsContentUtils.h"
 #include "nsIParser.h"
 #include "nsCharsetSource.h"
 #include "nsIParserService.h"
-#include "mozilla/CSSStyleSheet.h"
+#include "nsCSSStyleSheet.h"
 #include "mozilla/css/Loader.h"
 #include "nsIScriptError.h"
 #include "nsIStyleSheetLinkingElement.h"
 #include "nsIObserverService.h"
 #include "nsNodeUtils.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsIXULWindow.h"
 #include "nsXULPopupManager.h"
@@ -3283,17 +3283,17 @@ XULDocument::DoneWalking()
             }
         }
     }
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
-XULDocument::StyleSheetLoaded(CSSStyleSheet* aSheet,
+XULDocument::StyleSheetLoaded(nsCSSStyleSheet* aSheet,
                               bool aWasAlternate,
                               nsresult aStatus)
 {
     if (!aWasAlternate) {
         // Don't care about when alternate sheets finish loading
 
         NS_ASSERTION(mPendingSheets > 0,
             "Unexpected StyleSheetLoaded notification");
@@ -3934,17 +3934,17 @@ XULDocument::AddPrototypeSheets()
 {
     nsresult rv;
 
     const nsCOMArray<nsIURI>& sheets = mCurrentPrototype->GetStyleSheetReferences();
 
     for (int32_t i = 0; i < sheets.Count(); i++) {
         nsCOMPtr<nsIURI> uri = sheets[i];
 
-        nsRefPtr<CSSStyleSheet> incompleteSheet;
+        nsRefPtr<nsCSSStyleSheet> incompleteSheet;
         rv = CSSLoader()->LoadSheet(uri,
                                     mCurrentPrototype->DocumentPrincipal(),
                                     EmptyCString(), this,
                                     getter_AddRefs(incompleteSheet));
 
         // XXXldb We need to prevent bogus sheets from being held in the
         // prototype's list, but until then, don't propagate the failure
         // from LoadSheet (and thus exit the loop).
--- a/content/xul/document/src/XULDocument.h
+++ b/content/xul/document/src/XULDocument.h
@@ -158,17 +158,17 @@ public:
 
     // nsDocument interface overrides
     virtual Element* GetElementById(const nsAString & elementId) MOZ_OVERRIDE;
 
     // nsIDOMXULDocument interface
     NS_DECL_NSIDOMXULDOCUMENT
 
     // nsICSSLoaderObserver
-    NS_IMETHOD StyleSheetLoaded(CSSStyleSheet* aSheet,
+    NS_IMETHOD StyleSheetLoaded(nsCSSStyleSheet* aSheet,
                                 bool aWasAlternate,
                                 nsresult aStatus) MOZ_OVERRIDE;
 
     virtual void EndUpdate(nsUpdateType aUpdateType) MOZ_OVERRIDE;
 
     virtual bool IsDocumentRightToLeft() MOZ_OVERRIDE;
 
     virtual void ResetDocumentDirection() MOZ_OVERRIDE;
@@ -331,17 +331,17 @@ protected:
      */
     bool                           mRestrictPersistence;
     nsTHashtable<nsStringHashKey>  mPersistenceIds;
 
     /**
      * An array of style sheets, that will be added (preserving order) to the
      * document after all of them are loaded (in DoneWalking).
      */
-    nsTArray<nsRefPtr<CSSStyleSheet>> mOverlaySheets;
+    nsTArray<nsRefPtr<nsCSSStyleSheet> > mOverlaySheets;
 
     nsCOMPtr<nsIDOMXULCommandDispatcher>     mCommandDispatcher; // [OWNER] of the focus tracker
 
     // Maintains the template builders that have been attached to
     // content elements
     typedef nsInterfaceHashtable<nsISupportsHashKey, nsIXULTemplateBuilder>
         BuilderTable;
     BuilderTable* mTemplateBuilderTable;
--- a/content/xul/document/src/nsXULPrototypeCache.cpp
+++ b/content/xul/document/src/nsXULPrototypeCache.cpp
@@ -2,33 +2,33 @@
 /* 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 "nsXULPrototypeCache.h"
 
 #include "plstr.h"
 #include "nsXULPrototypeDocument.h"
+#include "nsCSSStyleSheet.h"
 #include "nsIServiceManager.h"
 #include "nsIURI.h"
 
 #include "nsIChromeRegistry.h"
 #include "nsIFile.h"
 #include "nsIObjectInputStream.h"
 #include "nsIObjectOutputStream.h"
 #include "nsIObserverService.h"
 #include "nsIStringStream.h"
 #include "nsIStorageStream.h"
 
 #include "nsNetUtil.h"
 #include "nsAppDirectoryServiceDefs.h"
 
 #include "js/TracingAPI.h"
 
-#include "mozilla/CSSStyleSheet.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/scache/StartupCache.h"
 #include "mozilla/scache/StartupCacheUtils.h"
 #include "mozilla/Telemetry.h"
 
 using namespace mozilla;
 using namespace mozilla::scache;
 
@@ -167,17 +167,17 @@ nsXULPrototypeCache::PutPrototype(nsXULP
     nsCOMPtr<nsIURI> uri = aDocument->GetURI();
     // Put() releases any old value and addrefs the new one
     mPrototypeTable.Put(uri, aDocument);
 
     return NS_OK;
 }
 
 nsresult
-nsXULPrototypeCache::PutStyleSheet(CSSStyleSheet* aStyleSheet)
+nsXULPrototypeCache::PutStyleSheet(nsCSSStyleSheet* aStyleSheet)
 {
     nsIURI* uri = aStyleSheet->GetSheetURI();
 
     mStyleSheetTable.Put(uri, aStyleSheet);
 
     return NS_OK;
 }
 
@@ -234,17 +234,17 @@ FlushSkinXBL(nsIURI* aKey, nsRefPtr<nsXB
   if (!strncmp(str.get(), "/skin", 5)) {
     ret = PL_DHASH_REMOVE;
   }
 
   return ret;
 }
 
 static PLDHashOperator
-FlushSkinSheets(nsIURI* aKey, nsRefPtr<CSSStyleSheet>& aSheet, void* aClosure)
+FlushSkinSheets(nsIURI* aKey, nsRefPtr<nsCSSStyleSheet>& aSheet, void* aClosure)
 {
   nsAutoCString str;
   aSheet->GetSheetURI()->GetPath(str);
 
   PLDHashOperator ret = PL_DHASH_NEXT;
 
   if (!strncmp(str.get(), "/skin", 5)) {
     // This is a skin binding. Add the key to the list.
--- a/content/xul/document/src/nsXULPrototypeCache.h
+++ b/content/xul/document/src/nsXULPrototypeCache.h
@@ -14,19 +14,17 @@
 #include "nsRefPtrHashtable.h"
 #include "nsURIHashKey.h"
 #include "nsXULPrototypeDocument.h"
 #include "nsIInputStream.h"
 #include "nsIStorageStream.h"
 
 #include "mozilla/scache/StartupCache.h"
 
-namespace mozilla {
-class CSSStyleSheet;
-} // namespace mozilla
+class nsCSSStyleSheet;
 
 /**
  * The XUL prototype cache can be used to store and retrieve shared data for
  * XUL documents, style sheets, XBL, and scripts.
  *
  * The cache has two levels:
  *  1. In-memory hashtables
  *  2. The on-disk cache file.
@@ -69,25 +67,25 @@ public:
         return mXBLDocTable.GetWeak(aURL);
     }
     nsresult PutXBLDocumentInfo(nsXBLDocumentInfo* aDocumentInfo);
 
     /**
      * Get a style sheet by URI. If the style sheet is not in the cache,
      * returns nullptr.
      */
-    mozilla::CSSStyleSheet* GetStyleSheet(nsIURI* aURI) {
+    nsCSSStyleSheet* GetStyleSheet(nsIURI* aURI) {
         return mStyleSheetTable.GetWeak(aURI);
     }
 
     /**
      * Store a style sheet in the cache. The key, style sheet's URI is obtained
      * from the style sheet itself.
      */
-    nsresult PutStyleSheet(mozilla::CSSStyleSheet* aStyleSheet);
+    nsresult PutStyleSheet(nsCSSStyleSheet* aStyleSheet);
 
     /**
      * Write the XUL prototype document to a cache file. The proto must be
      * fully loaded.
      */
     nsresult WritePrototype(nsXULPrototypeDocument* aPrototypeDocument);
 
     /**
@@ -118,17 +116,17 @@ protected:
     nsXULPrototypeCache();
     virtual ~nsXULPrototypeCache();
 
     static nsXULPrototypeCache* sInstance;
 
     void FlushSkinFiles();
 
     nsRefPtrHashtable<nsURIHashKey,nsXULPrototypeDocument>   mPrototypeTable; // owns the prototypes
-    nsRefPtrHashtable<nsURIHashKey,mozilla::CSSStyleSheet>   mStyleSheetTable;
+    nsRefPtrHashtable<nsURIHashKey,nsCSSStyleSheet>          mStyleSheetTable;
     nsJSThingHashtable<nsURIHashKey, JSScript*>              mScriptTable;
     nsRefPtrHashtable<nsURIHashKey,nsXBLDocumentInfo>        mXBLDocTable;
 
     nsTHashtable<nsURIHashKey>                               mCacheURITable;
 
     nsInterfaceHashtable<nsURIHashKey, nsIStorageStream>     mOutputStreamTable;
     nsInterfaceHashtable<nsURIHashKey, nsIObjectInputStream> mInputStreamTable;
 
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -258,17 +258,17 @@ DOMInterfaces = {
     'resultNotAddRefed': ['getRGBColorValue', 'getRectValue']
 },
 
 'CSSStyleDeclaration': {
     'nativeType': 'nsICSSDeclaration'
 },
 
 'CSSStyleSheet': {
-    'nativeType': 'mozilla::CSSStyleSheet',
+    'nativeType': 'nsCSSStyleSheet',
     'binaryNames': { 'ownerRule': 'DOMOwnerRule' },
 },
 
 'CSSValue': {
     'concrete': False
 },
 
 'CSSValueList': {
@@ -1061,17 +1061,17 @@ DOMInterfaces = {
     'workers': True,
 },
 
 'SourceBufferList': {
     'resultNotAddRefed': [ '__indexedGetter' ],
 },
 
 'StyleSheet': {
-    'nativeType': 'mozilla::CSSStyleSheet',
+    'nativeType': 'nsCSSStyleSheet',
 },
 
 'SVGAnimatedLengthList': {
     'nativeType': 'mozilla::DOMSVGAnimatedLengthList',
     'headerFile': 'DOMSVGAnimatedLengthList.h',
 },
 
 'SVGAnimatedNumberList': {
--- a/dom/xbl/nsBindingManager.cpp
+++ b/dom/xbl/nsBindingManager.cpp
@@ -808,27 +808,27 @@ nsBindingManager::MediumFeaturesChanged(
   set->EnumerateEntries(EnumMediumFeaturesChanged, &data);
   return NS_OK;
 }
 
 static PLDHashOperator
 EnumAppendAllSheets(nsRefPtrHashKey<nsIContent> *aKey, void* aClosure)
 {
   nsIContent *boundContent = aKey->GetKey();
-  nsTArray<CSSStyleSheet*>* array =
-    static_cast<nsTArray<CSSStyleSheet*>*>(aClosure);
+  nsTArray<nsCSSStyleSheet*>* array =
+    static_cast<nsTArray<nsCSSStyleSheet*>*>(aClosure);
   for (nsXBLBinding *binding = boundContent->GetXBLBinding(); binding;
        binding = binding->GetBaseBinding()) {
     binding->PrototypeBinding()->AppendStyleSheetsTo(*array);
   }
   return PL_DHASH_NEXT;
 }
 
 void
-nsBindingManager::AppendAllSheets(nsTArray<CSSStyleSheet*>& aArray)
+nsBindingManager::AppendAllSheets(nsTArray<nsCSSStyleSheet*>& aArray)
 {
   if (mBoundContentSet) {
     mBoundContentSet->EnumerateEntries(EnumAppendAllSheets, &aArray);
   }
 }
 
 static void
 InsertAppendedContent(XBLChildrenElement* aPoint,
--- a/dom/xbl/nsBindingManager.h
+++ b/dom/xbl/nsBindingManager.h
@@ -25,20 +25,17 @@ class nsIDocument;
 class nsIURI;
 class nsXBLDocumentInfo;
 class nsIStreamListener;
 class nsStyleSet;
 class nsXBLBinding;
 template<class E> class nsRefPtr;
 typedef nsTArray<nsRefPtr<nsXBLBinding> > nsBindingList;
 class nsIPrincipal;
-
-namespace mozilla {
-class CSSStyleSheet;
-} // namespace mozilla
+class nsCSSStyleSheet;
 
 class nsBindingManager MOZ_FINAL : public nsStubMutationObserver
 {
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
 
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
@@ -114,17 +111,17 @@ public:
   /**
    * Do any processing that needs to happen as a result of a change in
    * the characteristics of the medium, and return whether this rule
    * processor's rules have changed (e.g., because of media queries).
    */
   nsresult MediumFeaturesChanged(nsPresContext* aPresContext,
                                  bool* aRulesChanged);
 
-  void AppendAllSheets(nsTArray<mozilla::CSSStyleSheet*>& aArray);
+  void AppendAllSheets(nsTArray<nsCSSStyleSheet*>& aArray);
 
   void Traverse(nsIContent *aContent,
                             nsCycleCollectionTraversalCallback &cb);
 
   NS_DECL_CYCLE_COLLECTION_CLASS(nsBindingManager)
 
   // Notify the binding manager when an outermost update begins and
   // ends.  The end method can execute script.
--- a/dom/xbl/nsXBLPrototypeBinding.cpp
+++ b/dom/xbl/nsXBLPrototypeBinding.cpp
@@ -1681,40 +1681,40 @@ void
 nsXBLPrototypeBinding::EnsureResources()
 {
   if (!mResources) {
     mResources = new nsXBLPrototypeResources(this);
   }
 }
 
 void
-nsXBLPrototypeBinding::AppendStyleSheet(CSSStyleSheet* aSheet)
+nsXBLPrototypeBinding::AppendStyleSheet(nsCSSStyleSheet* aSheet)
 {
   EnsureResources();
   mResources->AppendStyleSheet(aSheet);
 }
 
 void
-nsXBLPrototypeBinding::RemoveStyleSheet(CSSStyleSheet* aSheet)
+nsXBLPrototypeBinding::RemoveStyleSheet(nsCSSStyleSheet* aSheet)
 {
   if (!mResources) {
     MOZ_ASSERT(false, "Trying to remove a sheet that does not exist.");
     return;
   }
 
   mResources->RemoveStyleSheet(aSheet);
 } 
 void
-nsXBLPrototypeBinding::InsertStyleSheetAt(size_t aIndex, CSSStyleSheet* aSheet)
+nsXBLPrototypeBinding::InsertStyleSheetAt(size_t aIndex, nsCSSStyleSheet* aSheet)
 {
   EnsureResources();
   mResources->InsertStyleSheetAt(aIndex, aSheet);
 }
 
-CSSStyleSheet*
+nsCSSStyleSheet*
 nsXBLPrototypeBinding::StyleSheetAt(size_t aIndex) const
 {
   MOZ_ASSERT(mResources);
   return mResources->StyleSheetAt(aIndex);
 }
 
 size_t
 nsXBLPrototypeBinding::SheetCount() const
@@ -1725,14 +1725,14 @@ nsXBLPrototypeBinding::SheetCount() cons
 bool
 nsXBLPrototypeBinding::HasStyleSheets() const
 {
   return mResources && mResources->HasStyleSheets();
 }
 
 void
 nsXBLPrototypeBinding::AppendStyleSheetsTo(
-                                      nsTArray<CSSStyleSheet*>& aResult) const
+                                      nsTArray<nsCSSStyleSheet*>& aResult) const
 {
   if (mResources) {
     mResources->AppendStyleSheetsTo(aResult);
   }
 }
--- a/dom/xbl/nsXBLPrototypeBinding.h
+++ b/dom/xbl/nsXBLPrototypeBinding.h
@@ -20,20 +20,16 @@
 
 class nsIAtom;
 class nsIContent;
 class nsIDocument;
 class nsXBLAttributeEntry;
 class nsXBLBinding;
 class nsXBLProtoImplField;
 
-namespace mozilla {
-class CSSStyleSheet;
-} // namespace mozilla
-
 // *********************************************************************/
 // The XBLPrototypeBinding class
 
 // Instances of this class are owned by the nsXBLDocumentInfo object returned
 // by XBLDocumentInfo().  Consumers who want to refcount things should refcount
 // that.
 class nsXBLPrototypeBinding MOZ_FINAL
 {
@@ -112,23 +108,23 @@ public:
   void SetBasePrototype(nsXBLPrototypeBinding* aBinding);
   nsXBLPrototypeBinding* GetBasePrototype() { return mBaseBinding; }
 
   nsXBLDocumentInfo* XBLDocumentInfo() const { return mXBLDocInfoWeak; }
   bool IsChrome() { return mXBLDocInfoWeak->IsChrome(); }
 
   void SetInitialAttributes(nsIContent* aBoundElement, nsIContent* aAnonymousContent);
 
-  void AppendStyleSheet(mozilla::CSSStyleSheet* aSheet);
-  void RemoveStyleSheet(mozilla::CSSStyleSheet* aSheet);
-  void InsertStyleSheetAt(size_t aIndex, mozilla::CSSStyleSheet* aSheet);
-  mozilla::CSSStyleSheet* StyleSheetAt(size_t aIndex) const;
+  void AppendStyleSheet(nsCSSStyleSheet* aSheet);
+  void RemoveStyleSheet(nsCSSStyleSheet* aSheet);
+  void InsertStyleSheetAt(size_t aIndex, nsCSSStyleSheet* aSheet);
+  nsCSSStyleSheet* StyleSheetAt(size_t aIndex) const;
   size_t SheetCount() const;
   bool HasStyleSheets() const;
-  void AppendStyleSheetsTo(nsTArray<mozilla::CSSStyleSheet*>& aResult) const;
+  void AppendStyleSheetsTo(nsTArray<nsCSSStyleSheet*>& aResult) const;
 
   nsIStyleRuleProcessor* GetRuleProcessor();
 
   nsresult FlushSkinSheets();
 
   nsIAtom* GetBaseTag(int32_t* aNamespaceID);
   void SetBaseTag(int32_t aNamespaceID, nsIAtom* aTag);
 
--- a/dom/xbl/nsXBLPrototypeResources.cpp
+++ b/dom/xbl/nsXBLPrototypeResources.cpp
@@ -75,28 +75,28 @@ nsXBLPrototypeResources::FlushSkinSheets
     return NS_OK;
   }
 
   // We have scoped stylesheets.  Reload any chrome stylesheets we
   // encounter.  (If they aren't skin sheets, it doesn't matter, since
   // they'll still be in the chrome cache.
   mRuleProcessor = nullptr;
 
-  nsTArray<nsRefPtr<CSSStyleSheet>> oldSheets;
+  nsTArray<nsRefPtr<nsCSSStyleSheet>> oldSheets;
 
   oldSheets.SwapElements(mStyleSheetList);
 
   mozilla::css::Loader* cssLoader = doc->CSSLoader();
 
   for (size_t i = 0, count = oldSheets.Length(); i < count; ++i) {
-    CSSStyleSheet* oldSheet = oldSheets[i];
+    nsCSSStyleSheet* oldSheet = oldSheets[i];
 
     nsIURI* uri = oldSheet->GetSheetURI();
 
-    nsRefPtr<CSSStyleSheet> newSheet;
+    nsRefPtr<nsCSSStyleSheet> newSheet;
     if (IsChromeURI(uri)) {
       if (NS_FAILED(cssLoader->LoadSheetSync(uri, getter_AddRefs(newSheet))))
         continue;
     }
     else {
       newSheet = oldSheet;
     }
 
@@ -133,35 +133,35 @@ void
 nsXBLPrototypeResources::GatherRuleProcessor()
 {
   mRuleProcessor = new nsCSSRuleProcessor(mStyleSheetList,
                                           nsStyleSet::eDocSheet,
                                           nullptr);
 }
 
 void
-nsXBLPrototypeResources::AppendStyleSheet(CSSStyleSheet* aSheet)
+nsXBLPrototypeResources::AppendStyleSheet(nsCSSStyleSheet* aSheet)
 {
   mStyleSheetList.AppendElement(aSheet);
 }
 
 void
-nsXBLPrototypeResources::RemoveStyleSheet(CSSStyleSheet* aSheet)
+nsXBLPrototypeResources::RemoveStyleSheet(nsCSSStyleSheet* aSheet)
 {
   DebugOnly<bool> found = mStyleSheetList.RemoveElement(aSheet);
   MOZ_ASSERT(found, "Trying to remove a sheet that does not exist.");
 }
 
 void
-nsXBLPrototypeResources::InsertStyleSheetAt(size_t aIndex, CSSStyleSheet* aSheet)
+nsXBLPrototypeResources::InsertStyleSheetAt(size_t aIndex, nsCSSStyleSheet* aSheet)
 {
   mStyleSheetList.InsertElementAt(aIndex, aSheet);
 }
 
-CSSStyleSheet*
+nsCSSStyleSheet*
 nsXBLPrototypeResources::StyleSheetAt(size_t aIndex) const
 {
   return mStyleSheetList[aIndex];
 }
 
 size_t
 nsXBLPrototypeResources::SheetCount() const
 {
@@ -171,12 +171,12 @@ nsXBLPrototypeResources::SheetCount() co
 bool
 nsXBLPrototypeResources::HasStyleSheets() const
 {
   return !mStyleSheetList.IsEmpty();
 }
 
 void
 nsXBLPrototypeResources::AppendStyleSheetsTo(
-                                      nsTArray<CSSStyleSheet*>& aResult) const
+                                      nsTArray<nsCSSStyleSheet*>& aResult) const
 {
   aResult.AppendElements(mStyleSheetList);
 }
--- a/dom/xbl/nsXBLPrototypeResources.h
+++ b/dom/xbl/nsXBLPrototypeResources.h
@@ -5,25 +5,22 @@
 
 #ifndef nsXBLPrototypeResources_h__
 #define nsXBLPrototypeResources_h__
 
 #include "nsAutoPtr.h"
 #include "nsICSSLoaderObserver.h"
 
 class nsCSSRuleProcessor;
+class nsCSSStyleSheet;
 class nsIAtom;
 class nsIContent;
 class nsXBLPrototypeBinding;
 class nsXBLResourceLoader;
 
-namespace mozilla {
-class CSSStyleSheet;
-} // namespace mozilla
-
 // *********************************************************************/
 // The XBLPrototypeResources class
 
 class nsXBLPrototypeResources
 {
 public:
   nsXBLPrototypeResources(nsXBLPrototypeBinding* aBinding);
   ~nsXBLPrototypeResources();
@@ -34,37 +31,37 @@ public:
   nsresult FlushSkinSheets();
 
   nsresult Write(nsIObjectOutputStream* aStream);
 
   void Traverse(nsCycleCollectionTraversalCallback &cb) const;
 
   void ClearLoader();
 
-  void AppendStyleSheet(mozilla::CSSStyleSheet* aSheet);
-  void RemoveStyleSheet(mozilla::CSSStyleSheet* aSheet);
-  void InsertStyleSheetAt(size_t aIndex, mozilla::CSSStyleSheet* aSheet);
-  mozilla::CSSStyleSheet* StyleSheetAt(size_t aIndex) const;
+  void AppendStyleSheet(nsCSSStyleSheet* aSheet);
+  void RemoveStyleSheet(nsCSSStyleSheet* aSheet);
+  void InsertStyleSheetAt(size_t aIndex, nsCSSStyleSheet* aSheet);
+  nsCSSStyleSheet* StyleSheetAt(size_t aIndex) const;
   size_t SheetCount() const;
   bool HasStyleSheets() const;
-  void AppendStyleSheetsTo(nsTArray<mozilla::CSSStyleSheet*>& aResult) const;
+  void AppendStyleSheetsTo(nsTArray<nsCSSStyleSheet*>& aResult) const;
 
   /**
    * Recreates mRuleProcessor to represent the current list of style sheets
    * stored in mStyleSheetList.  (Named GatherRuleProcessor to parallel
    * nsStyleSet::GatherRuleProcessors.)
    */
   void GatherRuleProcessor();
 
   nsCSSRuleProcessor* GetRuleProcessor() const { return mRuleProcessor; }
 
 private:
   // A loader object. Exists only long enough to load resources, and then it dies.
   nsRefPtr<nsXBLResourceLoader> mLoader;
 
   // A list of loaded stylesheets for this binding.
-  nsTArray<nsRefPtr<mozilla::CSSStyleSheet>> mStyleSheetList;
+  nsTArray<nsRefPtr<nsCSSStyleSheet>> mStyleSheetList;
 
   // The list of stylesheets converted to a rule processor.
   nsRefPtr<nsCSSRuleProcessor> mRuleProcessor;
 };
 
 #endif
--- a/dom/xbl/nsXBLResourceLoader.cpp
+++ b/dom/xbl/nsXBLResourceLoader.cpp
@@ -1,41 +1,39 @@
 /* -*- 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 "nsTArray.h"
 #include "nsString.h"
+#include "nsCSSStyleSheet.h"
 #include "nsIStyleRuleProcessor.h"
 #include "nsIDocument.h"
 #include "nsIContent.h"
 #include "nsIPresShell.h"
 #include "nsXBLService.h"
 #include "nsIServiceManager.h"
 #include "nsXBLResourceLoader.h"
 #include "nsXBLPrototypeResources.h"
 #include "nsIDocumentObserver.h"
 #include "imgILoader.h"
 #include "imgRequestProxy.h"
-#include "mozilla/CSSStyleSheet.h"
 #include "mozilla/css/Loader.h"
 #include "nsIURI.h"
 #include "nsNetUtil.h"
 #include "nsGkAtoms.h"
 #include "nsFrameManager.h"
 #include "nsStyleContext.h"
 #include "nsXBLPrototypeBinding.h"
 #include "nsCSSRuleProcessor.h"
 #include "nsContentUtils.h"
 #include "nsStyleSet.h"
 #include "nsIScriptSecurityManager.h"
 
-using namespace mozilla;
-
 NS_IMPL_CYCLE_COLLECTION(nsXBLResourceLoader, mBoundElements)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsXBLResourceLoader)
   NS_INTERFACE_MAP_ENTRY(nsICSSLoaderObserver)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsXBLResourceLoader)
@@ -132,17 +130,17 @@ nsXBLResourceLoader::LoadResources(bool*
       bool chrome;
       nsresult rv;
       if (NS_SUCCEEDED(url->SchemeIs("chrome", &chrome)) && chrome)
       {
         rv = nsContentUtils::GetSecurityManager()->
           CheckLoadURIWithPrincipal(docPrincipal, url,
                                     nsIScriptSecurityManager::ALLOW_CHROME);
         if (NS_SUCCEEDED(rv)) {
-          nsRefPtr<CSSStyleSheet> sheet;
+          nsRefPtr<nsCSSStyleSheet> sheet;
           rv = cssLoader->LoadSheetSync(url, getter_AddRefs(sheet));
           NS_ASSERTION(NS_SUCCEEDED(rv), "Load failed!!!");
           if (NS_SUCCEEDED(rv))
           {
             rv = StyleSheetLoaded(sheet, false, NS_OK);
             NS_ASSERTION(NS_SUCCEEDED(rv), "Processing the style sheet failed!!!");
           }
         }
@@ -161,17 +159,17 @@ nsXBLResourceLoader::LoadResources(bool*
   
   // Destroy our resource list.
   delete mResourceList;
   mResourceList = nullptr;
 }
 
 // nsICSSLoaderObserver
 NS_IMETHODIMP
-nsXBLResourceLoader::StyleSheetLoaded(CSSStyleSheet* aSheet,
+nsXBLResourceLoader::StyleSheetLoaded(nsCSSStyleSheet* aSheet,
                                       bool aWasAlternate,
                                       nsresult aStatus)
 {
   if (!mResources) {
     // Our resources got destroyed -- just bail out
     return NS_OK;
   }
    
--- a/dom/xbl/nsXBLResourceLoader.h
+++ b/dom/xbl/nsXBLResourceLoader.h
@@ -24,18 +24,17 @@ class nsIObjectOutputStream;
 
 class nsXBLResourceLoader : public nsICSSLoaderObserver
 {
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS(nsXBLResourceLoader)
 
   // nsICSSLoaderObserver
-  NS_IMETHOD StyleSheetLoaded(mozilla::CSSStyleSheet* aSheet,
-                              bool aWasAlternate,
+  NS_IMETHOD StyleSheetLoaded(nsCSSStyleSheet* aSheet, bool aWasAlternate,
                               nsresult aStatus) MOZ_OVERRIDE;
 
   void LoadResources(bool* aResult);
   void AddResource(nsIAtom* aResourceType, const nsAString& aSrc);
   void AddResourceListener(nsIContent* aElement);
 
   nsXBLResourceLoader(nsXBLPrototypeBinding* aBinding,
                       nsXBLPrototypeResources* aResources);
--- a/dom/xslt/xslt/txMozillaXMLOutput.cpp
+++ b/dom/xslt/xslt/txMozillaXMLOutput.cpp
@@ -18,22 +18,22 @@
 #include "nsContentCID.h"
 #include "nsNetUtil.h"
 #include "nsUnicharUtils.h"
 #include "nsGkAtoms.h"
 #include "txLog.h"
 #include "nsIConsoleService.h"
 #include "nsIDOMDocumentFragment.h"
 #include "nsNameSpaceManager.h"
+#include "nsCSSStyleSheet.h"
 #include "txStringUtils.h"
 #include "txURIUtils.h"
 #include "nsIHTMLDocument.h"
 #include "nsIStyleSheetLinkingElement.h"
 #include "nsIDocumentTransformer.h"
-#include "mozilla/CSSStyleSheet.h"
 #include "mozilla/css/Loader.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/EncodingUtils.h"
 #include "nsContentUtils.h"
 #include "txXMLUtils.h"
 #include "nsContentSink.h"
 #include "nsINode.h"
 #include "nsContentCreatorFunctions.h"
@@ -976,17 +976,17 @@ txTransformNotifier::ScriptEvaluated(nsr
     if (mScriptElements.RemoveObject(aElement)) {
         SignalTransformEnd();
     }
 
     return NS_OK;
 }
 
 NS_IMETHODIMP 
-txTransformNotifier::StyleSheetLoaded(CSSStyleSheet* aSheet,
+txTransformNotifier::StyleSheetLoaded(nsCSSStyleSheet* aSheet,
                                       bool aWasAlternate,
                                       nsresult aStatus)
 {
     if (mPendingStylesheetCount == 0) {
         // We weren't waiting on this stylesheet anyway.  This can happen if
         // SignalTransformEnd got called with an error aResult.  See
         // http://bugzilla.mozilla.org/show_bug.cgi?id=215465.
         return NS_OK;
--- a/dom/xslt/xslt/txMozillaXMLOutput.h
+++ b/dom/xslt/xslt/txMozillaXMLOutput.h
@@ -33,17 +33,17 @@ class txTransformNotifier MOZ_FINAL : pu
 {
 public:
     txTransformNotifier();
 
     NS_DECL_ISUPPORTS
     NS_DECL_NSISCRIPTLOADEROBSERVER
     
     // nsICSSLoaderObserver
-    NS_IMETHOD StyleSheetLoaded(mozilla::CSSStyleSheet* aSheet,
+    NS_IMETHOD StyleSheetLoaded(nsCSSStyleSheet* aSheet,
                                 bool aWasAlternate,
                                 nsresult aStatus) MOZ_OVERRIDE;
 
     void Init(nsITransformObserver* aObserver);
     nsresult AddScriptElement(nsIScriptElement* aElement);
     void AddPendingStylesheet();
     void OnTransformEnd(nsresult aResult = NS_OK);
     void OnTransformStart();
--- a/editor/idl/nsIEditorStyleSheets.idl
+++ b/editor/idl/nsIEditorStyleSheets.idl
@@ -1,22 +1,20 @@
 /* -*- 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 "nsISupports.idl"
 
 %{C++
-namespace mozilla {
-class CSSStyleSheet;
-} // namespace mozilla
+class nsCSSStyleSheet;
 %}
 
-[ptr] native CSSStyleSheet(mozilla::CSSStyleSheet);
+[ptr] native nsCSSStyleSheet(nsCSSStyleSheet);
 
 [scriptable, uuid(4805e682-49b9-11d3-9ce4-ed60bd6cb5bc)]
 
 interface nsIEditorStyleSheets : nsISupports
 {
   /** Load and apply the style sheet, specified by aURL, to the
     * editor's document, replacing the last style sheet added (if any).
     * This is always asynchronous, and may cause network I/O.
@@ -72,22 +70,22 @@ interface nsIEditorStyleSheets : nsISupp
   /** Enable or disable the given style sheet from the editor's document
     * This is always synchronous
     *
     * @param aURL  The style sheet to be enabled or disabled
     * @param aEnable true to enable, or false to disable the style sheet
     */
   void enableStyleSheet(in AString aURL, in boolean aEnable);
 
-  /** Get the CSSStyleSheet associated with the given URL.
+  /** Get the nsCSSStyleSheet associated with the given URL.
     *
     * @param aURL         The style sheet's URL
     * @return             the style sheet
     */
-  [noscript] CSSStyleSheet getStyleSheetForURL(in AString aURL);
+  [noscript] nsCSSStyleSheet getStyleSheetForURL(in AString aURL);
 
-  /** Get the URL associated with the given CSSStyleSheet.
+  /** Get the URL associated with the given nsCSSStyleSheet.
     *
     * @param aStyleSheet  The style sheet
     * @return             the style sheet's URL
     */
-  [noscript] AString getURLForStyleSheet(in CSSStyleSheet aStyleSheet);
+  [noscript] AString getURLForStyleSheet(in nsCSSStyleSheet aStyleSheet);
 };
--- a/editor/libeditor/base/nsEditor.cpp
+++ b/editor/libeditor/base/nsEditor.cpp
@@ -4421,33 +4421,33 @@ nsEditor::CreateTxnForIMEText(const nsAS
     txn.forget(aTxn);
   }
 
   return rv;
 }
 
 
 NS_IMETHODIMP 
-nsEditor::CreateTxnForAddStyleSheet(CSSStyleSheet* aSheet, AddStyleSheetTxn* *aTxn)
+nsEditor::CreateTxnForAddStyleSheet(nsCSSStyleSheet* aSheet, AddStyleSheetTxn* *aTxn)
 {
   nsRefPtr<AddStyleSheetTxn> txn = new AddStyleSheetTxn();
 
   nsresult rv = txn->Init(this, aSheet);
   if (NS_SUCCEEDED(rv))
   {
     txn.forget(aTxn);
   }
 
   return rv;
 }
 
 
 
 NS_IMETHODIMP 
-nsEditor::CreateTxnForRemoveStyleSheet(CSSStyleSheet* aSheet, RemoveStyleSheetTxn* *aTxn)
+nsEditor::CreateTxnForRemoveStyleSheet(nsCSSStyleSheet* aSheet, RemoveStyleSheetTxn* *aTxn)
 {
   nsRefPtr<RemoveStyleSheetTxn> txn = new RemoveStyleSheetTxn();
 
   nsresult rv = txn->Init(this, aSheet);
   if (NS_SUCCEEDED(rv))
   {
     txn.forget(aTxn);
   }
--- a/editor/libeditor/base/nsEditor.h
+++ b/editor/libeditor/base/nsEditor.h
@@ -34,16 +34,17 @@ class DeleteNodeTxn;
 class DeleteTextTxn;
 class EditAggregateTxn;
 class IMETextTxn;
 class InsertElementTxn;
 class InsertTextTxn;
 class JoinElementTxn;
 class RemoveStyleSheetTxn;
 class SplitElementTxn;
+class nsCSSStyleSheet;
 class nsIAtom;
 class nsIContent;
 class nsIDOMCharacterData;
 class nsIDOMDataTransfer;
 class nsIDOMDocument;
 class nsIDOMElement;
 class nsIDOMEvent;
 class nsIDOMEventListener;
@@ -62,17 +63,16 @@ class nsISelection;
 class nsISupports;
 class nsITransaction;
 class nsIWidget;
 class nsRange;
 class nsString;
 class nsTransactionManager;
 
 namespace mozilla {
-class CSSStyleSheet;
 class ErrorResult;
 class TextComposition;
 
 namespace dom {
 class DataTransfer;
 class Element;
 class EventTarget;
 class Selection;
@@ -316,23 +316,21 @@ protected:
                                     int32_t aOffset,
                                     InsertTextTxn ** aTxn);
 
   NS_IMETHOD CreateTxnForIMEText(const nsAString & aStringToInsert,
                                  IMETextTxn ** aTxn);
 
   /** create a transaction for adding a style sheet
     */
-  NS_IMETHOD CreateTxnForAddStyleSheet(mozilla::CSSStyleSheet* aSheet,
-                                       AddStyleSheetTxn* *aTxn);
+  NS_IMETHOD CreateTxnForAddStyleSheet(nsCSSStyleSheet* aSheet, AddStyleSheetTxn* *aTxn);
 
   /** create a transaction for removing a style sheet
     */
-  NS_IMETHOD CreateTxnForRemoveStyleSheet(mozilla::CSSStyleSheet* aSheet,
-                                          RemoveStyleSheetTxn* *aTxn);
+  NS_IMETHOD CreateTxnForRemoveStyleSheet(nsCSSStyleSheet* aSheet, RemoveStyleSheetTxn* *aTxn);
   
   NS_IMETHOD DeleteText(nsIDOMCharacterData *aElement,
                         uint32_t             aOffset,
                         uint32_t             aLength);
 
   inline nsresult DeleteText(mozilla::dom::Text* aText, uint32_t aOffset,
                              uint32_t aLength)
   {
--- a/editor/libeditor/base/nsStyleSheetTxns.cpp
+++ b/editor/libeditor/base/nsStyleSheetTxns.cpp
@@ -3,27 +3,25 @@
  * 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 <stddef.h>                     // for nullptr
 
 #include "nsAString.h"
 #include "nsCOMPtr.h"                   // for nsCOMPtr, do_QueryInterface, etc
-#include "mozilla/CSSStyleSheet.h"      // for mozilla::CSSStyleSheet
+#include "nsCSSStyleSheet.h"            // for nsCSSStyleSheet
 #include "nsDebug.h"                    // for NS_ENSURE_TRUE
 #include "nsError.h"                    // for NS_OK, etc
 #include "nsIDOMDocument.h"             // for nsIDOMDocument
 #include "nsIDocument.h"                // for nsIDocument
 #include "nsIDocumentObserver.h"        // for UPDATE_STYLE
 #include "nsIEditor.h"                  // for nsIEditor
 #include "nsStyleSheetTxns.h"
 
-using namespace mozilla;
-
 class nsIStyleSheet;
 
 static void
 AddStyleSheet(nsIEditor* aEditor, nsIStyleSheet* aSheet)
 {
   nsCOMPtr<nsIDOMDocument> domDoc;
   aEditor->GetDocument(getter_AddRefs(domDoc));
   nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
@@ -55,17 +53,17 @@ AddStyleSheetTxn::AddStyleSheetTxn()
 
 NS_IMPL_CYCLE_COLLECTION_INHERITED(AddStyleSheetTxn, EditTxn,
                                    mSheet)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(AddStyleSheetTxn)
 NS_INTERFACE_MAP_END_INHERITING(EditTxn)
 
 NS_IMETHODIMP
-AddStyleSheetTxn::Init(nsIEditor *aEditor, CSSStyleSheet *aSheet)
+AddStyleSheetTxn::Init(nsIEditor *aEditor, nsCSSStyleSheet *aSheet)
 {
   NS_ENSURE_TRUE(aEditor && aSheet, NS_ERROR_INVALID_ARG);
 
   mEditor = aEditor;
   mSheet = aSheet;
 
   return NS_OK;
 }
@@ -105,17 +103,17 @@ RemoveStyleSheetTxn::RemoveStyleSheetTxn
 
 NS_IMPL_CYCLE_COLLECTION_INHERITED(RemoveStyleSheetTxn, EditTxn,
                                    mSheet)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(RemoveStyleSheetTxn)
 NS_INTERFACE_MAP_END_INHERITING(EditTxn)
 
 NS_IMETHODIMP
-RemoveStyleSheetTxn::Init(nsIEditor *aEditor, CSSStyleSheet *aSheet)
+RemoveStyleSheetTxn::Init(nsIEditor *aEditor, nsCSSStyleSheet *aSheet)
 {
   NS_ENSURE_TRUE(aEditor && aSheet, NS_ERROR_INVALID_ARG);
 
   mEditor = aEditor;
   mSheet = aSheet;
 
   return NS_OK;
 }
--- a/editor/libeditor/base/nsStyleSheetTxns.h
+++ b/editor/libeditor/base/nsStyleSheetTxns.h
@@ -3,67 +3,67 @@
  * 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 nsStylesheetTxns_h__
 #define nsStylesheetTxns_h__
 
 #include "EditTxn.h"                    // for EditTxn, NS_DECL_EDITTXN
 #include "nsAutoPtr.h"                  // for nsRefPtr
-#include "mozilla/CSSStyleSheet.h"      // for mozilla::CSSStyleSheet
+#include "nsCSSStyleSheet.h"            // for nsCSSStyleSheet
 #include "nsCycleCollectionParticipant.h"
 #include "nsID.h"                       // for REFNSIID
-#include "nsISupportsImpl.h"            // for CSSStyleSheet::Release
+#include "nsISupportsImpl.h"            // for nsCSSStyleSheet::Release
 #include "nscore.h"                     // for NS_IMETHOD
 
 class nsIEditor;
 
 class AddStyleSheetTxn : public EditTxn
 {
 public:
   /** Initialize the transaction.
     * @param aEditor the object providing core editing operations
     * @param aSheet   the stylesheet to add
     */
-  NS_IMETHOD Init(nsIEditor* aEditor,
-                  mozilla::CSSStyleSheet* aSheet);
+  NS_IMETHOD Init(nsIEditor         *aEditor,
+                  nsCSSStyleSheet   *aSheet);
 
   AddStyleSheetTxn();
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(AddStyleSheetTxn, EditTxn)
   NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
 
   NS_DECL_EDITTXN
 
 protected:
 
-  nsIEditor* mEditor;                      // the editor that created this transaction
-  nsRefPtr<mozilla::CSSStyleSheet> mSheet; // the style sheet to add
+  nsIEditor*  mEditor;                  // the editor that created this transaction
+  nsRefPtr<nsCSSStyleSheet>  mSheet;    // the style sheet to add
 
 };
 
 
 class RemoveStyleSheetTxn : public EditTxn
 {
 public:
   /** Initialize the transaction.
     * @param aEditor the object providing core editing operations
     * @param aSheet   the stylesheet to remove
     */
-  NS_IMETHOD Init(nsIEditor* aEditor,
-                  mozilla::CSSStyleSheet* aSheet);
+  NS_IMETHOD Init(nsIEditor         *aEditor,
+                  nsCSSStyleSheet   *aSheet);
 
   RemoveStyleSheetTxn();
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(RemoveStyleSheetTxn, EditTxn)
   NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
 
   NS_DECL_EDITTXN
 
 protected:
 
-  nsIEditor* mEditor;                      // the editor that created this transaction
-  nsRefPtr<mozilla::CSSStyleSheet> mSheet; // the style sheet to remove
+  nsIEditor*  mEditor;                  // the editor that created this transaction
+  nsRefPtr<nsCSSStyleSheet>  mSheet;    // the style sheet to remove
 
 };
 
 
 #endif /* nsStylesheetTxns_h__ */
--- a/editor/libeditor/html/nsHTMLEditor.cpp
+++ b/editor/libeditor/html/nsHTMLEditor.cpp
@@ -31,18 +31,18 @@
 #include "nsIDOMKeyEvent.h"
 #include "nsIDOMMouseEvent.h"
 #include "nsIDOMHTMLAnchorElement.h"
 #include "nsISelectionController.h"
 #include "nsIDOMHTMLDocument.h"
 #include "nsILinkHandler.h"
 #include "nsIInlineSpellChecker.h"
 
-#include "mozilla/CSSStyleSheet.h"
 #include "mozilla/css/Loader.h"
+#include "nsCSSStyleSheet.h"
 #include "nsIDOMStyleSheet.h"
 
 #include "nsIContent.h"
 #include "nsIContentIterator.h"
 #include "nsIDOMRange.h"
 #include "nsISupportsArray.h"
 #include "nsContentUtils.h"
 #include "nsIDocumentEncoder.h"
@@ -2849,17 +2849,17 @@ nsHTMLEditor::ReplaceStyleSheet(const ns
 
   return ps->GetDocument()->CSSLoader()->
     LoadSheet(uaURI, nullptr, EmptyCString(), this);
 }
 
 NS_IMETHODIMP
 nsHTMLEditor::RemoveStyleSheet(const nsAString &aURL)
 {
-  nsRefPtr<CSSStyleSheet> sheet;
+  nsRefPtr<nsCSSStyleSheet> sheet;
   nsresult rv = GetStyleSheetForURL(aURL, getter_AddRefs(sheet));
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_TRUE(sheet, NS_ERROR_UNEXPECTED);
 
   nsRefPtr<RemoveStyleSheetTxn> txn;
   rv = CreateTxnForRemoveStyleSheet(sheet, getter_AddRefs(txn));
   if (!txn) rv = NS_ERROR_NULL_POINTER;
   if (NS_SUCCEEDED(rv))
@@ -2889,17 +2889,17 @@ nsHTMLEditor::AddOverrideStyleSheet(cons
 
   nsCOMPtr<nsIURI> uaURI;
   nsresult rv = NS_NewURI(getter_AddRefs(uaURI), aURL);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // We MUST ONLY load synchronous local files (no @import)
   // XXXbz Except this will actually try to load remote files
   // synchronously, of course..
-  nsRefPtr<CSSStyleSheet> sheet;
+  nsRefPtr<nsCSSStyleSheet> sheet;
   // Editor override style sheets may want to style Gecko anonymous boxes
   rv = ps->GetDocument()->CSSLoader()->
     LoadSheetSync(uaURI, true, true, getter_AddRefs(sheet));
 
   // Synchronous loads should ALWAYS return completed
   NS_ENSURE_TRUE(sheet, NS_ERROR_NULL_POINTER);
 
   // Add the override style sheet
@@ -2933,17 +2933,17 @@ nsHTMLEditor::ReplaceOverrideStyleSheet(
 
   return AddOverrideStyleSheet(aURL);
 }
 
 // Do NOT use transaction system for override style sheets
 NS_IMETHODIMP
 nsHTMLEditor::RemoveOverrideStyleSheet(const nsAString &aURL)
 {
-  nsRefPtr<CSSStyleSheet> sheet;
+  nsRefPtr<nsCSSStyleSheet> sheet;
   GetStyleSheetForURL(aURL, getter_AddRefs(sheet));
 
   // Make sure we remove the stylesheet from our internal list in all
   // cases.
   nsresult rv = RemoveStyleSheetFromList(aURL);
 
   NS_ENSURE_TRUE(sheet, NS_OK); /// Don't fail if sheet not found
 
@@ -2956,32 +2956,32 @@ nsHTMLEditor::RemoveOverrideStyleSheet(c
 
   // Remove it from our internal list
   return rv;
 }
 
 NS_IMETHODIMP
 nsHTMLEditor::EnableStyleSheet(const nsAString &aURL, bool aEnable)
 {
-  nsRefPtr<CSSStyleSheet> sheet;
+  nsRefPtr<nsCSSStyleSheet> sheet;
   nsresult rv = GetStyleSheetForURL(aURL, getter_AddRefs(sheet));
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_TRUE(sheet, NS_OK); // Don't fail if sheet not found
 
   // Ensure the style sheet is owned by our document.
   nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocWeak);
   sheet->SetOwningDocument(doc);
 
   return sheet->SetDisabled(!aEnable);
 }
 
 bool
 nsHTMLEditor::EnableExistingStyleSheet(const nsAString &aURL)
 {
-  nsRefPtr<CSSStyleSheet> sheet;
+  nsRefPtr<nsCSSStyleSheet> sheet;
   nsresult rv = GetStyleSheetForURL(aURL, getter_AddRefs(sheet));
   NS_ENSURE_SUCCESS(rv, false);
 
   // Enable sheet if already loaded.
   if (sheet)
   {
     // Ensure the style sheet is owned by our document.
     nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocWeak);
@@ -2990,17 +2990,17 @@ nsHTMLEditor::EnableExistingStyleSheet(c
     sheet->SetDisabled(false);
     return true;
   }
   return false;
 }
 
 nsresult
 nsHTMLEditor::AddNewStyleSheetToList(const nsAString &aURL,
-                                     CSSStyleSheet* aStyleSheet)
+                                     nsCSSStyleSheet *aStyleSheet)
 {
   uint32_t countSS = mStyleSheets.Length();
   uint32_t countU = mStyleSheetURLs.Length();
 
   if (countSS != countU)
     return NS_ERROR_UNEXPECTED;
 
   if (!mStyleSheetURLs.AppendElement(aURL))
@@ -3022,17 +3022,17 @@ nsHTMLEditor::RemoveStyleSheetFromList(c
   mStyleSheets.RemoveElementAt(foundIndex);
   mStyleSheetURLs.RemoveElementAt(foundIndex);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsHTMLEditor::GetStyleSheetForURL(const nsAString &aURL,
-                                  CSSStyleSheet** aStyleSheet)
+                                  nsCSSStyleSheet **aStyleSheet)
 {
   NS_ENSURE_ARG_POINTER(aStyleSheet);
   *aStyleSheet = 0;
 
   // is it already in the list?
   size_t foundIndex;
   foundIndex = mStyleSheetURLs.IndexOf(aURL);
   if (foundIndex == mStyleSheetURLs.NoIndex)
@@ -3042,17 +3042,17 @@ nsHTMLEditor::GetStyleSheetForURL(const 
   NS_ENSURE_TRUE(*aStyleSheet, NS_ERROR_FAILURE);
 
   NS_ADDREF(*aStyleSheet);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetURLForStyleSheet(CSSStyleSheet* aStyleSheet,
+nsHTMLEditor::GetURLForStyleSheet(nsCSSStyleSheet *aStyleSheet,
                                   nsAString &aURL)
 {
   // is it already in the list?
   int32_t foundIndex = mStyleSheets.IndexOf(aStyleSheet);
 
   // Don't fail if we don't find it in our list
   // Note: mStyleSheets is nsCOMArray, so its IndexOf() method
   // returns -1 on failure.
@@ -3420,17 +3420,17 @@ nsHTMLEditor::DebugUnitTests(int32_t *ou
   return NS_OK;
 #else
   return NS_ERROR_NOT_IMPLEMENTED;
 #endif
 }
 
 
 NS_IMETHODIMP 
-nsHTMLEditor::StyleSheetLoaded(CSSStyleSheet* aSheet, bool aWasAlternate,
+nsHTMLEditor::StyleSheetLoaded(nsCSSStyleSheet* aSheet, bool aWasAlternate,
                                nsresult aStatus)
 {
   nsresult rv = NS_OK;
   nsAutoEditBatch batchIt(this);
 
   if (!mLastStyleSheetURL.IsEmpty())
     RemoveStyleSheet(mLastStyleSheetURL);
 
--- a/editor/libeditor/html/nsHTMLEditor.h
+++ b/editor/libeditor/html/nsHTMLEditor.h
@@ -324,18 +324,18 @@ public:
 
   NS_IMETHOD GetIsSelectionEditable(bool* aIsSelectionEditable);
 
   NS_IMETHOD SelectAll();
 
   NS_IMETHOD GetRootElement(nsIDOMElement **aRootElement);
 
   /* ------------ nsICSSLoaderObserver -------------- */
-  NS_IMETHOD StyleSheetLoaded(mozilla::CSSStyleSheet* aSheet,
-                              bool aWasAlternate, nsresult aStatus);
+  NS_IMETHOD StyleSheetLoaded(nsCSSStyleSheet*aSheet, bool aWasAlternate,
+                              nsresult aStatus);
 
   /* ------------ Utility Routines, not part of public API -------------- */
   NS_IMETHOD TypedText(const nsAString& aString, ETypingAction aAction);
   nsresult InsertNodeAtPoint( nsIDOMNode *aNode, 
                               nsCOMPtr<nsIDOMNode> *ioParent, 
                               int32_t *ioOffset, 
                               bool aNoEmptyNodes);
 
@@ -370,23 +370,22 @@ public:
                            bool aSafeToAskFrames,
                            bool *aSeenBR);
 
   // Returns TRUE if sheet was loaded, false if it wasn't
   bool     EnableExistingStyleSheet(const nsAString& aURL);
 
   // Dealing with the internal style sheet lists:
   NS_IMETHOD GetStyleSheetForURL(const nsAString &aURL,
-                                 mozilla::CSSStyleSheet** _retval);
-  NS_IMETHOD GetURLForStyleSheet(mozilla::CSSStyleSheet* aStyleSheet,
-                                 nsAString& aURL);
+                                 nsCSSStyleSheet **_retval);
+  NS_IMETHOD GetURLForStyleSheet(nsCSSStyleSheet *aStyleSheet, nsAString &aURL);
 
   // Add a url + known style sheet to the internal lists:
   nsresult AddNewStyleSheetToList(const nsAString &aURL,
-                                  mozilla::CSSStyleSheet* aStyleSheet);
+                                  nsCSSStyleSheet *aStyleSheet);
 
   nsresult RemoveStyleSheetFromList(const nsAString &aURL);
 
   bool IsCSSEnabled()
   {
     // TODO: removal of mCSSAware and use only the presence of mHTMLCSSUtils
     return mCSSAware && mHTMLCSSUtils && mHTMLCSSUtils->IsCSSPrefChecked();
   }
@@ -770,17 +769,17 @@ protected:
   // Used by GetFirstSelectedCell and GetNextSelectedCell
   int32_t  mSelectedCellIndex;
 
   nsString mLastStyleSheetURL;
   nsString mLastOverrideStyleSheetURL;
 
   // Maintain a list of associated style sheets and their urls.
   nsTArray<nsString> mStyleSheetURLs;
-  nsTArray<nsRefPtr<mozilla::CSSStyleSheet>> mStyleSheets;
+  nsTArray<nsRefPtr<nsCSSStyleSheet> > mStyleSheets;
   
   // an array for holding default style settings
   nsTArray<PropItem*> mDefaultStyles;
 
 protected:
 
   /* ANONYMOUS UTILS */
   void     RemoveListenerAndDeleteRef(const nsAString& aEvent,
--- a/js/xpconnect/src/event_impl_gen.conf.in
+++ b/js/xpconnect/src/event_impl_gen.conf.in
@@ -46,12 +46,12 @@ exclude_automatic_type_include = [
     'mozIDOMApplication',
     'nsIDOMBlob'
   ]
 
 """ Map xpidl interface names to implementation classes. The third column is the canonical interface. """
 xpidl_to_native = [
     ['nsIDOMDocument', 'nsIDocument', 'nsIDocument'],
     ['nsIDOMElement', 'mozilla::dom::Element', 'mozilla::dom::Element'],
-    ['nsIDOMCSSStyleSheet', 'mozilla::CSSStyleSheet', 'nsIStyleSheet'],
+    ['nsIDOMCSSStyleSheet', 'nsCSSStyleSheet', 'nsIStyleSheet'],
     ['nsIDOMWindow', 'nsGlobalWindow', 'nsIDOMEventTarget']
   ]
 
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -16,16 +16,17 @@
 #include "nsIContentViewer.h"
 #include "nsIDocumentViewerPrint.h"
 #include "nsIDOMBeforeUnloadEvent.h"
 #include "nsIDocument.h"
 #include "nsIDOMWindowUtils.h"
 #include "nsPresContext.h"
 #include "nsIPresShell.h"
 #include "nsStyleSet.h"
+#include "nsCSSStyleSheet.h"
 #include "nsIFrame.h"
 #include "nsIWritablePropertyBag2.h"
 #include "nsSubDocumentFrame.h"
 
 #include "nsILinkHandler.h"
 #include "nsIDOMDocument.h"
 #include "nsISelectionListener.h"
 #include "nsISelectionPrivate.h"
@@ -43,17 +44,16 @@
 
 #include "nsViewManager.h"
 #include "nsView.h"
 
 #include "nsIPageSequenceFrame.h"
 #include "nsNetUtil.h"
 #include "nsIContentViewerEdit.h"
 #include "nsIContentViewerFile.h"
-#include "mozilla/CSSStyleSheet.h"
 #include "mozilla/css/Loader.h"
 #include "nsIMarkupDocumentViewer.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsDocShell.h"
 #include "nsIBaseWindow.h"
 #include "nsILayoutHistoryState.h"
 #include "nsCharsetSource.h"
@@ -2210,17 +2210,17 @@ nsDocumentViewer::CreateStyleSet(nsIDocu
     // should matter for SVG-as-an-image. If it does, I want to know why!
 
     // Caller will handle calling EndUpdate, per contract.
     *aStyleSet = styleSet;
     return NS_OK;
   }
 
   // Handle the user sheets.
-  CSSStyleSheet* sheet = nullptr;
+  nsCSSStyleSheet* sheet = nullptr;
   if (nsContentUtils::IsInChromeDocshell(aDocument)) {
     sheet = nsLayoutStylesheetCache::UserChromeSheet();
   }
   else {
     sheet = nsLayoutStylesheetCache::UserContentSheet();
   }
 
   if (sheet)
@@ -2228,17 +2228,17 @@ nsDocumentViewer::CreateStyleSet(nsIDocu
 
   // Append chrome sheets (scrollbars + forms).
   bool shouldOverride = false;
   // We don't want a docshell here for external resource docs, so just
   // look at mContainer.
   nsCOMPtr<nsIDocShell> ds(mContainer);
   nsCOMPtr<nsIDOMEventTarget> chromeHandler;
   nsCOMPtr<nsIURI> uri;
-  nsRefPtr<CSSStyleSheet> csssheet;
+  nsRefPtr<nsCSSStyleSheet> csssheet;
 
   if (ds) {
     ds->GetChromeEventHandler(getter_AddRefs(chromeHandler));
   }
   if (chromeHandler) {
     nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(chromeHandler));
     nsCOMPtr<nsIContent> content(do_QueryInterface(elt));
     if (elt && content) {
@@ -2297,18 +2297,18 @@ nsDocumentViewer::CreateStyleSet(nsIDocu
 
     sheet = nsLayoutStylesheetCache::FormsSheet();
     if (sheet) {
       styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, sheet);
     }
 
     // Make sure to clone the quirk sheet so that it can be usefully
     // enabled/disabled as needed.
-    nsRefPtr<CSSStyleSheet> quirkClone;
-    CSSStyleSheet* quirkSheet;
+    nsRefPtr<nsCSSStyleSheet> quirkClone;
+    nsCSSStyleSheet* quirkSheet;
     if (!nsLayoutStylesheetCache::UASheet() ||
         !(quirkSheet = nsLayoutStylesheetCache::QuirkSheet()) ||
         !(quirkClone = quirkSheet->Clone(nullptr, nullptr, nullptr, nullptr)) ||
         !sheet) {
       delete styleSet;
       return NS_ERROR_OUT_OF_MEMORY;
     }
     // quirk.css needs to come after the regular UA sheet (or more precisely,
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -2250,24 +2250,24 @@ nsPresContext::RebuildCounterStyles()
       mPostedFlushCounterStyles = true;
     }
   }
 }
 
 void
 nsPresContext::EnsureSafeToHandOutCSSRules()
 {
-  CSSStyleSheet::EnsureUniqueInnerResult res =
+  nsCSSStyleSheet::EnsureUniqueInnerResult res =
     mShell->StyleSet()->EnsureUniqueInnerOnCSSSheets();
-  if (res == CSSStyleSheet::eUniqueInner_AlreadyUnique) {
+  if (res == nsCSSStyleSheet::eUniqueInner_AlreadyUnique) {
     // Nothing to do.
     return;
   }
 
-  MOZ_ASSERT(res == CSSStyleSheet::eUniqueInner_ClonedInner);
+  MOZ_ASSERT(res == nsCSSStyleSheet::eUniqueInner_ClonedInner);
   RebuildAllStyleData(nsChangeHint(0));
 }
 
 void
 nsPresContext::FireDOMPaintEvent(nsInvalidateRequestList* aList)
 {
   nsPIDOMWindow* ourWindow = mDocument->GetWindow();
   if (!ourWindow)
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -19,17 +19,16 @@
 /* a presentation of a document, part 2 */
 
 #ifdef MOZ_LOGGING
 #define FORCE_PR_LOG /* Allow logging in the release build */
 #endif
 #include "prlog.h"
 
 #include "mozilla/ArrayUtils.h"
-#include "mozilla/CSSStyleSheet.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/EventStateManager.h"
 #include "mozilla/EventStates.h"
 #include "mozilla/IMEStateManager.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/dom/TabChild.h"
 #include "mozilla/Likely.h"
 #include "mozilla/MouseEvents.h"
@@ -44,16 +43,17 @@
 #include "nsPresShell.h"
 #include "nsPresContext.h"
 #include "nsIContent.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/Event.h" // for Event::GetEventPopupControlState()
 #include "mozilla/dom/ShadowRoot.h"
 #include "mozilla/dom/PointerEvent.h"
 #include "nsIDocument.h"
+#include "nsCSSStyleSheet.h"
 #include "nsAnimationManager.h"
 #include "nsNameSpaceManager.h"  // for Pref-related rule management (bugs 22963,20760,31816)
 #include "nsFrame.h"
 #include "FrameLayerBuilder.h"
 #include "nsViewManager.h"
 #include "nsView.h"
 #include "nsCRTGlue.h"
 #include "prprf.h"
@@ -1379,17 +1379,17 @@ nsresult PresShell::ClearPreferenceStyle
   }
   return result;
 }
 
 nsresult
 PresShell::CreatePreferenceStyleSheet()
 {
   NS_ASSERTION(!mPrefStyleSheet, "prefStyleSheet already exists");
-  mPrefStyleSheet = new CSSStyleSheet(CORS_NONE);
+  mPrefStyleSheet = new nsCSSStyleSheet(CORS_NONE);
   nsCOMPtr<nsIURI> uri;
   nsresult rv = NS_NewURI(getter_AddRefs(uri), "about:PreferenceStyleSheet", nullptr);
   if (NS_FAILED(rv)) {
     mPrefStyleSheet = nullptr;
     return rv;
   }
   NS_ASSERTION(uri, "null but no error");
   mPrefStyleSheet->SetURIs(uri, uri, uri);
@@ -4611,17 +4611,17 @@ nsIPresShell::ReconstructStyleDataExtern
 }
 
 void
 PresShell::RecordStyleSheetChange(nsIStyleSheet* aStyleSheet)
 {
   if (mStylesHaveChanged)
     return;
 
-  nsRefPtr<CSSStyleSheet> cssStyleSheet = do_QueryObject(aStyleSheet);
+  nsRefPtr<nsCSSStyleSheet> cssStyleSheet = do_QueryObject(aStyleSheet);
   if (cssStyleSheet) {
     Element* scopeElement = cssStyleSheet->GetScopeElement();
     if (scopeElement) {
       mChangedScopeStyleRoots.AppendElement(scopeElement);
       return;
     }
   }
 
--- a/layout/base/nsPresShell.h
+++ b/layout/base/nsPresShell.h
@@ -34,30 +34,27 @@
 #include "nsContentUtils.h" // For AddScriptBlocker().
 #include "nsRefreshDriver.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/EventForwards.h"
 #include "mozilla/MemoryReporting.h"
 
 class nsRange;
 class nsIDragService;
+class nsCSSStyleSheet;
 
 struct RangePaintInfo;
 struct nsCallbackEventRequest;
 #ifdef MOZ_REFLOW_PERF
 class ReflowCountMgr;
 #endif
 
 class nsPresShellEventCB;
 class nsAutoCauseReflowNotifier;
 
-namespace mozilla {
-class CSSStyleSheet;
-} // namespace mozilla
-
 // 250ms.  This is actually pref-controlled, but we use this value if we fail
 // to get the pref for any reason.
 #define PAINTLOCK_EVENT_DELAY 250
 
 class PresShell : public nsIPresShell,
                   public nsStubDocumentObserver,
                   public nsISelectionController, public nsIObserver,
                   public nsSupportsWeakReference
@@ -752,17 +749,17 @@ protected:
   // It is set only on a presshell for a root document, this value represents
   // the last observed location of the mouse relative to that root document. It
   // is set to (NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE) if the mouse isn't
   // over our window or there is no last observed mouse location for some
   // reason.
   nsPoint                   mMouseLocation;
 
   // mStyleSet owns it but we maintain a ref, may be null
-  nsRefPtr<mozilla::CSSStyleSheet> mPrefStyleSheet;
+  nsRefPtr<nsCSSStyleSheet> mPrefStyleSheet;
 
   // Set of frames that we should mark with NS_FRAME_HAS_DIRTY_CHILDREN after
   // we finish reflowing mCurrentReflowRoot.
   nsTHashtable<nsPtrHashKey<nsIFrame> > mFramesToDirty;
 
   // Reflow roots that need to be reflowed.
   nsTArray<nsIFrame*>       mDirtyRoots;
 
--- a/layout/base/nsStyleSheetService.cpp
+++ b/layout/base/nsStyleSheetService.cpp
@@ -3,22 +3,22 @@
 /* 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/. */
 
 /* implementation of interface for managing user and user-agent style sheets */
 
 #include "nsStyleSheetService.h"
 #include "nsIStyleSheet.h"
-#include "mozilla/CSSStyleSheet.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/unused.h"
 #include "mozilla/css/Loader.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/ipc/URIUtils.h"
+#include "nsCSSStyleSheet.h"
 #include "nsIURI.h"
 #include "nsCOMPtr.h"
 #include "nsICategoryManager.h"
 #include "nsISupportsPrimitives.h"
 #include "nsNetUtil.h"
 #include "nsIObserverService.h"
 #include "nsLayoutStatics.h"
 
@@ -181,17 +181,17 @@ nsStyleSheetService::LoadAndRegisterShee
 {
   NS_ENSURE_ARG(aSheetType == AGENT_SHEET ||
                 aSheetType == USER_SHEET ||
                 aSheetType == AUTHOR_SHEET);
   NS_ENSURE_ARG_POINTER(aSheetURI);
 
   nsRefPtr<css::Loader> loader = new css::Loader();
 
-  nsRefPtr<CSSStyleSheet> sheet;
+  nsRefPtr<nsCSSStyleSheet> sheet;
   // Allow UA sheets, but not user sheets, to use unsafe rules
   nsresult rv = loader->LoadSheetSync(aSheetURI, aSheetType == AGENT_SHEET,
                                       true, getter_AddRefs(sheet));
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (!mSheets[aSheetType].AppendObject(sheet)) {
     rv = NS_ERROR_OUT_OF_MEMORY;
   }
--- a/layout/inspector/inCSSValueSearch.cpp
+++ b/layout/inspector/inCSSValueSearch.cpp
@@ -1,16 +1,16 @@
 /* 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/CSSStyleSheet.h"
 #include "mozilla/dom/StyleSheetList.h"
+#include "nsCSSStyleSheet.h"
 #include "nsIComponentManager.h"
 #include "nsIServiceManager.h"
 #include "nsReadableUtils.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMStyleSheetList.h"
 #include "nsIDOMCSSStyleSheet.h"
 #include "nsIDOMCSSRuleList.h"
 #include "nsIDOMCSSStyleRule.h"
@@ -93,17 +93,17 @@ inCSSValueSearch::SearchSync()
 
   nsCOMPtr<nsIURI> baseURI = document->GetBaseURI();
 
   nsRefPtr<dom::StyleSheetList> sheets = document->StyleSheets();
   MOZ_ASSERT(sheets);
 
   uint32_t length = sheets->Length();
   for (uint32_t i = 0; i < length; ++i) {
-    nsRefPtr<CSSStyleSheet> sheet = sheets->Item(i);
+    nsRefPtr<nsCSSStyleSheet> sheet = sheets->Item(i);
     SearchStyleSheet(sheet, baseURI);
   }
 
   // XXX would be nice to search inline style as well.
 
   return NS_OK;
 }
 
--- a/layout/inspector/inDOMUtils.cpp
+++ b/layout/inspector/inDOMUtils.cpp
@@ -27,18 +27,18 @@
 #include "nsIMutableArray.h"
 #include "nsBindingManager.h"
 #include "ChildIterator.h"
 #include "nsComputedDOMStyle.h"
 #include "mozilla/EventStateManager.h"
 #include "nsIAtom.h"
 #include "nsRange.h"
 #include "nsContentList.h"
-#include "mozilla/CSSStyleSheet.h"
 #include "mozilla/dom/Element.h"
+#include "nsCSSStyleSheet.h"
 #include "nsRuleWalker.h"
 #include "nsRuleProcessorData.h"
 #include "nsCSSRuleProcessor.h"
 #include "mozilla/dom/InspectorUtilsBinding.h"
 #include "mozilla/dom/ToJSValue.h"
 #include "nsCSSProps.h"
 #include "nsColor.h"
 #include "nsStyleSet.h"
@@ -869,17 +869,17 @@ inDOMUtils::ClearPseudoClassLocks(nsIDOM
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 inDOMUtils::ParseStyleSheet(nsIDOMCSSStyleSheet *aSheet,
                             const nsAString& aInput)
 {
-  nsRefPtr<CSSStyleSheet> sheet = do_QueryObject(aSheet);
+  nsRefPtr<nsCSSStyleSheet> sheet = do_QueryObject(aSheet);
   NS_ENSURE_ARG_POINTER(sheet);
 
   return sheet->ParseSheet(aInput);
 }
 
 NS_IMETHODIMP
 inDOMUtils::ScrollElementIntoView(nsIDOMElement *aElement)
 {
--- a/layout/style/CSSRuleList.h
+++ b/layout/style/CSSRuleList.h
@@ -5,19 +5,19 @@
 
 #ifndef mozilla_dom_CSSRuleList_h
 #define mozilla_dom_CSSRuleList_h
 
 #include "nsIDOMCSSRule.h"
 #include "nsIDOMCSSRuleList.h"
 #include "nsWrapperCache.h"
 
+class nsCSSStyleSheet;
+
 namespace mozilla {
-class CSSStyleSheet;
-
 namespace dom {
 
 // IID for the CSSRuleList interface
 #define NS_ICSSRULELIST_IID \
 { 0x56ac8d1c, 0xc1ed, 0x45fe, \
   { 0x9a, 0x4d, 0x3a, 0xdc, 0xf9, 0xd1, 0xb9, 0x3f } }
 
 class CSSRuleList : public nsIDOMCSSRuleList
@@ -30,17 +30,17 @@ public:
   }
   virtual ~CSSRuleList() {}
 
   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 nsCSSStyleSheet* GetParentObject() = 0;
   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE MOZ_FINAL;
 
   NS_IMETHOD
   GetLength(uint32_t* aLength) MOZ_OVERRIDE MOZ_FINAL
   {
     *aLength = Length();
     return NS_OK;
   }
--- a/layout/style/ErrorReporter.cpp
+++ b/layout/style/ErrorReporter.cpp
@@ -1,34 +1,34 @@
 /* -*- 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/. */
 
 /* diagnostic reporting for CSS style sheet parser */
 
 #include "mozilla/css/ErrorReporter.h"
-
-#include "mozilla/CSSStyleSheet.h"
 #include "mozilla/css/Loader.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "nsCSSScanner.h"
+#include "nsCSSStyleSheet.h"
 #include "nsIConsoleService.h"
 #include "nsIDocument.h"
 #include "nsIFactory.h"
 #include "nsIScriptError.h"
 #include "nsIStringBundle.h"
 #include "nsServiceManagerUtils.h"
 #include "nsStyleUtil.h"
 #include "nsThreadUtils.h"
 
 #ifdef CSS_REPORT_PARSE_ERRORS
 
-using namespace mozilla;
+using mozilla::Preferences;
+namespace services = mozilla::services;
 
 namespace {
 class ShortTermURISpecCache : public nsRunnable {
 public:
   ShortTermURISpecCache() : mPending(false) {}
 
   nsString const& GetSpec(nsIURI* aURI) {
     if (mURI != aURI) {
@@ -127,17 +127,17 @@ ErrorReporter::ReleaseGlobals()
 {
   NS_IF_RELEASE(sConsoleService);
   NS_IF_RELEASE(sScriptErrorFactory);
   NS_IF_RELEASE(sStringBundle);
   NS_IF_RELEASE(sSpecCache);
 }
 
 ErrorReporter::ErrorReporter(const nsCSSScanner& aScanner,
-                             const CSSStyleSheet* aSheet,
+                             const nsCSSStyleSheet* aSheet,
                              const Loader* aLoader,
                              nsIURI* aURI)
   : mScanner(&aScanner), mSheet(aSheet), mLoader(aLoader), mURI(aURI),
     mInnerWindowID(0), mErrorLineNumber(0), mPrevErrorLineNumber(0),
     mErrorColNumber(0)
 {
 }
 
--- a/layout/style/ErrorReporter.h
+++ b/layout/style/ErrorReporter.h
@@ -9,32 +9,31 @@
 #define mozilla_css_ErrorReporter_h_
 
 // XXX turn this off for minimo builds
 #define CSS_REPORT_PARSE_ERRORS
 
 #include "nsString.h"
 
 struct nsCSSToken;
+class nsCSSStyleSheet;
 class nsCSSScanner;
 class nsIURI;
 
 namespace mozilla {
-class CSSStyleSheet;
-
 namespace css {
 
 class Loader;
 
 // If CSS_REPORT_PARSE_ERRORS is not defined, all of this class's
 // methods become inline stubs.
 class MOZ_STACK_CLASS ErrorReporter {
 public:
   ErrorReporter(const nsCSSScanner &aScanner,
-                const CSSStyleSheet *aSheet,
+                const nsCSSStyleSheet *aSheet,
                 const Loader *aLoader,
                 nsIURI *aURI);
   ~ErrorReporter();
 
   static void ReleaseGlobals();
 
   void OutputError();
   void OutputError(uint32_t aLineNumber, uint32_t aLineOffset);
@@ -63,29 +62,29 @@ public:
 private:
   void AddToError(const nsString &aErrorText);
 
 #ifdef CSS_REPORT_PARSE_ERRORS
   nsAutoString mError;
   nsString mErrorLine;
   nsString mFileName;
   const nsCSSScanner *mScanner;
-  const CSSStyleSheet *mSheet;
+  const nsCSSStyleSheet *mSheet;
   const Loader *mLoader;
   nsIURI *mURI;
   uint64_t mInnerWindowID;
   uint32_t mErrorLineNumber;
   uint32_t mPrevErrorLineNumber;
   uint32_t mErrorColNumber;
 #endif
 };
 
 #ifndef CSS_REPORT_PARSE_ERRORS
 inline ErrorReporter::ErrorReporter(const nsCSSScanner&,
-                                    const CSSStyleSheet*,
+                                    const nsCSSStyleSheet*,
                                     const Loader*,
                                     nsIURI*) {}
 inline ErrorReporter::~ErrorReporter() {}
 
 inline void ErrorReporter::ReleaseGlobals() {}
 
 inline void ErrorReporter::OutputError() {}
 inline void ErrorReporter::ClearError() {}
--- a/layout/style/GroupRule.h
+++ b/layout/style/GroupRule.h
@@ -17,19 +17,16 @@
 #include "nsCOMArray.h"
 #include "nsAutoPtr.h"
 #include "nsCycleCollectionParticipant.h"
 
 class nsPresContext;
 class nsMediaQueryResultCacheKey;
 
 namespace mozilla {
-
-class CSSStyleSheet;
-
 namespace css {
 
 class GroupRuleRuleList;
 
 // inherits from Rule so it can be shared between
 // MediaRule and DocumentRule
 class GroupRule : public Rule
 {
@@ -39,17 +36,17 @@ protected:
   virtual ~GroupRule();
 public:
 
   NS_DECL_CYCLE_COLLECTION_CLASS(GroupRule)
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
 
   // implement part of nsIStyleRule and Rule
   DECL_STYLE_RULE_INHERIT_NO_DOMRULE
-  virtual void SetStyleSheet(CSSStyleSheet* aSheet);
+  virtual void SetStyleSheet(nsCSSStyleSheet* aSheet);
 
   // to help implement nsIStyleRule
 #ifdef DEBUG
   virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE;
 #endif
 
 public:
   void AppendStyleRule(Rule* aRule);
--- a/layout/style/ImportRule.h
+++ b/layout/style/ImportRule.h
@@ -13,19 +13,16 @@
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/css/Rule.h"
 #include "nsIDOMCSSImportRule.h"
 
 class nsMediaList;
 class nsString;
 
 namespace mozilla {
-
-class CSSStyleSheet;
-
 namespace css {
 
 class ImportRule MOZ_FINAL : public Rule,
                              public nsIDOMCSSImportRule
 {
 public:
   ImportRule(nsMediaList* aMedia, const nsString& aURLSpec);
 private:
@@ -45,28 +42,28 @@ public:
 #ifdef DEBUG
   virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE;
 #endif
 
   // Rule methods
   virtual int32_t GetType() const;
   virtual already_AddRefed<Rule> Clone() const;
 
-  void SetSheet(CSSStyleSheet*);
+  void SetSheet(nsCSSStyleSheet*);
 
   virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
 
   // nsIDOMCSSRule interface
   NS_DECL_NSIDOMCSSRULE
 
   // nsIDOMCSSImportRule interface
   NS_DECL_NSIDOMCSSIMPORTRULE
 
 private:
   nsString  mURLSpec;
   nsRefPtr<nsMediaList> mMedia;
-  nsRefPtr<CSSStyleSheet> mChildSheet;
+  nsRefPtr<nsCSSStyleSheet> mChildSheet;
 };
 
 } // namespace css
 } // namespace mozilla
 
 #endif /* mozilla_css_ImportRule_h__ */
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -33,20 +33,20 @@
 #include "nsNetUtil.h"
 #include "nsContentUtils.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsContentPolicyUtils.h"
 #include "nsIHttpChannel.h"
 #include "nsIHttpChannelInternal.h"
 #include "nsIScriptError.h"
 #include "nsMimeTypes.h"
+#include "nsCSSStyleSheet.h"
 #include "nsIStyleSheetLinkingElement.h"
 #include "nsICSSLoaderObserver.h"
 #include "nsCSSParser.h"
-#include "mozilla/CSSStyleSheet.h"
 #include "mozilla/css/ImportRule.h"
 #include "nsThreadUtils.h"
 #include "nsGkAtoms.h"
 #include "nsIThreadInternal.h"
 #include "nsCrossSiteListenerProxy.h"
 #include "nsINetworkPredictor.h"
 #include "mozilla/dom/ShadowRoot.h"
 #include "mozilla/dom/URL.h"
@@ -108,34 +108,34 @@ class SheetLoadData : public nsIRunnable
                       public nsIThreadObserver
 {
 public:
   virtual ~SheetLoadData(void);
   // Data for loading a sheet linked from a document
   SheetLoadData(Loader* aLoader,
                 const nsSubstring& aTitle,
                 nsIURI* aURI,
-                CSSStyleSheet* aSheet,
+                nsCSSStyleSheet* aSheet,
                 nsIStyleSheetLinkingElement* aOwningElement,
                 bool aIsAlternate,
                 nsICSSLoaderObserver* aObserver,
                 nsIPrincipal* aLoaderPrincipal);
 
   // Data for loading a sheet linked from an @import rule
   SheetLoadData(Loader* aLoader,
                 nsIURI* aURI,
-                CSSStyleSheet* aSheet,
+                nsCSSStyleSheet* aSheet,
                 SheetLoadData* aParentData,
                 nsICSSLoaderObserver* aObserver,
                 nsIPrincipal* aLoaderPrincipal);
 
   // Data for loading a non-document sheet
   SheetLoadData(Loader* aLoader,
                 nsIURI* aURI,
-                CSSStyleSheet* aSheet,
+                nsCSSStyleSheet* aSheet,
                 bool aSyncLoad,
                 bool aAllowUnsafeRules,
                 bool aUseSystemPrincipal,
                 const nsCString& aCharset,
                 nsICSSLoaderObserver* aObserver,
                 nsIPrincipal* aLoaderPrincipal);
 
   already_AddRefed<nsIURI> GetReferrerURI();
@@ -160,17 +160,17 @@ public:
 
   // URI we're loading.  Null for inline sheets
   nsCOMPtr<nsIURI>           mURI;
 
   // Should be 1 for non-inline sheets.
   uint32_t                   mLineNumber;
 
   // The sheet we're loading data for
-  nsRefPtr<CSSStyleSheet>    mSheet;
+  nsRefPtr<nsCSSStyleSheet>  mSheet;
 
   // Linked list of datas for the same URI as us
   SheetLoadData*             mNext;  // strong ref
 
   // Load data for the sheet that @import-ed us if we were @import-ed
   // during the parse
   SheetLoadData*             mParentData;  // strong ref
 
@@ -303,17 +303,17 @@ static const char* const gStateStrings[]
  * SheetLoadData implementation *
  ********************************/
 NS_IMPL_ISUPPORTS(SheetLoadData, nsIUnicharStreamLoaderObserver, nsIRunnable,
                   nsIThreadObserver)
 
 SheetLoadData::SheetLoadData(Loader* aLoader,
                              const nsSubstring& aTitle,
                              nsIURI* aURI,
-                             CSSStyleSheet* aSheet,
+                             nsCSSStyleSheet* aSheet,
                              nsIStyleSheetLinkingElement* aOwningElement,
                              bool aIsAlternate,
                              nsICSSLoaderObserver* aObserver,
                              nsIPrincipal* aLoaderPrincipal)
   : mLoader(aLoader),
     mTitle(aTitle),
     mURI(aURI),
     mLineNumber(1),
@@ -335,17 +335,17 @@ SheetLoadData::SheetLoadData(Loader* aLo
     mLoaderPrincipal(aLoaderPrincipal)
 {
   NS_PRECONDITION(mLoader, "Must have a loader!");
   NS_ADDREF(mLoader);
 }
 
 SheetLoadData::SheetLoadData(Loader* aLoader,
                              nsIURI* aURI,
-                             CSSStyleSheet* aSheet,
+                             nsCSSStyleSheet* aSheet,
                              SheetLoadData* aParentData,
                              nsICSSLoaderObserver* aObserver,
                              nsIPrincipal* aLoaderPrincipal)
   : mLoader(aLoader),
     mURI(aURI),
     mLineNumber(1),
     mSheet(aSheet),
     mNext(nullptr),
@@ -376,17 +376,17 @@ SheetLoadData::SheetLoadData(Loader* aLo
   }
 
   NS_POSTCONDITION(!mUseSystemPrincipal || mSyncLoad,
                    "Shouldn't use system principal for async loads");
 }
 
 SheetLoadData::SheetLoadData(Loader* aLoader,
                              nsIURI* aURI,
-                             CSSStyleSheet* aSheet,
+                             nsCSSStyleSheet* aSheet,
                              bool aSyncLoad,
                              bool aAllowUnsafeRules,
                              bool aUseSystemPrincipal,
                              const nsCString& aCharset,
                              nsICSSLoaderObserver* aObserver,
                              nsIPrincipal* aLoaderPrincipal)
   : mLoader(aLoader),
     mURI(aURI),
@@ -965,17 +965,17 @@ Loader::IsAlternate(const nsAString& aTi
     return false;
   }
 
   return !aTitle.Equals(mPreferredSheet);
 }
 
 /* static */ PLDHashOperator
 Loader::RemoveEntriesWithURI(URIPrincipalAndCORSModeHashKey* aKey,
-                             nsRefPtr<CSSStyleSheet>& aSheet,
+                             nsRefPtr<nsCSSStyleSheet> &aSheet,
                              void* aUserData)
 {
   nsIURI* obsoleteURI = static_cast<nsIURI*>(aUserData);
   nsIURI* sheetURI = aKey->GetURI();
   bool areEqual;
   nsresult rv = sheetURI->Equals(obsoleteURI, &areEqual);
   if (NS_SUCCEEDED(rv) && areEqual) {
     return PL_DHASH_REMOVE;
@@ -1045,17 +1045,17 @@ Loader::CheckLoadAllowed(nsIPrincipal* a
       return NS_ERROR_CONTENT_BLOCKED;
     }
   }
 
   return NS_OK;
 }
 
 /**
- * CreateSheet() creates a CSSStyleSheet object for the given URI,
+ * CreateSheet() creates an nsCSSStyleSheet object for the given URI,
  * if any.  If there is no URI given, we just create a new style sheet
  * object.  Otherwise, we check for an existing style sheet object for
  * that uri in various caches and clone it if we find it.  Cloned
  * sheets will have the title/media/enabled state of the sheet they
  * are clones off; make sure to call PrepareSheet() on the result of
  * CreateSheet().
  */
 nsresult
@@ -1063,17 +1063,17 @@ Loader::CreateSheet(nsIURI* aURI,
                     nsIContent* aLinkingContent,
                     nsIPrincipal* aLoaderPrincipal,
                     CORSMode aCORSMode,
                     bool aSyncLoad,
                     bool aHasAlternateRel,
                     const nsAString& aTitle,                       
                     StyleSheetState& aSheetState,
                     bool *aIsAlternate,
-                    CSSStyleSheet** aSheet)
+                    nsCSSStyleSheet** aSheet)
 {
   LOG(("css::Loader::CreateSheet"));
   NS_PRECONDITION(aSheet, "Null out param!");
 
   if (!mSheets) {
     mSheets = new Sheets();
   }
 
@@ -1081,17 +1081,17 @@ Loader::CreateSheet(nsIURI* aURI,
   aSheetState = eSheetStateUnknown;
 
   // Check the alternate state before doing anything else, because it
   // can mess with our hashtables.
   *aIsAlternate = IsAlternate(aTitle, aHasAlternateRel);
 
   if (aURI) {
     aSheetState = eSheetComplete;
-    nsRefPtr<CSSStyleSheet> sheet;
+    nsRefPtr<nsCSSStyleSheet> sheet;
 
     // First, the XUL cache
 #ifdef MOZ_XUL
     if (IsChromeURI(aURI)) {
       nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
       if (cache) {
         if (cache->IsEnabled()) {
           sheet = cache->GetStyleSheet(aURI);
@@ -1205,17 +1205,17 @@ Loader::CreateSheet(nsIURI* aURI,
       sheetURI = aLinkingContent->OwnerDoc()->GetDocumentURI();
       originalURI = nullptr;
     } else {
       baseURI = aURI;
       sheetURI = aURI;
       originalURI = aURI;
     }
 
-    nsRefPtr<CSSStyleSheet> sheet = new CSSStyleSheet(aCORSMode);
+    nsRefPtr<nsCSSStyleSheet> sheet = new nsCSSStyleSheet(aCORSMode);
     sheet->SetURIs(sheetURI, originalURI, baseURI);
     sheet.forget(aSheet);
   }
 
   NS_ASSERTION(*aSheet, "We should have a sheet by now!");
   NS_ASSERTION(aSheetState != eSheetStateUnknown, "Have to set a state!");
   LOG(("  State: %s", gStateStrings[aSheetState]));
 
@@ -1223,17 +1223,17 @@ Loader::CreateSheet(nsIURI* aURI,
 }
 
 /**
  * PrepareSheet() handles setting the media and title on the sheet, as
  * well as setting the enabled state based on the title and whether
  * the sheet had "alternate" in its rel.
  */
 void
-Loader::PrepareSheet(CSSStyleSheet* aSheet,
+Loader::PrepareSheet(nsCSSStyleSheet* aSheet,
                      const nsSubstring& aTitle,
                      const nsSubstring& aMediaString,
                      nsMediaList* aMediaList,
                      Element* aScopeElement,
                      bool isAlternate)
 {
   NS_PRECONDITION(aSheet, "Must have a sheet!");
 
@@ -1267,17 +1267,17 @@ Loader::PrepareSheet(CSSStyleSheet* aShe
  *    linking elements
  * 2) Sheets without linking elements are inserted in the order in
  *    which the inserting requests come in, since all of these are
  *    inserted during header data processing in the content sink
  * 3) Sheets with linking elements are ordered based on document order
  *    as determined by CompareDocumentPosition.
  */
 nsresult
-Loader::InsertSheetInDoc(CSSStyleSheet* aSheet,
+Loader::InsertSheetInDoc(nsCSSStyleSheet* aSheet,
                          nsIContent* aLinkingContent,
                          nsIDocument* aDocument)
 {
   LOG(("css::Loader::InsertSheetInDoc"));
   NS_PRECONDITION(aSheet, "Nothing to insert");
   NS_PRECONDITION(aDocument, "Must have a document to insert into");
 
   // XXX Need to cancel pending sheet loads for this element, if any
@@ -1347,18 +1347,18 @@ Loader::InsertSheetInDoc(CSSStyleSheet* 
  * parent sheets.  Here we want to just insert based on order of the
  * @import rules that imported the sheets.  In theory we can't just
  * append to the end because the CSSOM can insert @import rules.  In
  * practice, we get the call to load the child sheet before the CSSOM
  * has finished inserting the @import rule, so we have no idea where
  * to put it anyway.  So just append for now.
  */
 nsresult
-Loader::InsertChildSheet(CSSStyleSheet* aSheet,
-                         CSSStyleSheet* aParentSheet,
+Loader::InsertChildSheet(nsCSSStyleSheet* aSheet,
+                         nsCSSStyleSheet* aParentSheet,
                          ImportRule* aParentRule)
 {
   LOG(("css::Loader::InsertChildSheet"));
   NS_PRECONDITION(aSheet, "Nothing to insert");
   NS_PRECONDITION(aParentSheet, "Need a parent to insert into");
   NS_PRECONDITION(aParentSheet, "How did we get imported?");
 
   // child sheets should always start out enabled, even if they got
@@ -1809,17 +1809,17 @@ Loader::DoSheetComplete(SheetLoadData* a
   // adjust the PostLoadEvent code that thinks anything already
   // complete must have loaded succesfully.
   if (NS_SUCCEEDED(aStatus) && aLoadData->mURI) {
     // Pick our sheet to cache carefully.  Ideally, we want to cache
     // one of the sheets that will be kept alive by a document or
     // parent sheet anyway, so that if someone then accesses it via
     // CSSOM we won't have extra clones of the inner lying around.
     data = aLoadData;
-    CSSStyleSheet* sheet = aLoadData->mSheet;
+    nsCSSStyleSheet* sheet = aLoadData->mSheet;
     while (data) {
       if (data->mSheet->GetParentSheet() || data->mSheet->GetOwnerNode()) {
         sheet = data->mSheet;
         break;
       }
       data = data->mNext;
     }
 #ifdef MOZ_XUL
@@ -1875,17 +1875,17 @@ Loader::LoadInlineStyle(nsIContent* aEle
 
   nsCOMPtr<nsIStyleSheetLinkingElement> owningElement(do_QueryInterface(aElement));
   NS_ASSERTION(owningElement, "Element is not a style linking element!");
 
   // Since we're not planning to load a URI, no need to hand a principal to the
   // load data or to CreateSheet().  Also, OK to use CORS_NONE for the CORS
   // mode.
   StyleSheetState state;
-  nsRefPtr<CSSStyleSheet> sheet;
+  nsRefPtr<nsCSSStyleSheet> sheet;
   nsresult rv = CreateSheet(nullptr, aElement, nullptr, CORS_NONE, false, false,
                             aTitle, state, aIsAlternate, getter_AddRefs(sheet));
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ASSERTION(state == eSheetNeedsParser,
                "Inline sheets should not be cached");
 
   LOG(("  Sheet is alternate: %d", *aIsAlternate));
 
@@ -1954,17 +1954,17 @@ Loader::LoadStyleLink(nsIContent* aEleme
     context = mDocument;
   }
   nsresult rv = CheckLoadAllowed(principal, aURL, context);
   if (NS_FAILED(rv)) return rv;
 
   LOG(("  Passed load check"));
 
   StyleSheetState state;
-  nsRefPtr<CSSStyleSheet> sheet;
+  nsRefPtr<nsCSSStyleSheet> sheet;
   rv = CreateSheet(aURL, aElement, principal, aCORSMode, false,
                    aHasAlternateRel, aTitle, state, aIsAlternate,
                    getter_AddRefs(sheet));
   NS_ENSURE_SUCCESS(rv, rv);
 
   LOG(("  Sheet is alternate: %d", *aIsAlternate));
 
   PrepareSheet(sheet, aTitle, aMedia, nullptr, nullptr, *aIsAlternate);
@@ -2038,17 +2038,17 @@ HaveAncestorDataWithURI(SheetLoadData *a
 
     aData = aData->mNext;
   }
 
   return false;
 }
 
 nsresult
-Loader::LoadChildSheet(CSSStyleSheet* aParentSheet,
+Loader::LoadChildSheet(nsCSSStyleSheet* aParentSheet,
                        nsIURI* aURL,
                        nsMediaList* aMedia,
                        ImportRule* aParentRule)
 {
   LOG(("css::Loader::LoadChildSheet"));
   NS_PRECONDITION(aURL, "Must have a URI to load");
   NS_PRECONDITION(aParentSheet, "Must have a parent sheet");
 
@@ -2109,17 +2109,17 @@ Loader::LoadChildSheet(CSSStyleSheet* aP
     LOG(("  No parent load; must be CSSOM"));
     // No parent load data, so the sheet will need to be notified when
     // we finish, if it can be, if we do the load asynchronously.
     observer = aParentSheet;
   }
 
   // Now that we know it's safe to load this (passes security check and not a
   // loop) do so.
-  nsRefPtr<CSSStyleSheet> sheet;
+  nsRefPtr<nsCSSStyleSheet> sheet;
   bool isAlternate;
   StyleSheetState state;
   const nsSubstring& empty = EmptyString();
   // For now, use CORS_NONE for child sheets
   rv = CreateSheet(aURL, nullptr, principal, CORS_NONE,
                    parentData ? parentData->mSyncLoad : false,
                    false, empty, state, &isAlternate, getter_AddRefs(sheet));
   NS_ENSURE_SUCCESS(rv, rv);
@@ -2152,30 +2152,30 @@ Loader::LoadChildSheet(CSSStyleSheet* aP
     data->mMustNotify = true;
   }
   return rv;
 }
 
 nsresult
 Loader::LoadSheetSync(nsIURI* aURL, bool aAllowUnsafeRules,
                       bool aUseSystemPrincipal,
-                      CSSStyleSheet** aSheet)
+                      nsCSSStyleSheet** aSheet)
 {
   LOG(("css::Loader::LoadSheetSync"));
   return InternalLoadNonDocumentSheet(aURL, aAllowUnsafeRules,
                                       aUseSystemPrincipal, nullptr,
                                       EmptyCString(), aSheet, nullptr);
 }
 
 nsresult
 Loader::LoadSheet(nsIURI* aURL,
                   nsIPrincipal* aOriginPrincipal,
                   const nsCString& aCharset,
                   nsICSSLoaderObserver* aObserver,
-                  CSSStyleSheet** aSheet)
+                  nsCSSStyleSheet** aSheet)
 {
   LOG(("css::Loader::LoadSheet(aURL, aObserver, aSheet) api call"));
   NS_PRECONDITION(aSheet, "aSheet is null");
   return InternalLoadNonDocumentSheet(aURL, false, false,
                                       aOriginPrincipal, aCharset,
                                       aSheet, aObserver);
 }
 
@@ -2193,17 +2193,17 @@ Loader::LoadSheet(nsIURI* aURL,
 }
 
 nsresult
 Loader::InternalLoadNonDocumentSheet(nsIURI* aURL,
                                      bool aAllowUnsafeRules,
                                      bool aUseSystemPrincipal,
                                      nsIPrincipal* aOriginPrincipal,
                                      const nsCString& aCharset,
-                                     CSSStyleSheet** aSheet,
+                                     nsCSSStyleSheet** aSheet,
                                      nsICSSLoaderObserver* aObserver,
                                      CORSMode aCORSMode)
 {
   NS_PRECONDITION(aURL, "Must have a URI to load");
   NS_PRECONDITION(aSheet || aObserver, "Sheet and observer can't both be null");
   NS_PRECONDITION(!aUseSystemPrincipal || !aObserver,
                   "Shouldn't load system-principal sheets async");
   NS_ASSERTION(mParsingDatas.Length() == 0, "We're in the middle of a parse?");
@@ -2221,17 +2221,17 @@ Loader::InternalLoadNonDocumentSheet(nsI
 
   nsresult rv = CheckLoadAllowed(aOriginPrincipal, aURL, mDocument);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   StyleSheetState state;
   bool isAlternate;
-  nsRefPtr<CSSStyleSheet> sheet;
+  nsRefPtr<nsCSSStyleSheet> sheet;
   bool syncLoad = (aObserver == nullptr);
   const nsSubstring& empty = EmptyString();
 
   rv = CreateSheet(aURL, nullptr, aOriginPrincipal, aCORSMode, syncLoad, false,
                    empty, state, &isAlternate, getter_AddRefs(sheet));
   NS_ENSURE_SUCCESS(rv, rv);
 
   PrepareSheet(sheet, empty, empty, nullptr, nullptr, isAlternate);
@@ -2263,17 +2263,17 @@ Loader::InternalLoadNonDocumentSheet(nsI
     data->mMustNotify = true;
   }
 
   return rv;
 }
 
 nsresult
 Loader::PostLoadEvent(nsIURI* aURI,
-                      CSSStyleSheet* aSheet,
+                      nsCSSStyleSheet* aSheet,
                       nsICSSLoaderObserver* aObserver,
                       bool aWasAlternate,
                       nsIStyleSheetLinkingElement* aElement)
 {
   LOG(("css::Loader::PostLoadEvent"));
   NS_PRECONDITION(aSheet, "Must have sheet");
   NS_PRECONDITION(aObserver || !mObservers.IsEmpty() || aElement,
                   "Must have observer or element");
@@ -2445,17 +2445,17 @@ Loader::StartAlternateLoads()
   for (uint32_t i = 0; i < arr.Length(); ++i) {
     --mDatasToNotifyOn;
     LoadSheet(arr[i], eSheetNeedsParser);
   }
 }
 
 static PLDHashOperator
 TraverseSheet(URIPrincipalAndCORSModeHashKey*,
-              CSSStyleSheet* aSheet,
+              nsCSSStyleSheet* aSheet,
               void* aClosure)
 {
   nsCycleCollectionTraversalCallback* cb =
     static_cast<nsCycleCollectionTraversalCallback*>(aClosure);
   NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*cb, "Sheet cache nsCSSLoader");
   cb->NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIStyleSheet*, aSheet));
   return PL_DHASH_NEXT;
 }
@@ -2478,17 +2478,17 @@ Loader::UnlinkCachedSheets()
 
 struct SheetMemoryCounter {
   size_t size;
   mozilla::MallocSizeOf mallocSizeOf;
 };
 
 static size_t
 CountSheetMemory(URIPrincipalAndCORSModeHashKey* /* unused */,
-                 const nsRefPtr<CSSStyleSheet>& aSheet,
+                 const nsRefPtr<nsCSSStyleSheet>& aSheet,
                  mozilla::MallocSizeOf aMallocSizeOf,
                  void* /* unused */)
 {
   // If aSheet has a parent, then its parent will report it so we don't
   // have to worry about it here.
   // Likewise, if aSheet has an owning node, then the document that
   // node is in will report it.
   if (aSheet->GetOwnerNode() || aSheet->GetParentSheet()) {
--- a/layout/style/Loader.h
+++ b/layout/style/Loader.h
@@ -18,25 +18,25 @@
 #include "nsTObserverArray.h"
 #include "nsURIHashKey.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/CORSMode.h"
 #include "mozilla/MemoryReporting.h"
 
 class nsIAtom;
 class nsICSSLoaderObserver;
+class nsCSSStyleSheet;
 class nsIContent;
 class nsIDocument;
 class nsCSSParser;
 class nsMediaList;
 class nsIStyleSheetLinkingElement;
 class nsCycleCollectionTraversalCallback;
 
 namespace mozilla {
-class CSSStyleSheet;
 namespace dom {
 class Element;
 }
 }
 
 namespace mozilla {
 
 class URIPrincipalAndCORSModeHashKey : public nsURIHashKey
@@ -217,17 +217,17 @@ public:
    * nsICSSLoaderObserver notification will be sent.
    *
    * @param aParentSheet the parent of this child sheet
    * @param aURL the URL of the child sheet
    * @param aMedia the already-parsed media list for the child sheet
    * @param aRule the @import rule importing this child.  This is used to
    *              properly order the child sheet list of aParentSheet.
    */
-  nsresult LoadChildSheet(CSSStyleSheet* aParentSheet,
+  nsresult LoadChildSheet(nsCSSStyleSheet* aParentSheet,
                           nsIURI* aURL,
                           nsMediaList* aMedia,
                           ImportRule* aRule);
 
   /**
    * Synchronously load and return the stylesheet at aURL.  Any child sheets
    * will also be loaded synchronously.  Note that synchronous loads over some
    * protocols may involve spinning up a new event loop, so use of this method
@@ -251,22 +251,22 @@ public:
    * non-UTF8 sheets being treated as UTF-8 by this method.
    *
    * NOTE: A successful return from this method doesn't indicate anything about
    * whether the data could be parsed as CSS and doesn't indicate anything
    * about the status of child sheets of the returned sheet.
    */
   nsresult LoadSheetSync(nsIURI* aURL, bool aEnableUnsafeRules,
                          bool aUseSystemPrincipal,
-                         CSSStyleSheet** aSheet);
+                         nsCSSStyleSheet** aSheet);
 
   /**
    * As above, but aUseSystemPrincipal and aEnableUnsafeRules are assumed false.
    */
-  nsresult LoadSheetSync(nsIURI* aURL, CSSStyleSheet** aSheet) {
+  nsresult LoadSheetSync(nsIURI* aURL, nsCSSStyleSheet** aSheet) {
     return LoadSheetSync(aURL, false, false, aSheet);
   }
 
   /**
    * Asynchronously load the stylesheet at aURL.  If a successful result is
    * returned, aObserver is guaranteed to be notified asynchronously once the
    * sheet is loaded and marked complete.  This method can be used to load
    * sheets not associated with a document.
@@ -284,17 +284,17 @@ public:
    *                  Must not be null.
    * @param [out] aSheet the sheet to load. Note that the sheet may well
    *              not be loaded by the time this method returns.
    */
   nsresult LoadSheet(nsIURI* aURL,
                      nsIPrincipal* aOriginPrincipal,
                      const nsCString& aCharset,
                      nsICSSLoaderObserver* aObserver,
-                     CSSStyleSheet** aSheet);
+                     nsCSSStyleSheet** aSheet);
 
   /**
    * Same as above, to be used when the caller doesn't care about the
    * not-yet-loaded sheet.
    */
   nsresult LoadSheet(nsIURI* aURL,
                      nsIPrincipal* aOriginPrincipal,
                      const nsCString& aCharset,
@@ -380,17 +380,17 @@ public:
   // cache.
   nsresult ObsoleteSheet(nsIURI* aURI);
 
 private:
   friend class SheetLoadData;
 
   static PLDHashOperator
   RemoveEntriesWithURI(URIPrincipalAndCORSModeHashKey* aKey,
-                       nsRefPtr<CSSStyleSheet>& aSheet,
+                       nsRefPtr<nsCSSStyleSheet> &aSheet,
                        void* aUserData);
 
   // Note: null aSourcePrincipal indicates that the content policy and
   // CheckLoadURI checks should be skipped.
   nsresult CheckLoadAllowed(nsIPrincipal* aSourcePrincipal,
                             nsIURI* aTargetURI,
                             nsISupports* aContext);
 
@@ -403,54 +403,54 @@ private:
                        nsIContent* aLinkingContent,
                        nsIPrincipal* aLoaderPrincipal,
                        CORSMode aCORSMode,
                        bool aSyncLoad,
                        bool aHasAlternateRel,
                        const nsAString& aTitle,
                        StyleSheetState& aSheetState,
                        bool *aIsAlternate,
-                       CSSStyleSheet** aSheet);
+                       nsCSSStyleSheet** aSheet);
 
   // Pass in either a media string or the nsMediaList from the
   // CSSParser.  Don't pass both.
   // This method will set the sheet's enabled state based on isAlternate
-  void PrepareSheet(CSSStyleSheet* aSheet,
+  void PrepareSheet(nsCSSStyleSheet* aSheet,
                     const nsAString& aTitle,
                     const nsAString& aMediaString,
                     nsMediaList* aMediaList,
                     dom::Element* aScopeElement,
                     bool isAlternate);
 
-  nsresult InsertSheetInDoc(CSSStyleSheet* aSheet,
+  nsresult InsertSheetInDoc(nsCSSStyleSheet* aSheet,
                             nsIContent* aLinkingContent,
                             nsIDocument* aDocument);
 
-  nsresult InsertChildSheet(CSSStyleSheet* aSheet,
-                            CSSStyleSheet* aParentSheet,
+  nsresult InsertChildSheet(nsCSSStyleSheet* aSheet,
+                            nsCSSStyleSheet* aParentSheet,
                             ImportRule* aParentRule);
 
   nsresult InternalLoadNonDocumentSheet(nsIURI* aURL,
                                         bool aAllowUnsafeRules,
                                         bool aUseSystemPrincipal,
                                         nsIPrincipal* aOriginPrincipal,
                                         const nsCString& aCharset,
-                                        CSSStyleSheet** aSheet,
+                                        nsCSSStyleSheet** aSheet,
                                         nsICSSLoaderObserver* aObserver,
                                         CORSMode aCORSMode = CORS_NONE);
 
   // Post a load event for aObserver to be notified about aSheet.  The
   // notification will be sent with status NS_OK unless the load event is
   // canceled at some point (in which case it will be sent with
   // NS_BINDING_ABORTED).  aWasAlternate indicates the state when the load was
   // initiated, not the state at some later time.  aURI should be the URI the
   // sheet was loaded from (may be null for inline sheets).  aElement is the
   // owning element for this sheet.
   nsresult PostLoadEvent(nsIURI* aURI,
-                         CSSStyleSheet* aSheet,
+                         nsCSSStyleSheet* aSheet,
                          nsICSSLoaderObserver* aObserver,
                          bool aWasAlternate,
                          nsIStyleSheetLinkingElement* aElement);
 
   // Start the loads of all the sheets in mPendingDatas
   void StartAlternateLoads();
 
   // Handle an event posted by PostLoadEvent
@@ -474,17 +474,17 @@ private:
 
   // The guts of SheetComplete.  This may be called recursively on parent datas
   // or datas that had glommed on to a single load.  The array is there so load
   // datas whose observers need to be notified can be added to it.
   void DoSheetComplete(SheetLoadData* aLoadData, nsresult aStatus,
                        LoadDataArray& aDatasToNotify);
 
   struct Sheets {
-    nsRefPtrHashtable<URIPrincipalAndCORSModeHashKey, CSSStyleSheet>
+    nsRefPtrHashtable<URIPrincipalAndCORSModeHashKey, nsCSSStyleSheet>
                       mCompleteSheets;
     nsDataHashtable<URIPrincipalAndCORSModeHashKey, SheetLoadData*>
                       mLoadingDatas; // weak refs
     nsDataHashtable<URIPrincipalAndCORSModeHashKey, SheetLoadData*>
                       mPendingDatas; // weak refs
   };
   nsAutoPtr<Sheets> mSheets;
 
--- a/layout/style/Rule.h
+++ b/layout/style/Rule.h
@@ -3,20 +3,20 @@
  * 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/. */
 
 /* base class for all rule types in a CSS style sheet */
 
 #ifndef mozilla_css_Rule_h___
 #define mozilla_css_Rule_h___
 
-#include "mozilla/CSSStyleSheet.h"
 #include "mozilla/MemoryReporting.h"
 #include "nsIStyleRule.h"
 #include "nsIDOMCSSRule.h"
+#include "nsCSSStyleSheet.h"
 
 class nsIStyleSheet;
 class nsIDocument;
 struct nsRuleData;
 template<class T> struct already_AddRefed;
 class nsHTMLCSSStyleSheet;
 
 namespace mozilla {
@@ -47,17 +47,17 @@ protected:
 
   virtual ~Rule() {}
 
 public:
 
   // The constants in this list must maintain the following invariants:
   //   If a rule of type N must appear before a rule of type M in stylesheets
   //   then N < M
-  // Note that CSSStyleSheet::RebuildChildList assumes that no other kinds of
+  // Note that nsCSSStyleSheet::RebuildChildList assumes that no other kinds of
   // rules can come between two rules of type IMPORT_RULE.
   enum {
     UNKNOWN_RULE = 0,
     CHARSET_RULE,
     IMPORT_RULE,
     NAMESPACE_RULE,
     STYLE_RULE,
     MEDIA_RULE,
@@ -68,27 +68,27 @@ public:
     DOCUMENT_RULE,
     SUPPORTS_RULE,
     FONT_FEATURE_VALUES_RULE,
     COUNTER_STYLE_RULE
   };
 
   virtual int32_t GetType() const = 0;
 
-  CSSStyleSheet* GetStyleSheet() const;
+  nsCSSStyleSheet* GetStyleSheet() const;
   nsHTMLCSSStyleSheet* GetHTMLCSSStyleSheet() const;
 
   // Return the document the rule lives in, if any
   nsIDocument* GetDocument() const
   {
-    CSSStyleSheet* sheet = GetStyleSheet();
+    nsCSSStyleSheet* sheet = GetStyleSheet();
     return sheet ? sheet->GetDocument() : nullptr;
   }
 
-  virtual void SetStyleSheet(CSSStyleSheet* aSheet);
+  virtual void SetStyleSheet(nsCSSStyleSheet* aSheet);
   // This does not need to be virtual, because GroupRule and MediaRule are not
   // used for inline style.
   void SetHTMLCSSStyleSheet(nsHTMLCSSStyleSheet* 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.
@@ -117,17 +117,17 @@ public:
     const MOZ_MUST_OVERRIDE = 0;
 
   // This is used to measure nsCOMArray<Rule>s.
   static size_t SizeOfCOMArrayElementIncludingThis(css::Rule* aElement,
                                                    mozilla::MallocSizeOf aMallocSizeOf,
                                                    void* aData);
 
 protected:
-  // This is either a CSSStyleSheet* or an nsHTMLStyleSheet*.  The former
+  // This is either an nsCSSStyleSheet* or a nsHTMLStyleSheet*.  The former
   // if the low bit is 0, the latter if the low bit is 1.
   uintptr_t         mSheet;
   GroupRule*        mParentRule;
 };
 
 } // namespace css
 } // namespace mozilla
 
--- a/layout/style/StyleRule.cpp
+++ b/layout/style/StyleRule.cpp
@@ -6,20 +6,20 @@
 /*
  * representation of CSS style rules (selectors+declaration), CSS
  * selectors, and DOM objects for style rules, selectors, and
  * declarations
  */
 
 #include "mozilla/css/StyleRule.h"
 
-#include "mozilla/CSSStyleSheet.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/css/GroupRule.h"
 #include "mozilla/css/Declaration.h"
+#include "nsCSSStyleSheet.h"
 #include "nsIDocument.h"
 #include "nsIAtom.h"
 #include "nsString.h"
 #include "nsStyleUtil.h"
 #include "nsICSSStyleRuleDOMWrapper.h"
 #include "nsDOMCSSDeclaration.h"
 #include "nsNameSpaceManager.h"
 #include "nsXMLNameSpaceMap.h"
@@ -536,17 +536,17 @@ int32_t nsCSSSelector::CalcWeight() cons
   return weight;
 }
 
 //
 // Builds the textual representation of a selector. Called by DOM 2 CSS 
 // StyleRule:selectorText
 //
 void
-nsCSSSelector::ToString(nsAString& aString, CSSStyleSheet* aSheet,
+nsCSSSelector::ToString(nsAString& aString, nsCSSStyleSheet* aSheet,
                         bool aAppend) const
 {
   if (!aAppend)
    aString.Truncate();
 
   // selectors are linked from right-to-left, so the next selector in
   // the linked list actually precedes this one in the resulting string
   nsAutoTArray<const nsCSSSelector*, 8> stack;
@@ -579,32 +579,32 @@ nsCSSSelector::ToString(nsAString& aStri
         }
       }
     }
   }
 }
 
 void
 nsCSSSelector::AppendToStringWithoutCombinators
-                   (nsAString& aString, CSSStyleSheet* aSheet) const
+                   (nsAString& aString, nsCSSStyleSheet* aSheet) const
 {
   AppendToStringWithoutCombinatorsOrNegations(aString, aSheet, false);
 
   for (const nsCSSSelector* negation = mNegations; negation;
        negation = negation->mNegations) {
     aString.AppendLiteral(":not(");
     negation->AppendToStringWithoutCombinatorsOrNegations(aString, aSheet,
                                                           true);
     aString.Append(char16_t(')'));
   }
 }
 
 void
 nsCSSSelector::AppendToStringWithoutCombinatorsOrNegations
-                   (nsAString& aString, CSSStyleSheet* aSheet,
+                   (nsAString& aString, nsCSSStyleSheet* aSheet,
                    bool aIsNegated) const
 {
   nsAutoString temp;
   bool isPseudoElement = IsPseudoElement();
 
   // For non-pseudo-element selectors or for lone pseudo-elements, deal with
   // namespace prefixes.
   bool wroteNamespace = false;
@@ -890,17 +890,17 @@ nsCSSSelectorList::AddSelector(char16_t 
   }
 
   newSel->mNext = mSelectors;
   mSelectors = newSel;
   return newSel;
 }
 
 void
-nsCSSSelectorList::ToString(nsAString& aResult, CSSStyleSheet* aSheet)
+nsCSSSelectorList::ToString(nsAString& aResult, nsCSSStyleSheet* aSheet)
 {
   aResult.Truncate();
   nsCSSSelectorList *p = this;
   for (;;) {
     p->mSelectors->ToString(aResult, aSheet, true);
     p = p->mNext;
     if (!p)
       break;
@@ -1433,17 +1433,17 @@ StyleRule::GetExistingDOMRule()
 
 /* virtual */ already_AddRefed<StyleRule>
 StyleRule::DeclarationChanged(Declaration* aDecl,
                               bool aHandleContainer)
 {
   nsRefPtr<StyleRule> clone = new StyleRule(*this, aDecl);
 
   if (aHandleContainer) {
-    CSSStyleSheet* sheet = GetStyleSheet();
+    nsCSSStyleSheet* sheet = GetStyleSheet();
     if (mParentRule) {
       if (sheet) {
         sheet->ReplaceRuleInGroup(mParentRule, this, clone);
       } else {
         mParentRule->ReplaceStyleRule(this, clone);
       }
     } else if (sheet) {
       sheet->ReplaceStyleRule(this, clone);
--- a/layout/style/StyleRule.h
+++ b/layout/style/StyleRule.h
@@ -16,23 +16,20 @@
 #include "mozilla/css/Rule.h"
 
 #include "nsString.h"
 #include "nsCOMPtr.h"
 #include "nsCSSPseudoElements.h"
 #include "nsCSSPseudoClasses.h"
 
 class nsIAtom;
+class nsCSSStyleSheet;
 struct nsCSSSelectorList;
 class nsCSSCompressedDataBlock;
 
-namespace mozilla {
-class CSSStyleSheet;
-} // namespace mozilla
-
 struct nsAtomList {
 public:
   nsAtomList(nsIAtom* aAtom);
   nsAtomList(const nsString& aAtomValue);
   ~nsAtomList(void);
 
   /** Do a deep clone.  Should be used only on the first in the linked list. */
   nsAtomList* Clone() const { return Clone(true); }
@@ -152,27 +149,27 @@ public:
 
   inline bool IsPseudoElement() const {
     return mLowercaseTag && !mCasedTag;
   }
 
   // Calculate the specificity of this selector (not including its mNext!).
   int32_t CalcWeight() const;
 
-  void ToString(nsAString& aString, mozilla::CSSStyleSheet* aSheet,
+  void ToString(nsAString& aString, nsCSSStyleSheet* aSheet,
                 bool aAppend = false) const;
 
 private:
   void AddPseudoClassInternal(nsPseudoClassList *aPseudoClass);
   nsCSSSelector* Clone(bool aDeepNext, bool aDeepNegations) const;
 
   void AppendToStringWithoutCombinators(nsAString& aString,
-                                        mozilla::CSSStyleSheet* aSheet) const;
+                                        nsCSSStyleSheet* aSheet) const;
   void AppendToStringWithoutCombinatorsOrNegations(nsAString& aString,
-                                                   mozilla::CSSStyleSheet* aSheet,
+                                                   nsCSSStyleSheet* aSheet,
                                                    bool aIsNegated)
                                                         const;
   // Returns true if this selector can have a namespace specified (which
   // happens if and only if the default namespace would apply to this
   // selector).
   bool CanBeNamespaced(bool aIsNegated) const;
   // Calculate the specificity of this selector (not including its mNext
   // or its mNegations).
@@ -236,17 +233,17 @@ struct nsCSSSelectorList {
    * The list owns the new selector.
    * The caller is responsible for updating |mWeight|.
    */
   nsCSSSelector* AddSelector(char16_t aOperator);
 
   /**
    * Should be used only on the first in the list
    */
-  void ToString(nsAString& aResult, mozilla::CSSStyleSheet* aSheet);
+  void ToString(nsAString& aResult, nsCSSStyleSheet* aSheet);
 
   /**
    * Do a deep clone.  Should be used only on the first in the list.
    */
   nsCSSSelectorList* Clone() const { return Clone(true); }
 
   size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
 
--- a/layout/style/moz.build
+++ b/layout/style/moz.build
@@ -24,16 +24,17 @@ EXPORTS += [
     'nsCSSPropList.h',
     'nsCSSProps.h',
     'nsCSSPseudoClasses.h',
     'nsCSSPseudoClassList.h',
     'nsCSSPseudoElementList.h',
     'nsCSSPseudoElements.h',
     'nsCSSRuleProcessor.h',
     'nsCSSScanner.h',
+    'nsCSSStyleSheet.h',
     'nsCSSValue.h',
     'nsDOMCSSAttrDeclaration.h',
     'nsDOMCSSDeclaration.h',
     'nsDOMCSSRGBColor.h',
     'nsICSSDeclaration.h',
     'nsICSSLoaderObserver.h',
     'nsICSSPseudoComparator.h',
     'nsICSSStyleRuleDOMWrapper.h',
@@ -53,17 +54,16 @@ EXPORTS += [
     'nsStyleStruct.h',
     'nsStyleStructFwd.h',
     'nsStyleStructInlines.h',
     'nsStyleTransformMatrix.h',
     'nsStyleUtil.h',
 ]
 
 EXPORTS.mozilla += [
-    'CSSStyleSheet.h',
     'CSSVariableDeclarations.h',
     'CSSVariableResolver.h',
     'CSSVariableValues.h',
 ]
 
 EXPORTS.mozilla.dom += [
     'CSS.h',
     'CSSRuleList.h',
@@ -83,17 +83,16 @@ EXPORTS.mozilla.css += [
     'StyleRule.h',
 ]
 
 UNIFIED_SOURCES += [
     'AnimationCommon.cpp',
     'CounterStyleManager.cpp',
     'CSS.cpp',
     'CSSRuleList.cpp',
-    'CSSStyleSheet.cpp',
     'CSSVariableDeclarations.cpp',
     'CSSVariableResolver.cpp',
     'CSSVariableValues.cpp',
     'Declaration.cpp',
     'ErrorReporter.cpp',
     'ImageLoader.cpp',
     'Loader.cpp',
     'MediaQueryList.cpp',
@@ -103,16 +102,17 @@ UNIFIED_SOURCES += [
     'nsCSSDataBlock.cpp',
     'nsCSSKeywords.cpp',
     'nsCSSParser.cpp',
     'nsCSSProps.cpp',
     'nsCSSPseudoClasses.cpp',
     'nsCSSPseudoElements.cpp',
     'nsCSSRules.cpp',
     'nsCSSScanner.cpp',
+    'nsCSSStyleSheet.cpp',
     'nsCSSValue.cpp',
     'nsDOMCSSAttrDeclaration.cpp',
     'nsDOMCSSDeclaration.cpp',
     'nsDOMCSSRect.cpp',
     'nsDOMCSSRGBColor.cpp',
     'nsDOMCSSValueList.cpp',
     'nsHTMLCSSStyleSheet.cpp',
     'nsHTMLStyleSheet.cpp',
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -17,17 +17,17 @@
 #include "nsCSSScanner.h"
 #include "mozilla/css/ErrorReporter.h"
 #include "mozilla/css/Loader.h"
 #include "mozilla/css/StyleRule.h"
 #include "mozilla/css/ImportRule.h"
 #include "nsCSSRules.h"
 #include "mozilla/css/NameSpaceRule.h"
 #include "nsTArray.h"
-#include "mozilla/CSSStyleSheet.h"
+#include "nsCSSStyleSheet.h"
 #include "mozilla/css/Declaration.h"
 #include "nsStyleConsts.h"
 #include "nsNetUtil.h"
 #include "nsCOMPtr.h"
 #include "nsString.h"
 #include "nsIAtom.h"
 #include "nsColor.h"
 #include "nsCSSPseudoClasses.h"
@@ -97,17 +97,17 @@ struct CSSParserInputState {
 // Your basic top-down recursive descent style parser
 // The exposed methods and members of this class are precisely those
 // needed by nsCSSParser, far below.
 class CSSParserImpl {
 public:
   CSSParserImpl();
   ~CSSParserImpl();
 
-  nsresult SetStyleSheet(CSSStyleSheet* aSheet);
+  nsresult SetStyleSheet(nsCSSStyleSheet* aSheet);
 
   nsresult SetQuirkMode(bool aQuirkMode);
 
   nsresult SetChildLoader(mozilla::css::Loader* aChildLoader);
 
   // Clears everything set by the above Set*() functions.
   void Reset();
 
@@ -274,17 +274,17 @@ public:
   void ParsePropertyWithVariableReferences(nsCSSProperty aPropertyID,
                                            nsCSSProperty aShorthandPropertyID,
                                            const nsAString& aValue,
                                            const CSSVariableValues* aVariables,
                                            nsRuleData* aRuleData,
                                            nsIURI* aDocURL,
                                            nsIURI* aBaseURL,
                                            nsIPrincipal* aDocPrincipal,
-                                           CSSStyleSheet* aSheet,
+                                           nsCSSStyleSheet* aSheet,
                                            uint32_t aLineNumber,
                                            uint32_t aLineOffset);
 
   nsCSSProperty LookupEnabledProperty(const nsAString& aProperty) {
     static_assert(nsCSSProps::eEnabledForAllContent == 0,
                   "nsCSSProps::eEnabledForAllContent should be zero for "
                   "this bitfield to work");
     nsCSSProps::EnabledState enabledState = nsCSSProps::eEnabledForAllContent;
@@ -966,25 +966,25 @@ protected:
 
   // The URI to be used as an HTTP "Referer" and for error reporting.
   nsCOMPtr<nsIURI> mSheetURI;
 
   // The principal of the sheet involved
   nsCOMPtr<nsIPrincipal> mSheetPrincipal;
 
   // The sheet we're parsing into
-  nsRefPtr<CSSStyleSheet> mSheet;
+  nsRefPtr<nsCSSStyleSheet> mSheet;
 
   // Used for @import rules
   mozilla::css::Loader* mChildLoader; // not ref counted, it owns us
 
   // Sheet section we're in.  This is used to enforce correct ordering of the
   // various rule types (eg the fact that a @charset rule must come before
   // anything else).  Note that there are checks of similar things in various
-  // places in CSSStyleSheet.cpp (e.g in insertRule, RebuildChildList).
+  // places in nsCSSStyleSheet.cpp (e.g in insertRule, RebuildChildList).
   enum nsCSSSection {
     eCSSSection_Charset,
     eCSSSection_Import,
     eCSSSection_NameSpace,
     eCSSSection_General
   };
   nsCSSSection  mSection;
 
@@ -1119,17 +1119,17 @@ CSSParserImpl::CSSParserImpl()
 
 CSSParserImpl::~CSSParserImpl()
 {
   mData.AssertInitialState();
   mTempData.AssertInitialState();
 }
 
 nsresult
-CSSParserImpl::SetStyleSheet(CSSStyleSheet* aSheet)
+CSSParserImpl::SetStyleSheet(nsCSSStyleSheet* aSheet)
 {
   if (aSheet != mSheet) {
     // Switch to using the new sheet, if any
     mGroupStack.Clear();
     mSheet = aSheet;
     if (mSheet) {
       mNameSpaceMap = mSheet->GetNameSpaceMap();
     } else {
@@ -2308,17 +2308,17 @@ CSSParserImpl::ParsePropertyWithVariable
                                             nsCSSProperty aPropertyID,
                                             nsCSSProperty aShorthandPropertyID,
                                             const nsAString& aValue,
                                             const CSSVariableValues* aVariables,
                                             nsRuleData* aRuleData,
                                             nsIURI* aDocURL,
                                             nsIURI* aBaseURL,
                                             nsIPrincipal* aDocPrincipal,
-                                            CSSStyleSheet* aSheet,
+                                            nsCSSStyleSheet* aSheet,
                                             uint32_t aLineNumber,
                                             uint32_t aLineOffset)
 {
   mTempData.AssertInitialState();
 
   bool valid;
   nsString expandedValue;
 
@@ -14500,17 +14500,17 @@ CSSParserImpl::ParseValueWithVariables(C
 
 } // anonymous namespace
 
 // Recycling of parser implementation objects
 
 static CSSParserImpl* gFreeList = nullptr;
 
 nsCSSParser::nsCSSParser(mozilla::css::Loader* aLoader,
-                         CSSStyleSheet* aSheet)
+                         nsCSSStyleSheet* aSheet)
 {
   CSSParserImpl *impl = gFreeList;
   if (impl) {
     gFreeList = impl->mNextFree;
     impl->mNextFree = nullptr;
   } else {
     impl = new CSSParserImpl();
   }
@@ -14546,17 +14546,17 @@ nsCSSParser::Shutdown()
       delete tofree;
       tofree = next;
     }
 }
 
 // Wrapper methods
 
 nsresult
-nsCSSParser::SetStyleSheet(CSSStyleSheet* aSheet)
+nsCSSParser::SetStyleSheet(nsCSSStyleSheet* aSheet)
 {
   return static_cast<CSSParserImpl*>(mImpl)->
     SetStyleSheet(aSheet);
 }
 
 nsresult
 nsCSSParser::SetQuirkMode(bool aQuirkMode)
 {
@@ -14761,17 +14761,17 @@ nsCSSParser::ParsePropertyWithVariableRe
                                             nsCSSProperty aPropertyID,
                                             nsCSSProperty aShorthandPropertyID,
                                             const nsAString& aValue,
                                             const CSSVariableValues* aVariables,
                                             nsRuleData* aRuleData,
                                             nsIURI* aDocURL,
                                             nsIURI* aBaseURL,
                                             nsIPrincipal* aDocPrincipal,
-                                            CSSStyleSheet* aSheet,
+                                            nsCSSStyleSheet* aSheet,
                                             uint32_t aLineNumber,
                                             uint32_t aLineOffset)
 {
   static_cast<CSSParserImpl*>(mImpl)->
     ParsePropertyWithVariableReferences(aPropertyID, aShorthandPropertyID,
                                         aValue, aVariables, aRuleData, aDocURL,
                                         aBaseURL, aDocPrincipal, aSheet,
                                         aLineNumber, aLineOffset);
--- a/layout/style/nsCSSParser.h
+++ b/layout/style/nsCSSParser.h
@@ -11,54 +11,54 @@
 #include "mozilla/Attributes.h"
 
 #include "nsCSSProperty.h"
 #include "nsCSSScanner.h"
 #include "nsCOMPtr.h"
 #include "nsStringFwd.h"
 #include "nsTArrayForwardDeclare.h"
 
+class nsCSSStyleSheet;
 class nsIPrincipal;
 class nsIURI;
 struct nsCSSSelectorList;
 class nsMediaList;
 class nsCSSKeyframeRule;
 class nsCSSValue;
 struct nsRuleData;
 
 namespace mozilla {
-class CSSStyleSheet;
 class CSSVariableValues;
 namespace css {
 class Rule;
 class Declaration;
 class Loader;
 class StyleRule;
 }
 }
 
 // Interface to the css parser.
 
 class MOZ_STACK_CLASS nsCSSParser {
 public:
   nsCSSParser(mozilla::css::Loader* aLoader = nullptr,
-              mozilla::CSSStyleSheet* aSheet = nullptr);
+              nsCSSStyleSheet* aSheet = nullptr);
   ~nsCSSParser();
 
   static void Shutdown();
 
 private:
   nsCSSParser(nsCSSParser const&) MOZ_DELETE;
   nsCSSParser& operator=(nsCSSParser const&) MOZ_DELETE;
 
 public:
   // Set a style sheet for the parser to fill in. The style sheet must
-  // implement the CSSStyleSheet interface.  Null can be passed in to clear
+  // implement the nsCSSStyleSheet interface.  Null can be passed in to clear
   // out an existing stylesheet reference.
-  nsresult SetStyleSheet(mozilla::CSSStyleSheet* aSheet);
+  nsresult SetStyleSheet(nsCSSStyleSheet* aSheet);
 
   // Set whether or not to emulate Nav quirks
   nsresult SetQuirkMode(bool aQuirkMode);
 
   // Set loader to use for child sheets
   nsresult SetChildLoader(mozilla::css::Loader* aChildLoader);
 
   /**
@@ -255,17 +255,17 @@ public:
                                    nsCSSProperty aPropertyID,
                                    nsCSSProperty aShorthandPropertyID,
                                    const nsAString& aValue,
                                    const mozilla::CSSVariableValues* aVariables,
                                    nsRuleData* aRuleData,
                                    nsIURI* aDocURL,
                                    nsIURI* aBaseURL,
                                    nsIPrincipal* aDocPrincipal,
-                                   mozilla::CSSStyleSheet* aSheet,
+                                   nsCSSStyleSheet* aSheet,
                                    uint32_t aLineNumber,
                                    uint32_t aLineOffset);
 
   bool ParseCounterStyleName(const nsAString& aBuffer,
                              nsIURI* aURL,
                              nsAString& aName);
 
   bool ParseCounterDescriptor(nsCSSCounterDesc aDescID,
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -557,17 +557,17 @@ RuleHash::~RuleHash()
     if (mUniversalRules.Length() > 0) {
       printf("  Universal rules:\n");
       for (uint32_t i = 0; i < mUniversalRules.Length(); ++i) {
         RuleValue* value = &(mUniversalRules[i]);
         nsAutoString selectorText;
         uint32_t lineNumber = value->mRule->GetLineNumber();
         nsCOMPtr<nsIStyleSheet> sheet;
         value->mRule->GetStyleSheet(*getter_AddRefs(sheet));
-        nsRefPtr<CSSStyleSheet> cssSheet = do_QueryObject(sheet);
+        nsRefPtr<nsCSSStyleSheet> cssSheet = do_QueryObject(sheet);
         value->mSelector->ToString(selectorText, cssSheet);
 
         printf("    line %d, %s\n",
                lineNumber, NS_ConvertUTF16toUTF8(selectorText).get());
       }
     }
   }
 #endif // PRINT_UNIVERSAL_RULES
@@ -3394,22 +3394,22 @@ CascadeRuleEnumFunc(css::Rule* aRule, vo
     if (!data->mCounterStyleRules.AppendElement(counterStyleRule)) {
       return false;
     }
   }
   return true;
 }
 
 /* static */ bool
-nsCSSRuleProcessor::CascadeSheet(CSSStyleSheet* aSheet, CascadeEnumData* aData)
+nsCSSRuleProcessor::CascadeSheet(nsCSSStyleSheet* aSheet, CascadeEnumData* aData)
 {
   if (aSheet->IsApplicable() &&
       aSheet->UseForPresentation(aData->mPresContext, aData->mCacheKey) &&
       aSheet->mInner) {
-    CSSStyleSheet* child = aSheet->mInner->mFirstChild;
+    nsCSSStyleSheet* child = aSheet->mInner->mFirstChild;
     while (child) {
       CascadeSheet(child, aData);
       child = child->mNext;
     }
 
     if (!aSheet->mInner->mOrderedRules.EnumerateForwards(CascadeRuleEnumFunc,
                                                          aData))
       return false;
--- a/layout/style/nsCSSRuleProcessor.h
+++ b/layout/style/nsCSSRuleProcessor.h
@@ -23,36 +23,33 @@
 struct CascadeEnumData;
 struct nsCSSSelector;
 struct nsCSSSelectorList;
 struct RuleCascadeData;
 struct TreeMatchContext;
 class nsCSSKeyframesRule;
 class nsCSSPageRule;
 class nsCSSFontFeatureValuesRule;
+class nsCSSStyleSheet;
 class nsCSSCounterStyleRule;
 
-namespace mozilla {
-class CSSStyleSheet;
-} // namespace mozilla
-
 /**
  * The CSS style rule processor provides a mechanism for sibling style
  * sheets to combine their rule processing in order to allow proper
  * cascading to happen.
  *
  * CSS style rule processors keep a live reference on all style sheets
  * bound to them.  The CSS style sheets keep a weak reference to all the
  * processors that they are bound to (many to many).  The CSS style sheet
  * is told when the rule processor is going away (via DropRuleProcessor).
  */
 
 class nsCSSRuleProcessor: public nsIStyleRuleProcessor {
 public:
-  typedef nsTArray<nsRefPtr<mozilla::CSSStyleSheet>> sheet_array_type;
+  typedef nsTArray<nsRefPtr<nsCSSStyleSheet> > sheet_array_type;
 
   // aScopeElement must be non-null iff aSheetType is
   // nsStyleSet::eScopedDocSheet.
   nsCSSRuleProcessor(const sheet_array_type& aSheets,
                      uint8_t aSheetType,
                      mozilla::dom::Element* aScopeElement);
   virtual ~nsCSSRuleProcessor();
 
@@ -171,18 +168,17 @@ public:
         mSelector(aSelector)
     {}
 
     mozilla::EventStates mStates;
     nsCSSSelector* mSelector;
   };
 
 private:
-  static bool CascadeSheet(mozilla::CSSStyleSheet* aSheet,
-                           CascadeEnumData* aData);
+  static bool CascadeSheet(nsCSSStyleSheet* aSheet, CascadeEnumData* aData);
 
   RuleCascadeData* GetRuleCascade(nsPresContext* aPresContext);
   void RefreshRuleCascade(nsPresContext* aPresContext);
 
   nsRestyleHint HasStateDependentStyle(ElementDependentRuleProcessorData* aData,
                                        mozilla::dom::Element* aStatefulElement,
                                        nsCSSPseudoElements::Type aPseudoType,
                                        mozilla::EventStates aStateMask);
--- a/layout/style/nsCSSRules.cpp
+++ b/layout/style/nsCSSRules.cpp
@@ -4,25 +4,25 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* rules in a CSS stylesheet other than style rules (e.g., @import rules) */
 
 #include "mozilla/Attributes.h"
 
 #include "nsCSSRules.h"
 #include "nsCSSValue.h"
-#include "mozilla/CSSStyleSheet.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/css/ImportRule.h"
 #include "mozilla/css/NameSpaceRule.h"
 
 #include "nsString.h"
 #include "nsIAtom.h"
 
 #include "nsCSSProps.h"
+#include "nsCSSStyleSheet.h"
 
 #include "nsCOMPtr.h"
 #include "nsIDOMCSSStyleSheet.h"
 #include "nsIMediaList.h"
 #include "mozilla/dom/CSSRuleList.h"
 #include "nsIDocument.h"
 #include "nsPresContext.h"
 
@@ -54,38 +54,38 @@ using namespace mozilla;
 IMPL_STYLE_RULE_INHERIT_GET_DOM_RULE_WEAK(class_, super_) \
 IMPL_STYLE_RULE_INHERIT_MAP_RULE_INFO_INTO(class_, super_)
 
 // base class for all rule types in a CSS style sheet
 
 namespace mozilla {
 namespace css {
 
-CSSStyleSheet*
+nsCSSStyleSheet*
 Rule::GetStyleSheet() const
 {
   if (!(mSheet & 0x1)) {
-    return reinterpret_cast<CSSStyleSheet*>(mSheet);
+    return reinterpret_cast<nsCSSStyleSheet*>(mSheet);
   }
 
   return nullptr;
 }
 
 nsHTMLCSSStyleSheet*
 Rule::GetHTMLCSSStyleSheet() const
 {
   if (mSheet & 0x1) {
     return reinterpret_cast<nsHTMLCSSStyleSheet*>(mSheet & ~uintptr_t(0x1));
   }
 
   return nullptr;
 }
 
 /* virtual */ void
-Rule::SetStyleSheet(CSSStyleSheet* aSheet)
+Rule::SetStyleSheet(nsCSSStyleSheet* 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 = reinterpret_cast<uintptr_t>(aSheet);
 }
 
 void
@@ -130,17 +130,17 @@ Rule::SizeOfCOMArrayElementIncludingThis
 // Style Rule List for group rules
 //
 
 class GroupRuleRuleList MOZ_FINAL : public dom::CSSRuleList
 {
 public:
   GroupRuleRuleList(GroupRule *aGroupRule);
 
-  virtual CSSStyleSheet* GetParentObject() MOZ_OVERRIDE;
+  virtual nsCSSStyleSheet* GetParentObject() MOZ_OVERRIDE;
 
   virtual nsIDOMCSSRule*
   IndexedGetter(uint32_t aIndex, bool& aFound) MOZ_OVERRIDE;
   virtual uint32_t
   Length() MOZ_OVERRIDE;
 
   void DropReference() { mGroupRule = nullptr; }
 
@@ -157,17 +157,17 @@ GroupRuleRuleList::GroupRuleRuleList(Gro
   // The rule will tell us when its going away.
   mGroupRule = aGroupRule;
 }
 
 GroupRuleRuleList::~GroupRuleRuleList()
 {
 }
 
-CSSStyleSheet*
+nsCSSStyleSheet*
 GroupRuleRuleList::GetParentObject()
 {
   if (!mGroupRule) {
     return nullptr;
   }
 
   return mGroupRule->GetStyleSheet();
 }
@@ -338,17 +338,17 @@ ImportRule::ImportRule(nsMediaList* aMed
 ImportRule::ImportRule(const ImportRule& aCopy)
   : Rule(aCopy),
     mURLSpec(aCopy.mURLSpec)
 {
   // Whether or not an @import rule has a null sheet is a permanent
   // property of that @import rule, since it is null only if the target
   // sheet failed security checks.
   if (aCopy.mChildSheet) {
-    nsRefPtr<CSSStyleSheet> sheet =
+    nsRefPtr<nsCSSStyleSheet> sheet =
       aCopy.mChildSheet->Clone(nullptr, this, nullptr, nullptr);
     SetSheet(sheet);
     // SetSheet sets mMedia appropriately
   }
 }
 
 ImportRule::~ImportRule()
 {
@@ -398,17 +398,17 @@ ImportRule::GetType() const
 /* virtual */ already_AddRefed<Rule>
 ImportRule::Clone() const
 {
   nsRefPtr<Rule> clone = new ImportRule(*this);
   return clone.forget();
 }
 
 void
-ImportRule::SetSheet(CSSStyleSheet* aSheet)
+ImportRule::SetSheet(nsCSSStyleSheet* aSheet)
 {
   NS_PRECONDITION(aSheet, "null arg");
 
   // set the new sheet
   mChildSheet = aSheet;
   aSheet->SetOwnerRule(this);
 
   // set our medialist to be the same as the sheet's medialist
@@ -489,18 +489,18 @@ ImportRule::SizeOfIncludingThis(MallocSi
 {
   return aMallocSizeOf(this);
 
   // Measurement of the following members may be added later if DMD finds it is
   // worthwhile:
   // - mURLSpec
   //
   // The following members are not measured:
-  // - mMedia, because it is measured via CSSStyleSheet::mMedia
-  // - mChildSheet, because it is measured via CSSStyleSheetInner::mSheets
+  // - mMedia, because it is measured via nsCSSStyleSheet::mMedia
+  // - mChildSheet, because it is measured via nsCSSStyleSheetInner::mSheets
 }
 
 } // namespace css
 } // namespace mozilla
 
 // must be outside the namespace
 DOMCI_DATA(CSSImportRule, css::ImportRule)
 
@@ -542,17 +542,17 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(GroupRu
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(GroupRule)
 NS_INTERFACE_MAP_END
 
 IMPL_STYLE_RULE_INHERIT_MAP_RULE_INFO_INTO(GroupRule, Rule)
 
 static bool
 SetStyleSheetReference(Rule* aRule, void* aSheet)
 {
-  CSSStyleSheet* sheet = (CSSStyleSheet*)aSheet;
+  nsCSSStyleSheet* sheet = (nsCSSStyleSheet*)aSheet;
   aRule->SetStyleSheet(sheet);
   return true;
 }
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(GroupRule)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(GroupRule)
   tmp->mRules.EnumerateForwards(SetParentRuleReference, nullptr);
@@ -577,17 +577,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(nsCSSStyleSheet* 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);
@@ -608,17 +608,17 @@ GroupRule::List(FILE* out, int32_t aInde
   fputs("}\n", out);
 }
 #endif
 
 void
 GroupRule::AppendStyleRule(Rule* aRule)
 {
   mRules.AppendObject(aRule);
-  CSSStyleSheet* sheet = GetStyleSheet();
+  nsCSSStyleSheet* sheet = GetStyleSheet();
   aRule->SetStyleSheet(sheet);
   aRule->SetParentRule(this);
   if (sheet) {
     sheet->SetModifiedByChildRule();
   }
 }
 
 Rule*
@@ -706,32 +706,32 @@ 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();
+  nsCSSStyleSheet* 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);
 }
 
 nsresult
 GroupRule::DeleteRule(uint32_t aIndex)
 {
-  CSSStyleSheet* sheet = GetStyleSheet();
+  nsCSSStyleSheet* 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!");
 
@@ -784,17 +784,17 @@ 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, nsIStyleRule)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSMediaRule)
 NS_INTERFACE_MAP_END_INHERITING(GroupRule)
 
 /* virtual */ void
-MediaRule::SetStyleSheet(CSSStyleSheet* aSheet)
+MediaRule::SetStyleSheet(nsCSSStyleSheet* aSheet)
 {
   if (mMedia) {
     // Set to null so it knows it's leaving one sheet and joining another.
     mMedia->SetStyleSheet(nullptr);
     mMedia->SetStyleSheet(aSheet);
   }
 
   GroupRule::SetStyleSheet(aSheet);
@@ -2362,17 +2362,17 @@ nsCSSKeyframeRule::SetKeyText(const nsAS
     return NS_OK;
   }
 
   nsIDocument* doc = GetDocument();
   MOZ_AUTO_DOC_UPDATE(doc, UPDATE_STYLE, true);
 
   newSelectors.SwapElements(mKeys);
 
-  CSSStyleSheet* sheet = GetStyleSheet();
+  nsCSSStyleSheet* sheet = GetStyleSheet();
   if (sheet) {
     sheet->SetModifiedByChildRule();
 
     if (doc) {
       doc->StyleRuleChanged(sheet, this, this);
     }
   }
 
@@ -2399,17 +2399,17 @@ nsCSSKeyframeRule::ChangeDeclaration(css
   MOZ_AUTO_DOC_UPDATE(doc, UPDATE_STYLE, true);
 
   // Be careful to not assign to an nsAutoPtr if we would be assigning
   // the thing it already holds.
   if (aDeclaration != mDeclaration) {
     mDeclaration = aDeclaration;
   }
 
-  CSSStyleSheet* sheet = GetStyleSheet();
+  nsCSSStyleSheet* sheet = GetStyleSheet();
   if (sheet) {
     sheet->SetModifiedByChildRule();
 
     if (doc) {
       doc->StyleRuleChanged(sheet, this, this);
     }
   }
 }
@@ -2538,17 +2538,17 @@ nsCSSKeyframesRule::SetName(const nsAStr
     return NS_OK;
   }
 
   nsIDocument* doc = GetDocument();
   MOZ_AUTO_DOC_UPDATE(doc, UPDATE_STYLE, true);
 
   mName = aName;
 
-  CSSStyleSheet* sheet = GetStyleSheet();
+  nsCSSStyleSheet* sheet = GetStyleSheet();
   if (sheet) {
     sheet->SetModifiedByChildRule();
 
     if (doc) {
       doc->StyleRuleChanged(sheet, this, this);
     }
   }
 
@@ -2573,17 +2573,17 @@ nsCSSKeyframesRule::AppendRule(const nsA
   nsRefPtr<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();
+    nsCSSStyleSheet* sheet = GetStyleSheet();
     if (sheet) {
       sheet->SetModifiedByChildRule();
 
       if (doc) {
         doc->StyleRuleChanged(sheet, this, this);
       }
     }
   }
@@ -2621,17 +2621,17 @@ 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();
+    nsCSSStyleSheet* sheet = GetStyleSheet();
     if (sheet) {
       sheet->SetModifiedByChildRule();
 
       if (doc) {
         doc->StyleRuleChanged(sheet, this, this);
       }
     }
   }
@@ -2882,17 +2882,17 @@ nsCSSPageRule::ChangeDeclaration(css::De
 {
   mImportantRule = nullptr;
   // Be careful to not assign to an nsAutoPtr if we would be assigning
   // the thing it already holds.
   if (aDeclaration != mDeclaration) {
     mDeclaration = aDeclaration;
   }
 
-  CSSStyleSheet* sheet = GetStyleSheet();
+  nsCSSStyleSheet* sheet = GetStyleSheet();
   if (sheet) {
     sheet->SetModifiedByChildRule();
   }
 }
 
 /* virtual */ size_t
 nsCSSPageRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
 {
@@ -3176,17 +3176,17 @@ 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();
+    nsCSSStyleSheet* sheet = GetStyleSheet();
     if (sheet) {
       sheet->SetModifiedByChildRule();
       if (doc) {
         doc->StyleRuleChanged(sheet, this, this);
       }
     }
   }
   return NS_OK;
@@ -3222,17 +3222,17 @@ 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();
+  nsCSSStyleSheet* sheet = GetStyleSheet();
   if (sheet) {
     sheet->SetModifiedByChildRule();
     if (doc) {
       doc->StyleRuleChanged(sheet, this, this);
     }
   }
 }
 
@@ -3452,17 +3452,17 @@ nsCSSCounterStyleRule::CheckDescValue(in
 }
 
 nsresult
 nsCSSCounterStyleRule::SetDescriptor(nsCSSCounterDesc aDescID,
                                      const nsAString& aValue)
 {
   nsCSSParser parser;
   nsCSSValue value;
-  CSSStyleSheet* sheet = GetStyleSheet();
+  nsCSSStyleSheet* sheet = GetStyleSheet();
   nsIURI* baseURL = nullptr;
   nsIPrincipal* principal = nullptr;
   if (sheet) {
     baseURL = sheet->GetBaseURI();
     principal = sheet->Principal();
   }
   if (parser.ParseCounterDescriptor(aDescID, aValue, nullptr,
                                     baseURL, principal, value)) {
--- a/layout/style/nsCSSRules.h
+++ b/layout/style/nsCSSRules.h
@@ -56,17 +56,17 @@ public:
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIStyleRule methods
 #ifdef DEBUG
   virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE;
 #endif
 
   // Rule methods
-  virtual void SetStyleSheet(mozilla::CSSStyleSheet* aSheet); //override GroupRule
+  virtual void SetStyleSheet(nsCSSStyleSheet* aSheet); //override GroupRule
   virtual int32_t GetType() const;
   virtual already_AddRefed<Rule> Clone() const;
   virtual nsIDOMCSSRule* GetDOMRule()
   {
     return this;
   }
   virtual nsIDOMCSSRule* GetExistingDOMRule()
   {
rename from layout/style/CSSStyleSheet.cpp
rename to layout/style/nsCSSStyleSheet.cpp
--- a/layout/style/CSSStyleSheet.cpp
+++ b/layout/style/nsCSSStyleSheet.cpp
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 // vim:cindent:tabstop=2:expandtab:shiftwidth=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/. */
 
 /* representation of a CSS style sheet */
 
-#include "mozilla/CSSStyleSheet.h"
+#include "nsCSSStyleSheet.h"
 
 #include "nsIAtom.h"
 #include "nsCSSRuleProcessor.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/ShadowRoot.h"
 #include "mozilla/dom/MediaListBinding.h"
 #include "mozilla/css/NameSpaceRule.h"
@@ -42,51 +42,52 @@
 #include "nsDOMClassInfoID.h"
 #include "mozilla/Likely.h"
 #include "mozilla/dom/CSSStyleSheetBinding.h"
 #include "nsComponentManagerUtils.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
+
 // -------------------------------
 // Style Rule List for the DOM
 //
 class CSSRuleListImpl : public CSSRuleList
 {
 public:
-  CSSRuleListImpl(CSSStyleSheet *aStyleSheet);
+  CSSRuleListImpl(nsCSSStyleSheet *aStyleSheet);
 
-  virtual CSSStyleSheet* GetParentObject() MOZ_OVERRIDE;
+  virtual nsCSSStyleSheet* GetParentObject() MOZ_OVERRIDE;
 
   virtual nsIDOMCSSRule*
   IndexedGetter(uint32_t aIndex, bool& aFound) MOZ_OVERRIDE;
   virtual uint32_t
   Length() MOZ_OVERRIDE;
 
   void DropReference() { mStyleSheet = nullptr; }
 
 protected:
   virtual ~CSSRuleListImpl();
 
-  CSSStyleSheet*  mStyleSheet;
+  nsCSSStyleSheet*  mStyleSheet;
 };
 
-CSSRuleListImpl::CSSRuleListImpl(CSSStyleSheet *aStyleSheet)
+CSSRuleListImpl::CSSRuleListImpl(nsCSSStyleSheet *aStyleSheet)
 {
   // Not reference counted to avoid circular references.
   // The style sheet will tell us when its going away.
   mStyleSheet = aStyleSheet;
 }
 
 CSSRuleListImpl::~CSSRuleListImpl()
 {
 }
 
-CSSStyleSheet*
+nsCSSStyleSheet*
 CSSRuleListImpl::GetParentObject()
 {
   return mStyleSheet;
 }
 
 uint32_t
 CSSRuleListImpl::Length()
 {
@@ -539,17 +540,17 @@ nsMediaList::Matches(nsPresContext* aPre
     if (mArray[i]->Matches(aPresContext, aKey)) {
       return true;
     }
   }
   return mArray.IsEmpty();
 }
 
 nsresult
-nsMediaList::SetStyleSheet(CSSStyleSheet* aSheet)
+nsMediaList::SetStyleSheet(nsCSSStyleSheet *aSheet)
 {
   NS_ASSERTION(aSheet == mStyleSheet || !aSheet || !mStyleSheet,
                "multiple style sheets competing for one media list");
   mStyleSheet = aSheet;
   return NS_OK;
 }
 
 already_AddRefed<nsMediaList>
@@ -566,17 +567,17 @@ nsMediaList::Clone()
 
 NS_IMETHODIMP
 nsMediaList::GetMediaText(nsAString& aMediaText)
 {
   GetText(aMediaText);
   return NS_OK;
 }
 
-// "sheet" should be a CSSStyleSheet and "doc" should be an
+// "sheet" should be an nsCSSStyleSheet and "doc" should be an
 // nsCOMPtr<nsIDocument>
 #define BEGIN_MEDIA_CHANGE(sheet, doc)                         \
   if (sheet) {                                                 \
     doc = sheet->GetOwningDocument();                          \
   }                                                            \
   mozAutoDocUpdate updateBatch(doc, UPDATE_STYLE, true);       \
   if (sheet) {                                                 \
     sheet->WillDirty();                                        \
@@ -709,112 +710,110 @@ nsMediaList::Append(const nsAString& aNe
       rv = NS_ERROR_OUT_OF_MEMORY;
     }
   }
 
   mArray.SwapElements(buf);
   return rv;
 }
 
-namespace mozilla {
-
 // -------------------------------
 // CSS Style Sheet Inner Data Container
 //
 
 
-CSSStyleSheetInner::CSSStyleSheetInner(CSSStyleSheet* aPrimarySheet,
-                                       CORSMode aCORSMode)
+nsCSSStyleSheetInner::nsCSSStyleSheetInner(nsCSSStyleSheet* aPrimarySheet,
+                                           CORSMode aCORSMode)
   : mSheets(),
     mCORSMode(aCORSMode),
     mComplete(false)
 #ifdef DEBUG
     , mPrincipalSet(false)
 #endif
 {
-  MOZ_COUNT_CTOR(CSSStyleSheetInner);
+  MOZ_COUNT_CTOR(nsCSSStyleSheetInner);
   mSheets.AppendElement(aPrimarySheet);
 
   mPrincipal = do_CreateInstance("@mozilla.org/nullprincipal;1");
   if (!mPrincipal) {
     NS_RUNTIMEABORT("OOM");
   }
 }
 
 static bool SetStyleSheetReference(css::Rule* aRule, void* aSheet)
 {
   if (aRule) {
-    aRule->SetStyleSheet(static_cast<CSSStyleSheet*>(aSheet));
+    aRule->SetStyleSheet(static_cast<nsCSSStyleSheet*>(aSheet));
   }
   return true;
 }
 
 struct ChildSheetListBuilder {
-  nsRefPtr<CSSStyleSheet>* sheetSlot;
-  CSSStyleSheet* parent;
+  nsRefPtr<nsCSSStyleSheet>* sheetSlot;
+  nsCSSStyleSheet* parent;
 
-  void SetParentLinks(CSSStyleSheet* aSheet) {
+  void SetParentLinks(nsCSSStyleSheet* aSheet) {
     aSheet->mParent = parent;
     aSheet->SetOwningDocument(parent->mDocument);
   }
 
-  static void ReparentChildList(CSSStyleSheet* aPrimarySheet,
-                                CSSStyleSheet* aFirstChild)
+  static void ReparentChildList(nsCSSStyleSheet* aPrimarySheet,
+                                nsCSSStyleSheet* aFirstChild)
   {
-    for (CSSStyleSheet *child = aFirstChild; child; child = child->mNext) {
+    for (nsCSSStyleSheet *child = aFirstChild; child; child = child->mNext) {
       child->mParent = aPrimarySheet;
       child->SetOwningDocument(aPrimarySheet->mDocument);
     }
   }
 };
   
 bool
-CSSStyleSheet::RebuildChildList(css::Rule* aRule, void* aBuilder)
+nsCSSStyleSheet::RebuildChildList(css::Rule* aRule, void* aBuilder)
 {
   int32_t type = aRule->GetType();
   if (type < css::Rule::IMPORT_RULE) {
     // Keep going till we get to the import rules.
     return true;
   }
 
   if (type != css::Rule::IMPORT_RULE) {
     // We're past all the import rules; stop the enumeration.
     return false;
   }
 
   ChildSheetListBuilder* builder =
     static_cast<ChildSheetListBuilder*>(aBuilder);
 
   // XXXbz We really need to decomtaminate all this stuff.  Is there a reason
-  // that I can't just QI to ImportRule and get a CSSStyleSheet
+  // that I can't just QI to ImportRule and get an nsCSSStyleSheet
   // directly from it?
   nsCOMPtr<nsIDOMCSSImportRule> importRule(do_QueryInterface(aRule));
   NS_ASSERTION(importRule, "GetType lied");
 
   nsCOMPtr<nsIDOMCSSStyleSheet> childSheet;
   importRule->GetStyleSheet(getter_AddRefs(childSheet));
 
   // Have to do this QI to be safe, since XPConnect can fake
   // nsIDOMCSSStyleSheets
-  nsRefPtr<CSSStyleSheet> cssSheet = do_QueryObject(childSheet);
+  nsRefPtr<nsCSSStyleSheet> cssSheet = do_QueryObject(childSheet);
   if (!cssSheet) {
     return true;
   }
 
   (*builder->sheetSlot) = cssSheet;
   builder->SetParentLinks(*builder->sheetSlot);
   builder->sheetSlot = &(*builder->sheetSlot)->mNext;
   return true;
 }
 
 size_t
-CSSStyleSheet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
+nsCSSStyleSheet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
 {
   size_t n = 0;
-  const CSSStyleSheet* s = this;
+  const nsCSSStyleSheet* s = this;
   while (s) {
     n += aMallocSizeOf(s);
 
     // Each inner can be shared by multiple sheets.  So we only count the inner
     // if this sheet is the first one in the list of those sharing it.  As a
     // result, the first such sheet takes all the blame for the memory
     // consumption of the inner, which isn't ideal but it's better than
     // double-counting the inner.
@@ -832,60 +831,60 @@ CSSStyleSheet::SizeOfIncludingThis(Mallo
     // The following members are not measured:
     // - s->mOwnerRule, because it's non-owning
 
     s = s->mNext;
   }
   return n;
 }
 
-CSSStyleSheetInner::CSSStyleSheetInner(CSSStyleSheetInner& aCopy,
-                                       CSSStyleSheet* aPrimarySheet)
+nsCSSStyleSheetInner::nsCSSStyleSheetInner(nsCSSStyleSheetInner& aCopy,
+                                           nsCSSStyleSheet* aPrimarySheet)
   : mSheets(),
     mSheetURI(aCopy.mSheetURI),
     mOriginalSheetURI(aCopy.mOriginalSheetURI),
     mBaseURI(aCopy.mBaseURI),
     mPrincipal(aCopy.mPrincipal),
     mCORSMode(aCopy.mCORSMode),
     mComplete(aCopy.mComplete)
 #ifdef DEBUG
     , mPrincipalSet(aCopy.mPrincipalSet)
 #endif
 {
-  MOZ_COUNT_CTOR(CSSStyleSheetInner);
+  MOZ_COUNT_CTOR(nsCSSStyleSheetInner);
   AddSheet(aPrimarySheet);
   aCopy.mOrderedRules.EnumerateForwards(css::GroupRule::CloneRuleInto, &mOrderedRules);
   mOrderedRules.EnumerateForwards(SetStyleSheetReference, aPrimarySheet);
 
   ChildSheetListBuilder builder = { &mFirstChild, aPrimarySheet };
-  mOrderedRules.EnumerateForwards(CSSStyleSheet::RebuildChildList, &builder);
+  mOrderedRules.EnumerateForwards(nsCSSStyleSheet::RebuildChildList, &builder);
 
   RebuildNameSpaces();
 }
 
-CSSStyleSheetInner::~CSSStyleSheetInner()
+nsCSSStyleSheetInner::~nsCSSStyleSheetInner()
 {
-  MOZ_COUNT_DTOR(CSSStyleSheetInner);
+  MOZ_COUNT_DTOR(nsCSSStyleSheetInner);
   mOrderedRules.EnumerateForwards(SetStyleSheetReference, nullptr);
 }
 
-CSSStyleSheetInner*
-CSSStyleSheetInner::CloneFor(CSSStyleSheet* aPrimarySheet)
+nsCSSStyleSheetInner* 
+nsCSSStyleSheetInner::CloneFor(nsCSSStyleSheet* aPrimarySheet)
 {
-  return new CSSStyleSheetInner(*this, aPrimarySheet);
+  return new nsCSSStyleSheetInner(*this, aPrimarySheet);
 }
 
 void
-CSSStyleSheetInner::AddSheet(CSSStyleSheet* aSheet)
+nsCSSStyleSheetInner::AddSheet(nsCSSStyleSheet* aSheet)
 {
   mSheets.AppendElement(aSheet);
 }
 
 void
-CSSStyleSheetInner::RemoveSheet(CSSStyleSheet* aSheet)
+nsCSSStyleSheetInner::RemoveSheet(nsCSSStyleSheet* aSheet)
 {
   if (1 == mSheets.Length()) {
     NS_ASSERTION(aSheet == mSheets.ElementAt(0), "bad parent");
     delete this;
     return;
   }
   if (aSheet == mSheets.ElementAt(0)) {
     mSheets.RemoveElementAt(0);
@@ -923,37 +922,37 @@ CreateNameSpace(css::Rule* aRule, void* 
     return true;
   }
   // stop if not namespace, import or charset because namespace can't follow
   // anything else
   return (css::Rule::CHARSET_RULE == type || css::Rule::IMPORT_RULE == type);
 }
 
 void 
-CSSStyleSheetInner::RebuildNameSpaces()
+nsCSSStyleSheetInner::RebuildNameSpaces()
 {
   // Just nuke our existing namespace map, if any
   if (NS_SUCCEEDED(CreateNamespaceMap())) {
     mOrderedRules.EnumerateForwards(CreateNameSpace, mNameSpaceMap);
   }
 }
 
 nsresult
-CSSStyleSheetInner::CreateNamespaceMap()
+nsCSSStyleSheetInner::CreateNamespaceMap()
 {
   mNameSpaceMap = nsXMLNameSpaceMap::Create(false);
   NS_ENSURE_TRUE(mNameSpaceMap, NS_ERROR_OUT_OF_MEMORY);
   // Override the default namespace map behavior for the null prefix to
   // return the wildcard namespace instead of the null namespace.
   mNameSpaceMap->AddPrefix(nullptr, kNameSpaceID_Unknown);
   return NS_OK;
 }
 
 size_t
-CSSStyleSheetInner::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
+nsCSSStyleSheetInner::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
 {
   size_t n = aMallocSizeOf(this);
   n += mOrderedRules.SizeOfExcludingThis(css::Rule::SizeOfCOMArrayElementIncludingThis,
                                          aMallocSizeOf);
   n += mFirstChild ? mFirstChild->SizeOfIncludingThis(aMallocSizeOf) : 0;
 
   // Measurement of the following members may be added later if DMD finds it is
   // worthwhile:
@@ -968,37 +967,37 @@ CSSStyleSheetInner::SizeOfIncludingThis(
 
   return n;
 }
 
 // -------------------------------
 // CSS Style Sheet
 //
 
-CSSStyleSheet::CSSStyleSheet(CORSMode aCORSMode)
+nsCSSStyleSheet::nsCSSStyleSheet(CORSMode aCORSMode)
   : mTitle(), 
     mParent(nullptr),
     mOwnerRule(nullptr),
     mDocument(nullptr),
     mOwningNode(nullptr),
     mDisabled(false),
     mDirty(false),
     mScopeElement(nullptr),
     mRuleProcessors(nullptr)
 {
-  mInner = new CSSStyleSheetInner(this, aCORSMode);
+  mInner = new nsCSSStyleSheetInner(this, aCORSMode);
 
   SetIsDOMBinding();
 }
 
-CSSStyleSheet::CSSStyleSheet(const CSSStyleSheet& aCopy,
-                             CSSStyleSheet* aParentToUse,
-                             css::ImportRule* aOwnerRuleToUse,
-                             nsIDocument* aDocumentToUse,
-                             nsINode* aOwningNodeToUse)
+nsCSSStyleSheet::nsCSSStyleSheet(const nsCSSStyleSheet& aCopy,
+                                 nsCSSStyleSheet* aParentToUse,
+                                 css::ImportRule* aOwnerRuleToUse,
+                                 nsIDocument* aDocumentToUse,
+                                 nsINode* aOwningNodeToUse)
   : mTitle(aCopy.mTitle),
     mParent(aParentToUse),
     mOwnerRule(aOwnerRuleToUse),
     mDocument(aDocumentToUse),
     mOwningNode(aOwningNodeToUse),
     mDisabled(aCopy.mDisabled),
     mDirty(aCopy.mDirty),
     mScopeElement(nullptr),
@@ -1018,19 +1017,19 @@ CSSStyleSheet::CSSStyleSheet(const CSSSt
     // XXX This is wrong; we should be keeping @import rules and
     // sheets in sync!
     mMedia = aCopy.mMedia->Clone();
   }
 
   SetIsDOMBinding();
 }
 
-CSSStyleSheet::~CSSStyleSheet()
+nsCSSStyleSheet::~nsCSSStyleSheet()
 {
-  for (CSSStyleSheet* child = mInner->mFirstChild;
+  for (nsCSSStyleSheet* child = mInner->mFirstChild;
        child;
        child = child->mNext) {
     // XXXbz this is a little bogus; see the XXX comment where we
     // declare mFirstChild.
     if (child->mParent == this) {
       child->mParent = nullptr;
       child->mDocument = nullptr;
     }
@@ -1043,255 +1042,255 @@ CSSStyleSheet::~CSSStyleSheet()
   // away.
   if (mRuleProcessors) {
     NS_ASSERTION(mRuleProcessors->Length() == 0, "destructing sheet with rule processor reference");
     delete mRuleProcessors; // weak refs, should be empty here anyway
   }
 }
 
 void
-CSSStyleSheet::DropRuleCollection()
+nsCSSStyleSheet::DropRuleCollection()
 {
   if (mRuleCollection) {
     mRuleCollection->DropReference();
     mRuleCollection = nullptr;
   }
 }
 
 void
-CSSStyleSheet::DropMedia()
+nsCSSStyleSheet::DropMedia()
 {
   if (mMedia) {
     mMedia->SetStyleSheet(nullptr);
     mMedia = nullptr;
   }
 }
 
 void
-CSSStyleSheet::UnlinkInner()
+nsCSSStyleSheet::UnlinkInner()
 {
   // We can only have a cycle through our inner if we have a unique inner,
   // because otherwise there are no JS wrappers for anything in the inner.
   if (mInner->mSheets.Length() != 1) {
     return;
   }
 
   mInner->mOrderedRules.EnumerateForwards(SetStyleSheetReference, nullptr);
   mInner->mOrderedRules.Clear();
 
   // Have to be a bit careful with child sheets, because we want to
   // drop their mNext pointers and null out their mParent and
   // mDocument, but don't want to work with deleted objects.  And we
   // don't want to do any addrefing in the process, just to make sure
   // we don't confuse the cycle collector (though on the face of it,
   // addref/release pairs during unlink should probably be ok).
-  nsRefPtr<CSSStyleSheet> child;
+  nsRefPtr<nsCSSStyleSheet> child;
   child.swap(mInner->mFirstChild);
   while (child) {
     MOZ_ASSERT(child->mParent == this, "We have a unique inner!");
     child->mParent = nullptr;
     child->mDocument = nullptr;
-    nsRefPtr<CSSStyleSheet> next;
+    nsRefPtr<nsCSSStyleSheet> next;
     // Null out child->mNext, but don't let it die yet
     next.swap(child->mNext);
     // Switch to looking at the old value of child->mNext next iteration
     child.swap(next);
     // "next" is now our previous value of child; it'll get released
     // as we loop around.
   }
 }
 
 void
-CSSStyleSheet::TraverseInner(nsCycleCollectionTraversalCallback &cb)
+nsCSSStyleSheet::TraverseInner(nsCycleCollectionTraversalCallback &cb)
 {
   // We can only have a cycle through our inner if we have a unique inner,
   // because otherwise there are no JS wrappers for anything in the inner.
   if (mInner->mSheets.Length() != 1) {
     return;
   }
 
-  nsRefPtr<CSSStyleSheet>* childSheetSlot = &mInner->mFirstChild;
+  nsRefPtr<nsCSSStyleSheet>* childSheetSlot = &mInner->mFirstChild;
   while (*childSheetSlot) {
     NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "child sheet");
     cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIStyleSheet*, childSheetSlot->get()));
     childSheetSlot = &(*childSheetSlot)->mNext;
   }
 
   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)
+// QueryInterface implementation for nsCSSStyleSheet
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsCSSStyleSheet)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsIStyleSheet)
   NS_INTERFACE_MAP_ENTRY(nsIDOMStyleSheet)
   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSStyleSheet)
   NS_INTERFACE_MAP_ENTRY(nsICSSLoaderObserver)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleSheet)
-  if (aIID.Equals(NS_GET_IID(CSSStyleSheet)))
+  if (aIID.Equals(NS_GET_IID(nsCSSStyleSheet)))
     foundInterface = reinterpret_cast<nsISupports*>(this);
   else
 NS_INTERFACE_MAP_END
 
 
-NS_IMPL_CYCLE_COLLECTING_ADDREF(CSSStyleSheet)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(CSSStyleSheet)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(nsCSSStyleSheet)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(nsCSSStyleSheet)
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(CSSStyleSheet)
+NS_IMPL_CYCLE_COLLECTION_CLASS(nsCSSStyleSheet)
 
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(CSSStyleSheet)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsCSSStyleSheet)
   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;
   tmp->ClearRuleCascades();
   NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(CSSStyleSheet)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsCSSStyleSheet)
   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)
+NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(nsCSSStyleSheet)
 
 nsresult
-CSSStyleSheet::AddRuleProcessor(nsCSSRuleProcessor* aProcessor)
+nsCSSStyleSheet::AddRuleProcessor(nsCSSRuleProcessor* aProcessor)
 {
   if (! mRuleProcessors) {
     mRuleProcessors = new nsAutoTArray<nsCSSRuleProcessor*, 8>();
     if (!mRuleProcessors)
       return NS_ERROR_OUT_OF_MEMORY;
   }
   NS_ASSERTION(mRuleProcessors->NoIndex == mRuleProcessors->IndexOf(aProcessor),
                "processor already registered");
   mRuleProcessors->AppendElement(aProcessor); // weak ref
   return NS_OK;
 }
 
 nsresult
-CSSStyleSheet::DropRuleProcessor(nsCSSRuleProcessor* aProcessor)
+nsCSSStyleSheet::DropRuleProcessor(nsCSSRuleProcessor* aProcessor)
 {
   if (!mRuleProcessors)
     return NS_ERROR_FAILURE;
   return mRuleProcessors->RemoveElement(aProcessor)
            ? NS_OK
            : NS_ERROR_FAILURE;
 }
 
 
 void
-CSSStyleSheet::SetURIs(nsIURI* aSheetURI, nsIURI* aOriginalSheetURI,
-                       nsIURI* aBaseURI)
+nsCSSStyleSheet::SetURIs(nsIURI* aSheetURI, nsIURI* aOriginalSheetURI,
+                         nsIURI* aBaseURI)
 {
   NS_PRECONDITION(aSheetURI && aBaseURI, "null ptr");
 
   NS_ASSERTION(mInner->mOrderedRules.Count() == 0 && !mInner->mComplete,
                "Can't call SetURL on sheets that are complete or have rules");
 
   mInner->mSheetURI = aSheetURI;
   mInner->mOriginalSheetURI = aOriginalSheetURI;
   mInner->mBaseURI = aBaseURI;
 }
 
 void
-CSSStyleSheet::SetPrincipal(nsIPrincipal* aPrincipal)
+nsCSSStyleSheet::SetPrincipal(nsIPrincipal* aPrincipal)
 {
   NS_PRECONDITION(!mInner->mPrincipalSet,
                   "Should have an inner whose principal has not yet been set");
   if (aPrincipal) {
     mInner->mPrincipal = aPrincipal;
 #ifdef DEBUG
     mInner->mPrincipalSet = true;
 #endif
   }
 }
 
 /* virtual */ nsIURI*
-CSSStyleSheet::GetSheetURI() const
+nsCSSStyleSheet::GetSheetURI() const
 {
   return mInner->mSheetURI;
 }
 
 /* virtual */ nsIURI*
-CSSStyleSheet::GetBaseURI() const
+nsCSSStyleSheet::GetBaseURI() const
 {
   return mInner->mBaseURI;
 }
 
 /* virtual */ void
-CSSStyleSheet::GetType(nsString& aType) const
+nsCSSStyleSheet::GetType(nsString& aType) const
 {
   aType.AssignLiteral("text/css");
 }
 
 bool
-CSSStyleSheet::UseForPresentation(nsPresContext* aPresContext,
-                                  nsMediaQueryResultCacheKey& aKey) const
+nsCSSStyleSheet::UseForPresentation(nsPresContext* aPresContext,
+                                    nsMediaQueryResultCacheKey& aKey) const
 {
   if (mMedia) {
     return mMedia->Matches(aPresContext, &aKey);
   }
   return true;
 }
 
 
 void
-CSSStyleSheet::SetMedia(nsMediaList* aMedia)
+nsCSSStyleSheet::SetMedia(nsMediaList* aMedia)
 {
   mMedia = aMedia;
 }
 
 /* virtual */ bool
-CSSStyleSheet::HasRules() const
+nsCSSStyleSheet::HasRules() const
 {
   return StyleRuleCount() != 0;
 }
 
 /* virtual */ bool
-CSSStyleSheet::IsApplicable() const
+nsCSSStyleSheet::IsApplicable() const
 {
   return !mDisabled && mInner->mComplete;
 }
 
 /* virtual */ void
-CSSStyleSheet::SetEnabled(bool aEnabled)
+nsCSSStyleSheet::SetEnabled(bool aEnabled)
 {
   // Internal method, so callers must handle BeginUpdate/EndUpdate
   bool oldDisabled = mDisabled;
   mDisabled = !aEnabled;
 
   if (mInner->mComplete && oldDisabled != mDisabled) {
     ClearRuleCascades();
 
     if (mDocument) {
       mDocument->SetStyleSheetApplicableState(this, !mDisabled);
     }
   }
 }
 
 /* virtual */ bool
-CSSStyleSheet::IsComplete() const
+nsCSSStyleSheet::IsComplete() const
 {
   return mInner->mComplete;
 }
 
 /* virtual */ void
-CSSStyleSheet::SetComplete()
+nsCSSStyleSheet::SetComplete()
 {
   NS_ASSERTION(!mDirty, "Can't set a dirty sheet complete!");
   mInner->mComplete = true;
   if (mDocument && !mDisabled) {
     // Let the document know
     mDocument->BeginUpdate(UPDATE_STYLE);
     mDocument->SetStyleSheetApplicableState(this, true);
     mDocument->EndUpdate(UPDATE_STYLE);
@@ -1301,129 +1300,129 @@ CSSStyleSheet::SetComplete()
       mOwningNode->HasFlag(NODE_IS_IN_SHADOW_TREE) &&
       mOwningNode->IsContent()) {
     ShadowRoot* shadowRoot = mOwningNode->AsContent()->GetContainingShadow();
     shadowRoot->StyleSheetChanged();
   }
 }
 
 /* virtual */ nsIStyleSheet*
-CSSStyleSheet::GetParentSheet() const
+nsCSSStyleSheet::GetParentSheet() const
 {
   return mParent;
 }
 
 /* virtual */ nsIDocument*
-CSSStyleSheet::GetOwningDocument() const
+nsCSSStyleSheet::GetOwningDocument() const
 {
   return mDocument;
 }
 
 /* virtual */ void
-CSSStyleSheet::SetOwningDocument(nsIDocument* aDocument)
+nsCSSStyleSheet::SetOwningDocument(nsIDocument* aDocument)
 { // not ref counted
   mDocument = aDocument;
   // Now set the same document on all our child sheets....
   // XXXbz this is a little bogus; see the XXX comment where we
   // declare mFirstChild.
-  for (CSSStyleSheet* child = mInner->mFirstChild;
+  for (nsCSSStyleSheet* child = mInner->mFirstChild;
        child; child = child->mNext) {
     if (child->mParent == this) {
       child->SetOwningDocument(aDocument);
     }
   }
 }
 
 uint64_t
-CSSStyleSheet::FindOwningWindowInnerID() const
+nsCSSStyleSheet::FindOwningWindowInnerID() const
 {
   uint64_t windowID = 0;
   if (mDocument) {
     windowID = mDocument->InnerWindowID();
   }
 
   if (windowID == 0 && mOwningNode) {
     windowID = mOwningNode->OwnerDoc()->InnerWindowID();
   }
 
   if (windowID == 0 && mOwnerRule) {
     nsCOMPtr<nsIStyleSheet> sheet = static_cast<css::Rule*>(mOwnerRule)->GetStyleSheet();
     if (sheet) {
-      nsRefPtr<CSSStyleSheet> cssSheet = do_QueryObject(sheet);
+      nsRefPtr<nsCSSStyleSheet> cssSheet = do_QueryObject(sheet);
       if (cssSheet) {
         windowID = cssSheet->FindOwningWindowInnerID();
       }
     }
   }
 
   if (windowID == 0 && mParent) {
     windowID = mParent->FindOwningWindowInnerID();
   }
 
   return windowID;
 }
 
 void
-CSSStyleSheet::AppendStyleSheet(CSSStyleSheet* aSheet)
+nsCSSStyleSheet::AppendStyleSheet(nsCSSStyleSheet* aSheet)
 {
   NS_PRECONDITION(nullptr != aSheet, "null arg");
 
   WillDirty();
-  nsRefPtr<CSSStyleSheet>* tail = &mInner->mFirstChild;
+  nsRefPtr<nsCSSStyleSheet>* tail = &mInner->mFirstChild;
   while (*tail) {
     tail = &(*tail)->mNext;
   }
   *tail = aSheet;
 
   // This is not reference counted. Our parent tells us when
   // it's going away.
   aSheet->mParent = this;
   aSheet->mDocument = mDocument;
   DidDirty();
 }
 
 void
-CSSStyleSheet::InsertStyleSheetAt(CSSStyleSheet* aSheet, int32_t aIndex)
+nsCSSStyleSheet::InsertStyleSheetAt(nsCSSStyleSheet* aSheet, int32_t aIndex)
 {
   NS_PRECONDITION(nullptr != aSheet, "null arg");
 
   WillDirty();
-  nsRefPtr<CSSStyleSheet>* tail = &mInner->mFirstChild;
+  nsRefPtr<nsCSSStyleSheet>* tail = &mInner->mFirstChild;
   while (*tail && aIndex) {
     --aIndex;
     tail = &(*tail)->mNext;
   }
   aSheet->mNext = *tail;
   *tail = aSheet;
 
   // This is not reference counted. Our parent tells us when
   // it's going away.
   aSheet->mParent = this;
   aSheet->mDocument = mDocument;
   DidDirty();
 }
 
 void
-CSSStyleSheet::PrependStyleRule(css::Rule* aRule)
+nsCSSStyleSheet::PrependStyleRule(css::Rule* aRule)
 {
   NS_PRECONDITION(nullptr != aRule, "null arg");
 
   WillDirty();
   mInner->mOrderedRules.InsertObjectAt(aRule, 0);
   aRule->SetStyleSheet(this);
   DidDirty();
 
   if (css::Rule::NAMESPACE_RULE == aRule->GetType()) {
     // no api to prepend a namespace (ugh), release old ones and re-create them all
     mInner->RebuildNameSpaces();
   }
 }
 
 void
-CSSStyleSheet::AppendStyleRule(css::Rule* aRule)
+nsCSSStyleSheet::AppendStyleRule(css::Rule* aRule)
 {
   NS_PRECONDITION(nullptr != aRule, "null arg");
 
   WillDirty();
   mInner->mOrderedRules.AppendObject(aRule);
   aRule->SetStyleSheet(this);
   DidDirty();
 
@@ -1433,17 +1432,17 @@ CSSStyleSheet::AppendStyleRule(css::Rule
 #endif
       RegisterNamespaceRule(aRule);
     NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
                      "RegisterNamespaceRule returned error");
   }
 }
 
 void
-CSSStyleSheet::ReplaceStyleRule(css::Rule* aOld, css::Rule* aNew)
+nsCSSStyleSheet::ReplaceStyleRule(css::Rule* aOld, css::Rule* aNew)
 {
   NS_PRECONDITION(mInner->mOrderedRules.Count() != 0, "can't have old rule");
   NS_PRECONDITION(mInner->mComplete, "No replacing in an incomplete sheet!");
 
   WillDirty();
   int32_t index = mInner->mOrderedRules.IndexOf(aOld);
   if (MOZ_UNLIKELY(index == -1)) {
     NS_NOTREACHED("Couldn't find old rule");
@@ -1454,87 +1453,87 @@ CSSStyleSheet::ReplaceStyleRule(css::Rul
   aNew->SetStyleSheet(this);
   aOld->SetStyleSheet(nullptr);
   DidDirty();
   NS_ASSERTION(css::Rule::NAMESPACE_RULE != aNew->GetType(), "not yet implemented");
   NS_ASSERTION(css::Rule::NAMESPACE_RULE != aOld->GetType(), "not yet implemented");
 }
 
 int32_t
-CSSStyleSheet::StyleRuleCount() const
+nsCSSStyleSheet::StyleRuleCount() const
 {
   return mInner->mOrderedRules.Count();
 }
 
 css::Rule*
-CSSStyleSheet::GetStyleRuleAt(int32_t aIndex) const
+nsCSSStyleSheet::GetStyleRuleAt(int32_t aIndex) const
 {
   // Important: If this function is ever made scriptable, we must add
   // a security check here. See GetCssRules below for an example.
   return mInner->mOrderedRules.SafeObjectAt(aIndex);
 }
 
 int32_t
-CSSStyleSheet::StyleSheetCount() const
+nsCSSStyleSheet::StyleSheetCount() const
 {
   // XXX Far from an ideal way to do this, but the hope is that
   // it won't be done too often. If it is, we might want to 
   // consider storing the children in an array.
   int32_t count = 0;
 
-  const CSSStyleSheet* child = mInner->mFirstChild;
+  const nsCSSStyleSheet* child = mInner->mFirstChild;
   while (child) {
     count++;
     child = child->mNext;
   }
 
   return count;
 }
 
-CSSStyleSheet::EnsureUniqueInnerResult
-CSSStyleSheet::EnsureUniqueInner()
+nsCSSStyleSheet::EnsureUniqueInnerResult
+nsCSSStyleSheet::EnsureUniqueInner()
 {
   mDirty = true;
 
   NS_ABORT_IF_FALSE(mInner->mSheets.Length() != 0,
                     "unexpected number of outers");
   if (mInner->mSheets.Length() == 1) {
     return eUniqueInner_AlreadyUnique;
   }
-  CSSStyleSheetInner* clone = mInner->CloneFor(this);
+  nsCSSStyleSheetInner* clone = mInner->CloneFor(this);
   MOZ_ASSERT(clone);
   mInner->RemoveSheet(this);
   mInner = clone;
 
   // otherwise the rule processor has pointers to the old rules
   ClearRuleCascades();
 
   return eUniqueInner_ClonedInner;
 }
 
 void
-CSSStyleSheet::AppendAllChildSheets(nsTArray<CSSStyleSheet*>& aArray)
+nsCSSStyleSheet::AppendAllChildSheets(nsTArray<nsCSSStyleSheet*>& aArray)
 {
-  for (CSSStyleSheet* child = mInner->mFirstChild; child;
+  for (nsCSSStyleSheet* child = mInner->mFirstChild; child;
        child = child->mNext) {
     aArray.AppendElement(child);
   }
 }
 
-already_AddRefed<CSSStyleSheet>
-CSSStyleSheet::Clone(CSSStyleSheet* aCloneParent,
-                     css::ImportRule* aCloneOwnerRule,
-                     nsIDocument* aCloneDocument,
-                     nsINode* aCloneOwningNode) const
+already_AddRefed<nsCSSStyleSheet>
+nsCSSStyleSheet::Clone(nsCSSStyleSheet* aCloneParent,
+                       css::ImportRule* aCloneOwnerRule,
+                       nsIDocument* aCloneDocument,
+                       nsINode* aCloneOwningNode) const
 {
-  nsRefPtr<CSSStyleSheet> clone = new CSSStyleSheet(*this,
-                                                    aCloneParent,
-                                                    aCloneOwnerRule,
-                                                    aCloneDocument,
-                                                    aCloneOwningNode);
+  nsRefPtr<nsCSSStyleSheet> clone = new nsCSSStyleSheet(*this,
+                                                        aCloneParent,
+                                                        aCloneOwnerRule,
+                                                        aCloneDocument,
+                                                        aCloneOwningNode);
   return clone.forget();
 }
 
 #ifdef DEBUG
 static void
 ListRules(const nsCOMArray<css::Rule>& aRules, FILE* aOut, int32_t aIndent)
 {
   for (int32_t index = aRules.Count() - 1; index >= 0; --index) {
@@ -1548,17 +1547,17 @@ struct ListEnumData {
       mIndent(aIndent)
   {
   }
   FILE*   mOut;
   int32_t mIndent;
 };
 
 /* virtual */ void
-CSSStyleSheet::List(FILE* out, int32_t aIndent) const
+nsCSSStyleSheet::List(FILE* out, int32_t aIndent) const
 {
 
   int32_t index;
 
   // Indent
   for (index = aIndent; --index >= 0; ) fputs("  ", out);
 
   fputs("CSS Style Sheet: ", out);
@@ -1571,61 +1570,61 @@ CSSStyleSheet::List(FILE* out, int32_t a
   if (mMedia) {
     fputs(" media: ", out);
     nsAutoString  buffer;
     mMedia->GetText(buffer);
     fputs(NS_ConvertUTF16toUTF8(buffer).get(), out);
   }
   fputs("\n", out);
 
-  for (const CSSStyleSheet* child = mInner->mFirstChild;
+  for (const nsCSSStyleSheet*  child = mInner->mFirstChild;
        child;
        child = child->mNext) {
     child->List(out, aIndent + 1);
   }
 
   fputs("Rules in source order:\n", out);
   ListRules(mInner->mOrderedRules, out, aIndent);
 }
 #endif
 
 void 
-CSSStyleSheet::ClearRuleCascades()
+nsCSSStyleSheet::ClearRuleCascades()
 {
   if (mRuleProcessors) {
     nsCSSRuleProcessor **iter = mRuleProcessors->Elements(),
                        **end = iter + mRuleProcessors->Length();
     for(; iter != end; ++iter) {
       (*iter)->ClearRuleCascades();
     }
   }
   if (mParent) {
-    CSSStyleSheet* parent = (CSSStyleSheet*)mParent;
+    nsCSSStyleSheet* parent = (nsCSSStyleSheet*)mParent;
     parent->ClearRuleCascades();
   }
 }
 
 void
-CSSStyleSheet::WillDirty()
+nsCSSStyleSheet::WillDirty()
 {
   if (mInner->mComplete) {
     EnsureUniqueInner();
   }
 }
 
 void
-CSSStyleSheet::DidDirty()
+nsCSSStyleSheet::DidDirty()
 {
   NS_ABORT_IF_FALSE(!mInner->mComplete || mDirty,
                     "caller must have called WillDirty()");
   ClearRuleCascades();
 }
 
 nsresult
-CSSStyleSheet::SubjectSubsumesInnerPrincipal()
+nsCSSStyleSheet::SubjectSubsumesInnerPrincipal()
 {
   nsCOMPtr<nsIPrincipal> subjectPrincipal = nsContentUtils::SubjectPrincipal();
   if (subjectPrincipal->Subsumes(mInner->mPrincipal)) {
     return NS_OK;
   }
 
   // Allow access only if CORS mode is not NONE
   if (GetCORSMode() == CORS_NONE) {
@@ -1646,138 +1645,138 @@ CSSStyleSheet::SubjectSubsumesInnerPrinc
   mInner->mPrincipal = subjectPrincipal;
 
   DidDirty();
 
   return NS_OK;
 }
 
 nsresult
-CSSStyleSheet::RegisterNamespaceRule(css::Rule* aRule)
+nsCSSStyleSheet::RegisterNamespaceRule(css::Rule* aRule)
 {
   if (!mInner->mNameSpaceMap) {
     nsresult rv = mInner->CreateNamespaceMap();
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   AddNamespaceRuleToMap(aRule, mInner->mNameSpaceMap);
   return NS_OK;
 }
 
   // nsIDOMStyleSheet interface
 NS_IMETHODIMP    
-CSSStyleSheet::GetType(nsAString& aType)
+nsCSSStyleSheet::GetType(nsAString& aType)
 {
   aType.AssignLiteral("text/css");
   return NS_OK;
 }
 
 NS_IMETHODIMP    
-CSSStyleSheet::GetDisabled(bool* aDisabled)
+nsCSSStyleSheet::GetDisabled(bool* aDisabled)
 {
   *aDisabled = Disabled();
   return NS_OK;
 }
 
 NS_IMETHODIMP    
-CSSStyleSheet::SetDisabled(bool aDisabled)
+nsCSSStyleSheet::SetDisabled(bool aDisabled)
 {
   // DOM method, so handle BeginUpdate/EndUpdate
   MOZ_AUTO_DOC_UPDATE(mDocument, UPDATE_STYLE, true);
-  CSSStyleSheet::SetEnabled(!aDisabled);
+  nsCSSStyleSheet::SetEnabled(!aDisabled);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-CSSStyleSheet::GetOwnerNode(nsIDOMNode** aOwnerNode)
+nsCSSStyleSheet::GetOwnerNode(nsIDOMNode** aOwnerNode)
 {
   nsCOMPtr<nsIDOMNode> ownerNode = do_QueryInterface(GetOwnerNode());
   ownerNode.forget(aOwnerNode);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-CSSStyleSheet::GetParentStyleSheet(nsIDOMStyleSheet** aParentStyleSheet)
+nsCSSStyleSheet::GetParentStyleSheet(nsIDOMStyleSheet** aParentStyleSheet)
 {
   NS_ENSURE_ARG_POINTER(aParentStyleSheet);
 
   NS_IF_ADDREF(*aParentStyleSheet = mParent);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-CSSStyleSheet::GetHref(nsAString& aHref)
+nsCSSStyleSheet::GetHref(nsAString& aHref)
 {
   if (mInner->mOriginalSheetURI) {
     nsAutoCString str;
     mInner->mOriginalSheetURI->GetSpec(str);
     CopyUTF8toUTF16(str, aHref);
   } else {
     SetDOMStringToNull(aHref);
   }
 
   return NS_OK;
 }
 
 /* virtual */ void
-CSSStyleSheet::GetTitle(nsString& aTitle) const
+nsCSSStyleSheet::GetTitle(nsString& aTitle) const
 {
   aTitle = mTitle;
 }
 
 NS_IMETHODIMP
-CSSStyleSheet::GetTitle(nsAString& aTitle)
+nsCSSStyleSheet::GetTitle(nsAString& aTitle)
 {
   aTitle.Assign(mTitle);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-CSSStyleSheet::GetMedia(nsIDOMMediaList** aMedia)
+nsCSSStyleSheet::GetMedia(nsIDOMMediaList** aMedia)
 {
   NS_ADDREF(*aMedia = Media());
   return NS_OK;
 }
 
 nsMediaList*
-CSSStyleSheet::Media()
+nsCSSStyleSheet::Media()
 {
   if (!mMedia) {
     mMedia = new nsMediaList();
     mMedia->SetStyleSheet(this);
   }
 
   return mMedia;
 }
 
 NS_IMETHODIMP    
-CSSStyleSheet::GetOwnerRule(nsIDOMCSSRule** aOwnerRule)
+nsCSSStyleSheet::GetOwnerRule(nsIDOMCSSRule** aOwnerRule)
 {
   NS_IF_ADDREF(*aOwnerRule = GetOwnerRule());
   return NS_OK;
 }
 
 nsIDOMCSSRule*
-CSSStyleSheet::GetDOMOwnerRule() const
+nsCSSStyleSheet::GetDOMOwnerRule() const
 {
   return mOwnerRule ? mOwnerRule->GetDOMRule() : nullptr;
 }
 
 NS_IMETHODIMP    
-CSSStyleSheet::GetCssRules(nsIDOMCSSRuleList** aCssRules)
+nsCSSStyleSheet::GetCssRules(nsIDOMCSSRuleList** aCssRules)
 {
   ErrorResult rv;
   nsCOMPtr<nsIDOMCSSRuleList> rules = GetCssRules(rv);
   rules.forget(aCssRules);
   return rv.ErrorCode();
 }
 
 CSSRuleList*
-CSSStyleSheet::GetCssRules(ErrorResult& aRv)
+nsCSSStyleSheet::GetCssRules(ErrorResult& aRv)
 {
   // No doing this on incomplete sheets!
   if (!mInner->mComplete) {
     aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
     return nullptr;
   }
   
   //-- Security check: Only scripts whose principal subsumes that of the
@@ -1792,43 +1791,43 @@ CSSStyleSheet::GetCssRules(ErrorResult& 
   if (!mRuleCollection) {
     mRuleCollection = new CSSRuleListImpl(this);
   }
 
   return mRuleCollection;
 }
 
 NS_IMETHODIMP    
-CSSStyleSheet::InsertRule(const nsAString& aRule,
-                          uint32_t aIndex,
-                          uint32_t* aReturn)
+nsCSSStyleSheet::InsertRule(const nsAString& aRule, 
+                            uint32_t aIndex, 
+                            uint32_t* aReturn)
 {
   //-- Security check: Only scripts whose principal subsumes that of the
   //   style sheet can modify rule collections.
   nsresult rv = SubjectSubsumesInnerPrincipal();
   NS_ENSURE_SUCCESS(rv, rv);
 
   return InsertRuleInternal(aRule, aIndex, aReturn);
 }
 
 static bool
 RuleHasPendingChildSheet(css::Rule *cssRule)
 {
   nsCOMPtr<nsIDOMCSSImportRule> importRule(do_QueryInterface(cssRule));
   NS_ASSERTION(importRule, "Rule which has type IMPORT_RULE and does not implement nsIDOMCSSImportRule!");
   nsCOMPtr<nsIDOMCSSStyleSheet> childSheet;
   importRule->GetStyleSheet(getter_AddRefs(childSheet));
-  nsRefPtr<CSSStyleSheet> cssSheet = do_QueryObject(childSheet);
+  nsRefPtr<nsCSSStyleSheet> cssSheet = do_QueryObject(childSheet);
   return cssSheet != nullptr && !cssSheet->IsComplete();
 }
 
 nsresult
-CSSStyleSheet::InsertRuleInternal(const nsAString& aRule,
-                                  uint32_t aIndex,
-                                  uint32_t* aReturn)
+nsCSSStyleSheet::InsertRuleInternal(const nsAString& aRule, 
+                                    uint32_t aIndex, 
+                                    uint32_t* aReturn)
 {
   // No doing this if the sheet is not complete!
   if (!mInner->mComplete) {
     return NS_ERROR_DOM_INVALID_ACCESS_ERR;
   }
 
   WillDirty();
   
@@ -1926,17 +1925,17 @@ CSSStyleSheet::InsertRuleInternal(const 
     mDocument->StyleRuleAdded(this, rule);
   }
 
   *aReturn = aIndex;
   return NS_OK;
 }
 
 NS_IMETHODIMP    
-CSSStyleSheet::DeleteRule(uint32_t aIndex)
+nsCSSStyleSheet::DeleteRule(uint32_t aIndex)
 {
   // No doing this if the sheet is not complete!
   if (!mInner->mComplete) {
     return NS_ERROR_DOM_INVALID_ACCESS_ERR;
   }
 
   //-- Security check: Only scripts whose principal subsumes that of the
   //   style sheet can modify rule collections.
@@ -1970,17 +1969,17 @@ CSSStyleSheet::DeleteRule(uint32_t aInde
       mDocument->StyleRuleRemoved(this, rule);
     }
   }
 
   return NS_OK;
 }
 
 nsresult
-CSSStyleSheet::DeleteRuleFromGroup(css::GroupRule* aGroup, uint32_t aIndex)
+nsCSSStyleSheet::DeleteRuleFromGroup(css::GroupRule* aGroup, uint32_t aIndex)
 {
   NS_ENSURE_ARG_POINTER(aGroup);
   NS_ASSERTION(mInner->mComplete, "No deleting from an incomplete sheet!");
   nsRefPtr<css::Rule> rule = aGroup->GetStyleRuleAt(aIndex);
   NS_ENSURE_TRUE(rule, NS_ERROR_ILLEGAL_VALUE);
 
   // check that the rule actually belongs to this sheet!
   if (this != rule->GetStyleSheet()) {
@@ -2001,20 +2000,20 @@ CSSStyleSheet::DeleteRuleFromGroup(css::
   if (mDocument) {
     mDocument->StyleRuleRemoved(this, rule);
   }
 
   return NS_OK;
 }
 
 nsresult
-CSSStyleSheet::InsertRuleIntoGroup(const nsAString & aRule,
-                                   css::GroupRule* aGroup,
-                                   uint32_t aIndex,
-                                   uint32_t* _retval)
+nsCSSStyleSheet::InsertRuleIntoGroup(const nsAString & aRule,
+                                     css::GroupRule* aGroup,
+                                     uint32_t aIndex,
+                                     uint32_t* _retval)
 {
   NS_ASSERTION(mInner->mComplete, "No inserting into an incomplete sheet!");
   // check that the group actually belongs to this sheet!
   if (this != aGroup->GetStyleSheet()) {
     return NS_ERROR_INVALID_ARG;
   }
 
   // Hold strong ref to the CSSLoader in case the document update
@@ -2067,34 +2066,34 @@ CSSStyleSheet::InsertRuleIntoGroup(const
     mDocument->StyleRuleAdded(this, rule);
   }
 
   *_retval = aIndex;
   return NS_OK;
 }
 
 nsresult
-CSSStyleSheet::ReplaceRuleInGroup(css::GroupRule* aGroup,
-                                  css::Rule* aOld, css::Rule* aNew)
+nsCSSStyleSheet::ReplaceRuleInGroup(css::GroupRule* aGroup,
+                                    css::Rule* aOld, css::Rule* aNew)
 {
   NS_PRECONDITION(mInner->mComplete, "No replacing in an incomplete sheet!");
   NS_ASSERTION(this == aGroup->GetStyleSheet(), "group doesn't belong to this sheet");
 
   WillDirty();
 
   nsresult result = aGroup->ReplaceStyleRule(aOld, aNew);
   DidDirty();
   return result;
 }
 
 // nsICSSLoaderObserver implementation
 NS_IMETHODIMP
-CSSStyleSheet::StyleSheetLoaded(CSSStyleSheet* aSheet,
-                                bool aWasAlternate,
-                                nsresult aStatus)
+nsCSSStyleSheet::StyleSheetLoaded(nsCSSStyleSheet* aSheet,
+                                  bool aWasAlternate,
+                                  nsresult aStatus)
 {
   if (aSheet->GetParentSheet() == nullptr) {
     return NS_OK; // ignore if sheet has been detached already (see parseSheet)
   }
   NS_ASSERTION(this == aSheet->GetParentSheet(),
                "We are being notified of a sheet load for a sheet that is not our child!");
 
   if (mDocument && NS_SUCCEEDED(aStatus)) {
@@ -2104,17 +2103,17 @@ CSSStyleSheet::StyleSheetLoaded(CSSStyle
     // they do)!
     mDocument->StyleRuleAdded(this, aSheet->GetOwnerRule());
   }
 
   return NS_OK;
 }
 
 nsresult
-CSSStyleSheet::ParseSheet(const nsAString& aInput)
+nsCSSStyleSheet::ParseSheet(const nsAString& aInput)
 {
   // Not doing this if the sheet is not complete!
   if (!mInner->mComplete) {
     return NS_ERROR_DOM_INVALID_ACCESS_ERR;
   }
 
   // Hold strong ref to the CSSLoader in case the document update
   // kills the document
@@ -2137,17 +2136,17 @@ CSSStyleSheet::ParseSheet(const nsAStrin
     mInner->mOrderedRules.RemoveObjectAt(ruleCount - 1);
     rule->SetStyleSheet(nullptr);
     if (mDocument) {
       mDocument->StyleRuleRemoved(this, rule);
     }
   }
 
   // nuke child sheets list and current namespace map
-  for (CSSStyleSheet* child = mInner->mFirstChild; child; child = child->mNext) {
+  for (nsCSSStyleSheet* child = mInner->mFirstChild; child; child = child->mNext) {
     NS_ASSERTION(child->mParent == this, "Child sheet is not parented to this!");
     child->mParent = nullptr;
     child->mDocument = nullptr;
   }
   mInner->mFirstChild = nullptr;
   mInner->mNameSpaceMap = nullptr;
 
   // allow unsafe rules if the style sheet's principal is the system principal
@@ -2169,21 +2168,19 @@ CSSStyleSheet::ParseSheet(const nsAStrin
       }
       mDocument->StyleRuleAdded(this, rule);
     }
   }
   return NS_OK;
 }
 
 /* virtual */ nsIURI*
-CSSStyleSheet::GetOriginalURI() const
+nsCSSStyleSheet::GetOriginalURI() const
 {
   return mInner->mOriginalSheetURI;
 }
 
 /* virtual */
 JSObject*
-CSSStyleSheet::WrapObject(JSContext* aCx)
+nsCSSStyleSheet::WrapObject(JSContext* aCx)
 {
   return CSSStyleSheetBinding::Wrap(aCx, this);
 }
-
-} // namespace mozilla
rename from layout/style/CSSStyleSheet.h
rename to layout/style/nsCSSStyleSheet.h
--- a/layout/style/CSSStyleSheet.h
+++ b/layout/style/nsCSSStyleSheet.h
@@ -1,18 +1,18 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 // vim:cindent:tabstop=2:expandtab:shiftwidth=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/. */
 
 /* representation of a CSS style sheet */
 
-#ifndef mozilla_CSSStyleSheet_h
-#define mozilla_CSSStyleSheet_h
+#ifndef nsCSSStyleSheet_h_
+#define nsCSSStyleSheet_h_
 
 #include "mozilla/Attributes.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/dom/Element.h"
 
 #include "nscore.h"
 #include "nsCOMPtr.h"
 #include "nsAutoPtr.h"
@@ -21,109 +21,107 @@
 #include "nsICSSLoaderObserver.h"
 #include "nsCOMArray.h"
 #include "nsTArrayForwardDeclare.h"
 #include "nsString.h"
 #include "mozilla/CORSMode.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
 
-class CSSRuleListImpl;
+class nsXMLNameSpaceMap;
 class nsCSSRuleProcessor;
-class nsICSSRuleList;
 class nsIPrincipal;
 class nsIURI;
 class nsMediaList;
 class nsMediaQueryResultCacheKey;
+class nsCSSStyleSheet;
 class nsPresContext;
-class nsXMLNameSpaceMap;
 
 namespace mozilla {
-class ChildSheetListBuilder;
-class CSSStyleSheet;
-
 namespace css {
 class Rule;
 class GroupRule;
 class ImportRule;
 }
 namespace dom {
 class CSSRuleList;
 }
+}
 
 // -------------------------------
 // CSS Style Sheet Inner Data Container
 //
 
-class CSSStyleSheetInner
-{
+class nsCSSStyleSheetInner {
 public:
-  friend class mozilla::CSSStyleSheet;
-  friend class ::nsCSSRuleProcessor;
+  friend class nsCSSStyleSheet;
+  friend class nsCSSRuleProcessor;
 private:
-  CSSStyleSheetInner(CSSStyleSheet* aPrimarySheet,
-                     CORSMode aCORSMode);
-  CSSStyleSheetInner(CSSStyleSheetInner& aCopy,
-                     CSSStyleSheet* aPrimarySheet);
-  ~CSSStyleSheetInner();
+  nsCSSStyleSheetInner(nsCSSStyleSheet* aPrimarySheet,
+                       mozilla::CORSMode aCORSMode);
+  nsCSSStyleSheetInner(nsCSSStyleSheetInner& aCopy,
+                       nsCSSStyleSheet* aPrimarySheet);
+  ~nsCSSStyleSheetInner();
 
-  CSSStyleSheetInner* CloneFor(CSSStyleSheet* aPrimarySheet);
-  void AddSheet(CSSStyleSheet* aSheet);
-  void RemoveSheet(CSSStyleSheet* aSheet);
+  nsCSSStyleSheetInner* CloneFor(nsCSSStyleSheet* aPrimarySheet);
+  void AddSheet(nsCSSStyleSheet* aSheet);
+  void RemoveSheet(nsCSSStyleSheet* aSheet);
 
   void RebuildNameSpaces();
 
   // Create a new namespace map
   nsresult CreateNamespaceMap();
 
-  size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
+  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
 
-  nsAutoTArray<CSSStyleSheet*, 8> mSheets;
+  nsAutoTArray<nsCSSStyleSheet*, 8> mSheets;
   nsCOMPtr<nsIURI>       mSheetURI; // for error reports, etc.
   nsCOMPtr<nsIURI>       mOriginalSheetURI;  // for GetHref.  Can be null.
   nsCOMPtr<nsIURI>       mBaseURI; // for resolving relative URIs
   nsCOMPtr<nsIPrincipal> mPrincipal;
-  nsCOMArray<css::Rule>  mOrderedRules;
+  nsCOMArray<mozilla::css::Rule> mOrderedRules;
   nsAutoPtr<nsXMLNameSpaceMap> mNameSpaceMap;
   // Linked list of child sheets.  This is al fundamentally broken, because
   // each of the child sheets has a unique parent... We can only hope (and
   // currently this is the case) that any time page JS can get ts hands on a
   // child sheet that means we've already ensured unique inners throughout its
   // parent chain and things are good.
-  nsRefPtr<CSSStyleSheet> mFirstChild;
-  CORSMode               mCORSMode;
+  nsRefPtr<nsCSSStyleSheet> mFirstChild;
+  mozilla::CORSMode      mCORSMode;
   bool                   mComplete;
 
 #ifdef DEBUG
   bool                   mPrincipalSet;
 #endif
 };
 
 
 // -------------------------------
 // CSS Style Sheet
 //
 
-// CID for the CSSStyleSheet class
+class CSSRuleListImpl;
+
+// CID for the nsCSSStyleSheet class
 // ca926f30-2a7e-477e-8467-803fb32af20a
 #define NS_CSS_STYLE_SHEET_IMPL_CID     \
 { 0xca926f30, 0x2a7e, 0x477e, \
  { 0x84, 0x67, 0x80, 0x3f, 0xb3, 0x2a, 0xf2, 0x0a } }
 
 
-class CSSStyleSheet MOZ_FINAL : public nsIStyleSheet,
-                                public nsIDOMCSSStyleSheet,
-                                public nsICSSLoaderObserver,
-                                public nsWrapperCache
+class nsCSSStyleSheet MOZ_FINAL : public nsIStyleSheet,
+                                  public nsIDOMCSSStyleSheet,
+                                  public nsICSSLoaderObserver,
+                                  public nsWrapperCache
 {
 public:
-  CSSStyleSheet(CORSMode aCORSMode);
+  nsCSSStyleSheet(mozilla::CORSMode aCORSMode);
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(CSSStyleSheet,
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsCSSStyleSheet,
                                                          nsIStyleSheet)
 
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_CSS_STYLE_SHEET_IMPL_CID)
 
   // nsIStyleSheet interface
   virtual nsIURI* GetSheetURI() const MOZ_OVERRIDE;
   virtual nsIURI* GetBaseURI() const MOZ_OVERRIDE;
   virtual void GetTitle(nsString& aTitle) const MOZ_OVERRIDE;
@@ -138,30 +136,30 @@ public:
   virtual void SetOwningDocument(nsIDocument* aDocument) MOZ_OVERRIDE;
 
   // Find the ID of the owner inner window.
   uint64_t FindOwningWindowInnerID() const;
 #ifdef DEBUG
   virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE;
 #endif
 
-  void AppendStyleSheet(CSSStyleSheet* aSheet);
-  void InsertStyleSheetAt(CSSStyleSheet* aSheet, int32_t aIndex);
+  void AppendStyleSheet(nsCSSStyleSheet* aSheet);
+  void InsertStyleSheetAt(nsCSSStyleSheet* aSheet, int32_t aIndex);
 
   // XXX do these belong here or are they generic?
-  void PrependStyleRule(css::Rule* aRule);
-  void AppendStyleRule(css::Rule* aRule);
-  void ReplaceStyleRule(css::Rule* aOld, css::Rule* aNew);
+  void PrependStyleRule(mozilla::css::Rule* aRule);
+  void AppendStyleRule(mozilla::css::Rule* aRule);
+  void ReplaceStyleRule(mozilla::css::Rule* aOld, mozilla::css::Rule* aNew);
 
   int32_t StyleRuleCount() const;
-  css::Rule* GetStyleRuleAt(int32_t aIndex) const;
+  mozilla::css::Rule* GetStyleRuleAt(int32_t aIndex) const;
 
-  nsresult DeleteRuleFromGroup(css::GroupRule* aGroup, uint32_t aIndex);
-  nsresult InsertRuleIntoGroup(const nsAString& aRule, css::GroupRule* aGroup, uint32_t aIndex, uint32_t* _retval);
-  nsresult ReplaceRuleInGroup(css::GroupRule* aGroup, css::Rule* aOld, css::Rule* aNew);
+  nsresult DeleteRuleFromGroup(mozilla::css::GroupRule* aGroup, uint32_t aIndex);
+  nsresult InsertRuleIntoGroup(const nsAString& aRule, mozilla::css::GroupRule* aGroup, uint32_t aIndex, uint32_t* _retval);
+  nsresult ReplaceRuleInGroup(mozilla::css::GroupRule* aGroup, mozilla::css::Rule* aOld, mozilla::css::Rule* aNew);
 
   int32_t StyleSheetCount() const;
 
   /**
    * SetURIs must be called on all sheets before parsing into them.
    * SetURIs may only be called while the sheet is 1) incomplete and 2)
    * has no rules in it
    */
@@ -179,25 +177,25 @@ public:
 
   // The document this style sheet is associated with.  May be null
   nsIDocument* GetDocument() const { return mDocument; }
 
   void SetTitle(const nsAString& aTitle) { mTitle = aTitle; }
   void SetMedia(nsMediaList* aMedia);
   void SetOwningNode(nsINode* aOwningNode) { mOwningNode = aOwningNode; /* Not ref counted */ }
 
-  void SetOwnerRule(css::ImportRule* aOwnerRule) { mOwnerRule = aOwnerRule; /* Not ref counted */ }
-  css::ImportRule* GetOwnerRule() const { return mOwnerRule; }
+  void SetOwnerRule(mozilla::css::ImportRule* aOwnerRule) { mOwnerRule = aOwnerRule; /* Not ref counted */ }
+  mozilla::css::ImportRule* GetOwnerRule() const { return mOwnerRule; }
 
   nsXMLNameSpaceMap* GetNameSpaceMap() const { return mInner->mNameSpaceMap; }
 
-  already_AddRefed<CSSStyleSheet> Clone(CSSStyleSheet* aCloneParent,
-                                        css::ImportRule* aCloneOwnerRule,
-                                        nsIDocument* aCloneDocument,
-                                        nsINode* aCloneOwningNode) const;
+  already_AddRefed<nsCSSStyleSheet> Clone(nsCSSStyleSheet* aCloneParent,
+                                          mozilla::css::ImportRule* aCloneOwnerRule,
+                                          nsIDocument* aCloneDocument,
+                                          nsINode* aCloneOwningNode) const;
 
   bool IsModified() const { return mDirty; }
 
   void SetModifiedByChildRule() {
     NS_ASSERTION(mDirty,
                  "sheet must be marked dirty before handing out child rules");
     DidDirty();
   }
@@ -211,159 +209,158 @@ public:
   nsresult InsertRuleInternal(const nsAString& aRule,
                               uint32_t aIndex, uint32_t* aReturn);
 
   /* Get the URI this sheet was originally loaded from, if any.  Can
      return null */
   virtual nsIURI* GetOriginalURI() const;
 
   // nsICSSLoaderObserver interface
-  NS_IMETHOD StyleSheetLoaded(CSSStyleSheet* aSheet, bool aWasAlternate,
+  NS_IMETHOD StyleSheetLoaded(nsCSSStyleSheet* aSheet, bool aWasAlternate,
                               nsresult aStatus) MOZ_OVERRIDE;
 
   enum EnsureUniqueInnerResult {
     // No work was needed to ensure a unique inner.
     eUniqueInner_AlreadyUnique,
     // A clone was done to ensure a unique inner (which means the style
     // rules in this sheet have changed).
     eUniqueInner_ClonedInner
   };
   EnsureUniqueInnerResult EnsureUniqueInner();
 
   // Append all of this sheet's child sheets to aArray.
-  void AppendAllChildSheets(nsTArray<CSSStyleSheet*>& aArray);
+  void AppendAllChildSheets(nsTArray<nsCSSStyleSheet*>& aArray);
 
   bool UseForPresentation(nsPresContext* aPresContext,
                             nsMediaQueryResultCacheKey& aKey) const;
 
   nsresult ParseSheet(const nsAString& aInput);
 
   // nsIDOMStyleSheet interface
   NS_DECL_NSIDOMSTYLESHEET
 
   // nsIDOMCSSStyleSheet interface
   NS_DECL_NSIDOMCSSSTYLESHEET
 
   // Function used as a callback to rebuild our inner's child sheet
   // list after we clone a unique inner for ourselves.
-  static bool RebuildChildList(css::Rule* aRule, void* aBuilder);
+  static bool RebuildChildList(mozilla::css::Rule* aRule, void* aBuilder);
 
-  size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
+  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
 
   // Get this style sheet's CORS mode
-  CORSMode GetCORSMode() const { return mInner->mCORSMode; }
+  mozilla::CORSMode GetCORSMode() const { return mInner->mCORSMode; }
 
-  dom::Element* GetScopeElement() const { return mScopeElement; }
-  void SetScopeElement(dom::Element* aScopeElement)
+  mozilla::dom::Element* GetScopeElement() const { return mScopeElement; }
+  void SetScopeElement(mozilla::dom::Element* aScopeElement)
   {
     mScopeElement = aScopeElement;
   }
 
   // WebIDL StyleSheet API
   // Our nsIStyleSheet::GetType is a const method, so it ends up
   // ambiguous with with the XPCOM version.  Just disambiguate.
   void GetType(nsString& aType) {
-    const_cast<const CSSStyleSheet*>(this)->GetType(aType);
+    const_cast<const nsCSSStyleSheet*>(this)->GetType(aType);
   }
   // Our XPCOM GetHref is fine for WebIDL
   nsINode* GetOwnerNode() const { return mOwningNode; }
-  CSSStyleSheet* GetParentStyleSheet() const { return mParent; }
+  nsCSSStyleSheet* GetParentStyleSheet() const { return mParent; }
   // Our nsIStyleSheet::GetTitle is a const method, so it ends up
   // ambiguous with with the XPCOM version.  Just disambiguate.
   void GetTitle(nsString& aTitle) {
-    const_cast<const CSSStyleSheet*>(this)->GetTitle(aTitle);
+    const_cast<const nsCSSStyleSheet*>(this)->GetTitle(aTitle);
   }
   nsMediaList* Media();
   bool Disabled() const { return mDisabled; }
   // The XPCOM SetDisabled is fine for WebIDL
 
   // 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;
-  dom::CSSRuleList* GetCssRules(ErrorResult& aRv);
+  mozilla::dom::CSSRuleList* GetCssRules(mozilla::ErrorResult& aRv);
   uint32_t InsertRule(const nsAString& aRule, uint32_t aIndex,
-                      ErrorResult& aRv) {
+                      mozilla::ErrorResult& aRv) {
     uint32_t retval;
     aRv = InsertRule(aRule, aIndex, &retval);
     return retval;
   }
-  void DeleteRule(uint32_t aIndex, ErrorResult& aRv) {
+  void DeleteRule(uint32_t aIndex, mozilla::ErrorResult& aRv) {
     aRv = DeleteRule(aIndex);
   }
 
   // WebIDL miscellaneous bits
-  dom::ParentObject GetParentObject() const {
+  mozilla::dom::ParentObject GetParentObject() const {
     if (mOwningNode) {
-      return dom::ParentObject(mOwningNode);
+      return mozilla::dom::ParentObject(mOwningNode);
     }
 
-    return dom::ParentObject(static_cast<nsIStyleSheet*>(mParent), mParent);
+    return mozilla::dom::ParentObject(static_cast<nsIStyleSheet*>(mParent),
+                                      mParent);
   }
   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
 
 private:
-  CSSStyleSheet(const CSSStyleSheet& aCopy,
-                CSSStyleSheet* aParentToUse,
-                css::ImportRule* aOwnerRuleToUse,
-                nsIDocument* aDocumentToUse,
-                nsINode* aOwningNodeToUse);
+  nsCSSStyleSheet(const nsCSSStyleSheet& aCopy,
+                  nsCSSStyleSheet* aParentToUse,
+                  mozilla::css::ImportRule* aOwnerRuleToUse,
+                  nsIDocument* aDocumentToUse,
+                  nsINode* aOwningNodeToUse);
 
-  CSSStyleSheet(const CSSStyleSheet& aCopy) MOZ_DELETE;
-  CSSStyleSheet& operator=(const CSSStyleSheet& aCopy) MOZ_DELETE;
+  nsCSSStyleSheet(const nsCSSStyleSheet& aCopy) MOZ_DELETE;
+  nsCSSStyleSheet& operator=(const nsCSSStyleSheet& aCopy) MOZ_DELETE;
 
 protected:
-  virtual ~CSSStyleSheet();
+  virtual ~nsCSSStyleSheet();
 
   void ClearRuleCascades();
 
   void     WillDirty();
   void     DidDirty();
 
   // Return success if the subject principal subsumes the principal of our
   // inner, error otherwise.  This will also succeed if the subject has
   // UniversalXPConnect or if access is allowed by CORS.  In the latter case,
   // it will set the principal of the inner to the subject principal.
   nsresult SubjectSubsumesInnerPrincipal();
 
   // Add the namespace mapping from this @namespace rule to our namespace map
-  nsresult RegisterNamespaceRule(css::Rule* aRule);
+  nsresult RegisterNamespaceRule(mozilla::css::Rule* aRule);
 
   // Drop our reference to mRuleCollection
   void DropRuleCollection();
 
   // Drop our reference to mMedia
   void DropMedia();
 
   // Unlink our inner, if needed, for cycle collection
   void UnlinkInner();
   // Traverse our inner, if needed, for cycle collection
   void TraverseInner(nsCycleCollectionTraversalCallback &);
 
 protected:
   nsString              mTitle;
   nsRefPtr<nsMediaList> mMedia;
-  nsRefPtr<CSSStyleSheet> mNext;
-  CSSStyleSheet*        mParent;    // weak ref
-  css::ImportRule*      mOwnerRule; // weak ref
+  nsRefPtr<nsCSSStyleSheet> mNext;
+  nsCSSStyleSheet*      mParent;    // weak ref
+  mozilla::css::ImportRule* mOwnerRule; // weak ref
 
   nsRefPtr<CSSRuleListImpl> mRuleCollection;
   nsIDocument*          mDocument; // weak ref; parents maintain this for their children
   nsINode*              mOwningNode; // weak ref
   bool                  mDisabled;
   bool                  mDirty; // has been modified 
-  nsRefPtr<dom::Element> mScopeElement;
+  nsRefPtr<mozilla::dom::Element> mScopeElement;
 
-  CSSStyleSheetInner*   mInner;
+  nsCSSStyleSheetInner* mInner;
 
   nsAutoTArray<nsCSSRuleProcessor*, 8>* mRuleProcessors;
 
-  friend class ::nsMediaList;
-  friend class ::nsCSSRuleProcessor;
-  friend struct mozilla::ChildSheetListBuilder;
+  friend class nsMediaList;
+  friend class nsCSSRuleProcessor;
+  friend struct ChildSheetListBuilder;
 };
 
-NS_DEFINE_STATIC_IID_ACCESSOR(CSSStyleSheet, NS_CSS_STYLE_SHEET_IMPL_CID)
+NS_DEFINE_STATIC_IID_ACCESSOR(nsCSSStyleSheet, NS_CSS_STYLE_SHEET_IMPL_CID)
 
-} // namespace mozilla
-
-#endif /* !defined(mozilla_CSSStyleSheet_h) */
+#endif /* !defined(nsCSSStyleSheet_h_) */
--- a/layout/style/nsCSSValue.cpp
+++ b/layout/style/nsCSSValue.cpp
@@ -3,27 +3,27 @@
 /* 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/. */
 
 /* representation of simple property values within CSS declarations */
 
 #include "nsCSSValue.h"
 
-#include "mozilla/CSSStyleSheet.h"
 #include "mozilla/Likely.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/css/ImageLoader.h"
 #include "CSSCalc.h"
 #include "gfxFontConstants.h"
 #include "imgIRequest.h"
 #include "imgRequestProxy.h"
 #include "nsIDocument.h"
 #include "nsIPrincipal.h"
 #include "nsCSSProps.h"
+#include "nsCSSStyleSheet.h"
 #include "nsNetUtil.h"
 #include "nsPresContext.h"
 #include "nsStyleUtil.h"
 #include "nsDeviceContext.h"
 
 using namespace mozilla;
 
 nsCSSValue::nsCSSValue(int32_t aValue, nsCSSUnit aUnit)
--- a/layout/style/nsCSSValue.h
+++ b/layout/style/nsCSSValue.h
@@ -21,27 +21,24 @@
 #include "nsRefPtrHashtable.h"
 #include "nsString.h"
 #include "nsStringBuffer.h"
 #include "nsTArray.h"
 #include "nsStyleConsts.h"
 #include "gfxFontFamilyList.h"
 
 class imgRequestProxy;
+class nsCSSStyleSheet;
 class nsIDocument;
 class nsIPrincipal;
 class nsIURI;
 class nsPresContext;
 template <class T>
 class nsPtrHashKey;
 
-namespace mozilla {
-class CSSStyleSheet;
-} // namespace mozilla
-
 // Deletes a linked list iteratively to avoid blowing up the stack (bug 456196).
 #define NS_CSS_DELETE_LIST_MEMBER(type_, ptr_, member_)                        \
   {                                                                            \
     type_ *cur = (ptr_)->member_;                                              \
     (ptr_)->member_ = nullptr;                                                 \
     while (cur) {                                                              \
       type_ *dlm_next = cur->member_;                                          \
       cur->member_ = nullptr;                                                  \
@@ -1454,17 +1451,17 @@ public:
   // When the value of a shorthand property has a variable reference, the
   // same mTokenStream value is used on each of the nsCSSValueTokenStream
   // objects that will be set by parsing the shorthand.
   nsString mTokenStream;
 
   nsCOMPtr<nsIURI> mBaseURI;
   nsCOMPtr<nsIURI> mSheetURI;
   nsCOMPtr<nsIPrincipal> mSheetPrincipal;
-  mozilla::CSSStyleSheet* mSheet;
+  nsCSSStyleSheet* mSheet;
   uint32_t mLineNumber;
   uint32_t mLineOffset;
 
   // This table is used to hold a reference on to any ImageValue that results
   // from re-parsing this token stream at computed value time.  When properties
   // like background-image contain a normal url(), the Declaration's data block
   // will hold a reference to the ImageValue.  When a token stream is used,
   // the Declaration only holds on to this nsCSSValueTokenStream object, and
--- a/layout/style/nsDOMCSSDeclaration.cpp
+++ b/layout/style/nsDOMCSSDeclaration.cpp
@@ -3,17 +3,17 @@
  * 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/. */
 
 /* base class for DOM objects for element.style and cssStyleRule.style */
 
 #include "nsDOMCSSDeclaration.h"
 
 #include "nsCSSParser.h"
-#include "mozilla/CSSStyleSheet.h"
+#include "nsCSSStyleSheet.h"
 #include "mozilla/css/Rule.h"
 #include "mozilla/css/Declaration.h"
 #include "mozilla/dom/CSS2PropertiesBinding.h"
 #include "nsCSSProps.h"
 #include "nsCOMPtr.h"
 #include "mozAutoDocUpdate.h"
 #include "nsIURI.h"
 #include "mozilla/dom/BindingUtils.h"
@@ -287,17 +287,17 @@ nsDOMCSSDeclaration::RemoveProperty(cons
   return RemoveProperty(propID);
 }
 
 /* static */ void
 nsDOMCSSDeclaration::GetCSSParsingEnvironmentForRule(css::Rule* aRule,
                                                      CSSParsingEnvironment& aCSSParseEnv)
 {
   nsIStyleSheet* sheet = aRule ? aRule->GetStyleSheet() : nullptr;
-  nsRefPtr<CSSStyleSheet> cssSheet(do_QueryObject(sheet));
+  nsRefPtr<nsCSSStyleSheet> cssSheet(do_QueryObject(sheet));
   if (!cssSheet) {
     aCSSParseEnv.mPrincipal = nullptr;
     return;
   }
 
   nsIDocument* document = sheet->GetOwningDocument();
   aCSSParseEnv.mSheetURI = sheet->GetSheetURI();
   aCSSParseEnv.mBaseURI = sheet->GetBaseURI();
--- a/layout/style/nsICSSLoaderObserver.h
+++ b/layout/style/nsICSSLoaderObserver.h
@@ -9,19 +9,17 @@
 #define nsICSSLoaderObserver_h___
 
 #include "nsISupports.h"
 
 #define NS_ICSSLOADEROBSERVER_IID     \
 { 0x7eb90c74, 0xea0c, 0x4df5,       \
 {0xa1, 0x5f, 0x95, 0xf0, 0x6a, 0x98, 0xb9, 0x40} }
 
-namespace mozilla {
-class CSSStyleSheet;
-} // namespace mozilla
+class nsCSSStyleSheet;
 
 class nsICSSLoaderObserver : public nsISupports {
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICSSLOADEROBSERVER_IID)
 
   /**
    * StyleSheetLoaded is called after aSheet is marked complete and before any
    * load events associated with aSheet are fired.
@@ -32,16 +30,15 @@ public:
    *        aIsAlternate if one of those methods were used to load the sheet,
    *        and will always be false otherwise.
    * @param aStatus is a success code if the sheet loaded successfully and a
    *        failure code otherwise.  Note that successful load of aSheet
    *        doesn't indicate anything about whether the data actually parsed
    *        as CSS, and doesn't indicate anything about the status of any child
    *        sheets of aSheet.
    */
-  NS_IMETHOD StyleSheetLoaded(mozilla::CSSStyleSheet* aSheet,
-                              bool aWasAlternate,
+  NS_IMETHOD StyleSheetLoaded(nsCSSStyleSheet* aSheet, bool aWasAlternate,
                               nsresult aStatus) = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsICSSLoaderObserver, NS_ICSSLOADEROBSERVER_IID)
 
 #endif // nsICSSLoaderObserver_h___
--- a/layout/style/nsIMediaList.h
+++ b/layout/style/nsIMediaList.h
@@ -16,23 +16,20 @@
 #include "nsTArray.h"
 #include "nsIAtom.h"
 #include "nsCSSValue.h"
 #include "nsWrapperCache.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/ErrorResult.h"
 
 class nsPresContext;
+class nsCSSStyleSheet;
 class nsAString;
 struct nsMediaFeature;
 
-namespace mozilla {
-class CSSStyleSheet;
-} // namespace mozilla
-
 struct nsMediaExpression {
   enum Range { eMin, eMax, eEqual };
 
   const nsMediaFeature *mFeature;
   Range mRange;
   nsCSSValue mValue;
 
   // aActualValue must be obtained from mFeature->mGetter
@@ -171,17 +168,17 @@ public:
   void GetText(nsAString& aMediaText);
   void SetText(const nsAString& aMediaText);
 
   // Does this query apply to the presentation?
   // If |aKey| is non-null, add cache information to it.
   bool Matches(nsPresContext* aPresContext,
                  nsMediaQueryResultCacheKey* aKey);
 
-  nsresult SetStyleSheet(mozilla::CSSStyleSheet* aSheet);
+  nsresult SetStyleSheet(nsCSSStyleSheet* aSheet);
   void AppendQuery(nsAutoPtr<nsMediaQuery>& aQuery) {
     // Takes ownership of aQuery
     mArray.AppendElement(aQuery.forget());
   }
 
   already_AddRefed<nsMediaList> Clone();
 
   nsMediaQuery* MediumAt(int32_t aIndex) { return mArray[aIndex]; }
@@ -206,11 +203,11 @@ protected:
 
   nsresult Delete(const nsAString & aOldMedium);
   nsresult Append(const nsAString & aOldMedium);
 
   InfallibleTArray<nsAutoPtr<nsMediaQuery> > mArray;
   // not refcounted; sheet will let us know when it goes away
   // mStyleSheet is the sheet that needs to be dirtied when this medialist
   // changes
-  mozilla::CSSStyleSheet* mStyleSheet;
+  nsCSSStyleSheet*         mStyleSheet;
 };
 #endif /* !defined(nsIMediaList_h_) */
--- a/layout/style/nsIStyleSheet.h
+++ b/layout/style/nsIStyleSheet.h
@@ -25,17 +25,17 @@ class nsIDocument;
 { 0x3eb34a60, 0x04bd, 0x41d9,   \
  { 0x9f, 0x60, 0x88, 0x26, 0x94, 0xe6, 0x1c, 0x38 } }
 
 /**
  * A style sheet is a thing associated with a document that has style
  * rules.  Those style rules can be reached in one of two ways, depending
  * on which level of the nsStyleSet it is in:
  *   1) It can be |QueryInterface|d to nsIStyleRuleProcessor
- *   2) It can be |QueryInterface|d to CSSStyleSheet, with which the
+ *   2) It can be |QueryInterface|d to nsCSSStyleSheet, with which the
  *      |nsStyleSet| uses an |nsCSSRuleProcessor| to access the rules.
  */
 class nsIStyleSheet : public nsISupports {
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISTYLE_SHEET_IID)
 
   // basic style sheet data
   virtual nsIURI* GetSheetURI() const = 0;
--- a/layout/style/nsLayoutStylesheetCache.cpp
+++ b/layout/style/nsLayoutStylesheetCache.cpp
@@ -2,25 +2,25 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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 "nsLayoutStylesheetCache.h"
 
 #include "nsAppDirectoryServiceDefs.h"
-#include "mozilla/CSSStyleSheet.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/css/Loader.h"
 #include "nsIFile.h"
 #include "nsNetUtil.h"
 #include "nsIObserverService.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIXULRuntime.h"
+#include "nsCSSStyleSheet.h"
 
 using namespace mozilla;
 
 static bool sNumberControlEnabled;
 
 #define NUMBER_CONTROL_PREF "dom.forms.number"
 
 NS_IMPL_ISUPPORTS(
@@ -45,17 +45,17 @@ nsLayoutStylesheetCache::Observe(nsISupp
     mNumberControlSheet = nullptr;
   }
   else {
     NS_NOTREACHED("Unexpected observer topic.");
   }
   return NS_OK;
 }
 
-CSSStyleSheet*
+nsCSSStyleSheet*
 nsLayoutStylesheetCache::ScrollbarsSheet()
 {
   EnsureGlobal();
   if (!gStyleCache)
     return nullptr;
 
   if (!gStyleCache->mScrollbarsSheet) {
     nsCOMPtr<nsIURI> sheetURI;
@@ -66,17 +66,17 @@ nsLayoutStylesheetCache::ScrollbarsSheet
     if (sheetURI)
       LoadSheet(sheetURI, gStyleCache->mScrollbarsSheet, false);
     NS_ASSERTION(gStyleCache->mScrollbarsSheet, "Could not load scrollbars.css.");
   }
 
   return gStyleCache->mScrollbarsSheet;
 }
 
-CSSStyleSheet*
+nsCSSStyleSheet*
 nsLayoutStylesheetCache::FormsSheet()
 {
   EnsureGlobal();
   if (!gStyleCache)
     return nullptr;
 
   if (!gStyleCache->mFormsSheet) {
     nsCOMPtr<nsIURI> sheetURI;
@@ -88,17 +88,17 @@ nsLayoutStylesheetCache::FormsSheet()
       LoadSheet(sheetURI, gStyleCache->mFormsSheet, true);
 
     NS_ASSERTION(gStyleCache->mFormsSheet, "Could not load forms.css.");
   }
 
   return gStyleCache->mFormsSheet;
 }
 
-CSSStyleSheet*
+nsCSSStyleSheet*
 nsLayoutStylesheetCache::NumberControlSheet()
 {
   EnsureGlobal();
   if (!gStyleCache)
     return nullptr;
 
   if (!sNumberControlEnabled) {
     return nullptr;
@@ -113,107 +113,107 @@ nsLayoutStylesheetCache::NumberControlSh
       LoadSheet(sheetURI, gStyleCache->mNumberControlSheet, false);
 
     NS_ASSERTION(gStyleCache->mNumberControlSheet, "Could not load number-control.css");
   }
 
   return gStyleCache->mNumberControlSheet;
 }
 
-CSSStyleSheet*
+nsCSSStyleSheet*
 nsLayoutStylesheetCache::UserContentSheet()
 {
   EnsureGlobal();
   if (!gStyleCache)
     return nullptr;
 
   return gStyleCache->mUserContentSheet;
 }
 
-CSSStyleSheet*
+nsCSSStyleSheet*
 nsLayoutStylesheetCache::UserChromeSheet()
 {
   EnsureGlobal();
   if (!gStyleCache)
     return nullptr;
 
   return gStyleCache->mUserChromeSheet;
 }
 
-CSSStyleSheet*
+nsCSSStyleSheet*
 nsLayoutStylesheetCache::UASheet()
 {
   EnsureGlobal();
   if (!gStyleCache)
     return nullptr;
 
   return gStyleCache->mUASheet;
 }
 
-CSSStyleSheet*
+nsCSSStyleSheet*
 nsLayoutStylesheetCache::HTMLSheet()
 {
   EnsureGlobal();
   if (!gStyleCache)
     return nullptr;
 
   return gStyleCache->mHTMLSheet;
 }
 
-CSSStyleSheet*
+nsCSSStyleSheet*
 nsLayoutStylesheetCache::MinimalXULSheet()
 {
   EnsureGlobal();
   if (!gStyleCache)
     return nullptr;
 
   return gStyleCache->mMinimalXULSheet;
 }
 
-CSSStyleSheet*
+nsCSSStyleSheet*
 nsLayoutStylesheetCache::XULSheet()
 {
   EnsureGlobal();
   if (!gStyleCache)
     return nullptr;
 
   return gStyleCache->mXULSheet;
 }
 
-CSSStyleSheet*
+nsCSSStyleSheet*
 nsLayoutStylesheetCache::QuirkSheet()
 {
   EnsureGlobal();
   if (!gStyleCache)
     return nullptr;
 
   return gStyleCache->mQuirkSheet;
 }
 
-CSSStyleSheet*
+nsCSSStyleSheet*
 nsLayoutStylesheetCache::FullScreenOverrideSheet()
 {
   EnsureGlobal();
   if (!gStyleCache)
     return nullptr;
 
   return gStyleCache->mFullScreenOverrideSheet;
 }
 
-CSSStyleSheet*
+nsCSSStyleSheet*
 nsLayoutStylesheetCache::SVGSheet()
 {
   EnsureGlobal();
   if (!gStyleCache)
     return nullptr;
 
   return gStyleCache->mSVGSheet;
 }
 
-CSSStyleSheet*
+nsCSSStyleSheet*
 nsLayoutStylesheetCache::MathMLSheet()
 {
   EnsureGlobal();
   if (!gStyleCache)
     return nullptr;
 
   if (!gStyleCache->mMathMLSheet) {
     nsCOMPtr<nsIURI> uri;
@@ -222,17 +222,17 @@ nsLayoutStylesheetCache::MathMLSheet()
       LoadSheet(uri, gStyleCache->mMathMLSheet, true);
     }
     NS_ASSERTION(gStyleCache->mMathMLSheet, "Could not load mathml.css");
   }
 
   return gStyleCache->mMathMLSheet;
 }
 
-CSSStyleSheet*
+nsCSSStyleSheet*
 nsLayoutStylesheetCache::CounterStylesSheet()
 {
   EnsureGlobal();
   if (!gStyleCache)
     return nullptr;
 
   return gStyleCache->mCounterStylesSheet;
 }
@@ -412,32 +412,32 @@ nsLayoutStylesheetCache::InitFromProfile
   contentFile->Append(NS_LITERAL_STRING("userContent.css"));
   chromeFile->Append(NS_LITERAL_STRING("userChrome.css"));
 
   LoadSheetFile(contentFile, mUserContentSheet);
   LoadSheetFile(chromeFile, mUserChromeSheet);
 }
 
 void
-nsLayoutStylesheetCache::LoadSheetFile(nsIFile* aFile, nsRefPtr<CSSStyleSheet>& aSheet)
+nsLayoutStylesheetCache::LoadSheetFile(nsIFile* aFile, nsRefPtr<nsCSSStyleSheet> &aSheet)
 {
   bool exists = false;
   aFile->Exists(&exists);
 
   if (!exists) return;
 
   nsCOMPtr<nsIURI> uri;
   NS_NewFileURI(getter_AddRefs(uri), aFile);
 
   LoadSheet(uri, aSheet, false);
 }
 
 void
 nsLayoutStylesheetCache::LoadSheet(nsIURI* aURI,
-                                   nsRefPtr<CSSStyleSheet>& aSheet,
+                                   nsRefPtr<nsCSSStyleSheet> &aSheet,
                                    bool aEnableUnsafeRules)
 {
   if (!aURI) {
     NS_ERROR("Null URI. Out of memory?");
     return;
   }
 
   if (!gCSSLoader) {
--- a/layout/style/nsLayoutStylesheetCache.h
+++ b/layout/style/nsLayoutStylesheetCache.h
@@ -8,78 +8,77 @@
 #define nsLayoutStylesheetCache_h__
 
 #include "nsIMemoryReporter.h"
 #include "nsIObserver.h"
 #include "nsAutoPtr.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/MemoryReporting.h"
 
+class nsCSSStyleSheet;
 class nsIFile;
 class nsIURI;
 
 namespace mozilla {
-class CSSStyleSheet;
 namespace css {
 class Loader;
 }
 }
 
 class nsLayoutStylesheetCache MOZ_FINAL
  : public nsIObserver
  , public nsIMemoryReporter
 {
   NS_DECL_ISUPPORTS
   NS_DECL_NSIOBSERVER
   NS_DECL_NSIMEMORYREPORTER
 
-  static mozilla::CSSStyleSheet* ScrollbarsSheet();
-  static mozilla::CSSStyleSheet* FormsSheet();
+  static nsCSSStyleSheet* ScrollbarsSheet();
+  static nsCSSStyleSheet* FormsSheet();
   // This function is expected to return nullptr when the dom.forms.number
   // pref is disabled.
-  static mozilla::CSSStyleSheet* NumberControlSheet();
-  static mozilla::CSSStyleSheet* UserContentSheet();
-  static mozilla::CSSStyleSheet* UserChromeSheet();
-  static mozilla::CSSStyleSheet* UASheet();
-  static mozilla::CSSStyleSheet* HTMLSheet();
-  static mozilla::CSSStyleSheet* MinimalXULSheet();
-  static mozilla::CSSStyleSheet* XULSheet();
-  static mozilla::CSSStyleSheet* QuirkSheet();
-  static mozilla::CSSStyleSheet* FullScreenOverrideSheet();
-  static mozilla::CSSStyleSheet* SVGSheet();
-  static mozilla::CSSStyleSheet* MathMLSheet();
-  static mozilla::CSSStyleSheet* CounterStylesSheet();
+  static nsCSSStyleSheet* NumberControlSheet();
+  static nsCSSStyleSheet* UserContentSheet();
+  static nsCSSStyleSheet* UserChromeSheet();
+  static nsCSSStyleSheet* UASheet();
+  static nsCSSStyleSheet* HTMLSheet();
+  static nsCSSStyleSheet* MinimalXULSheet();
+  static nsCSSStyleSheet* XULSheet();
+  static nsCSSStyleSheet* QuirkSheet();
+  static nsCSSStyleSheet* FullScreenOverrideSheet();
+  static nsCSSStyleSheet* SVGSheet();
+  static nsCSSStyleSheet* MathMLSheet();
+  static nsCSSStyleSheet* CounterStylesSheet();
 
   static void Shutdown();
 
   size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
 
 private:
   nsLayoutStylesheetCache();
   ~nsLayoutStylesheetCache();
 
   static void EnsureGlobal();
   void InitFromProfile();
   void InitMemoryReporter();
-  static void LoadSheetFile(nsIFile* aFile,
-                            nsRefPtr<mozilla::CSSStyleSheet>& aSheet);
-  static void LoadSheet(nsIURI* aURI, nsRefPtr<mozilla::CSSStyleSheet>& aSheet,
+  static void LoadSheetFile(nsIFile* aFile, nsRefPtr<nsCSSStyleSheet> &aSheet);
+  static void LoadSheet(nsIURI* aURI, nsRefPtr<nsCSSStyleSheet> &aSheet,
                         bool aEnableUnsafeRules);
 
   static nsLayoutStylesheetCache* gStyleCache;
   static mozilla::css::Loader* gCSSLoader;
-  nsRefPtr<mozilla::CSSStyleSheet> mScrollbarsSheet;
-  nsRefPtr<mozilla::CSSStyleSheet> mFormsSheet;
-  nsRefPtr<mozilla::CSSStyleSheet> mNumberControlSheet;
-  nsRefPtr<mozilla::CSSStyleSheet> mUserContentSheet;
-  nsRefPtr<mozilla::CSSStyleSheet> mUserChromeSheet;
-  nsRefPtr<mozilla::CSSStyleSheet> mUASheet;
-  nsRefPtr<mozilla::CSSStyleSheet> mHTMLSheet;
-  nsRefPtr<mozilla::CSSStyleSheet> mMinimalXULSheet;
-  nsRefPtr<mozilla::CSSStyleSheet> mXULSheet;
-  nsRefPtr<mozilla::CSSStyleSheet> mQuirkSheet;
-  nsRefPtr<mozilla::CSSStyleSheet> mFullScreenOverrideSheet;
-  nsRefPtr<mozilla::CSSStyleSheet> mSVGSheet;
-  nsRefPtr<mozilla::CSSStyleSheet> mMathMLSheet;
-  nsRefPtr<mozilla::CSSStyleSheet> mCounterStylesSheet;
+  nsRefPtr<nsCSSStyleSheet> mScrollbarsSheet;
+  nsRefPtr<nsCSSStyleSheet> mFormsSheet;
+  nsRefPtr<nsCSSStyleSheet> mNumberControlSheet;
+  nsRefPtr<nsCSSStyleSheet> mUserContentSheet;
+  nsRefPtr<nsCSSStyleSheet> mUserChromeSheet;
+  nsRefPtr<nsCSSStyleSheet> mUASheet;
+  nsRefPtr<nsCSSStyleSheet> mHTMLSheet;
+  nsRefPtr<nsCSSStyleSheet> mMinimalXULSheet;
+  nsRefPtr<nsCSSStyleSheet> mXULSheet;
+  nsRefPtr<nsCSSStyleSheet> mQuirkSheet;
+  nsRefPtr<nsCSSStyleSheet> mFullScreenOverrideSheet;
+  nsRefPtr<nsCSSStyleSheet> mSVGSheet;
+  nsRefPtr<nsCSSStyleSheet> mMathMLSheet;
+  nsRefPtr<nsCSSStyleSheet> mCounterStylesSheet;
 };
 
 #endif
--- a/layout/style/nsStyleSet.cpp
+++ b/layout/style/nsStyleSet.cpp
@@ -4,22 +4,22 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * the container for the style sheets that apply to a presentation, and
  * the internal API that the style system exposes for creating (and
  * potentially re-creating) style contexts
  */
 
-#include "nsStyleSet.h"
-
 #include "mozilla/ArrayUtils.h"
-#include "mozilla/CSSStyleSheet.h"
 #include "mozilla/EventStates.h"
 #include "mozilla/MemoryReporting.h"
+
+#include "nsStyleSet.h"
+#include "nsCSSStyleSheet.h"
 #include "nsIDocumentInlines.h"
 #include "nsRuleWalker.h"
 #include "nsStyleContext.h"
 #include "mozilla/css/StyleRule.h"
 #include "nsCSSAnonBoxes.h"
 #include "nsCSSPseudoElements.h"
 #include "nsCSSRuleProcessor.h"
 #include "nsDataHashtable.h"
@@ -277,17 +277,17 @@ GetScopeDepth(nsINode* aScopeElement, Sc
       }
     }
   }
   return depth;
 }
 
 struct ScopedSheetOrder
 {
-  CSSStyleSheet* mSheet;
+  nsCSSStyleSheet* mSheet;
   uint32_t mDepth;
   uint32_t mOrder;
 
   bool operator==(const ScopedSheetOrder& aRHS) const
   {
     return mDepth == aRHS.mDepth &&
            mOrder == aRHS.mOrder;
   }
@@ -300,17 +300,17 @@ struct ScopedSheetOrder
     return mOrder < aRHS.mOrder;
   }
 };
 
 // Sorts aSheets such that style sheets for ancestor scopes come
 // before those for descendant scopes, and with sheets for a single
 // scope in document order.
 static void
-SortStyleSheetsByScope(nsTArray<CSSStyleSheet*>& aSheets)
+SortStyleSheetsByScope(nsTArray<nsCSSStyleSheet*>& aSheets)
 {
   uint32_t n = aSheets.Length();
   if (n == 1) {
     return;
   }
 
   ScopeDepthCache cache;
 
@@ -377,21 +377,21 @@ nsStyleSet::GatherRuleProcessors(sheetTy
       // keep going
       break;
   }
   if (aType == eScopedDocSheet) {
     // Create a rule processor for each scope.
     uint32_t count = mSheets[eScopedDocSheet].Count();
     if (count) {
       // Gather the scoped style sheets into an array as
-      // CSSStyleSheets, and mark all of their scope elements
+      // nsCSSStyleSheets, and mark all of their scope elements
       // as scoped style roots.
-      nsTArray<CSSStyleSheet*> sheets(count);
+      nsTArray<nsCSSStyleSheet*> sheets(count);
       for (uint32_t i = 0; i < count; i++) {
-        nsRefPtr<CSSStyleSheet> sheet =
+        nsRefPtr<nsCSSStyleSheet> sheet =
           do_QueryObject(mSheets[eScopedDocSheet].ObjectAt(i));
         sheets.AppendElement(sheet);
 
         Element* scope = sheet->GetScopeElement();
         scope->SetIsScopedStyleRoot();
       }
 
       // Sort the scoped style sheets so that those for the same scope are
@@ -405,17 +405,17 @@ nsStyleSet::GatherRuleProcessors(sheetTy
         end = start + 1;
         while (end < count && sheets[end]->GetScopeElement() == scope) {
           end++;
         }
 
         scope->SetIsScopedStyleRoot();
 
         // Create a rule processor for the scope.
-        nsTArray<nsRefPtr<CSSStyleSheet>> sheetsForScope;
+        nsTArray< nsRefPtr<nsCSSStyleSheet> > sheetsForScope;
         sheetsForScope.AppendElements(sheets.Elements() + start, end - start);
         mScopedDocSheetRuleProcessors.AppendElement
           (new nsCSSRuleProcessor(sheetsForScope, uint8_t(aType), scope));
 
         start = end;
       } while (start < count);
     }
     return NS_OK;
@@ -423,19 +423,19 @@ nsStyleSet::GatherRuleProcessors(sheetTy
   if (mSheets[aType].Count()) {
     switch (aType) {
       case eAgentSheet:
       case eUserSheet:
       case eDocSheet:
       case eOverrideSheet: {
         // levels containing CSS stylesheets (apart from eScopedDocSheet)
         nsCOMArray<nsIStyleSheet>& sheets = mSheets[aType];
-        nsTArray<nsRefPtr<CSSStyleSheet>> cssSheets(sheets.Count());
+        nsTArray<nsRefPtr<nsCSSStyleSheet> > cssSheets(sheets.Count());
         for (int32_t i = 0, i_end = sheets.Count(); i < i_end; ++i) {
-          nsRefPtr<CSSStyleSheet> cssSheet = do_QueryObject(sheets[i]);
+          nsRefPtr<nsCSSStyleSheet> cssSheet = do_QueryObject(sheets[i]);
           NS_ASSERTION(cssSheet, "not a CSS sheet");
           cssSheets.AppendElement(cssSheet);
         }
         mRuleProcessors[aType] =
           new nsCSSRuleProcessor(cssSheets, uint8_t(aType), nullptr);
       } break;
 
       default:
@@ -447,18 +447,18 @@ nsStyleSet::GatherRuleProcessors(sheetTy
   }
 
   return NS_OK;
 }
 
 static bool
 IsScopedStyleSheet(nsIStyleSheet* aSheet)
 {
-  nsRefPtr<CSSStyleSheet> cssSheet = do_QueryObject(aSheet);
-  NS_ASSERTION(cssSheet, "expected aSheet to be a CSSStyleSheet");
+  nsRefPtr<nsCSSStyleSheet> cssSheet = do_QueryObject(aSheet);
+  NS_ASSERTION(cssSheet, "expected aSheet to be an nsCSSStyleSheet");
 
   return cssSheet->GetScopeElement();
 }
 
 nsresult
 nsStyleSet::AppendStyleSheet(sheetType aType, nsIStyleSheet *aSheet)
 {
   NS_PRECONDITION(aSheet, "null arg");
@@ -597,17 +597,17 @@ nsStyleSet::AddDocStyleSheet(nsIStyleShe
     return NS_ERROR_OUT_OF_MEMORY;
 
   return DirtyRuleProcessors(type);
 }
 
 nsresult
 nsStyleSet::RemoveDocStyleSheet(nsIStyleSheet *aSheet)
 {
-  nsRefPtr<CSSStyleSheet> cssSheet = do_QueryObject(aSheet);
+  nsRefPtr<nsCSSStyleSheet> cssSheet = do_QueryObject(aSheet);
   bool isScoped = cssSheet && cssSheet->GetScopeElement();
   return RemoveStyleSheet(isScoped ? eScopedDocSheet : eDocSheet, aSheet);
 }
 
 // Batching
 void
 nsStyleSet::BeginUpdate()
 {
@@ -2060,42 +2060,42 @@ nsStyleSet::MediumFeaturesChanged(nsPres
     bool thisChanged = false;
     mBindingManager->MediumFeaturesChanged(aPresContext, &thisChanged);
     stylesChanged = stylesChanged || thisChanged;
   }
 
   return stylesChanged;
 }
 
-CSSStyleSheet::EnsureUniqueInnerResult
+nsCSSStyleSheet::EnsureUniqueInnerResult
 nsStyleSet::EnsureUniqueInnerOnCSSSheets()
 {
-  nsAutoTArray<CSSStyleSheet*, 32> queue;
+  nsAutoTArray<nsCSSStyleSheet*, 32> queue;
   for (uint32_t i = 0; i < ArrayLength(gCSSSheetTypes); ++i) {
     nsCOMArray<nsIStyleSheet> &sheets = mSheets[gCSSSheetTypes[i]];
     for (uint32_t j = 0, j_end = sheets.Count(); j < j_end; ++j) {
-      CSSStyleSheet* sheet = static_cast<CSSStyleSheet*>(sheets[j]);
+      nsCSSStyleSheet *sheet = static_cast<nsCSSStyleSheet*>(sheets[j]);
       queue.AppendElement(sheet);
     }
   }
 
   if (mBindingManager) {
     mBindingManager->AppendAllSheets(queue);
   }
 
-  CSSStyleSheet::EnsureUniqueInnerResult res =
-    CSSStyleSheet::eUniqueInner_AlreadyUnique;
+  nsCSSStyleSheet::EnsureUniqueInnerResult res =
+    nsCSSStyleSheet::eUniqueInner_AlreadyUnique;
   while (!queue.IsEmpty()) {
     uint32_t idx = queue.Length() - 1;
-    CSSStyleSheet* sheet = queue[idx];
+    nsCSSStyleSheet *sheet = queue[idx];
     queue.RemoveElementAt(idx);
 
-    CSSStyleSheet::EnsureUniqueInnerResult sheetRes =
+    nsCSSStyleSheet::EnsureUniqueInnerResult sheetRes =
       sheet->EnsureUniqueInner();
-    if (sheetRes == CSSStyleSheet::eUniqueInner_ClonedInner) {
+    if (sheetRes == nsCSSStyleSheet::eUniqueInner_ClonedInner) {
       res = sheetRes;
     }
 
     // Enqueue all the sheet's children.
     sheet->AppendAllChildSheets(queue);
   }
   return res;
 }
--- a/layout/style/nsStyleSet.h
+++ b/layout/style/nsStyleSet.h
@@ -8,20 +8,20 @@
  * the internal API that the style system exposes for creating (and
  * potentially re-creating) style contexts
  */
 
 #ifndef nsStyleSet_h_
 #define nsStyleSet_h_
 
 #include "mozilla/Attributes.h"
-#include "mozilla/CSSStyleSheet.h"
 #include "mozilla/MemoryReporting.h"
 
 #include "nsIStyleRuleProcessor.h"
+#include "nsCSSStyleSheet.h"
 #include "nsBindingManager.h"
 #include "nsRuleNode.h"
 #include "nsTArray.h"
 #include "nsCOMArray.h"
 #include "nsAutoPtr.h"
 #include "nsIStyleRule.h"
 #include "nsCSSPseudoElements.h"
 
@@ -333,17 +333,17 @@ class nsStyleSet
     ++mUnusedRuleNodeCount;
   }
 
   // Notify the style set that a rulenode that wasn't in use now is
   void RuleNodeInUse() {
     --mUnusedRuleNodeCount;
   }
 
-  mozilla::CSSStyleSheet::EnsureUniqueInnerResult EnsureUniqueInnerOnCSSSheets();
+  nsCSSStyleSheet::EnsureUniqueInnerResult EnsureUniqueInnerOnCSSSheets();
 
   nsIStyleRule* InitialStyleRule();
 
  private:
   nsStyleSet(const nsStyleSet& aCopy) MOZ_DELETE;
   nsStyleSet& operator=(const nsStyleSet& aCopy) MOZ_DELETE;
 
   // Run mark-and-sweep GC on mRuleTree and mOldRuleTrees, based on mRoots.
--- a/layout/style/test/ParseCSS.cpp
+++ b/layout/style/test/ParseCSS.cpp
@@ -14,20 +14,18 @@
 
 #include "nsXPCOM.h"
 #include "nsCOMPtr.h"
 
 #include "nsIFile.h"
 #include "nsNetUtil.h"
 
 #include "nsContentCID.h"
-#include "mozilla/CSSStyleSheet.h"
 #include "mozilla/css/Loader.h"
-
-using namespace mozilla;
+#include "nsCSSStyleSheet.h"
 
 static already_AddRefed<nsIURI>
 FileToURI(const char *aFilename, nsresult *aRv = 0)
 {
     nsCOMPtr<nsIFile> lf(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, aRv));
     NS_ENSURE_TRUE(lf, nullptr);
     // XXX Handle relative paths somehow.
     lf->InitWithNativePath(nsDependentCString(aFilename));
@@ -38,17 +36,17 @@ FileToURI(const char *aFilename, nsresul
         *aRv = rv;
     return uri;
 }
 
 static int
 ParseCSSFile(nsIURI *aSheetURI)
 {
     nsRefPtr<mozilla::css::Loader> = new mozilla::css::Loader();
-    nsRefPtr<CSSStyleSheet> sheet;
+    nsRefPtr<nsCSSStyleSheet> sheet;
     loader->LoadSheetSync(aSheetURI, getter_AddRefs(sheet));
     NS_ASSERTION(sheet, "sheet load failed");
     /* This can happen if the file can't be found (e.g. you
      * ask for a relative path and xpcom/io rejects it)
      */
     if (!sheet)
         return -1;
     bool complete;