Bug 1126010 - XULContentSinkImpl::mParser should be an nsRefPtr. r=smaug

This commit is contained in:
Andrew McCreight 2015-04-20 12:47:20 -07:00
parent d0f6f3bedc
commit fdc89d08f8
2 changed files with 5 additions and 11 deletions

View File

@ -162,8 +162,7 @@ XULContentSinkImpl::XULContentSinkImpl()
mTextLength(0),
mTextSize(0),
mConstrainSize(true),
mState(eInProlog),
mParser(nullptr)
mState(eInProlog)
{
#ifdef PR_LOGGING
@ -175,8 +174,6 @@ XULContentSinkImpl::XULContentSinkImpl()
XULContentSinkImpl::~XULContentSinkImpl()
{
NS_IF_RELEASE(mParser); // XXX should've been released by now, unless error.
// The context stack _should_ be empty, unless something has gone wrong.
NS_ASSERTION(mContextStack.Depth() == 0, "Context stack not empty?");
mContextStack.Clear();
@ -193,14 +190,14 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(XULContentSinkImpl)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mNodeInfoManager)
tmp->mContextStack.Clear();
NS_IMPL_CYCLE_COLLECTION_UNLINK(mPrototype)
NS_IF_RELEASE(tmp->mParser);
NS_IMPL_CYCLE_COLLECTION_UNLINK(mParser)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(XULContentSinkImpl)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mNodeInfoManager)
tmp->mContextStack.Traverse(cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPrototype)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(mParser)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParser)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(XULContentSinkImpl)
@ -241,7 +238,7 @@ XULContentSinkImpl::DidBuildModel(bool aTerminated)
// Drop our reference to the parser to get rid of a circular
// reference.
NS_IF_RELEASE(mParser);
mParser = nullptr;
return NS_OK;
}
@ -262,9 +259,7 @@ XULContentSinkImpl::WillResume(void)
NS_IMETHODIMP
XULContentSinkImpl::SetParser(nsParserBase* aParser)
{
NS_IF_RELEASE(mParser);
mParser = aParser;
NS_IF_ADDREF(mParser);
return NS_OK;
}

View File

@ -144,8 +144,7 @@ protected:
nsRefPtr<nsXULPrototypeDocument> mPrototype; // [OWNER]
// We use regular pointer b/c of funky exports on nsIParser:
nsParserBase* mParser; // [OWNER]
nsRefPtr<nsParserBase> mParser;
nsCOMPtr<nsIScriptSecurityManager> mSecMan;
};