Bug 851892 part 8. Get rid of css::Rule::GetDOMRule. r=heycam

This commit is contained in:
Boris Zbarsky 2017-01-13 10:41:03 -05:00
parent e1ec75387e
commit 4cc8d36e13
13 changed files with 18 additions and 109 deletions

View File

@ -5198,7 +5198,7 @@ nsDocument::StyleRuleChanged(StyleSheet* aSheet,
DO_STYLESHEET_NOTIFICATION(StyleRuleChangeEvent,
"StyleRuleChanged",
mRule,
aStyleRule ? aStyleRule->GetDOMRule() : nullptr);
aStyleRule);
}
}
@ -5212,8 +5212,7 @@ nsDocument::StyleRuleAdded(StyleSheet* aSheet,
DO_STYLESHEET_NOTIFICATION(StyleRuleChangeEvent,
"StyleRuleAdded",
mRule,
aStyleRule ? aStyleRule->GetDOMRule()
: nullptr);
aStyleRule);
}
}
@ -5227,8 +5226,7 @@ nsDocument::StyleRuleRemoved(StyleSheet* aSheet,
DO_STYLESHEET_NOTIFICATION(StyleRuleChangeEvent,
"StyleRuleRemoved",
mRule,
aStyleRule ? aStyleRule->GetDOMRule()
: nullptr);
aStyleRule);
}
}

View File

@ -253,13 +253,9 @@ inDOMUtils::GetCSSStyleRules(nsIDOMElement *aElement,
for (nsRuleNode* ruleNode : Reversed(ruleNodes)) {
RefPtr<Declaration> decl = do_QueryObject(ruleNode->GetRule());
if (decl) {
RefPtr<mozilla::css::StyleRule> styleRule =
do_QueryObject(decl->GetOwningRule());
if (styleRule) {
nsCOMPtr<nsIDOMCSSRule> domRule = styleRule->GetDOMRule();
if (domRule) {
rules->AppendElement(domRule, /*weak =*/ false);
}
css::Rule* owningRule = decl->GetOwningRule();
if (owningRule) {
rules->AppendElement(owningRule, /*weak =*/ false);
}
}
}

View File

@ -112,7 +112,7 @@ CSSRuleListImpl::IndexedGetter(uint32_t aIndex, bool& aFound)
css::Rule* rule = mStyleSheet->GetStyleRuleAt(aIndex);
if (rule) {
aFound = true;
return rule->GetDOMRule();
return rule;
}
}
@ -878,7 +878,7 @@ CSSStyleSheet::RegisterNamespaceRule(css::Rule* aRule)
nsIDOMCSSRule*
CSSStyleSheet::GetDOMOwnerRule() const
{
return mOwnerRule ? mOwnerRule->GetDOMRule() : nullptr;
return mOwnerRule;
}
CSSRuleList*
@ -1041,11 +1041,6 @@ CSSStyleSheet::DeleteRuleInternal(uint32_t aIndex, ErrorResult& aRv)
RefPtr<css::Rule> rule = mInner->mOrderedRules.ObjectAt(aIndex);
if (rule) {
mInner->mOrderedRules.RemoveObjectAt(aIndex);
if (mDocument && mDocument->StyleSheetChangeEventsEnabled()) {
// Force creation of the DOM rule, so that it can be put on the
// StyleRuleRemoved event object.
rule->GetDOMRule();
}
rule->SetStyleSheet(nullptr);
DidDirty();

View File

@ -42,8 +42,6 @@ public:
NS_DECL_ISUPPORTS_INHERITED
virtual bool IsCCLeaf() const override;
// implement part of Rule
DECL_STYLE_RULE_INHERIT_NO_DOMRULE
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif

View File

@ -38,8 +38,6 @@ public:
NS_DECL_ISUPPORTS_INHERITED
virtual bool IsCCLeaf() const override;
DECL_STYLE_RULE_INHERIT
using Rule::GetStyleSheet; // unhide since nsIDOMCSSImportRule has its own GetStyleSheet
// Rule methods

View File

@ -39,8 +39,6 @@ public:
NS_DECL_ISUPPORTS_INHERITED
virtual bool IsCCLeaf() const override;
// Rule methods
DECL_STYLE_RULE_INHERIT
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif

View File

@ -23,13 +23,6 @@ namespace mozilla {
namespace css {
class GroupRule;
#define DECL_STYLE_RULE_INHERIT_NO_DOMRULE \
/* nothing */
#define DECL_STYLE_RULE_INHERIT \
DECL_STYLE_RULE_INHERIT_NO_DOMRULE \
virtual nsIDOMCSSRule* GetDOMRule() override;
class Rule : public nsIDOMCSSRule
, public nsWrapperCache
{
@ -117,10 +110,6 @@ public:
*/
virtual already_AddRefed<Rule> 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).
virtual nsIDOMCSSRule* GetDOMRule() = 0;
// This is pure virtual because all of Rule's data members are non-owning and
// thus measured elsewhere.
virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)

View File

@ -90,7 +90,7 @@ ServoCSSRuleList::IndexedGetter(uint32_t aIndex, bool& aFound)
}
aFound = true;
if (css::Rule* rule = GetRule(aIndex)) {
return rule->GetDOMRule();
return rule;
}
return nullptr;
}

View File

@ -69,7 +69,6 @@ public:
int32_t GetType() const final { return css::Rule::STYLE_RULE; }
using Rule::GetType;
already_AddRefed<Rule> Clone() const final;
nsIDOMCSSRule* GetDOMRule() final { return this; }
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const final;
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;

View File

@ -1125,7 +1125,7 @@ DOMCSSDeclarationImpl::GetParentRule(nsIDOMCSSRule **aParent)
{
NS_ENSURE_ARG_POINTER(aParent);
NS_IF_ADDREF(*aParent = mRule->GetDOMRule());
NS_IF_ADDREF(*aParent = mRule);
return NS_OK;
}
@ -1292,12 +1292,6 @@ StyleRule::Clone() const
return clone.forget();
}
/* virtual */ nsIDOMCSSRule*
StyleRule::GetDOMRule()
{
return this;
}
void
StyleRule::SetDeclaration(Declaration* aDecl)
{

View File

@ -355,8 +355,6 @@ public:
virtual already_AddRefed<Rule> Clone() const override;
virtual nsIDOMCSSRule* GetDOMRule() override;
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif

View File

@ -43,13 +43,6 @@
using namespace mozilla;
using namespace mozilla::dom;
#define IMPL_STYLE_RULE_INHERIT_GET_DOM_RULE_WEAK(class_, super_) \
/* virtual */ nsIDOMCSSRule* class_::GetDOMRule() \
{ return this; }
#define IMPL_STYLE_RULE_INHERIT(class_, super_) \
IMPL_STYLE_RULE_INHERIT_GET_DOM_RULE_WEAK(class_, super_)
// base class for all rule types in a CSS style sheet
namespace mozilla {
@ -120,11 +113,7 @@ Rule::SetStyleSheet(StyleSheet* aSheet)
NS_IMETHODIMP
Rule::GetParentRule(nsIDOMCSSRule** aParentRule)
{
if (mParentRule) {
NS_IF_ADDREF(*aParentRule = mParentRule->GetDOMRule());
} else {
*aParentRule = nullptr;
}
NS_IF_ADDREF(*aParentRule = mParentRule);
return NS_OK;
}
@ -230,7 +219,7 @@ GroupRuleRuleList::IndexedGetter(uint32_t aIndex, bool& aFound)
RefPtr<Rule> rule = mGroupRule->GetStyleRuleAt(aIndex);
if (rule) {
aFound = true;
return rule->GetDOMRule();
return rule;
}
}
@ -294,8 +283,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ImportRule)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSImportRule)
NS_INTERFACE_MAP_END_INHERITING(Rule)
IMPL_STYLE_RULE_INHERIT(ImportRule, Rule)
#ifdef DEBUG
/* virtual */ void
ImportRule::List(FILE* out, int32_t aIndent) const
@ -578,14 +565,11 @@ GroupRule::AppendRulesToCssText(nsAString& aCssText) const
// get all the rules
for (int32_t index = 0, count = mRules.Count(); index < count; ++index) {
Rule* rule = mRules.ObjectAt(index);
nsIDOMCSSRule* domRule = rule->GetDOMRule();
if (domRule) {
nsAutoString cssText;
domRule->GetCssText(cssText);
aCssText.AppendLiteral(" ");
aCssText.Append(cssText);
aCssText.Append('\n');
}
nsAutoString cssText;
rule->GetCssText(cssText);
aCssText.AppendLiteral(" ");
aCssText.Append(cssText);
aCssText.Append('\n');
}
aCssText.Append('}');
@ -1146,8 +1130,6 @@ NameSpaceRule::IsCCLeaf() const
return Rule::IsCCLeaf();
}
IMPL_STYLE_RULE_INHERIT(NameSpaceRule, Rule)
#ifdef DEBUG
/* virtual */ void
NameSpaceRule::List(FILE* out, int32_t aIndent) const
@ -1495,7 +1477,7 @@ nsCSSFontFaceStyleDecl::IndexedGetter(uint32_t index, bool& aFound, nsAString &
NS_IMETHODIMP
nsCSSFontFaceStyleDecl::GetParentRule(nsIDOMCSSRule** aParentRule)
{
NS_IF_ADDREF(*aParentRule = ContainingRule()->GetDOMRule());
NS_IF_ADDREF(*aParentRule = ContainingRule());
return NS_OK;
}
@ -1585,8 +1567,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsCSSFontFaceRule)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSFontFaceRule)
NS_INTERFACE_MAP_END_INHERITING(Rule)
IMPL_STYLE_RULE_INHERIT(nsCSSFontFaceRule, Rule)
#ifdef DEBUG
void
nsCSSFontFaceRule::List(FILE* out, int32_t aIndent) const
@ -1716,8 +1696,6 @@ nsCSSFontFeatureValuesRule::IsCCLeaf() const
return Rule::IsCCLeaf();
}
IMPL_STYLE_RULE_INHERIT(nsCSSFontFeatureValuesRule, Rule)
static void
FeatureValuesToString(
const nsTArray<gfxFontFeatureValueSet::FeatureValues>& aFeatureValues,
@ -2041,8 +2019,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsCSSKeyframeRule)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSKeyframeRule)
NS_INTERFACE_MAP_END_INHERITING(mozilla::css::Rule)
IMPL_STYLE_RULE_INHERIT_GET_DOM_RULE_WEAK(nsCSSKeyframeRule, Rule)
#ifdef DEBUG
void
nsCSSKeyframeRule::List(FILE* out, int32_t aIndent) const
@ -2546,8 +2522,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsCSSPageRule)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSPageRule)
NS_INTERFACE_MAP_END_INHERITING(mozilla::css::Rule)
IMPL_STYLE_RULE_INHERIT_GET_DOM_RULE_WEAK(nsCSSPageRule, Rule)
#ifdef DEBUG
void
nsCSSPageRule::List(FILE* out, int32_t aIndent) const
@ -2815,8 +2789,6 @@ nsCSSCounterStyleRule::IsCCLeaf() const
return Rule::IsCCLeaf();
}
IMPL_STYLE_RULE_INHERIT(nsCSSCounterStyleRule, css::Rule)
#ifdef DEBUG
void
nsCSSCounterStyleRule::List(FILE* out, int32_t aIndent) const

View File

@ -69,10 +69,6 @@ public:
virtual int32_t GetType() const override;
using Rule::GetType;
virtual already_AddRefed<Rule> Clone() const override;
virtual nsIDOMCSSRule* GetDOMRule() override
{
return this;
}
// nsIDOMCSSGroupingRule interface
NS_DECL_NSIDOMCSSGROUPINGRULE
@ -125,10 +121,6 @@ public:
virtual int32_t GetType() const override;
using Rule::GetType;
virtual already_AddRefed<Rule> Clone() const override;
virtual nsIDOMCSSRule* GetDOMRule() override
{
return this;
}
// nsIDOMCSSGroupingRule interface
NS_DECL_NSIDOMCSSGROUPINGRULE
@ -265,8 +257,6 @@ public:
mozilla::css::Rule)
virtual bool IsCCLeaf() const override;
// Rule methods
DECL_STYLE_RULE_INHERIT
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif
@ -342,8 +332,6 @@ public:
NS_DECL_ISUPPORTS_INHERITED
virtual bool IsCCLeaf() const override;
// Rule methods
DECL_STYLE_RULE_INHERIT
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif
@ -432,8 +420,6 @@ public:
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsCSSKeyframeRule, mozilla::css::Rule)
virtual bool IsCCLeaf() const override;
// Rule methods
DECL_STYLE_RULE_INHERIT
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif
@ -491,10 +477,6 @@ public:
virtual int32_t GetType() const override;
using Rule::GetType;
virtual already_AddRefed<mozilla::css::Rule> Clone() const override;
virtual nsIDOMCSSRule* GetDOMRule() override
{
return this;
}
// nsIDOMCSSKeyframesRule interface
NS_DECL_NSIDOMCSSKEYFRAMESRULE
@ -568,8 +550,6 @@ public:
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsCSSPageRule, mozilla::css::Rule)
virtual bool IsCCLeaf() const override;
// Rule methods
DECL_STYLE_RULE_INHERIT
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif
@ -618,10 +598,6 @@ public:
virtual already_AddRefed<mozilla::css::Rule> Clone() const override;
virtual bool UseForPresentation(nsPresContext* aPresContext,
nsMediaQueryResultCacheKey& aKey) override;
virtual nsIDOMCSSRule* GetDOMRule() override
{
return this;
}
NS_DECL_ISUPPORTS_INHERITED
@ -673,8 +649,6 @@ public:
NS_DECL_ISUPPORTS_INHERITED
virtual bool IsCCLeaf() const override;
// Rule methods
DECL_STYLE_RULE_INHERIT
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif