From c3d4c659c70b4c35a17089eb078a69f1df3adee1 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Thu, 7 Apr 2011 18:23:46 -0700 Subject: [PATCH] Bug 648925 - Part 1: Change uses of nsICSSRule to css::Rule. r=bzbarsky --- .../html/content/src/nsGenericHTMLElement.cpp | 4 +- .../src/nsHTMLFragmentContentSink.cpp | 8 +- content/xul/content/src/nsXULElement.cpp | 4 +- dom/base/nsDOMClassInfo.cpp | 1 - layout/mathml/nsMathMLFrame.cpp | 12 -- layout/style/GroupRule.h | 16 +-- layout/style/ImportRule.h | 6 +- layout/style/Makefile.in | 2 +- layout/style/NameSpaceRule.h | 8 +- layout/style/Rule.h | 44 ++++++- layout/style/StyleRule.cpp | 9 +- layout/style/StyleRule.h | 4 +- layout/style/nsAnimationManager.cpp | 4 +- layout/style/nsCSSParser.cpp | 34 +++--- layout/style/nsCSSParser.h | 4 +- layout/style/nsCSSRuleProcessor.cpp | 12 +- layout/style/nsCSSRules.cpp | 96 +++++++-------- layout/style/nsCSSRules.h | 32 ++--- layout/style/nsCSSStyleSheet.cpp | 106 ++++++++--------- layout/style/nsCSSStyleSheet.h | 18 +-- layout/style/nsDOMCSSDeclaration.cpp | 4 +- layout/style/nsDOMCSSDeclaration.h | 6 +- layout/style/nsFontFaceLoader.cpp | 2 +- layout/style/nsICSSRule.h | 112 ------------------ 24 files changed, 226 insertions(+), 322 deletions(-) delete mode 100644 layout/style/nsICSSRule.h diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 0da5c474f1b8..de962cd29c37 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -315,8 +315,8 @@ nsGenericHTMLElement::CopyInnerTo(nsGenericElement* aDst) const value->Type() == nsAttrValue::eCSSStyleRule) { // We can't just set this as a string, because that will fail // to reparse the string into style data until the node is - // inserted into the document. Clone the nsICSSRule instead. - nsCOMPtr ruleClone = value->GetCSSStyleRuleValue()->Clone(); + // inserted into the document. Clone the Rule instead. + nsRefPtr ruleClone = value->GetCSSStyleRuleValue()->Clone(); nsRefPtr styleRule = do_QueryObject(ruleClone); NS_ENSURE_TRUE(styleRule, NS_ERROR_UNEXPECTED); diff --git a/content/html/document/src/nsHTMLFragmentContentSink.cpp b/content/html/document/src/nsHTMLFragmentContentSink.cpp index 2d4f14a21fee..b47eb478c18d 100644 --- a/content/html/document/src/nsHTMLFragmentContentSink.cpp +++ b/content/html/document/src/nsHTMLFragmentContentSink.cpp @@ -1180,7 +1180,7 @@ nsHTMLParanoidFragmentSink::CloseContainer(const nsHTMLTag aTag) // Loop through all the rules found in the CSS text PRInt32 ruleCount = sheet->StyleRuleCount(); for (PRInt32 i = 0; i < ruleCount; ++i) { - nsRefPtr rule; + nsRefPtr rule; rv = sheet->GetStyleRuleAt(i, *getter_AddRefs(rule)); if (NS_FAILED(rv)) continue; @@ -1190,8 +1190,8 @@ nsHTMLParanoidFragmentSink::CloseContainer(const nsHTMLTag aTag) didSanitize = PR_TRUE; // Ignore these rule types. break; - case nsICSSRule::NAMESPACE_RULE: - case nsICSSRule::FONT_FACE_RULE: { + case css::Rule::NAMESPACE_RULE: + case css::Rule::FONT_FACE_RULE: { // Append @namespace and @font-face rules verbatim. nsAutoString cssText; nsCOMPtr styleRule = do_QueryInterface(rule); @@ -1203,7 +1203,7 @@ nsHTMLParanoidFragmentSink::CloseContainer(const nsHTMLTag aTag) } break; } - case nsICSSRule::STYLE_RULE: { + case css::Rule::STYLE_RULE: { // For style rules, we will just look for and remove the // -moz-binding properties. nsRefPtr styleRule = do_QueryObject(rule); diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index 24d9b857e259..f09f322b49b6 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -1960,7 +1960,7 @@ nsXULElement::EnsureLocalStyle() nsXULPrototypeAttribute *protoattr = FindPrototypeAttribute(kNameSpaceID_None, nsGkAtoms::style); if (protoattr && protoattr->mValue.Type() == nsAttrValue::eCSSStyleRule) { - nsCOMPtr ruleClone = + nsRefPtr ruleClone = protoattr->mValue.GetCSSStyleRuleValue()->Clone(); nsString stringValue; @@ -2339,7 +2339,7 @@ nsresult nsXULElement::MakeHeavyweight() // Style rules need to be cloned. if (protoattr->mValue.Type() == nsAttrValue::eCSSStyleRule) { - nsCOMPtr ruleClone = + nsRefPtr ruleClone = protoattr->mValue.GetCSSStyleRuleValue()->Clone(); nsString stringValue; diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index e2ba752a2cf3..163610c8de80 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -179,7 +179,6 @@ #include "nsIDOMStyleSheetList.h" #include "nsIDOMCSSStyleDeclaration.h" #include "nsIDOMCSSRule.h" -#include "nsICSSRule.h" #include "nsICSSRuleList.h" #include "nsIDOMRect.h" #include "nsIDOMRGBColor.h" diff --git a/layout/mathml/nsMathMLFrame.cpp b/layout/mathml/nsMathMLFrame.cpp index ee660e57ed72..a02e059de5a2 100644 --- a/layout/mathml/nsMathMLFrame.cpp +++ b/layout/mathml/nsMathMLFrame.cpp @@ -42,21 +42,9 @@ #include "nsCSSPseudoElements.h" // used to map attributes into CSS rules -#include "nsIDocument.h" #include "nsStyleSet.h" -#include "nsIStyleSheet.h" -#include "nsIDOMCSSStyleSheet.h" -#include "nsICSSRule.h" -#include "nsStyleChangeList.h" -#include "nsFrameManager.h" -#include "nsNetUtil.h" -#include "nsIURI.h" -#include "nsContentCID.h" #include "nsAutoPtr.h" -#include "nsStyleSet.h" -#include "nsStyleUtil.h" #include "nsDisplayList.h" -#include "nsAttrName.h" #include "nsRenderingContext.h" eMathMLFrameType diff --git a/layout/style/GroupRule.h b/layout/style/GroupRule.h index 8f61f62c55e0..e8f2ec4ae7b2 100644 --- a/layout/style/GroupRule.h +++ b/layout/style/GroupRule.h @@ -43,7 +43,7 @@ #ifndef mozilla_css_GroupRule_h__ #define mozilla_css_GroupRule_h__ -#include "Rule.h" +#include "mozilla/css/Rule.h" #include "nsCOMArray.h" #include "nsAutoPtr.h" @@ -65,7 +65,7 @@ protected: virtual ~GroupRule(); public: - // implement part of nsIStyleRule and nsICSSRule + // implement part of nsIStyleRule and Rule DECL_STYLE_RULE_INHERIT_NO_DOMRULE virtual void SetStyleSheet(nsCSSStyleSheet* aSheet); @@ -75,12 +75,12 @@ public: #endif public: - void AppendStyleRule(nsICSSRule* aRule); + void AppendStyleRule(Rule* aRule); PRInt32 StyleRuleCount() const { return mRules.Count(); } - nsICSSRule* GetStyleRuleAt(PRInt32 aIndex) const; + Rule* GetStyleRuleAt(PRInt32 aIndex) const; - typedef nsCOMArray::nsCOMArrayEnumFunc RuleEnumFunc; + typedef nsCOMArray::nsCOMArrayEnumFunc RuleEnumFunc; PRBool EnumerateRulesForwards(RuleEnumFunc aFunc, void * aData) const; /* @@ -90,8 +90,8 @@ public: */ nsresult DeleteStyleRuleAt(PRUint32 aIndex); nsresult InsertStyleRulesAt(PRUint32 aIndex, - nsCOMArray& aRules); - nsresult ReplaceStyleRule(nsICSSRule *aOld, nsICSSRule *aNew); + nsCOMArray& aRules); + nsresult ReplaceStyleRule(Rule *aOld, Rule *aNew); virtual PRBool UseForPresentation(nsPresContext* aPresContext, nsMediaQueryResultCacheKey& aKey) = 0; @@ -109,7 +109,7 @@ protected: PRUint32* _retval); nsresult DeleteRule(PRUint32 aIndex); - nsCOMArray mRules; + nsCOMArray mRules; nsRefPtr mRuleCollection; // lazily constructed }; diff --git a/layout/style/ImportRule.h b/layout/style/ImportRule.h index 2a366c5208b6..b1903fd8bb10 100644 --- a/layout/style/ImportRule.h +++ b/layout/style/ImportRule.h @@ -40,7 +40,7 @@ #ifndef mozilla_css_ImportRule_h__ #define mozilla_css_ImportRule_h__ -#include "Rule.h" +#include "mozilla/css/Rule.h" #include "nsIDOMCSSImportRule.h" #include "nsCSSRules.h" @@ -73,9 +73,9 @@ public: virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; #endif - // nsICSSRule methods + // Rule methods virtual PRInt32 GetType() const; - virtual already_AddRefed Clone() const; + virtual already_AddRefed Clone() const; void SetSheet(nsCSSStyleSheet*); diff --git a/layout/style/Makefile.in b/layout/style/Makefile.in index c1b629537729..330fe21321e5 100644 --- a/layout/style/Makefile.in +++ b/layout/style/Makefile.in @@ -75,7 +75,6 @@ EXPORTS = \ nsICSSDeclaration.h \ nsICSSLoaderObserver.h \ nsICSSPseudoComparator.h \ - nsICSSRule.h \ nsICSSRuleList.h \ nsICSSStyleRuleDOMWrapper.h \ nsIStyleRule.h \ @@ -103,6 +102,7 @@ EXPORTS_mozilla/css = \ ImportRule.h \ Loader.h \ NameSpaceRule.h \ + Rule.h \ StyleRule.h \ $(NULL) diff --git a/layout/style/NameSpaceRule.h b/layout/style/NameSpaceRule.h index 03e827b3ec44..48976ef22dba 100644 --- a/layout/style/NameSpaceRule.h +++ b/layout/style/NameSpaceRule.h @@ -40,12 +40,12 @@ #ifndef mozilla_css_NameSpaceRule_h__ #define mozilla_css_NameSpaceRule_h__ -#include "Rule.h" +#include "mozilla/css/Rule.h" #include "nsIDOMCSSRule.h" class nsIAtom; -// IID for the nsCSSNameSpaceRule class {f0b0dbe1-5031-4a21-b06a-dc141ef2af98} +// IID for the NameSpaceRule class {f0b0dbe1-5031-4a21-b06a-dc141ef2af98} #define NS_CSS_NAMESPACE_RULE_IMPL_CID \ {0xf0b0dbe1, 0x5031, 0x4a21, {0xb0, 0x6a, 0xdc, 0x14, 0x1e, 0xf2, 0xaf, 0x98}} @@ -74,9 +74,9 @@ public: virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; #endif - // nsICSSRule methods + // Rule methods virtual PRInt32 GetType() const; - virtual already_AddRefed Clone() const; + virtual already_AddRefed Clone() const; nsIAtom* GetPrefix() const { return mPrefix; } diff --git a/layout/style/Rule.h b/layout/style/Rule.h index 75afbd1d567f..6a908d927cae 100644 --- a/layout/style/Rule.h +++ b/layout/style/Rule.h @@ -40,7 +40,8 @@ #ifndef mozilla_css_Rule_h___ #define mozilla_css_Rule_h___ -#include "nsICSSRule.h" +#include "nsIStyleRule.h" +#include "nsIDOMCSSRule.h" class nsIStyleSheet; class nsCSSStyleSheet; @@ -58,7 +59,7 @@ virtual void MapRuleInfoInto(nsRuleData* aRuleData); DECL_STYLE_RULE_INHERIT_NO_DOMRULE \ virtual nsIDOMCSSRule* GetDOMRuleWeak(nsresult* aResult); -class Rule : public nsICSSRule { +class Rule : public nsIStyleRule { protected: Rule() : mSheet(nsnull), @@ -83,11 +84,48 @@ protected: NS_DECL_OWNINGTHREAD 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 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, + FONT_FACE_RULE, + PAGE_RULE, +#ifdef MOZ_CSS_ANIMATIONS + KEYFRAME_RULE, + KEYFRAMES_RULE, +#endif + DOCUMENT_RULE + }; + + virtual PRInt32 GetType() const = 0; + virtual nsIStyleSheet* GetStyleSheet() const; virtual void SetStyleSheet(nsCSSStyleSheet* aSheet); - virtual void SetParentRule(GroupRule* aRule); + /** + * Clones |this|. Never returns NULL. + */ + virtual already_AddRefed Clone() const = 0; + + // Note that this returns null for inline style rules since they aren't + // supposed to have a DOM rule representation (and our code wouldn't work). + nsresult GetDOMRule(nsIDOMCSSRule** aDOMRule) + { + nsresult rv; + NS_IF_ADDREF(*aDOMRule = GetDOMRuleWeak(&rv)); + return rv; + } + virtual nsIDOMCSSRule* GetDOMRuleWeak(nsresult* aResult) = 0; + protected: nsCSSStyleSheet* mSheet; GroupRule* mParentRule; diff --git a/layout/style/StyleRule.cpp b/layout/style/StyleRule.cpp index 905d152aac8f..f17a2b007e1e 100644 --- a/layout/style/StyleRule.cpp +++ b/layout/style/StyleRule.cpp @@ -1306,9 +1306,8 @@ NS_INTERFACE_MAP_BEGIN(StyleRule) return NS_OK; } else - NS_INTERFACE_MAP_ENTRY(nsICSSRule) NS_INTERFACE_MAP_ENTRY(nsIStyleRule) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICSSRule) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule) NS_INTERFACE_MAP_END NS_IMPL_ADDREF_INHERITED(StyleRule, Rule) @@ -1336,13 +1335,13 @@ StyleRule::RuleMatched() /* virtual */ PRInt32 StyleRule::GetType() const { - return nsICSSRule::STYLE_RULE; + return Rule::STYLE_RULE; } -/* virtual */ already_AddRefed +/* virtual */ already_AddRefed StyleRule::Clone() const { - nsCOMPtr clone = new StyleRule(*this); + nsRefPtr clone = new StyleRule(*this); return clone.forget(); } diff --git a/layout/style/StyleRule.h b/layout/style/StyleRule.h index ccea1697fc83..0bac085e8c2e 100644 --- a/layout/style/StyleRule.h +++ b/layout/style/StyleRule.h @@ -46,7 +46,7 @@ #define mozilla_css_StyleRule_h__ //#include -#include "Rule.h" +#include "mozilla/css/Rule.h" #include "nsString.h" #include "nsCOMPtr.h" #include "nsCSSPseudoElements.h" @@ -348,7 +348,7 @@ public: virtual PRInt32 GetType() const; - virtual already_AddRefed Clone() const; + virtual already_AddRefed Clone() const; nsIDOMCSSRule* GetDOMRuleWeak(nsresult* aResult); diff --git a/layout/style/nsAnimationManager.cpp b/layout/style/nsAnimationManager.cpp index f0d4becc47cc..6024a7371647 100644 --- a/layout/style/nsAnimationManager.cpp +++ b/layout/style/nsAnimationManager.cpp @@ -670,9 +670,9 @@ nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext, keyframes.Init(16); // FIXME: make infallible! for (PRUint32 ruleIdx = 0, ruleEnd = rule->StyleRuleCount(); ruleIdx != ruleEnd; ++ruleIdx) { - nsICSSRule* cssRule = rule->GetStyleRuleAt(ruleIdx); + css::Rule* cssRule = rule->GetStyleRuleAt(ruleIdx); NS_ABORT_IF_FALSE(cssRule, "must have rule"); - NS_ABORT_IF_FALSE(cssRule->GetType() == nsICSSRule::KEYFRAME_RULE, + NS_ABORT_IF_FALSE(cssRule->GetType() == css::Rule::KEYFRAME_RULE, "must be keyframe rule"); nsCSSKeyframeRule *kfRule = static_cast(cssRule); diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index bd6c0fb7a81c..5f17d5852f7a 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -178,9 +178,9 @@ nsCSSProps::kParserVariantTable[eCSSProperty_COUNT_no_shorthands] = { namespace { // Rule processing function -typedef void (* RuleAppendFunc) (nsICSSRule* aRule, void* aData); -static void AppendRuleToArray(nsICSSRule* aRule, void* aArray); -static void AppendRuleToSheet(nsICSSRule* aRule, void* aParser); +typedef void (* RuleAppendFunc) (css::Rule* aRule, void* aData); +static void AppendRuleToArray(css::Rule* aRule, void* aArray); +static void AppendRuleToSheet(css::Rule* aRule, void* aParser); // Your basic top-down recursive descent style parser // The exposed methods and members of this class are precisely those @@ -227,7 +227,7 @@ public: nsIURI* aSheetURL, nsIURI* aBaseURL, nsIPrincipal* aSheetPrincipal, - nsCOMArray& aResult); + nsCOMArray& aResult); nsresult ParseProperty(const nsCSSProperty aPropID, const nsAString& aPropValue, @@ -270,8 +270,8 @@ protected: class nsAutoParseCompoundProperty; friend class nsAutoParseCompoundProperty; - void AppendRule(nsICSSRule* aRule); - friend void AppendRuleToSheet(nsICSSRule*, void*); // calls AppendRule + void AppendRule(css::Rule* aRule); + friend void AppendRuleToSheet(css::Rule*, void*); // calls AppendRule /** * This helper class automatically calls SetParsingCompoundProperty in its @@ -703,12 +703,12 @@ public: CSSParserImpl* mNextFree; }; -static void AppendRuleToArray(nsICSSRule* aRule, void* aArray) +static void AppendRuleToArray(css::Rule* aRule, void* aArray) { - static_cast*>(aArray)->AppendObject(aRule); + static_cast*>(aArray)->AppendObject(aRule); } -static void AppendRuleToSheet(nsICSSRule* aRule, void* aParser) +static void AppendRuleToSheet(css::Rule* aRule, void* aParser) { CSSParserImpl* parser = (CSSParserImpl*) aParser; parser->AppendRule(aRule); @@ -921,15 +921,15 @@ CSSParserImpl::Parse(nsIUnicharInputStream* aInput, PRInt32 ruleCount = mSheet->StyleRuleCount(); if (0 < ruleCount) { - nsICSSRule* lastRule = nsnull; + css::Rule* lastRule = nsnull; mSheet->GetStyleRuleAt(ruleCount - 1, lastRule); if (lastRule) { switch (lastRule->GetType()) { - case nsICSSRule::CHARSET_RULE: - case nsICSSRule::IMPORT_RULE: + case css::Rule::CHARSET_RULE: + case css::Rule::IMPORT_RULE: mSection = eCSSSection_Import; break; - case nsICSSRule::NAMESPACE_RULE: + case css::Rule::NAMESPACE_RULE: mSection = eCSSSection_NameSpace; break; default: @@ -1076,7 +1076,7 @@ CSSParserImpl::ParseRule(const nsAString& aRule, nsIURI* aSheetURI, nsIURI* aBaseURI, nsIPrincipal* aSheetPrincipal, - nsCOMArray& aResult) + nsCOMArray& aResult) { NS_PRECONDITION(aSheetPrincipal, "Must have principal here!"); AssertInitialState(); @@ -1646,7 +1646,7 @@ CSSParserImpl::ParseCharsetRule(RuleAppendFunc aAppendFunc, return PR_FALSE; } - nsCOMPtr rule = new css::CharsetRule(charset); + nsRefPtr rule = new css::CharsetRule(charset); (*aAppendFunc)(rule, aData); return PR_TRUE; @@ -2582,7 +2582,7 @@ CSSParserImpl::PopGroup() } void -CSSParserImpl::AppendRule(nsICSSRule* aRule) +CSSParserImpl::AppendRule(css::Rule* aRule) { PRUint32 count = mGroupStack.Length(); if (0 < count) { @@ -8804,7 +8804,7 @@ nsCSSParser::ParseRule(const nsAString& aRule, nsIURI* aSheetURI, nsIURI* aBaseURI, nsIPrincipal* aSheetPrincipal, - nsCOMArray& aResult) + nsCOMArray& aResult) { return static_cast(mImpl)-> ParseRule(aRule, aSheetURI, aBaseURI, aSheetPrincipal, aResult); diff --git a/layout/style/nsCSSParser.h b/layout/style/nsCSSParser.h index 696ea1b331ad..93d472294d7c 100644 --- a/layout/style/nsCSSParser.h +++ b/layout/style/nsCSSParser.h @@ -46,7 +46,6 @@ #include "nsCOMArray.h" #include "nsCOMPtr.h" -class nsICSSRule; class nsCSSStyleSheet; class nsIPrincipal; class nsIURI; @@ -59,6 +58,7 @@ class nsCSSKeyframeRule; namespace mozilla { namespace css { +class Rule; class Declaration; class Loader; class StyleRule; @@ -145,7 +145,7 @@ public: nsIURI* aSheetURL, nsIURI* aBaseURL, nsIPrincipal* aSheetPrincipal, - nsCOMArray& aResult); + nsCOMArray& aResult); nsresult ParseProperty(const nsCSSProperty aPropID, const nsAString& aPropValue, diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp index 8127df965c31..aa1f247b3ea2 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -2822,12 +2822,12 @@ struct CascadeEnumData { * (3) add any @keyframes rules, in order, into data->mKeyframesRules. */ static PRBool -CascadeRuleEnumFunc(nsICSSRule* aRule, void* aData) +CascadeRuleEnumFunc(css::Rule* aRule, void* aData) { CascadeEnumData* data = (CascadeEnumData*)aData; PRInt32 type = aRule->GetType(); - if (nsICSSRule::STYLE_RULE == type) { + if (css::Rule::STYLE_RULE == type) { css::StyleRule* styleRule = static_cast(aRule); for (nsCSSSelectorList *sel = styleRule->Selector(); @@ -2844,14 +2844,14 @@ CascadeRuleEnumFunc(nsICSSRule* aRule, void* aData) sel->mSelectors)); } } - else if (nsICSSRule::MEDIA_RULE == type || - nsICSSRule::DOCUMENT_RULE == type) { + else if (css::Rule::MEDIA_RULE == type || + css::Rule::DOCUMENT_RULE == type) { css::GroupRule* groupRule = static_cast(aRule); if (groupRule->UseForPresentation(data->mPresContext, data->mCacheKey)) if (!groupRule->EnumerateRulesForwards(CascadeRuleEnumFunc, aData)) return PR_FALSE; } - else if (nsICSSRule::FONT_FACE_RULE == type) { + else if (css::Rule::FONT_FACE_RULE == type) { nsCSSFontFaceRule *fontFaceRule = static_cast(aRule); nsFontFaceRuleContainer *ptr = data->mFontFaceRules.AppendElement(); if (!ptr) @@ -2860,7 +2860,7 @@ CascadeRuleEnumFunc(nsICSSRule* aRule, void* aData) ptr->mSheetType = data->mSheetType; } #ifdef MOZ_CSS_ANIMATIONS - else if (nsICSSRule::KEYFRAMES_RULE == type) { + else if (css::Rule::KEYFRAMES_RULE == type) { nsCSSKeyframesRule *keyframesRule = static_cast(aRule); if (!data->mKeyframesRules.AppendElement(keyframesRule)) { diff --git a/layout/style/nsCSSRules.cpp b/layout/style/nsCSSRules.cpp index 48eb670d365e..803d8dc2888e 100644 --- a/layout/style/nsCSSRules.cpp +++ b/layout/style/nsCSSRules.cpp @@ -182,7 +182,7 @@ GroupRuleRuleList::GetItemAt(PRUint32 aIndex, nsresult* aResult) *aResult = NS_OK; if (mGroupRule) { - nsCOMPtr rule = mGroupRule->GetStyleRuleAt(aIndex); + nsRefPtr rule = mGroupRule->GetStyleRuleAt(aIndex); if (rule) { return rule->GetDOMRuleWeak(aResult); } @@ -238,11 +238,10 @@ NS_IMPL_RELEASE_INHERITED(CharsetRule, css::Rule) // QueryInterface implementation for CharsetRule NS_INTERFACE_MAP_BEGIN(CharsetRule) - NS_INTERFACE_MAP_ENTRY(nsICSSRule) NS_INTERFACE_MAP_ENTRY(nsIStyleRule) NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule) NS_INTERFACE_MAP_ENTRY(nsIDOMCSSCharsetRule) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICSSRule) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSCharsetRule) NS_INTERFACE_MAP_END @@ -264,13 +263,13 @@ CharsetRule::List(FILE* out, PRInt32 aIndent) const /* virtual */ PRInt32 CharsetRule::GetType() const { - return nsICSSRule::CHARSET_RULE; + return Rule::CHARSET_RULE; } -/* virtual */ already_AddRefed +/* virtual */ already_AddRefed CharsetRule::Clone() const { - nsCOMPtr clone = new CharsetRule(*this); + nsRefPtr clone = new CharsetRule(*this); return clone.forget(); } @@ -372,11 +371,10 @@ NS_IMPL_RELEASE_INHERITED(ImportRule, Rule) // QueryInterface implementation for ImportRule NS_INTERFACE_MAP_BEGIN(ImportRule) - 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, nsICSSRule) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSImportRule) NS_INTERFACE_MAP_END @@ -403,13 +401,13 @@ ImportRule::List(FILE* out, PRInt32 aIndent) const /* virtual */ PRInt32 ImportRule::GetType() const { - return nsICSSRule::IMPORT_RULE; + return Rule::IMPORT_RULE; } -/* virtual */ already_AddRefed +/* virtual */ already_AddRefed ImportRule::Clone() const { - nsCOMPtr clone = new ImportRule(*this); + nsRefPtr clone = new ImportRule(*this); return clone.forget(); } @@ -512,10 +510,10 @@ ImportRule::GetStyleSheet(nsIDOMCSSStyleSheet * *aStyleSheet) DOMCI_DATA(CSSImportRule, css::ImportRule) static PRBool -CloneRuleInto(nsICSSRule* aRule, void* aArray) +CloneRuleInto(css::Rule* aRule, void* aArray) { - nsCOMPtr clone = aRule->Clone(); - static_cast*>(aArray)->AppendObject(clone); + nsRefPtr clone = aRule->Clone(); + static_cast*>(aArray)->AppendObject(clone); return PR_TRUE; } @@ -528,7 +526,7 @@ GroupRule::GroupRule() } static PRBool -SetParentRuleReference(nsICSSRule* aRule, void* aParentRule) +SetParentRuleReference(Rule* aRule, void* aParentRule) { GroupRule* parentRule = static_cast(aParentRule); aRule->SetParentRule(parentRule); @@ -554,7 +552,7 @@ GroupRule::~GroupRule() IMPL_STYLE_RULE_INHERIT_MAP_RULE_INFO_INTO(GroupRule, Rule) static PRBool -SetStyleSheetReference(nsICSSRule* aRule, void* aSheet) +SetStyleSheetReference(Rule* aRule, void* aSheet) { nsCSSStyleSheet* sheet = (nsCSSStyleSheet*)aSheet; aRule->SetStyleSheet(sheet); @@ -582,7 +580,7 @@ GroupRule::List(FILE* out, PRInt32 aIndent) const #endif void -GroupRule::AppendStyleRule(nsICSSRule* aRule) +GroupRule::AppendStyleRule(Rule* aRule) { mRules.AppendObject(aRule); aRule->SetStyleSheet(mSheet); @@ -592,7 +590,7 @@ GroupRule::AppendStyleRule(nsICSSRule* aRule) } } -nsICSSRule* +Rule* GroupRule::GetStyleRuleAt(PRInt32 aIndex) const { return mRules.SafeObjectAt(aIndex); @@ -614,7 +612,7 @@ GroupRule::EnumerateRulesForwards(RuleEnumFunc aFunc, void * aData) const nsresult GroupRule::DeleteStyleRuleAt(PRUint32 aIndex) { - nsICSSRule* rule = mRules.SafeObjectAt(aIndex); + Rule* rule = mRules.SafeObjectAt(aIndex); if (rule) { rule->SetStyleSheet(nsnull); rule->SetParentRule(nsnull); @@ -624,7 +622,7 @@ GroupRule::DeleteStyleRuleAt(PRUint32 aIndex) nsresult GroupRule::InsertStyleRulesAt(PRUint32 aIndex, - nsCOMArray& aRules) + nsCOMArray& aRules) { aRules.EnumerateForwards(SetStyleSheetReference, mSheet); aRules.EnumerateForwards(SetParentRuleReference, this); @@ -635,7 +633,7 @@ GroupRule::InsertStyleRulesAt(PRUint32 aIndex, } nsresult -GroupRule::ReplaceStyleRule(nsICSSRule* aOld, nsICSSRule* aNew) +GroupRule::ReplaceStyleRule(Rule* aOld, Rule* aNew) { PRInt32 index = mRules.IndexOf(aOld); NS_ENSURE_TRUE(index != -1, NS_ERROR_UNEXPECTED); @@ -654,7 +652,7 @@ GroupRule::AppendRulesToCssText(nsAString& aCssText) // get all the rules for (PRInt32 index = 0, count = mRules.Count(); index < count; ++index) { - nsICSSRule* rule = mRules.ObjectAt(index); + Rule* rule = mRules.ObjectAt(index); nsCOMPtr domRule; rule->GetDOMRule(getter_AddRefs(domRule)); if (domRule) { @@ -752,11 +750,10 @@ NS_IMPL_RELEASE_INHERITED(MediaRule, Rule) // QueryInterface implementation for MediaRule NS_INTERFACE_MAP_BEGIN(MediaRule) - NS_INTERFACE_MAP_ENTRY(nsICSSRule) NS_INTERFACE_MAP_ENTRY(nsIStyleRule) NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule) NS_INTERFACE_MAP_ENTRY(nsIDOMCSSMediaRule) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICSSRule) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSMediaRule) NS_INTERFACE_MAP_END @@ -795,13 +792,13 @@ MediaRule::List(FILE* out, PRInt32 aIndent) const /* virtual */ PRInt32 MediaRule::GetType() const { - return nsICSSRule::MEDIA_RULE; + return Rule::MEDIA_RULE; } -/* virtual */ already_AddRefed +/* virtual */ already_AddRefed MediaRule::Clone() const { - nsCOMPtr clone = new MediaRule(*this); + nsRefPtr clone = new MediaRule(*this); return clone.forget(); } @@ -922,11 +919,10 @@ NS_IMPL_RELEASE_INHERITED(DocumentRule, Rule) // QueryInterface implementation for DocumentRule NS_INTERFACE_MAP_BEGIN(DocumentRule) - NS_INTERFACE_MAP_ENTRY(nsICSSRule) NS_INTERFACE_MAP_ENTRY(nsIStyleRule) NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule) NS_INTERFACE_MAP_ENTRY(nsIDOMCSSMozDocumentRule) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICSSRule) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSMozDocumentRule) NS_INTERFACE_MAP_END @@ -967,13 +963,13 @@ DocumentRule::List(FILE* out, PRInt32 aIndent) const /* virtual */ PRInt32 DocumentRule::GetType() const { - return nsICSSRule::DOCUMENT_RULE; + return Rule::DOCUMENT_RULE; } -/* virtual */ already_AddRefed +/* virtual */ already_AddRefed DocumentRule::Clone() const { - nsCOMPtr clone = new DocumentRule(*this); + nsRefPtr clone = new DocumentRule(*this); return clone.forget(); } @@ -1147,10 +1143,9 @@ NS_INTERFACE_MAP_BEGIN(NameSpaceRule) return NS_OK; } else - NS_INTERFACE_MAP_ENTRY(nsICSSRule) NS_INTERFACE_MAP_ENTRY(nsIStyleRule) NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICSSRule) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSNameSpaceRule) NS_INTERFACE_MAP_END @@ -1181,13 +1176,13 @@ NameSpaceRule::List(FILE* out, PRInt32 aIndent) const /* virtual */ PRInt32 NameSpaceRule::GetType() const { - return nsICSSRule::NAMESPACE_RULE; + return Rule::NAMESPACE_RULE; } -/* virtual */ already_AddRefed +/* virtual */ already_AddRefed NameSpaceRule::Clone() const { - nsCOMPtr clone = new NameSpaceRule(*this); + nsRefPtr clone = new NameSpaceRule(*this); return clone.forget(); } @@ -1574,10 +1569,10 @@ nsCSSFontFaceStyleDecl::GetParentRule(nsIDOMCSSRule** aParentRule) // nsCSSFontFaceRule // -/* virtual */ already_AddRefed +/* virtual */ already_AddRefed nsCSSFontFaceRule::Clone() const { - nsCOMPtr clone = new nsCSSFontFaceRule(*this); + nsRefPtr clone = new nsCSSFontFaceRule(*this); return clone.forget(); } @@ -1588,11 +1583,10 @@ DOMCI_DATA(CSSFontFaceRule, nsCSSFontFaceRule) // QueryInterface implementation for nsCSSFontFaceRule NS_INTERFACE_MAP_BEGIN(nsCSSFontFaceRule) - NS_INTERFACE_MAP_ENTRY(nsICSSRule) NS_INTERFACE_MAP_ENTRY(nsIStyleRule) NS_INTERFACE_MAP_ENTRY(nsIDOMCSSFontFaceRule) NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICSSRule) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSFontFaceRule) NS_INTERFACE_MAP_END @@ -1632,7 +1626,7 @@ nsCSSFontFaceRule::List(FILE* out, PRInt32 aIndent) const /* virtual */ PRInt32 nsCSSFontFaceRule::GetType() const { - return nsICSSRule::FONT_FACE_RULE; + return css::Rule::FONT_FACE_RULE; } NS_IMETHODIMP @@ -1783,10 +1777,10 @@ nsCSSKeyframeRule::~nsCSSKeyframeRule() } } -/* virtual */ already_AddRefed +/* virtual */ already_AddRefed nsCSSKeyframeRule::Clone() const { - nsCOMPtr clone = new nsCSSKeyframeRule(*this); + nsRefPtr clone = new nsCSSKeyframeRule(*this); return clone.forget(); } @@ -1797,11 +1791,10 @@ DOMCI_DATA(MozCSSKeyframeRule, nsCSSKeyframeRule) // QueryInterface implementation for nsCSSKeyframeRule NS_INTERFACE_MAP_BEGIN(nsCSSKeyframeRule) - NS_INTERFACE_MAP_ENTRY(nsICSSRule) NS_INTERFACE_MAP_ENTRY(nsIStyleRule) NS_INTERFACE_MAP_ENTRY(nsIDOMMozCSSKeyframeRule) NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICSSRule) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozCSSKeyframeRule) NS_INTERFACE_MAP_END @@ -1833,7 +1826,7 @@ nsCSSKeyframeRule::List(FILE* out, PRInt32 aIndent) const /* virtual */ PRInt32 nsCSSKeyframeRule::GetType() const { - return nsICSSRule::KEYFRAME_RULE; + return css::Rule::KEYFRAME_RULE; } NS_IMETHODIMP @@ -1953,10 +1946,10 @@ nsCSSKeyframesRule::~nsCSSKeyframesRule() { } -/* virtual */ already_AddRefed +/* virtual */ already_AddRefed nsCSSKeyframesRule::Clone() const { - nsCOMPtr clone = new nsCSSKeyframesRule(*this); + nsRefPtr clone = new nsCSSKeyframesRule(*this); return clone.forget(); } @@ -1967,11 +1960,10 @@ DOMCI_DATA(MozCSSKeyframesRule, nsCSSKeyframesRule) // QueryInterface implementation for nsCSSKeyframesRule NS_INTERFACE_MAP_BEGIN(nsCSSKeyframesRule) - NS_INTERFACE_MAP_ENTRY(nsICSSRule) NS_INTERFACE_MAP_ENTRY(nsIStyleRule) NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule) NS_INTERFACE_MAP_ENTRY(nsIDOMMozCSSKeyframesRule) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICSSRule) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozCSSKeyframesRule) NS_INTERFACE_MAP_END @@ -1986,7 +1978,7 @@ nsCSSKeyframesRule::List(FILE* out, PRInt32 aIndent) const /* virtual */ PRInt32 nsCSSKeyframesRule::GetType() const { - return nsICSSRule::KEYFRAMES_RULE; + return css::Rule::KEYFRAMES_RULE; } NS_IMETHODIMP diff --git a/layout/style/nsCSSRules.h b/layout/style/nsCSSRules.h index 742b26bd65c8..61335dc550e0 100644 --- a/layout/style/nsCSSRules.h +++ b/layout/style/nsCSSRules.h @@ -43,7 +43,6 @@ #ifndef nsCSSRules_h_ #define nsCSSRules_h_ -#include "Rule.h" #include "mozilla/css/GroupRule.h" #include "nsIDOMCSSMediaRule.h" #include "nsIDOMCSSMozDocumentRule.h" @@ -90,10 +89,10 @@ public: virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; #endif - // nsICSSRule methods + // Rule methods virtual void SetStyleSheet(nsCSSStyleSheet* aSheet); //override GroupRule virtual PRInt32 GetType() const; - virtual already_AddRefed Clone() const; + virtual already_AddRefed Clone() const; virtual nsIDOMCSSRule* GetDOMRuleWeak(nsresult *aResult) { *aResult = NS_OK; @@ -134,9 +133,9 @@ public: virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; #endif - // nsICSSRule methods + // Rule methods virtual PRInt32 GetType() const; - virtual already_AddRefed Clone() const; + virtual already_AddRefed Clone() const; virtual nsIDOMCSSRule* GetDOMRuleWeak(nsresult *aResult) { *aResult = NS_OK; @@ -234,11 +233,11 @@ public: virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; #endif - // nsICSSRule methods + // Rule methods DECL_STYLE_RULE_INHERIT virtual PRInt32 GetType() const; - virtual already_AddRefed Clone() const; + virtual already_AddRefed Clone() const; // nsIDOMCSSRule interface NS_DECL_NSIDOMCSSRULE @@ -298,9 +297,9 @@ public: virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; #endif - // nsICSSRule methods + // Rule methods virtual PRInt32 GetType() const; - virtual already_AddRefed Clone() const; + virtual already_AddRefed Clone() const; // nsIDOMCSSRule interface NS_DECL_NSIDOMCSSRULE @@ -361,10 +360,10 @@ public: { mKeys.SwapElements(aKeys); } - +private: nsCSSKeyframeRule(const nsCSSKeyframeRule& aCopy); ~nsCSSKeyframeRule(); - +public: NS_DECL_ISUPPORTS // nsIStyleRule methods @@ -372,10 +371,10 @@ public: virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; #endif - // nsICSSRule methods + // Rule methods DECL_STYLE_RULE_INHERIT virtual PRInt32 GetType() const; - virtual already_AddRefed Clone() const; + virtual already_AddRefed Clone() const; // nsIDOMCSSRule interface NS_DECL_NSIDOMCSSRULE @@ -403,9 +402,10 @@ public: : mName(aName) { } +private: nsCSSKeyframesRule(const nsCSSKeyframesRule& aCopy); ~nsCSSKeyframesRule(); - +public: NS_DECL_ISUPPORTS_INHERITED // nsIStyleRule methods @@ -413,9 +413,9 @@ public: virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; #endif - // nsICSSRule methods + // Rule methods virtual PRInt32 GetType() const; - virtual already_AddRefed Clone() const; + virtual already_AddRefed Clone() const; virtual nsIDOMCSSRule* GetDOMRuleWeak(nsresult *aResult) { *aResult = NS_OK; diff --git a/layout/style/nsCSSStyleSheet.cpp b/layout/style/nsCSSStyleSheet.cpp index d486f9b876df..152b8299fdd9 100644 --- a/layout/style/nsCSSStyleSheet.cpp +++ b/layout/style/nsCSSStyleSheet.cpp @@ -148,7 +148,7 @@ CSSRuleListImpl::GetItemAt(PRUint32 aIndex, nsresult* aResult) // ensure rules have correct parent if (mStyleSheet->EnsureUniqueInner() != nsCSSStyleSheet::eUniqueInner_CloneFailed) { - nsCOMPtr rule; + nsRefPtr rule; result = mStyleSheet->GetStyleRuleAt(aIndex, *getter_AddRefs(rule)); if (rule) { @@ -805,7 +805,7 @@ nsCSSStyleSheetInner::nsCSSStyleSheetInner(nsCSSStyleSheet* aPrimarySheet) mPrincipal = do_CreateInstance("@mozilla.org/nullprincipal;1"); } -static PRBool SetStyleSheetReference(nsICSSRule* aRule, void* aSheet) +static PRBool SetStyleSheetReference(css::Rule* aRule, void* aSheet) { if (aRule) { aRule->SetStyleSheet(static_cast(aSheet)); @@ -814,10 +814,10 @@ static PRBool SetStyleSheetReference(nsICSSRule* aRule, void* aSheet) } static PRBool -CloneRuleInto(nsICSSRule* aRule, void* aArray) +CloneRuleInto(css::Rule* aRule, void* aArray) { - nsCOMPtr clone = aRule->Clone(); - static_cast*>(aArray)->AppendObject(clone); + nsRefPtr clone = aRule->Clone(); + static_cast*>(aArray)->AppendObject(clone); return PR_TRUE; } @@ -841,15 +841,15 @@ struct ChildSheetListBuilder { }; PRBool -nsCSSStyleSheet::RebuildChildList(nsICSSRule* aRule, void* aBuilder) +nsCSSStyleSheet::RebuildChildList(css::Rule* aRule, void* aBuilder) { PRInt32 type = aRule->GetType(); - if (type < nsICSSRule::IMPORT_RULE) { + if (type < css::Rule::IMPORT_RULE) { // Keep going till we get to the import rules. return PR_TRUE; } - if (type != nsICSSRule::IMPORT_RULE) { + if (type != css::Rule::IMPORT_RULE) { // We're past all the import rules; stop the enumeration. return PR_FALSE; } @@ -942,9 +942,9 @@ nsCSSStyleSheetInner::RemoveSheet(nsCSSStyleSheet* aSheet) } static void -AddNamespaceRuleToMap(nsICSSRule* aRule, nsXMLNameSpaceMap* aMap) +AddNamespaceRuleToMap(css::Rule* aRule, nsXMLNameSpaceMap* aMap) { - NS_ASSERTION(aRule->GetType() == nsICSSRule::NAMESPACE_RULE, "Bogus rule type"); + NS_ASSERTION(aRule->GetType() == css::Rule::NAMESPACE_RULE, "Bogus rule type"); nsRefPtr nameSpaceRule = do_QueryObject(aRule); @@ -955,17 +955,17 @@ AddNamespaceRuleToMap(nsICSSRule* aRule, nsXMLNameSpaceMap* aMap) } static PRBool -CreateNameSpace(nsICSSRule* aRule, void* aNameSpacePtr) +CreateNameSpace(css::Rule* aRule, void* aNameSpacePtr) { PRInt32 type = aRule->GetType(); - if (nsICSSRule::NAMESPACE_RULE == type) { + if (css::Rule::NAMESPACE_RULE == type) { AddNamespaceRuleToMap(aRule, static_cast(aNameSpacePtr)); return PR_TRUE; } // stop if not namespace, import or charset because namespace can't follow // anything else - return (nsICSSRule::CHARSET_RULE == type || nsICSSRule::IMPORT_RULE == type); + return (css::Rule::CHARSET_RULE == type || css::Rule::IMPORT_RULE == type); } void @@ -1329,7 +1329,7 @@ nsCSSStyleSheet::InsertStyleSheetAt(nsCSSStyleSheet* aSheet, PRInt32 aIndex) } void -nsCSSStyleSheet::PrependStyleRule(nsICSSRule* aRule) +nsCSSStyleSheet::PrependStyleRule(css::Rule* aRule) { NS_PRECONDITION(nsnull != aRule, "null arg"); @@ -1338,7 +1338,7 @@ nsCSSStyleSheet::PrependStyleRule(nsICSSRule* aRule) aRule->SetStyleSheet(this); DidDirty(); - if (nsICSSRule::NAMESPACE_RULE == aRule->GetType()) { + if (css::Rule::NAMESPACE_RULE == aRule->GetType()) { // no api to prepend a namespace (ugh), release old ones and re-create them all mInner->RebuildNameSpaces(); } @@ -1346,7 +1346,7 @@ nsCSSStyleSheet::PrependStyleRule(nsICSSRule* aRule) } void -nsCSSStyleSheet::AppendStyleRule(nsICSSRule* aRule) +nsCSSStyleSheet::AppendStyleRule(css::Rule* aRule) { NS_PRECONDITION(nsnull != aRule, "null arg"); @@ -1355,7 +1355,7 @@ nsCSSStyleSheet::AppendStyleRule(nsICSSRule* aRule) aRule->SetStyleSheet(this); DidDirty(); - if (nsICSSRule::NAMESPACE_RULE == aRule->GetType()) { + if (css::Rule::NAMESPACE_RULE == aRule->GetType()) { #ifdef DEBUG nsresult rv = #endif @@ -1367,7 +1367,7 @@ nsCSSStyleSheet::AppendStyleRule(nsICSSRule* aRule) } void -nsCSSStyleSheet::ReplaceStyleRule(nsICSSRule* aOld, nsICSSRule* 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!"); @@ -1383,8 +1383,8 @@ nsCSSStyleSheet::ReplaceStyleRule(nsICSSRule* aOld, nsICSSRule* aNew) aNew->SetStyleSheet(this); aOld->SetStyleSheet(nsnull); DidDirty(); - NS_ASSERTION(nsICSSRule::NAMESPACE_RULE != aNew->GetType(), "not yet implemented"); - NS_ASSERTION(nsICSSRule::NAMESPACE_RULE != aOld->GetType(), "not yet implemented"); + NS_ASSERTION(css::Rule::NAMESPACE_RULE != aNew->GetType(), "not yet implemented"); + NS_ASSERTION(css::Rule::NAMESPACE_RULE != aOld->GetType(), "not yet implemented"); } } @@ -1395,7 +1395,7 @@ nsCSSStyleSheet::StyleRuleCount() const } nsresult -nsCSSStyleSheet::GetStyleRuleAt(PRInt32 aIndex, nsICSSRule*& aRule) const +nsCSSStyleSheet::GetStyleRuleAt(PRInt32 aIndex, css::Rule*& aRule) const { // Important: If this function is ever made scriptable, we must add // a security check here. See GetCssRules below for an example. @@ -1477,7 +1477,7 @@ nsCSSStyleSheet::Clone(nsCSSStyleSheet* aCloneParent, #ifdef DEBUG static void -ListRules(const nsCOMArray& aRules, FILE* aOut, PRInt32 aIndent) +ListRules(const nsCOMArray& aRules, FILE* aOut, PRInt32 aIndent) { for (PRInt32 index = aRules.Count() - 1; index >= 0; --index) { aRules.ObjectAt(index)->List(aOut, aIndent); @@ -1597,7 +1597,7 @@ nsCSSStyleSheet::SubjectSubsumesInnerPrincipal() const } nsresult -nsCSSStyleSheet::RegisterNamespaceRule(nsICSSRule* aRule) +nsCSSStyleSheet::RegisterNamespaceRule(css::Rule* aRule) { if (!mInner->mNameSpaceMap) { nsresult rv = mInner->CreateNamespaceMap(); @@ -1785,7 +1785,7 @@ nsCSSStyleSheet::InsertRuleInternal(const nsAString& aRule, mozAutoDocUpdate updateBatch(mDocument, UPDATE_STYLE, PR_TRUE); - nsCOMArray rules; + nsCOMArray rules; result = css.ParseRule(aRule, mInner->mSheetURI, mInner->mBaseURI, mInner->mPrincipal, rules); if (NS_FAILED(result)) @@ -1800,52 +1800,52 @@ nsCSSStyleSheet::InsertRuleInternal(const nsAString& aRule, // Hierarchy checking. Just check the first and last rule in the list. // check that we're not inserting before a charset rule - nsICSSRule* nextRule = mInner->mOrderedRules.SafeObjectAt(aIndex); + css::Rule* nextRule = mInner->mOrderedRules.SafeObjectAt(aIndex); if (nextRule) { PRInt32 nextType = nextRule->GetType(); - if (nextType == nsICSSRule::CHARSET_RULE) { + if (nextType == css::Rule::CHARSET_RULE) { return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR; } // check last rule in list - nsICSSRule* lastRule = rules.ObjectAt(rulecount - 1); + css::Rule* lastRule = rules.ObjectAt(rulecount - 1); PRInt32 lastType = lastRule->GetType(); - if (nextType == nsICSSRule::IMPORT_RULE && - lastType != nsICSSRule::CHARSET_RULE && - lastType != nsICSSRule::IMPORT_RULE) { + if (nextType == css::Rule::IMPORT_RULE && + lastType != css::Rule::CHARSET_RULE && + lastType != css::Rule::IMPORT_RULE) { return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR; } - if (nextType == nsICSSRule::NAMESPACE_RULE && - lastType != nsICSSRule::CHARSET_RULE && - lastType != nsICSSRule::IMPORT_RULE && - lastType != nsICSSRule::NAMESPACE_RULE) { + if (nextType == css::Rule::NAMESPACE_RULE && + lastType != css::Rule::CHARSET_RULE && + lastType != css::Rule::IMPORT_RULE && + lastType != css::Rule::NAMESPACE_RULE) { return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR; } } // check first rule in list - nsICSSRule* firstRule = rules.ObjectAt(0); + css::Rule* firstRule = rules.ObjectAt(0); PRInt32 firstType = firstRule->GetType(); if (aIndex != 0) { - if (firstType == nsICSSRule::CHARSET_RULE) { // no inserting charset at nonzero position + if (firstType == css::Rule::CHARSET_RULE) { // no inserting charset at nonzero position return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR; } - nsICSSRule* prevRule = mInner->mOrderedRules.SafeObjectAt(aIndex - 1); + css::Rule* prevRule = mInner->mOrderedRules.SafeObjectAt(aIndex - 1); PRInt32 prevType = prevRule->GetType(); - if (firstType == nsICSSRule::IMPORT_RULE && - prevType != nsICSSRule::CHARSET_RULE && - prevType != nsICSSRule::IMPORT_RULE) { + if (firstType == css::Rule::IMPORT_RULE && + prevType != css::Rule::CHARSET_RULE && + prevType != css::Rule::IMPORT_RULE) { return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR; } - if (firstType == nsICSSRule::NAMESPACE_RULE && - prevType != nsICSSRule::CHARSET_RULE && - prevType != nsICSSRule::IMPORT_RULE && - prevType != nsICSSRule::NAMESPACE_RULE) { + if (firstType == css::Rule::NAMESPACE_RULE && + prevType != css::Rule::CHARSET_RULE && + prevType != css::Rule::IMPORT_RULE && + prevType != css::Rule::NAMESPACE_RULE) { return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR; } } @@ -1855,11 +1855,11 @@ nsCSSStyleSheet::InsertRuleInternal(const nsAString& aRule, DidDirty(); for (PRInt32 counter = 0; counter < rulecount; counter++) { - nsICSSRule* cssRule = rules.ObjectAt(counter); + css::Rule* cssRule = rules.ObjectAt(counter); cssRule->SetStyleSheet(this); PRInt32 type = cssRule->GetType(); - if (type == nsICSSRule::NAMESPACE_RULE) { + if (type == css::Rule::NAMESPACE_RULE) { // XXXbz does this screw up when inserting a namespace rule before // another namespace rule that binds the same prefix to a different // namespace? @@ -1870,7 +1870,7 @@ nsCSSStyleSheet::InsertRuleInternal(const nsAString& aRule, // We don't notify immediately for @import rules, but rather when // the sheet the rule is importing is loaded PRBool notify = PR_TRUE; - if (type == nsICSSRule::IMPORT_RULE) { + if (type == css::Rule::IMPORT_RULE) { nsCOMPtr importRule(do_QueryInterface(cssRule)); NS_ASSERTION(importRule, "Rule which has type IMPORT_RULE and does not implement nsIDOMCSSImportRule!"); nsCOMPtr childSheet; @@ -1915,7 +1915,7 @@ nsCSSStyleSheet::DeleteRule(PRUint32 aIndex) "Too many style rules!"); // Hold a strong ref to the rule so it doesn't die when we RemoveObjectAt - nsCOMPtr rule = mInner->mOrderedRules.ObjectAt(aIndex); + nsRefPtr rule = mInner->mOrderedRules.ObjectAt(aIndex); if (rule) { mInner->mOrderedRules.RemoveObjectAt(aIndex); rule->SetStyleSheet(nsnull); @@ -1936,7 +1936,7 @@ nsCSSStyleSheet::DeleteRuleFromGroup(css::GroupRule* aGroup, PRUint32 aIndex) NS_ENSURE_ARG_POINTER(aGroup); NS_ASSERTION(mInner->mComplete, "No deleting from an incomplete sheet!"); nsresult result; - nsCOMPtr rule = aGroup->GetStyleRuleAt(aIndex); + nsRefPtr rule = aGroup->GetStyleRuleAt(aIndex); NS_ENSURE_TRUE(rule, NS_ERROR_ILLEGAL_VALUE); // check that the rule actually belongs to this sheet! @@ -1997,7 +1997,7 @@ nsCSSStyleSheet::InsertRuleIntoGroup(const nsAString & aRule, result = WillDirty(); NS_ENSURE_SUCCESS(result, result); - nsCOMArray rules; + nsCOMArray rules; result = css.ParseRule(aRule, mInner->mSheetURI, mInner->mBaseURI, mInner->mPrincipal, rules); NS_ENSURE_SUCCESS(result, result); @@ -2009,11 +2009,11 @@ nsCSSStyleSheet::InsertRuleIntoGroup(const nsAString & aRule, } PRInt32 counter; - nsICSSRule* rule; + css::Rule* rule; for (counter = 0; counter < rulecount; counter++) { // Only rulesets are allowed in a group as of CSS2 rule = rules.ObjectAt(counter); - if (rule->GetType() != nsICSSRule::STYLE_RULE) { + if (rule->GetType() != css::Rule::STYLE_RULE) { return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR; } } @@ -2035,7 +2035,7 @@ nsCSSStyleSheet::InsertRuleIntoGroup(const nsAString & aRule, nsresult nsCSSStyleSheet::ReplaceRuleInGroup(css::GroupRule* aGroup, - nsICSSRule* aOld, nsICSSRule* aNew) + css::Rule* aOld, css::Rule* aNew) { nsresult result; NS_PRECONDITION(mInner->mComplete, "No replacing in an incomplete sheet!"); diff --git a/layout/style/nsCSSStyleSheet.h b/layout/style/nsCSSStyleSheet.h index 3462e2728d52..dbf8e72d2ef6 100644 --- a/layout/style/nsCSSStyleSheet.h +++ b/layout/style/nsCSSStyleSheet.h @@ -52,7 +52,6 @@ #include "nsICSSLoaderObserver.h" #include "nsCOMArray.h" -class nsICSSRule; class nsXMLNameSpaceMap; class nsCSSRuleProcessor; class nsMediaList; @@ -66,6 +65,7 @@ template class nsTArray; namespace mozilla { namespace css { +class Rule; class GroupRule; class ImportRule; } @@ -100,7 +100,7 @@ private: nsCOMPtr mOriginalSheetURI; // for GetHref. Can be null. nsCOMPtr mBaseURI; // for resolving relative URIs nsCOMPtr mPrincipal; - nsCOMArray mOrderedRules; + nsCOMArray mOrderedRules; nsAutoPtr 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 @@ -165,16 +165,16 @@ public: void InsertStyleSheetAt(nsCSSStyleSheet* aSheet, PRInt32 aIndex); // XXX do these belong here or are they generic? - void PrependStyleRule(nsICSSRule* aRule); - void AppendStyleRule(nsICSSRule* aRule); - void ReplaceStyleRule(nsICSSRule* aOld, nsICSSRule* aNew); + void PrependStyleRule(mozilla::css::Rule* aRule); + void AppendStyleRule(mozilla::css::Rule* aRule); + void ReplaceStyleRule(mozilla::css::Rule* aOld, mozilla::css::Rule* aNew); PRInt32 StyleRuleCount() const; - nsresult GetStyleRuleAt(PRInt32 aIndex, nsICSSRule*& aRule) const; + nsresult GetStyleRuleAt(PRInt32 aIndex, mozilla::css::Rule*& aRule) const; nsresult DeleteRuleFromGroup(mozilla::css::GroupRule* aGroup, PRUint32 aIndex); nsresult InsertRuleIntoGroup(const nsAString& aRule, mozilla::css::GroupRule* aGroup, PRUint32 aIndex, PRUint32* _retval); - nsresult ReplaceRuleInGroup(mozilla::css::GroupRule* aGroup, nsICSSRule* aOld, nsICSSRule* aNew); + nsresult ReplaceRuleInGroup(mozilla::css::GroupRule* aGroup, mozilla::css::Rule* aOld, mozilla::css::Rule* aNew); PRInt32 StyleSheetCount() const; @@ -260,7 +260,7 @@ 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); + static PRBool RebuildChildList(mozilla::css::Rule* aRule, void* aBuilder); private: nsCSSStyleSheet(const nsCSSStyleSheet& aCopy, @@ -287,7 +287,7 @@ protected: nsresult SubjectSubsumesInnerPrincipal() const; // Add the namespace mapping from this @namespace rule to our namespace map - nsresult RegisterNamespaceRule(nsICSSRule* aRule); + nsresult RegisterNamespaceRule(mozilla::css::Rule* aRule); protected: nsString mTitle; diff --git a/layout/style/nsDOMCSSDeclaration.cpp b/layout/style/nsDOMCSSDeclaration.cpp index ba63fe0632f6..f309a92c2140 100644 --- a/layout/style/nsDOMCSSDeclaration.cpp +++ b/layout/style/nsDOMCSSDeclaration.cpp @@ -44,7 +44,7 @@ #include "mozilla/css/Loader.h" #include "nsCSSStyleSheet.h" #include "nsIStyleRule.h" -#include "nsICSSRule.h" +#include "mozilla/css/Rule.h" #include "mozilla/css/Declaration.h" #include "nsCSSProps.h" #include "nsCOMPtr.h" @@ -265,7 +265,7 @@ nsDOMCSSDeclaration::RemoveProperty(const nsAString& aPropertyName, } /* static */ void -nsDOMCSSDeclaration::GetCSSParsingEnvironmentForRule(nsICSSRule* aRule, +nsDOMCSSDeclaration::GetCSSParsingEnvironmentForRule(css::Rule* aRule, CSSParsingEnvironment& aCSSParseEnv) { nsIStyleSheet* sheet = aRule ? aRule->GetStyleSheet() : nsnull; diff --git a/layout/style/nsDOMCSSDeclaration.h b/layout/style/nsDOMCSSDeclaration.h index 0e48022a33bd..01af139cd35e 100644 --- a/layout/style/nsDOMCSSDeclaration.h +++ b/layout/style/nsDOMCSSDeclaration.h @@ -48,12 +48,12 @@ class nsCSSParser; class nsIURI; class nsIPrincipal; class nsIDocument; -class nsICSSRule; namespace mozilla { namespace css { class Declaration; class Loader; +class Rule; } } @@ -120,8 +120,8 @@ protected: virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) = 0; // An implementation for GetCSSParsingEnvironment for callers wrapping - // an nsICSSRule. - static void GetCSSParsingEnvironmentForRule(nsICSSRule* aRule, + // an css::Rule. + static void GetCSSParsingEnvironmentForRule(mozilla::css::Rule* aRule, CSSParsingEnvironment& aCSSParseEnv); nsresult ParsePropertyValue(const nsCSSProperty aPropID, diff --git a/layout/style/nsFontFaceLoader.cpp b/layout/style/nsFontFaceLoader.cpp index 97489db91c2b..2eaebf5e9c57 100644 --- a/layout/style/nsFontFaceLoader.cpp +++ b/layout/style/nsFontFaceLoader.cpp @@ -478,7 +478,7 @@ nsUserFontSet::InsertRule(nsCSSFontFaceRule *aRule, PRUint8 aSheetType, nsTArray& aOldRules, PRBool& aFontSetModified) { - NS_ABORT_IF_FALSE(aRule->GetType() == nsICSSRule::FONT_FACE_RULE, + NS_ABORT_IF_FALSE(aRule->GetType() == mozilla::css::Rule::FONT_FACE_RULE, "InsertRule passed a non-fontface CSS rule"); // set up family name diff --git a/layout/style/nsICSSRule.h b/layout/style/nsICSSRule.h deleted file mode 100644 index 5f48f850ba30..000000000000 --- a/layout/style/nsICSSRule.h +++ /dev/null @@ -1,112 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * 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 all rule types in a CSS style sheet */ - -#ifndef nsICSSRule_h -#define nsICSSRule_h - -#include "nsIStyleRule.h" -#include "nsIDOMCSSRule.h" - -class nsCSSStyleSheet; -class nsAString; -template struct already_AddRefed; -class nsIStyleSheet; - -namespace mozilla { -namespace css { -class GroupRule; -} -} - -// IID for the nsICSSRule interface -#define NS_ICSS_RULE_IID \ -{ 0x471d733e, 0xc138, 0x4a50, \ - { 0x9e, 0x1a, 0xd1, 0x3c, 0xbb, 0x65, 0xb5, 0x26 } } - - -// inheriting from nsIStyleRule is only for style rules, not other rule types -class nsICSSRule : public nsIStyleRule { -public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICSS_RULE_IID) - // 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 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, - FONT_FACE_RULE, - PAGE_RULE, -#ifdef MOZ_CSS_ANIMATIONS - KEYFRAME_RULE, - KEYFRAMES_RULE, -#endif - DOCUMENT_RULE - }; - - virtual PRInt32 GetType() const = 0; - - virtual nsIStyleSheet* GetStyleSheet() const = 0; - virtual void SetStyleSheet(nsCSSStyleSheet* aSheet) = 0; - virtual void SetParentRule(mozilla::css::GroupRule* aRule) = 0; - - /** - * Clones |this|. Never returns NULL. - */ - virtual already_AddRefed Clone() const = 0; - - // Note that this returns null for inline style rules since they aren't - // supposed to have a DOM rule representation (and our code wouldn't work). - nsresult GetDOMRule(nsIDOMCSSRule** aDOMRule) - { - nsresult rv; - NS_IF_ADDREF(*aDOMRule = GetDOMRuleWeak(&rv)); - return rv; - } - virtual nsIDOMCSSRule* GetDOMRuleWeak(nsresult* aResult) = 0; -}; - -NS_DEFINE_STATIC_IID_ACCESSOR(nsICSSRule, NS_ICSS_RULE_IID) - -#endif /* nsICSSRule_h */