Bug 577002 Part 2: Remove nsICSSImportRule. r=bzbarsky
authorCraig Topper <craig.topper@gmail.com>
Thu, 17 Mar 2011 13:41:52 -0400
changeset 63734 9ce52762e87a9719fd9ca6d8b1ab1b74c5d81efa
parent 63733 ecf6c47436b6f7ab93a0bac434bf9500cd333493
child 63735 5de818f2b9920d454abaf2cf2b3d4b57395b4cec
push idunknown
push userunknown
push dateunknown
reviewersbzbarsky
bugs577002
milestone2.0b13pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 577002 Part 2: Remove nsICSSImportRule. r=bzbarsky
layout/style/ImportRule.h
layout/style/Loader.cpp
layout/style/Loader.h
layout/style/Makefile.in
layout/style/nsCSSParser.cpp
layout/style/nsCSSRules.cpp
layout/style/nsCSSStyleSheet.cpp
layout/style/nsCSSStyleSheet.h
layout/style/nsICSSImportRule.h
layout/style/nsICSSRule.h
layout/style/nsIStyleRule.h
rename from layout/style/nsICSSImportRule.h
rename to layout/style/ImportRule.h
--- a/layout/style/nsICSSImportRule.h
+++ b/layout/style/ImportRule.h
@@ -30,43 +30,76 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-/* internal interface for CSS @import rules */
+/* class for CSS @import rules */
 
-#ifndef nsICSSImportRule_h
-#define nsICSSImportRule_h
+#ifndef mozilla_css_ImportRule_h__
+#define mozilla_css_ImportRule_h__
 
 #include "nsICSSRule.h"
+#include "nsCSSRule.h"
+#include "nsIDOMCSSImportRule.h"
+#include "nsCSSRules.h"
 
 class nsMediaList;
 class nsString;
 
-#define NS_ICSS_IMPORT_RULE_IID \
-{ 0x07bd9b80, 0x721e, 0x4566, \
-  { 0xb7, 0x90, 0xed, 0x25, 0x10, 0xed, 0x99, 0xde } }
+namespace mozilla {
+namespace css {
 
-
-class nsICSSImportRule : public nsICSSRule {
+class NS_FINAL_CLASS ImportRule : public nsCSSRule,
+                                  public nsICSSRule,
+                                  public nsIDOMCSSImportRule
+{
+public:
+  ImportRule(nsMediaList* aMedia);
+private:
+  // for |Clone|
+  ImportRule(const ImportRule& aCopy);
+  ~ImportRule();
 public:
-  NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICSS_IMPORT_RULE_IID)
+  NS_DECL_ISUPPORTS
+
+  DECL_STYLE_RULE_INHERIT
 
-  NS_IMETHOD SetURLSpec(const nsString& aURLSpec) = 0;
-  NS_IMETHOD GetURLSpec(nsString& aURLSpec) const = 0;
+  // nsIStyleRule methods
+#ifdef DEBUG
+  virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
+#endif
+
+  // nsICSSRule methods
+  virtual PRInt32 GetType() const;
+  virtual already_AddRefed<nsICSSRule> Clone() const;
+
+  NS_IMETHOD SetURLSpec(const nsString& aURLSpec);
+  NS_IMETHOD GetURLSpec(nsString& aURLSpec) const;
 
-  NS_IMETHOD SetMedia(const nsString& aMedia) = 0;
-  NS_IMETHOD GetMedia(nsString& aMedia) const = 0;
+  NS_IMETHOD SetMedia(const nsString& aMedia);
+  NS_IMETHOD GetMedia(nsString& aMedia) const;
+
+  NS_IMETHOD SetSheet(nsCSSStyleSheet*);
+
+  // nsIDOMCSSRule interface
+  NS_DECL_NSIDOMCSSRULE
 
-  NS_IMETHOD SetSheet(nsCSSStyleSheet*) = 0;
+  // nsIDOMCSSImportRule interface
+  NS_DECL_NSIDOMCSSIMPORTRULE
+
+private:
+  nsString  mURLSpec;
+  nsRefPtr<nsMediaList> mMedia;
+  nsRefPtr<nsCSSStyleSheet> mChildSheet;
 };
 
-NS_DEFINE_STATIC_IID_ACCESSOR(nsICSSImportRule, NS_ICSS_IMPORT_RULE_IID)
+} // namespace css
+} // namespace mozilla
 
 nsresult
-NS_NewCSSImportRule(nsICSSImportRule** aInstancePtrResult, 
+NS_NewCSSImportRule(mozilla::css::ImportRule** aInstancePtrResult,
                     const nsString& aURLSpec, nsMediaList* aMedia);
 
-#endif /* nsICSSImportRule_h */
+#endif /* mozilla_css_ImportRule_h__ */
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -76,29 +76,28 @@
 #include "nsIScriptError.h"
 #include "nsMimeTypes.h"
 #include "nsIAtom.h"
 #include "nsIDOM3Node.h"
 #include "nsCSSStyleSheet.h"
 #include "nsIStyleSheetLinkingElement.h"
 #include "nsICSSLoaderObserver.h"
 #include "nsCSSParser.h"
-#include "nsICSSImportRule.h"
+#include "mozilla/css/ImportRule.h"
 #include "nsThreadUtils.h"
 #include "nsGkAtoms.h"
 #include "nsDocShellCID.h"
 
 #ifdef MOZ_XUL
 #include "nsXULPrototypeCache.h"
 #endif
 
 #include "nsIMediaList.h"
 #include "nsIDOMStyleSheet.h"
 #include "nsIDOMCSSStyleSheet.h"
-#include "nsIDOMCSSImportRule.h"
 #include "nsContentErrors.h"
 
 #include "nsIChannelPolicy.h"
 #include "nsIContentSecurityPolicy.h"
 
 #include "mozilla/FunctionTimer.h"
 
 /**
@@ -1338,17 +1337,17 @@ Loader::InsertSheetInDoc(nsCSSStyleSheet
  * 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(nsCSSStyleSheet* aSheet,
                          nsCSSStyleSheet* aParentSheet,
-                         nsICSSImportRule* aParentRule)
+                         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
   // cloned off of top-level sheets which were disabled
@@ -1975,17 +1974,17 @@ Loader::LoadStyleLink(nsIContent* aEleme
   data->mMustNotify = PR_TRUE;
   return rv;
 }
 
 nsresult
 Loader::LoadChildSheet(nsCSSStyleSheet* aParentSheet,
                        nsIURI* aURL, 
                        nsMediaList* aMedia,
-                       nsICSSImportRule* aParentRule)
+                       ImportRule* aParentRule)
 {
   LOG(("css::Loader::LoadChildSheet"));
   NS_PRECONDITION(aURL, "Must have a URI to load");
   NS_PRECONDITION(aParentSheet, "Must have a parent sheet");
 
   if (!mEnabled) {
     LOG_WARN(("  Not enabled"));
     return NS_ERROR_NOT_AVAILABLE;
--- a/layout/style/Loader.h
+++ b/layout/style/Loader.h
@@ -47,17 +47,16 @@
 #include "nsDataHashtable.h"
 #include "nsInterfaceHashtable.h"
 #include "nsRefPtrHashtable.h"
 #include "nsTArray.h"
 #include "nsTObserverArray.h"
 #include "nsURIHashKey.h"
 
 class nsIAtom;
-class nsICSSImportRule;
 class nsICSSLoaderObserver;
 class nsCSSStyleSheet;
 class nsIContent;
 class nsIDocument;
 class nsIUnicharInputStream;
 class nsCSSParser;
 class nsMediaList;
 
@@ -121,16 +120,17 @@ protected:
   nsCOMPtr<nsIPrincipal> mPrincipal;
 };
 
 
 
 namespace css {
 
 class SheetLoadData;
+class ImportRule;
 
 /***********************************************************************
  * Enum that describes the state of the sheet returned by CreateSheet. *
  ***********************************************************************/
 enum StyleSheetState {
   eSheetStateUnknown = 0,
   eSheetNeedsParser,
   eSheetPending,
@@ -227,17 +227,17 @@ public:
    * @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(nsCSSStyleSheet* aParentSheet,
                           nsIURI* aURL,
                           nsMediaList* aMedia,
-                          nsICSSImportRule* aRule);
+                          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
    * does NOT guarantee not receiving any events before the sheet loads.  This
    * method can be used to load sheets not associated with a document.
    *
@@ -403,17 +403,17 @@ private:
                         PRBool *aIsAlternate = nsnull);
 
   nsresult InsertSheetInDoc(nsCSSStyleSheet* aSheet,
                             nsIContent* aLinkingContent,
                             nsIDocument* aDocument);
 
   nsresult InsertChildSheet(nsCSSStyleSheet* aSheet,
                             nsCSSStyleSheet* aParentSheet,
-                            nsICSSImportRule* aParentRule);
+                            ImportRule* aParentRule);
 
   nsresult InternalLoadNonDocumentSheet(nsIURI* aURL,
                                         PRBool aAllowUnsafeRules,
                                         PRBool aUseSystemPrincipal,
                                         nsIPrincipal* aOriginPrincipal,
                                         const nsCString& aCharset,
                                         nsCSSStyleSheet** aSheet,
                                         nsICSSLoaderObserver* aObserver);
--- a/layout/style/Makefile.in
+++ b/layout/style/Makefile.in
@@ -69,17 +69,16 @@ EXPORTS		= \
 		nsCSSRuleProcessor.h \
 		nsCSSStyleSheet.h \
 		nsCSSStruct.h \
 		nsCSSValue.h \
 		nsDOMCSSAttrDeclaration.h \
 		nsDOMCSSDeclaration.h \
 		nsICSSDeclaration.h \
 		nsICSSGroupRule.h \
-		nsICSSImportRule.h \
 		nsICSSLoaderObserver.h \
 		nsICSSPseudoComparator.h \
 		nsICSSRule.h \
 		nsICSSRuleList.h \
 		nsICSSStyleRuleDOMWrapper.h \
 		nsIStyleRule.h \
 		nsIStyleRuleProcessor.h \
 		nsIStyleSheet.h \
@@ -96,16 +95,17 @@ EXPORTS		= \
 		nsStyleStructInlines.h \
 		nsStyleStructList.h \
 		nsStyleTransformMatrix.h \
 		nsStyleUtil.h \
 		$(NULL)
 
 EXPORTS_mozilla/css = \
 		Declaration.h \
+		ImportRule.h \
 		Loader.h \
 		NameSpaceRule.h \
 		StyleRule.h \
 		$(NULL)
 
 CPPSRCS		= \
 		nsCSSAnonBoxes.cpp \
 		nsCSSDataBlock.cpp \
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -47,17 +47,17 @@
 /* parsing of CSS stylesheets, based on a token stream from the CSS scanner */
 
 #include "nsCSSParser.h"
 #include "nsCSSProps.h"
 #include "nsCSSKeywords.h"
 #include "nsCSSScanner.h"
 #include "mozilla/css/Loader.h"
 #include "mozilla/css/StyleRule.h"
-#include "nsICSSImportRule.h"
+#include "mozilla/css/ImportRule.h"
 #include "nsCSSRules.h"
 #include "mozilla/css/NameSpaceRule.h"
 #include "nsIUnicharInputStream.h"
 #include "nsCSSStyleSheet.h"
 #include "mozilla/css/Declaration.h"
 #include "nsStyleConsts.h"
 #include "nsIURL.h"
 #include "nsNetUtil.h"
@@ -1925,17 +1925,17 @@ CSSParserImpl::ParseImportRule(RuleAppen
 
 
 void
 CSSParserImpl::ProcessImport(const nsString& aURLSpec,
                              nsMediaList* aMedia,
                              RuleAppendFunc aAppendFunc,
                              void* aData)
 {
-  nsCOMPtr<nsICSSImportRule> rule;
+  nsRefPtr<css::ImportRule> rule;
   nsresult rv = NS_NewCSSImportRule(getter_AddRefs(rule), aURLSpec, aMedia);
   if (NS_FAILED(rv)) { // out of memory
     mScanner.SetLowLevelError(rv);
     return;
   }
   (*aAppendFunc)(rule, aData);
 
   // Diagnose bad URIs even if we don't have a child loader.
--- a/layout/style/nsCSSRules.cpp
+++ b/layout/style/nsCSSRules.cpp
@@ -35,29 +35,28 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 /* rules in a CSS stylesheet other than style rules (e.g., @import rules) */
 
 #include "nsCSSRules.h"
 #include "nsCSSValue.h"
-#include "nsICSSImportRule.h"
+#include "mozilla/css/ImportRule.h"
 #include "mozilla/css/NameSpaceRule.h"
 
 #include "nsString.h"
 #include "nsIAtom.h"
 #include "nsIURL.h"
 
 #include "nsCSSProps.h"
 #include "nsCSSStyleSheet.h"
 
 #include "nsCOMPtr.h"
 #include "nsIDOMCSSStyleSheet.h"
-#include "nsIDOMCSSImportRule.h"
 #include "nsIDOMCSSMediaRule.h"
 #include "nsIDOMCSSMozDocumentRule.h"
 #include "nsIDOMCSSCharsetRule.h"
 #include "nsIDOMCSSStyleDeclaration.h"
 #include "nsIMediaList.h"
 #include "nsICSSRuleList.h"
 #include "nsIDocument.h"
 #include "nsPresContext.h"
@@ -350,61 +349,16 @@ CSSCharsetRuleImpl::GetParentRule(nsIDOM
 
 // -------------------------------------------
 // ImportRule
 //
 
 namespace mozilla {
 namespace css {
 
-class NS_FINAL_CLASS ImportRule : public nsCSSRule,
-                                  public nsICSSImportRule,
-                                  public nsIDOMCSSImportRule
-{
-public:
-  ImportRule(nsMediaList* aMedia);
-  ImportRule(const ImportRule& aCopy);
-private:
-  ~ImportRule();
-public:
-
-  NS_DECL_ISUPPORTS
-
-  DECL_STYLE_RULE_INHERIT
-
-  // nsIStyleRule methods
-#ifdef DEBUG
-  virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
-#endif
-
-  // nsICSSRule methods
-  virtual PRInt32 GetType() const;
-  virtual already_AddRefed<nsICSSRule> Clone() const;
-
-  // nsICSSImportRule methods
-  NS_IMETHOD SetURLSpec(const nsString& aURLSpec);
-  NS_IMETHOD GetURLSpec(nsString& aURLSpec) const;
-
-  NS_IMETHOD SetMedia(const nsString& aMedia);
-  NS_IMETHOD GetMedia(nsString& aMedia) const;
-
-  NS_IMETHOD SetSheet(nsCSSStyleSheet*);
-  
-  // nsIDOMCSSRule interface
-  NS_DECL_NSIDOMCSSRULE
-
-  // nsIDOMCSSImportRule interface
-  NS_DECL_NSIDOMCSSIMPORTRULE
-
-protected:
-  nsString  mURLSpec;
-  nsRefPtr<nsMediaList> mMedia;
-  nsRefPtr<nsCSSStyleSheet> mChildSheet;
-};
-
 ImportRule::ImportRule(nsMediaList* aMedia)
   : nsCSSRule()
   , mURLSpec()
   , mMedia(aMedia)
 {
   // XXXbz This is really silly.... the mMedia here will be replaced
   // with itself if we manage to load a sheet.  Which should really
   // never fail nowadays, in sane cases.
@@ -429,22 +383,21 @@ ImportRule::~ImportRule()
   }
 }
 
 NS_IMPL_ADDREF(ImportRule)
 NS_IMPL_RELEASE(ImportRule)
 
 // QueryInterface implementation for ImportRule
 NS_INTERFACE_MAP_BEGIN(ImportRule)
-  NS_INTERFACE_MAP_ENTRY(nsICSSImportRule)
   NS_INTERFACE_MAP_ENTRY(nsICSSRule)
   NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSImportRule)
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICSSImportRule)
+  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICSSRule)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSImportRule)
 NS_INTERFACE_MAP_END
 
 IMPL_STYLE_RULE_INHERIT(ImportRule, nsCSSRule)
 
 #ifdef DEBUG
 /* virtual */ void
 ImportRule::List(FILE* out, PRInt32 aIndent) const
@@ -608,17 +561,17 @@ ImportRule::GetStyleSheet(nsIDOMCSSStyle
 
 } // namespace css
 } // namespace mozilla
 
 // must be outside the namespace
 DOMCI_DATA(CSSImportRule, css::ImportRule)
 
 nsresult
-NS_NewCSSImportRule(nsICSSImportRule** aInstancePtrResult,
+NS_NewCSSImportRule(css::ImportRule** aInstancePtrResult,
                     const nsString& aURLSpec,
                     nsMediaList* aMedia)
 {
   NS_ENSURE_ARG_POINTER(aInstancePtrResult);
 
   css::ImportRule* it = new css::ImportRule(aMedia);
 
   if (!it) {
--- a/layout/style/nsCSSStyleSheet.cpp
+++ b/layout/style/nsCSSStyleSheet.cpp
@@ -43,25 +43,24 @@
 
 #include "nsCSSStyleSheet.h"
 
 #include "nsCRT.h"
 #include "nsIAtom.h"
 #include "nsCSSRuleProcessor.h"
 #include "mozilla/css/NameSpaceRule.h"
 #include "nsICSSGroupRule.h"
-#include "nsICSSImportRule.h"
+#include "mozilla/css/ImportRule.h"
 #include "nsIMediaList.h"
 #include "nsIDocument.h"
 #include "nsPresContext.h"
 #include "nsGkAtoms.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "nsIDOMCSSStyleSheet.h"
-#include "nsIDOMCSSImportRule.h"
 #include "nsICSSRuleList.h"
 #include "nsIDOMMediaList.h"
 #include "nsIDOMNode.h"
 #include "nsDOMError.h"
 #include "nsCSSParser.h"
 #include "mozilla/css/Loader.h"
 #include "nsICSSLoaderObserver.h"
 #include "nsINameSpaceManager.h"
@@ -857,17 +856,17 @@ nsCSSStyleSheet::RebuildChildList(nsICSS
     // We're past all the import rules; stop the enumeration.
     return PR_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 nsICSSImportRule and get an nsCSSStyleSheet
+  // 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
@@ -1008,17 +1007,17 @@ nsCSSStyleSheet::nsCSSStyleSheet()
     mRuleProcessors(nsnull)
 {
 
   mInner = new nsCSSStyleSheetInner(this);
 }
 
 nsCSSStyleSheet::nsCSSStyleSheet(const nsCSSStyleSheet& aCopy,
                                  nsCSSStyleSheet* aParentToUse,
-                                 nsICSSImportRule* aOwnerRuleToUse,
+                                 css::ImportRule* aOwnerRuleToUse,
                                  nsIDocument* aDocumentToUse,
                                  nsIDOMNode* aOwningNodeToUse)
   : mTitle(aCopy.mTitle),
     mParent(aParentToUse),
     mOwnerRule(aOwnerRuleToUse),
     mRuleCollection(nsnull), // re-created lazily
     mDocument(aDocumentToUse),
     mOwningNode(aOwningNodeToUse),
@@ -1457,17 +1456,17 @@ nsCSSStyleSheet::AppendAllChildSheets(ns
       return PR_FALSE;
     }
   }
   return PR_TRUE;
 }
 
 already_AddRefed<nsCSSStyleSheet>
 nsCSSStyleSheet::Clone(nsCSSStyleSheet* aCloneParent,
-                       nsICSSImportRule* aCloneOwnerRule,
+                       css::ImportRule* aCloneOwnerRule,
                        nsIDocument* aCloneDocument,
                        nsIDOMNode* aCloneOwningNode) const
 {
   nsCSSStyleSheet* clone = new nsCSSStyleSheet(*this,
                                                aCloneParent,
                                                aCloneOwnerRule,
                                                aCloneDocument,
                                                aCloneOwningNode);
@@ -2065,24 +2064,24 @@ NS_IMETHODIMP
 nsCSSStyleSheet::StyleSheetLoaded(nsCSSStyleSheet* aSheet,
                                   PRBool aWasAlternate,
                                   nsresult aStatus)
 {
   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)) {
-    nsCOMPtr<nsICSSImportRule> ownerRule = aSheet->GetOwnerRule();
-    
+    nsRefPtr<css::ImportRule> ownerRule = aSheet->GetOwnerRule();
+
     mozAutoDocUpdate updateBatch(mDocument, UPDATE_STYLE, PR_TRUE);
 
     // XXXldb @import rules shouldn't even implement nsIStyleRule (but
     // they do)!
-    nsCOMPtr<nsIStyleRule> styleRule(do_QueryInterface(ownerRule));
-    
+    nsIStyleRule* styleRule = ownerRule;
+
     mDocument->StyleRuleAdded(this, styleRule);
   }
 
   return NS_OK;
 }
 
 /* virtual */ nsIURI*
 nsCSSStyleSheet::GetOriginalURI() const
--- a/layout/style/nsCSSStyleSheet.h
+++ b/layout/style/nsCSSStyleSheet.h
@@ -52,25 +52,30 @@
 #include "nsICSSLoaderObserver.h"
 #include "nsCOMArray.h"
 
 class nsICSSRule;
 class nsXMLNameSpaceMap;
 class nsCSSRuleProcessor;
 class nsMediaList;
 class nsICSSGroupRule;
-class nsICSSImportRule;
 class nsIPrincipal;
 class nsIURI;
 class nsMediaList;
 class nsMediaQueryResultCacheKey;
 class nsCSSStyleSheet;
 class nsPresContext;
 template<class E, class A> class nsTArray;
 
+namespace mozilla {
+namespace css {
+class ImportRule;
+}
+}
+
 // -------------------------------
 // CSS Style Sheet Inner Data Container
 //
 
 class nsCSSStyleSheetInner {
 public:
   friend class nsCSSStyleSheet;
   friend class nsCSSRuleProcessor;
@@ -189,23 +194,23 @@ public:
 
   // Principal() never returns a null pointer.
   nsIPrincipal* Principal() const { return mInner->mPrincipal; }
 
   void SetTitle(const nsAString& aTitle) { mTitle = aTitle; }
   void SetMedia(nsMediaList* aMedia);
   void SetOwningNode(nsIDOMNode* aOwningNode) { mOwningNode = aOwningNode; /* Not ref counted */ }
 
-  void SetOwnerRule(nsICSSImportRule* aOwnerRule) { mOwnerRule = aOwnerRule; /* Not ref counted */ }
-  nsICSSImportRule* 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<nsCSSStyleSheet> Clone(nsCSSStyleSheet* aCloneParent,
-                                          nsICSSImportRule* aCloneOwnerRule,
+                                          mozilla::css::ImportRule* aCloneOwnerRule,
                                           nsIDocument* aCloneDocument,
                                           nsIDOMNode* aCloneOwningNode) const;
 
   PRBool IsModified() const { return mDirty; }
   void SetModified(PRBool aModified) { mDirty = aModified; }
 
   nsresult AddRuleProcessor(nsCSSRuleProcessor* aProcessor);
   nsresult DropRuleProcessor(nsCSSRuleProcessor* aProcessor);
@@ -250,17 +255,17 @@ public:
 
   // Function used as a callback to rebuild our inner's child sheet
   // list after we clone a unique inner for ourselves.
   static PRBool RebuildChildList(nsICSSRule* aRule, void* aBuilder);
 
 private:
   nsCSSStyleSheet(const nsCSSStyleSheet& aCopy,
                   nsCSSStyleSheet* aParentToUse,
-                  nsICSSImportRule* aOwnerRuleToUse,
+                  mozilla::css::ImportRule* aOwnerRuleToUse,
                   nsIDocument* aDocumentToUse,
                   nsIDOMNode* aOwningNodeToUse);
 
   // These are not supported and are not implemented! 
   nsCSSStyleSheet(const nsCSSStyleSheet& aCopy); 
   nsCSSStyleSheet& operator=(const nsCSSStyleSheet& aCopy); 
 
 protected:
@@ -279,17 +284,17 @@ protected:
   // Add the namespace mapping from this @namespace rule to our namespace map
   nsresult RegisterNamespaceRule(nsICSSRule* aRule);
 
 protected:
   nsString              mTitle;
   nsRefPtr<nsMediaList> mMedia;
   nsRefPtr<nsCSSStyleSheet> mNext;
   nsCSSStyleSheet*      mParent;    // weak ref
-  nsICSSImportRule*     mOwnerRule; // weak ref
+  mozilla::css::ImportRule* mOwnerRule; // weak ref
 
   CSSRuleListImpl*      mRuleCollection;
   nsIDocument*          mDocument; // weak ref; parents maintain this for their children
   nsIDOMNode*           mOwningNode; // weak ref
   PRPackedBool          mDisabled;
   PRPackedBool          mDirty; // has been modified 
 
   nsCSSStyleSheetInner* mInner;
--- a/layout/style/nsICSSRule.h
+++ b/layout/style/nsICSSRule.h
@@ -42,16 +42,17 @@
 
 #include "nsIStyleRule.h"
 #include "nsIDOMCSSRule.h"
 
 class nsCSSStyleSheet;
 class nsICSSGroupRule;
 class nsAString;
 template<class T> struct already_AddRefed;
+class nsIStyleSheet;
 
 // IID for the nsICSSRule interface
 #define NS_ICSS_RULE_IID \
 { 0x1f560b20, 0xa829, 0x4b99, \
   { 0x87, 0xbd, 0x8c, 0x87, 0x95, 0x2b, 0x3b, 0xb6 } }
 
 
 // inheriting from nsIStyleRule is only for style rules, not other rule types
--- a/layout/style/nsIStyleRule.h
+++ b/layout/style/nsIStyleRule.h
@@ -42,18 +42,16 @@
 
 #ifndef nsIStyleRule_h___
 #define nsIStyleRule_h___
 
 #include <stdio.h>
 
 #include "nsISupports.h"
 
-class nsIStyleSheet;
-class nsIContent;
 struct nsRuleData;
 
 // IID for the nsIStyleRule interface {f75f3f70-435d-43a6-a01b-65970489ca26}
 #define NS_ISTYLE_RULE_IID     \
 { 0xf75f3f70, 0x435d, 0x43a6, \
  { 0xa0, 0x1b, 0x65, 0x97, 0x04, 0x89, 0xca, 0x26 } }
 
 /**