Bug 978833 patch 15 - Make css::Rule no longer inherit from nsIStyleRule. r=heycam

This inheritance was previously needed only by a subset of the classes
derived from css::Rule (css::StyleRule, nsCSSKeyframeRule,
nsCSSPageRule).  After patch 12, it is now needed by none.
This commit is contained in:
L. David Baron 2015-11-05 16:44:10 +08:00
parent d96935fa9d
commit 1e661b7270
8 changed files with 42 additions and 108 deletions

View File

@ -42,14 +42,12 @@ public:
NS_DECL_CYCLE_COLLECTION_CLASS(GroupRule)
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
// implement part of nsIStyleRule and Rule
// implement part of Rule
DECL_STYLE_RULE_INHERIT_NO_DOMRULE
virtual void SetStyleSheet(CSSStyleSheet* aSheet) override;
// to help implement nsIStyleRule
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif
virtual void SetStyleSheet(CSSStyleSheet* aSheet) override;
public:
void AppendStyleRule(Rule* aRule);

View File

@ -34,7 +34,7 @@ private:
ImportRule(const ImportRule& aCopy);
~ImportRule();
public:
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(ImportRule, nsIStyleRule)
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(ImportRule, mozilla::css::Rule)
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
DECL_STYLE_RULE_INHERIT
@ -43,12 +43,10 @@ public:
using Rule::GetStyleSheet; // unhide since nsIDOMCSSImportRule has its own GetStyleSheet
#endif
// nsIStyleRule methods
// Rule methods
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif
// Rule methods
virtual int32_t GetType() const override;
virtual already_AddRefed<Rule> Clone() const override;

View File

@ -39,14 +39,11 @@ public:
NS_DECL_ISUPPORTS
// Rule methods
DECL_STYLE_RULE_INHERIT
// nsIStyleRule methods
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif
// Rule methods
virtual int32_t GetType() const override;
virtual already_AddRefed<Rule> Clone() const override;

View File

@ -10,7 +10,7 @@
#include "mozilla/CSSStyleSheet.h"
#include "mozilla/MemoryReporting.h"
#include "nsIStyleRule.h"
#include "nsISupports.h"
#include "nsIDOMCSSRule.h"
class nsIDocument;
@ -23,14 +23,14 @@ namespace css {
class GroupRule;
#define DECL_STYLE_RULE_INHERIT_NO_DOMRULE \
virtual void MapRuleInfoInto(nsRuleData* aRuleData) override;
/* nothing */
#define DECL_STYLE_RULE_INHERIT \
DECL_STYLE_RULE_INHERIT_NO_DOMRULE \
virtual nsIDOMCSSRule* GetDOMRule() override; \
virtual nsIDOMCSSRule* GetExistingDOMRule() override;
class Rule : public nsIStyleRule {
class Rule : public nsISupports {
protected:
Rule(uint32_t aLineNumber, uint32_t aColumnNumber)
: mSheet(0),
@ -54,6 +54,10 @@ protected:
public:
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const = 0;
#endif
// 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

View File

@ -1441,8 +1441,7 @@ NS_INTERFACE_MAP_BEGIN(StyleRule)
return NS_OK;
}
else
NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, mozilla::css::Rule)
NS_INTERFACE_MAP_END
NS_IMPL_ADDREF(StyleRule)
@ -1513,14 +1512,6 @@ StyleRule::DeclarationChanged(Declaration* aDecl,
return clone.forget();
}
/* virtual */ void
StyleRule::MapRuleInfoInto(nsRuleData* aRuleData)
{
MOZ_ASSERT(mWasMatched,
"somebody forgot to call css::StyleRule::RuleMatched");
mDeclaration->MapRuleInfoInto(aRuleData);
}
#ifdef DEBUG
/* virtual */ void
StyleRule::List(FILE* out, int32_t aIndent) const

View File

@ -19,6 +19,7 @@
#include "nsCOMPtr.h"
#include "nsCSSPseudoElements.h"
#include "nsCSSPseudoClasses.h"
#include "nsIStyleRule.h"
class nsIAtom;
struct nsCSSSelectorList;
@ -346,9 +347,6 @@ public:
virtual nsIDOMCSSRule* GetExistingDOMRule() override;
// The new mapping function.
virtual void MapRuleInfoInto(nsRuleData* aRuleData) override;
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif

View File

@ -46,13 +46,9 @@ using namespace mozilla::dom;
{ return this; } \
/* virtual */ nsIDOMCSSRule* class_::GetExistingDOMRule() \
{ return this; }
#define IMPL_STYLE_RULE_INHERIT_MAP_RULE_INFO_INTO(class_, super_) \
/* virtual */ void class_::MapRuleInfoInto(nsRuleData* aRuleData) \
{ MOZ_ASSERT(false, "should not be called"); }
#define IMPL_STYLE_RULE_INHERIT(class_, super_) \
IMPL_STYLE_RULE_INHERIT_GET_DOM_RULE_WEAK(class_, super_) \
IMPL_STYLE_RULE_INHERIT_MAP_RULE_INFO_INTO(class_, super_)
IMPL_STYLE_RULE_INHERIT_GET_DOM_RULE_WEAK(class_, super_)
// base class for all rule types in a CSS style sheet
@ -248,10 +244,9 @@ NS_IMPL_CYCLE_COLLECTION(ImportRule, mMedia, mChildSheet)
// QueryInterface implementation for ImportRule
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ImportRule)
NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSImportRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, mozilla::css::Rule)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSImportRule)
NS_INTERFACE_MAP_END
@ -429,8 +424,6 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(GroupRule)
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)
{
@ -662,12 +655,11 @@ NS_IMPL_RELEASE_INHERITED(MediaRule, GroupRule)
// QueryInterface implementation for MediaRule
NS_INTERFACE_MAP_BEGIN(MediaRule)
NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSGroupingRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSConditionRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSMediaRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, mozilla::css::Rule)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSMediaRule)
NS_INTERFACE_MAP_END_INHERITING(GroupRule)
@ -880,12 +872,11 @@ NS_IMPL_RELEASE_INHERITED(DocumentRule, GroupRule)
// QueryInterface implementation for DocumentRule
NS_INTERFACE_MAP_BEGIN(DocumentRule)
NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSGroupingRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSConditionRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSMozDocumentRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, mozilla::css::Rule)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSMozDocumentRule)
NS_INTERFACE_MAP_END_INHERITING(GroupRule)
@ -1149,9 +1140,8 @@ NS_INTERFACE_MAP_BEGIN(NameSpaceRule)
return NS_OK;
}
else
NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, mozilla::css::Rule)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSNameSpaceRule)
NS_INTERFACE_MAP_END
@ -1581,10 +1571,9 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
// QueryInterface implementation for nsCSSFontFaceRule
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsCSSFontFaceRule)
NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSFontFaceRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, mozilla::css::Rule)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSFontFaceRule)
NS_INTERFACE_MAP_END
@ -1726,10 +1715,9 @@ NS_IMPL_RELEASE(nsCSSFontFeatureValuesRule)
// QueryInterface implementation for nsCSSFontFeatureValuesRule
NS_INTERFACE_MAP_BEGIN(nsCSSFontFeatureValuesRule)
NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSFontFeatureValuesRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, mozilla::css::Rule)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSFontFeatureValuesRule)
NS_INTERFACE_MAP_END
@ -2063,24 +2051,14 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
// QueryInterface implementation for nsCSSKeyframeRule
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsCSSKeyframeRule)
NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMMozCSSKeyframeRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, mozilla::css::Rule)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozCSSKeyframeRule)
NS_INTERFACE_MAP_END
IMPL_STYLE_RULE_INHERIT_GET_DOM_RULE_WEAK(nsCSSKeyframeRule, Rule)
/* virtual */ void
nsCSSKeyframeRule::MapRuleInfoInto(nsRuleData* aRuleData)
{
// We need to implement MapRuleInfoInto because the animation manager
// constructs a rule node pointing to us in order to compute the
// styles it needs to animate.
mDeclaration->MapRuleInfoInto(aRuleData);
}
#ifdef DEBUG
void
nsCSSKeyframeRule::List(FILE* out, int32_t aIndent) const
@ -2280,10 +2258,9 @@ NS_IMPL_RELEASE_INHERITED(nsCSSKeyframesRule, css::GroupRule)
// QueryInterface implementation for nsCSSKeyframesRule
NS_INTERFACE_MAP_BEGIN(nsCSSKeyframesRule)
NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMMozCSSKeyframesRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, mozilla::css::Rule)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozCSSKeyframesRule)
NS_INTERFACE_MAP_END_INHERITING(GroupRule)
@ -2620,10 +2597,9 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
// QueryInterface implementation for nsCSSPageRule
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsCSSPageRule)
NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSPageRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, mozilla::css::Rule)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSPageRule)
NS_INTERFACE_MAP_END
@ -2696,12 +2672,6 @@ nsCSSPageRule::GetCSSRule()
return Rule::GetCSSRule();
}
/* virtual */ void
nsCSSPageRule::MapRuleInfoInto(nsRuleData* aRuleData)
{
mDeclaration->MapRuleInfoInto(aRuleData);
}
NS_IMETHODIMP
nsCSSPageRule::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
{
@ -2798,12 +2768,11 @@ NS_IMPL_RELEASE_INHERITED(CSSSupportsRule, css::GroupRule)
// QueryInterface implementation for CSSSupportsRule
NS_INTERFACE_MAP_BEGIN(CSSSupportsRule)
NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSGroupingRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSConditionRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSSupportsRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, mozilla::css::Rule)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSSupportsRule)
NS_INTERFACE_MAP_END_INHERITING(GroupRule)
@ -2929,10 +2898,9 @@ NS_IMPL_RELEASE(nsCSSCounterStyleRule)
// QueryInterface implementation for nsCSSCounterStyleRule
NS_INTERFACE_MAP_BEGIN(nsCSSCounterStyleRule)
NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSCounterStyleRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, mozilla::css::Rule)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSCounterStyleRule)
NS_INTERFACE_MAP_END

View File

@ -55,12 +55,10 @@ public:
NS_DECL_ISUPPORTS_INHERITED
// nsIStyleRule methods
// Rule methods
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif
// Rule methods
virtual void SetStyleSheet(mozilla::CSSStyleSheet* aSheet) override; //override GroupRule
virtual int32_t GetType() const override;
virtual already_AddRefed<Rule> Clone() const override;
@ -113,12 +111,10 @@ public:
NS_DECL_ISUPPORTS_INHERITED
// nsIStyleRule methods
// Rule methods
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif
// Rule methods
virtual int32_t GetType() const override;
virtual already_AddRefed<Rule> Clone() const override;
virtual nsIDOMCSSRule* GetDOMRule() override
@ -251,14 +247,11 @@ public:
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsCSSFontFaceRule,
mozilla::css::Rule)
// nsIStyleRule methods
// Rule methods
DECL_STYLE_RULE_INHERIT
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif
// Rule methods
DECL_STYLE_RULE_INHERIT
virtual int32_t GetType() const override;
virtual already_AddRefed<mozilla::css::Rule> Clone() const override;
@ -319,14 +312,11 @@ public:
NS_DECL_ISUPPORTS
// nsIStyleRule methods
// Rule methods
DECL_STYLE_RULE_INHERIT
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif
// Rule methods
DECL_STYLE_RULE_INHERIT
virtual int32_t GetType() const override;
virtual already_AddRefed<mozilla::css::Rule> Clone() const override;
@ -403,15 +393,13 @@ private:
~nsCSSKeyframeRule();
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsCSSKeyframeRule, nsIStyleRule)
// nsIStyleRule methods
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsCSSKeyframeRule, mozilla::css::Rule)
// Rule methods
DECL_STYLE_RULE_INHERIT
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif
virtual int32_t GetType() const override;
virtual already_AddRefed<mozilla::css::Rule> Clone() const override;
@ -453,12 +441,10 @@ private:
public:
NS_DECL_ISUPPORTS_INHERITED
// nsIStyleRule methods
// Rule methods
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif
// Rule methods
virtual int32_t GetType() const override;
virtual already_AddRefed<mozilla::css::Rule> Clone() const override;
virtual nsIDOMCSSRule* GetDOMRule() override
@ -536,13 +522,11 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsCSSPageRule, nsIDOMCSSPageRule)
// nsIStyleRule methods
// Rule methods
DECL_STYLE_RULE_INHERIT
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif
// Rule methods
DECL_STYLE_RULE_INHERIT
virtual int32_t GetType() const override;
virtual already_AddRefed<mozilla::css::Rule> Clone() const override;
@ -573,12 +557,10 @@ public:
uint32_t aLineNumber, uint32_t aColumnNumber);
CSSSupportsRule(const CSSSupportsRule& aCopy);
// nsIStyleRule methods
// Rule methods
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif
// Rule methods
virtual int32_t GetType() const override;
virtual already_AddRefed<mozilla::css::Rule> Clone() const override;
virtual bool UseForPresentation(nsPresContext* aPresContext,
@ -636,13 +618,11 @@ private:
public:
NS_DECL_ISUPPORTS
// nsIStyleRule methods
// Rule methods
DECL_STYLE_RULE_INHERIT
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif
// Rule methods
DECL_STYLE_RULE_INHERIT
virtual int32_t GetType() const override;
virtual already_AddRefed<mozilla::css::Rule> Clone() const override;