From 435a97bcbe033dcea2ff5fc222dda94fb20df63c Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Thu, 17 Mar 2011 13:41:52 -0400 Subject: [PATCH] Bug 577002 Part 2: Remove nsICSSImportRule. r=bzbarsky --HG-- rename : layout/style/nsICSSImportRule.h => layout/style/ImportRule.h --- .../{nsICSSImportRule.h => ImportRule.h} | 67 ++++++++++++++----- layout/style/Loader.cpp | 7 +- layout/style/Loader.h | 6 +- layout/style/Makefile.in | 2 +- layout/style/nsCSSParser.cpp | 4 +- layout/style/nsCSSRules.cpp | 53 +-------------- layout/style/nsCSSStyleSheet.cpp | 17 +++-- layout/style/nsCSSStyleSheet.h | 17 +++-- layout/style/nsICSSRule.h | 1 + layout/style/nsIStyleRule.h | 2 - 10 files changed, 82 insertions(+), 94 deletions(-) rename layout/style/{nsICSSImportRule.h => ImportRule.h} (58%) diff --git a/layout/style/nsICSSImportRule.h b/layout/style/ImportRule.h similarity index 58% rename from layout/style/nsICSSImportRule.h rename to layout/style/ImportRule.h index 8c61da75a43..0c72c55c61c 100644 --- a/layout/style/nsICSSImportRule.h +++ b/layout/style/ImportRule.h @@ -35,38 +35,71 @@ * * ***** 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: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICSS_IMPORT_RULE_IID) + ImportRule(nsMediaList* aMedia); +private: + // for |Clone| + ImportRule(const ImportRule& aCopy); + ~ImportRule(); +public: + NS_DECL_ISUPPORTS - NS_IMETHOD SetURLSpec(const nsString& aURLSpec) = 0; - NS_IMETHOD GetURLSpec(nsString& aURLSpec) const = 0; + DECL_STYLE_RULE_INHERIT - NS_IMETHOD SetMedia(const nsString& aMedia) = 0; - NS_IMETHOD GetMedia(nsString& aMedia) const = 0; + // nsIStyleRule methods +#ifdef DEBUG + virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; +#endif - NS_IMETHOD SetSheet(nsCSSStyleSheet*) = 0; + // nsICSSRule methods + virtual PRInt32 GetType() const; + virtual already_AddRefed Clone() const; + + 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 + +private: + nsString mURLSpec; + nsRefPtr mMedia; + nsRefPtr 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__ */ diff --git a/layout/style/Loader.cpp b/layout/style/Loader.cpp index c81dbd2c3fc..4fdd7191f99 100644 --- a/layout/style/Loader.cpp +++ b/layout/style/Loader.cpp @@ -81,7 +81,7 @@ #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" @@ -93,7 +93,6 @@ #include "nsIMediaList.h" #include "nsIDOMStyleSheet.h" #include "nsIDOMCSSStyleSheet.h" -#include "nsIDOMCSSImportRule.h" #include "nsContentErrors.h" #include "nsIChannelPolicy.h" @@ -1343,7 +1342,7 @@ Loader::InsertSheetInDoc(nsCSSStyleSheet* aSheet, nsresult Loader::InsertChildSheet(nsCSSStyleSheet* aSheet, nsCSSStyleSheet* aParentSheet, - nsICSSImportRule* aParentRule) + ImportRule* aParentRule) { LOG(("css::Loader::InsertChildSheet")); NS_PRECONDITION(aSheet, "Nothing to insert"); @@ -1980,7 +1979,7 @@ 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"); diff --git a/layout/style/Loader.h b/layout/style/Loader.h index 5d05f751cb6..0b100321978 100644 --- a/layout/style/Loader.h +++ b/layout/style/Loader.h @@ -52,7 +52,6 @@ #include "nsURIHashKey.h" class nsIAtom; -class nsICSSImportRule; class nsICSSLoaderObserver; class nsCSSStyleSheet; class nsIContent; @@ -126,6 +125,7 @@ protected: namespace css { class SheetLoadData; +class ImportRule; /*********************************************************************** * Enum that describes the state of the sheet returned by CreateSheet. * @@ -232,7 +232,7 @@ public: nsresult LoadChildSheet(nsCSSStyleSheet* aParentSheet, nsIURI* aURL, nsMediaList* aMedia, - nsICSSImportRule* aRule); + ImportRule* aRule); /** * Synchronously load and return the stylesheet at aURL. Any child sheets @@ -408,7 +408,7 @@ private: nsresult InsertChildSheet(nsCSSStyleSheet* aSheet, nsCSSStyleSheet* aParentSheet, - nsICSSImportRule* aParentRule); + ImportRule* aParentRule); nsresult InternalLoadNonDocumentSheet(nsIURI* aURL, PRBool aAllowUnsafeRules, diff --git a/layout/style/Makefile.in b/layout/style/Makefile.in index babe64e58ae..9c72b690b16 100644 --- a/layout/style/Makefile.in +++ b/layout/style/Makefile.in @@ -74,7 +74,6 @@ EXPORTS = \ nsDOMCSSDeclaration.h \ nsICSSDeclaration.h \ nsICSSGroupRule.h \ - nsICSSImportRule.h \ nsICSSLoaderObserver.h \ nsICSSPseudoComparator.h \ nsICSSRule.h \ @@ -101,6 +100,7 @@ EXPORTS = \ EXPORTS_mozilla/css = \ Declaration.h \ + ImportRule.h \ Loader.h \ NameSpaceRule.h \ StyleRule.h \ diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index a12c1437707..51a3afd7b39 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -52,7 +52,7 @@ #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" @@ -1930,7 +1930,7 @@ CSSParserImpl::ProcessImport(const nsString& aURLSpec, RuleAppendFunc aAppendFunc, void* aData) { - nsCOMPtr rule; + nsRefPtr rule; nsresult rv = NS_NewCSSImportRule(getter_AddRefs(rule), aURLSpec, aMedia); if (NS_FAILED(rv)) { // out of memory mScanner.SetLowLevelError(rv); diff --git a/layout/style/nsCSSRules.cpp b/layout/style/nsCSSRules.cpp index 5153cf661ed..c80cd83bcdf 100644 --- a/layout/style/nsCSSRules.cpp +++ b/layout/style/nsCSSRules.cpp @@ -40,7 +40,7 @@ #include "nsCSSRules.h" #include "nsCSSValue.h" -#include "nsICSSImportRule.h" +#include "mozilla/css/ImportRule.h" #include "mozilla/css/NameSpaceRule.h" #include "nsString.h" @@ -52,7 +52,6 @@ #include "nsCOMPtr.h" #include "nsIDOMCSSStyleSheet.h" -#include "nsIDOMCSSImportRule.h" #include "nsIDOMCSSMediaRule.h" #include "nsIDOMCSSMozDocumentRule.h" #include "nsIDOMCSSCharsetRule.h" @@ -355,51 +354,6 @@ CSSCharsetRuleImpl::GetParentRule(nsIDOMCSSRule** aParentRule) 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 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 mMedia; - nsRefPtr mChildSheet; -}; - ImportRule::ImportRule(nsMediaList* aMedia) : nsCSSRule() , mURLSpec() @@ -434,12 +388,11 @@ 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 @@ -613,7 +566,7 @@ ImportRule::GetStyleSheet(nsIDOMCSSStyleSheet * *aStyleSheet) DOMCI_DATA(CSSImportRule, css::ImportRule) nsresult -NS_NewCSSImportRule(nsICSSImportRule** aInstancePtrResult, +NS_NewCSSImportRule(css::ImportRule** aInstancePtrResult, const nsString& aURLSpec, nsMediaList* aMedia) { diff --git a/layout/style/nsCSSStyleSheet.cpp b/layout/style/nsCSSStyleSheet.cpp index 6aaecd5d70c..8d2c5ce20c4 100644 --- a/layout/style/nsCSSStyleSheet.cpp +++ b/layout/style/nsCSSStyleSheet.cpp @@ -48,7 +48,7 @@ #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" @@ -56,7 +56,6 @@ #include "nsString.h" #include "nsTArray.h" #include "nsIDOMCSSStyleSheet.h" -#include "nsIDOMCSSImportRule.h" #include "nsICSSRuleList.h" #include "nsIDOMMediaList.h" #include "nsIDOMNode.h" @@ -862,7 +861,7 @@ nsCSSStyleSheet::RebuildChildList(nsICSSRule* aRule, void* aBuilder) static_cast(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 importRule(do_QueryInterface(aRule)); NS_ASSERTION(importRule, "GetType lied"); @@ -1013,7 +1012,7 @@ nsCSSStyleSheet::nsCSSStyleSheet() nsCSSStyleSheet::nsCSSStyleSheet(const nsCSSStyleSheet& aCopy, nsCSSStyleSheet* aParentToUse, - nsICSSImportRule* aOwnerRuleToUse, + css::ImportRule* aOwnerRuleToUse, nsIDocument* aDocumentToUse, nsIDOMNode* aOwningNodeToUse) : mTitle(aCopy.mTitle), @@ -1462,7 +1461,7 @@ nsCSSStyleSheet::AppendAllChildSheets(nsTArray& aArray) already_AddRefed nsCSSStyleSheet::Clone(nsCSSStyleSheet* aCloneParent, - nsICSSImportRule* aCloneOwnerRule, + css::ImportRule* aCloneOwnerRule, nsIDocument* aCloneDocument, nsIDOMNode* aCloneOwningNode) const { @@ -2070,14 +2069,14 @@ nsCSSStyleSheet::StyleSheetLoaded(nsCSSStyleSheet* aSheet, "We are being notified of a sheet load for a sheet that is not our child!"); if (mDocument && NS_SUCCEEDED(aStatus)) { - nsCOMPtr ownerRule = aSheet->GetOwnerRule(); - + nsRefPtr ownerRule = aSheet->GetOwnerRule(); + mozAutoDocUpdate updateBatch(mDocument, UPDATE_STYLE, PR_TRUE); // XXXldb @import rules shouldn't even implement nsIStyleRule (but // they do)! - nsCOMPtr styleRule(do_QueryInterface(ownerRule)); - + nsIStyleRule* styleRule = ownerRule; + mDocument->StyleRuleAdded(this, styleRule); } diff --git a/layout/style/nsCSSStyleSheet.h b/layout/style/nsCSSStyleSheet.h index 77f5ba8f0ee..99976c2ef31 100644 --- a/layout/style/nsCSSStyleSheet.h +++ b/layout/style/nsCSSStyleSheet.h @@ -57,7 +57,6 @@ class nsXMLNameSpaceMap; class nsCSSRuleProcessor; class nsMediaList; class nsICSSGroupRule; -class nsICSSImportRule; class nsIPrincipal; class nsIURI; class nsMediaList; @@ -66,6 +65,12 @@ class nsCSSStyleSheet; class nsPresContext; template class nsTArray; +namespace mozilla { +namespace css { +class ImportRule; +} +} + // ------------------------------- // CSS Style Sheet Inner Data Container // @@ -194,13 +199,13 @@ public: 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 Clone(nsCSSStyleSheet* aCloneParent, - nsICSSImportRule* aCloneOwnerRule, + mozilla::css::ImportRule* aCloneOwnerRule, nsIDocument* aCloneDocument, nsIDOMNode* aCloneOwningNode) const; @@ -255,7 +260,7 @@ public: private: nsCSSStyleSheet(const nsCSSStyleSheet& aCopy, nsCSSStyleSheet* aParentToUse, - nsICSSImportRule* aOwnerRuleToUse, + mozilla::css::ImportRule* aOwnerRuleToUse, nsIDocument* aDocumentToUse, nsIDOMNode* aOwningNodeToUse); @@ -284,7 +289,7 @@ protected: nsRefPtr mMedia; nsRefPtr 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 diff --git a/layout/style/nsICSSRule.h b/layout/style/nsICSSRule.h index 5bf95a20747..b8544c1f5a0 100644 --- a/layout/style/nsICSSRule.h +++ b/layout/style/nsICSSRule.h @@ -47,6 +47,7 @@ class nsCSSStyleSheet; class nsICSSGroupRule; class nsAString; template struct already_AddRefed; +class nsIStyleSheet; // IID for the nsICSSRule interface #define NS_ICSS_RULE_IID \ diff --git a/layout/style/nsIStyleRule.h b/layout/style/nsIStyleRule.h index 819f169f563..128542a694d 100644 --- a/layout/style/nsIStyleRule.h +++ b/layout/style/nsIStyleRule.h @@ -47,8 +47,6 @@ #include "nsISupports.h" -class nsIStyleSheet; -class nsIContent; struct nsRuleData; // IID for the nsIStyleRule interface {f75f3f70-435d-43a6-a01b-65970489ca26}