Bug 529087: Fix crash involving XBL and cloned XUL elements. r=smaug

This commit is contained in:
Jonas Sicking 2010-05-26 15:39:13 -07:00
parent 7e8118a1bf
commit f2fa47761e
2 changed files with 18 additions and 2 deletions

View File

@ -269,8 +269,22 @@ nsNodeUtils::LastRelease(nsINode* aNode)
if (aNode->IsElement()) {
nsIDocument* ownerDoc = aNode->GetOwnerDoc();
Element* elem = aNode->AsElement();
if (ownerDoc) {
ownerDoc->ClearBoxObjectFor(aNode->AsElement());
ownerDoc->ClearBoxObjectFor(elem);
}
NS_ASSERTION(aNode->HasFlag(NODE_FORCE_XBL_BINDINGS) ||
!ownerDoc ||
!ownerDoc->BindingManager() ||
!ownerDoc->BindingManager()->GetBinding(cont),
"Non-forced node has binding on destruction");
// if NODE_FORCE_XBL_BINDINGS is set, the node might still have a binding
// attached
if (aNode->HasFlag(NODE_FORCE_XBL_BINDINGS) &&
ownerDoc && ownerDoc->BindingManager()) {
ownerDoc->BindingManager()->ChangeDocumentFor(elem, ownerDoc, nsnull);
}
}

View File

@ -972,7 +972,9 @@ nsXBLBinding::ExecuteAttachedHandler()
if (mNextBinding)
mNextBinding->ExecuteAttachedHandler();
if (AllowScripts())
// Executing mNextBindings constructor might have caused us to loose our
// bound element
if (mBoundElement && AllowScripts())
mPrototypeBinding->BindingAttached(mBoundElement);
}