Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 810103 - Make nsCSSStyleSheet::mRuleCollection into an nsRefPtr. …
Browse files Browse the repository at this point in the history
…r=bz
  • Loading branch information
amccreight committed Nov 12, 2012
1 parent 41349c5 commit 495f8d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
13 changes: 3 additions & 10 deletions layout/style/nsCSSStyleSheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,6 @@ nsCSSStyleSheet::nsCSSStyleSheet(CORSMode aCORSMode)
: mTitle(),
mParent(nullptr),
mOwnerRule(nullptr),
mRuleCollection(nullptr),
mDocument(nullptr),
mOwningNode(nullptr),
mDisabled(false),
Expand All @@ -1048,7 +1047,6 @@ nsCSSStyleSheet::nsCSSStyleSheet(const nsCSSStyleSheet& aCopy,
: mTitle(aCopy.mTitle),
mParent(aParentToUse),
mOwnerRule(aOwnerRuleToUse),
mRuleCollection(nullptr), // re-created lazily
mDocument(aDocumentToUse),
mOwningNode(aOwningNodeToUse),
mDisabled(aCopy.mDisabled),
Expand Down Expand Up @@ -1101,7 +1099,7 @@ nsCSSStyleSheet::DropRuleCollection()
{
if (mRuleCollection) {
mRuleCollection->DropReference();
NS_RELEASE(mRuleCollection);
mRuleCollection = nullptr;
}
}

Expand Down Expand Up @@ -1204,7 +1202,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsCSSStyleSheet)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mMedia)
// We do not traverse mNext; our parent will handle that. See
// comments in Unlink for why.
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(mRuleCollection)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mRuleCollection)
tmp->TraverseInner(cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

Expand Down Expand Up @@ -1858,14 +1856,9 @@ nsCSSStyleSheet::GetCssRules(nsIDOMCSSRuleList** aCssRules)
// OK, security check passed, so get the rule collection
if (nullptr == mRuleCollection) {
mRuleCollection = new CSSRuleListImpl(this);
if (nullptr == mRuleCollection) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(mRuleCollection);
}

*aCssRules = mRuleCollection;
NS_ADDREF(mRuleCollection);
NS_ADDREF(*aCssRules = mRuleCollection);

return NS_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion layout/style/nsCSSStyleSheet.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ class nsCSSStyleSheet MOZ_FINAL : public nsIStyleSheet,
nsCSSStyleSheet* mParent; // weak ref
mozilla::css::ImportRule* mOwnerRule; // weak ref

CSSRuleListImpl* mRuleCollection;
nsRefPtr<CSSRuleListImpl> mRuleCollection;
nsIDocument* mDocument; // weak ref; parents maintain this for their children
nsIDOMNode* mOwningNode; // weak ref
bool mDisabled;
Expand Down

0 comments on commit 495f8d8

Please sign in to comment.