From 247eec6f18c0717fbe7de0a56d23fe3d2b3da70e Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Sat, 7 Aug 2010 22:33:15 -0700 Subject: [PATCH] Bug 577976 - Part 5: Remove AddRef from GetStyleSheet, r=bzbarsky --- layout/style/Rule.h | 2 +- layout/style/StyleRule.cpp | 3 +-- layout/style/nsCSSRules.cpp | 3 +-- layout/style/nsCSSStyleSheet.cpp | 13 +++---------- layout/style/nsICSSRule.h | 2 +- 5 files changed, 7 insertions(+), 16 deletions(-) diff --git a/layout/style/Rule.h b/layout/style/Rule.h index 50c7e45bf35..75afbd1d567 100644 --- a/layout/style/Rule.h +++ b/layout/style/Rule.h @@ -83,7 +83,7 @@ protected: NS_DECL_OWNINGTHREAD public: - virtual already_AddRefed GetStyleSheet() const; + virtual nsIStyleSheet* GetStyleSheet() const; virtual void SetStyleSheet(nsCSSStyleSheet* aSheet); virtual void SetParentRule(GroupRule* aRule); diff --git a/layout/style/StyleRule.cpp b/layout/style/StyleRule.cpp index e421a93981c..4c3eaf431c8 100644 --- a/layout/style/StyleRule.cpp +++ b/layout/style/StyleRule.cpp @@ -1074,9 +1074,8 @@ DOMCSSDeclarationImpl::GetCSSParsingEnvironment(nsIURI** aSheetURI, *aSheetPrincipal = nsnull; *aCSSLoader = nsnull; - nsCOMPtr sheet; if (mRule) { - sheet = mRule->GetStyleSheet(); + nsIStyleSheet* sheet = mRule->GetStyleSheet(); if (sheet) { NS_IF_ADDREF(*aSheetURI = sheet->GetSheetURI()); NS_IF_ADDREF(*aBaseURI = sheet->GetBaseURI()); diff --git a/layout/style/nsCSSRules.cpp b/layout/style/nsCSSRules.cpp index e0f2c9b64b5..cd535e2a258 100644 --- a/layout/style/nsCSSRules.cpp +++ b/layout/style/nsCSSRules.cpp @@ -86,10 +86,9 @@ namespace css { NS_IMPL_ADDREF(Rule) NS_IMPL_RELEASE(Rule) -/* virtual */ already_AddRefed +/* virtual */ nsIStyleSheet* Rule::GetStyleSheet() const { - NS_IF_ADDREF(mSheet); return mSheet; } diff --git a/layout/style/nsCSSStyleSheet.cpp b/layout/style/nsCSSStyleSheet.cpp index 60886846b89..e7e73917f60 100644 --- a/layout/style/nsCSSStyleSheet.cpp +++ b/layout/style/nsCSSStyleSheet.cpp @@ -1943,8 +1943,7 @@ nsCSSStyleSheet::DeleteRuleFromGroup(css::GroupRule* aGroup, PRUint32 aIndex) NS_ENSURE_TRUE(rule, NS_ERROR_ILLEGAL_VALUE); // check that the rule actually belongs to this sheet! - nsCOMPtr ruleSheet = rule->GetStyleSheet(); - if (this != ruleSheet) { + if (this != rule->GetStyleSheet()) { return NS_ERROR_INVALID_ARG; } @@ -1976,8 +1975,7 @@ nsCSSStyleSheet::InsertRuleIntoGroup(const nsAString & aRule, nsresult result; NS_ASSERTION(mInner->mComplete, "No inserting into an incomplete sheet!"); // check that the group actually belongs to this sheet! - nsCOMPtr groupSheet = aGroup->GetStyleSheet(); - if (this != groupSheet) { + if (this != aGroup->GetStyleSheet()) { return NS_ERROR_INVALID_ARG; } @@ -2047,12 +2045,7 @@ nsCSSStyleSheet::ReplaceRuleInGroup(css::GroupRule* aGroup, { nsresult result; NS_PRECONDITION(mInner->mComplete, "No replacing in an incomplete sheet!"); -#ifdef DEBUG - { - nsCOMPtr groupSheet = aGroup->GetStyleSheet(); - NS_ASSERTION(this == groupSheet, "group doesn't belong to this sheet"); - } -#endif + NS_ASSERTION(this == aGroup->GetStyleSheet(), "group doesn't belong to this sheet"); result = WillDirty(); NS_ENSURE_SUCCESS(result, result); diff --git a/layout/style/nsICSSRule.h b/layout/style/nsICSSRule.h index 94fefbf19c0..3d0f5656d57 100644 --- a/layout/style/nsICSSRule.h +++ b/layout/style/nsICSSRule.h @@ -83,7 +83,7 @@ public: virtual PRInt32 GetType() const = 0; - virtual already_AddRefed GetStyleSheet() const = 0; + virtual nsIStyleSheet* GetStyleSheet() const = 0; virtual void SetStyleSheet(nsCSSStyleSheet* aSheet) = 0; virtual void SetParentRule(mozilla::css::GroupRule* aRule) = 0;