зеркало из https://github.com/mozilla/pjs.git
Bug 732495 - clean up refcounting for nsXBLDocumentInfo creation to fix leak. r=smaug
This commit is contained in:
Родитель
1e10331fe7
Коммит
c735d40322
|
@ -423,8 +423,13 @@ nsXBLContentSink::OnOpenContainer(const PRUnichar **aAtts,
|
|||
bool ret = true;
|
||||
if (aTagName == nsGkAtoms::bindings) {
|
||||
ENSURE_XBL_STATE(mState == eXBL_InDocument);
|
||||
|
||||
mDocInfo = NS_NewXBLDocumentInfo(mDocument);
|
||||
|
||||
NS_ASSERTION(mDocument, "Must have a document!");
|
||||
nsRefPtr<nsXBLDocumentInfo> info = new nsXBLDocumentInfo(mDocument);
|
||||
|
||||
// We keep a weak ref. We're creating a cycle between doc/binding manager/doc info.
|
||||
mDocInfo = info;
|
||||
|
||||
if (!mDocInfo) {
|
||||
mState = eXBL_Error;
|
||||
return true;
|
||||
|
@ -433,16 +438,14 @@ nsXBLContentSink::OnOpenContainer(const PRUnichar **aAtts,
|
|||
mDocument->BindingManager()->PutXBLDocumentInfo(mDocInfo);
|
||||
|
||||
nsIURI *uri = mDocument->GetDocumentURI();
|
||||
|
||||
|
||||
bool isChrome = false;
|
||||
bool isRes = false;
|
||||
|
||||
uri->SchemeIs("chrome", &isChrome);
|
||||
uri->SchemeIs("resource", &isRes);
|
||||
mIsChromeOrResource = isChrome || isRes;
|
||||
|
||||
nsXBLDocumentInfo* info = mDocInfo;
|
||||
NS_RELEASE(info); // We keep a weak ref. We've created a cycle between doc/binding manager/doc info.
|
||||
|
||||
mState = eXBL_InBindings;
|
||||
}
|
||||
else if (aTagName == nsGkAtoms::binding) {
|
||||
|
|
|
@ -682,7 +682,8 @@ nsXBLDocumentInfo::ReadPrototypeBindings(nsIURI* aURI, nsXBLDocumentInfo** aDocI
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
|
||||
nsRefPtr<nsXBLDocumentInfo> docInfo = NS_NewXBLDocumentInfo(doc);
|
||||
NS_ASSERTION(doc, "Must have a document!");
|
||||
nsRefPtr<nsXBLDocumentInfo> docInfo = new nsXBLDocumentInfo(doc);
|
||||
|
||||
while (1) {
|
||||
PRUint8 flags;
|
||||
|
@ -783,14 +784,3 @@ nsXBLDocumentInfo::GetScriptGlobalObject()
|
|||
|
||||
return mGlobalObject;
|
||||
}
|
||||
|
||||
nsXBLDocumentInfo* NS_NewXBLDocumentInfo(nsIDocument* aDocument)
|
||||
{
|
||||
NS_PRECONDITION(aDocument, "Must have a document!");
|
||||
|
||||
nsXBLDocumentInfo* result;
|
||||
|
||||
result = new nsXBLDocumentInfo(aDocument);
|
||||
NS_ADDREF(result);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -101,6 +101,4 @@ private:
|
|||
nsRefPtr<nsXBLDocGlobalObject> mGlobalObject;
|
||||
};
|
||||
|
||||
nsXBLDocumentInfo* NS_NewXBLDocumentInfo(nsIDocument* aDocument);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1106,11 +1106,7 @@ nsXBLService::LoadBindingDocumentInfo(nsIContent* aBoundElement,
|
|||
}
|
||||
}
|
||||
|
||||
if (!info)
|
||||
return NS_OK;
|
||||
|
||||
*aResult = info;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
info.forget(aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче