From 8bbf26beb96ac69b08d887ec65b15baa1049ae64 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 50c7e45bf355..75afbd1d567f 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 e421a93981c0..4c3eaf431c85 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 e0f2c9b64b5c..cd535e2a2589 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 60886846b895..e7e73917f601 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 94fefbf19c00..3d0f5656d57b 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;