mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-29 03:44:37 +00:00
bug 329335, unhook template builder when removing root node, r+sr=bz
This commit is contained in:
parent
d930ffbce5
commit
16fd9a63a3
@ -1808,7 +1808,7 @@ nsXULDocument::SetTemplateBuilderFor(nsIContent* aContent,
|
||||
|
||||
nsISupportsKey key(aContent);
|
||||
|
||||
if (aContent) {
|
||||
if (aBuilder) {
|
||||
mTemplateBuilderTable->Put(&key, aBuilder);
|
||||
}
|
||||
else {
|
||||
|
@ -1582,10 +1582,11 @@ nsresult
|
||||
nsXULContentBuilder::GetElementsForResult(nsIXULTemplateResult* aResult,
|
||||
nsISupportsArray* aElements)
|
||||
{
|
||||
// if the root has been removed from the document, just return
|
||||
// since there won't be any generated content any more
|
||||
nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(mRoot->GetDocument());
|
||||
NS_ASSERTION(xuldoc, "expected a XUL document");
|
||||
if (! xuldoc)
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_OK;
|
||||
|
||||
nsAutoString id;
|
||||
aResult->GetId(id);
|
||||
@ -1697,10 +1698,10 @@ nsXULContentBuilder::HasGeneratedContent(nsIRDFResource* aResource,
|
||||
|
||||
NS_ConvertUTF8toUTF16 refID(uri);
|
||||
|
||||
// just return if the node is no longer in a document
|
||||
nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(mRoot->GetDocument());
|
||||
NS_ASSERTION(xuldoc, "expected a XUL document");
|
||||
if (! xuldoc)
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsISupportsArray> elements;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(elements));
|
||||
@ -2004,9 +2005,8 @@ nsXULContentBuilder::OpenContainer(nsIContent* aElement)
|
||||
// The tree widget is special, and has to be spanked every
|
||||
// time we add content to a container.
|
||||
nsCOMPtr<nsIDocument> doc = mRoot->GetDocument();
|
||||
NS_ASSERTION(doc, "root element has no document");
|
||||
if (! doc)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
return NS_OK;
|
||||
|
||||
doc->ContentAppended(container, newIndex);
|
||||
}
|
||||
|
@ -880,6 +880,31 @@ nsXULTemplateBuilder::AttributeChanged(nsIDocument* aDocument,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsXULTemplateBuilder::ContentRemoved(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
if (mRoot && nsContentUtils::ContentIsDescendantOf(mRoot, aChild)) {
|
||||
if (mQueryProcessor)
|
||||
mQueryProcessor->Done();
|
||||
|
||||
// use false since content is going away anyway
|
||||
Uninit(PR_FALSE);
|
||||
|
||||
aDocument->RemoveObserver(this);
|
||||
|
||||
nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(aDocument);
|
||||
if (xuldoc)
|
||||
xuldoc->SetTemplateBuilderFor(aChild, nsnull);
|
||||
|
||||
mDB = nsnull;
|
||||
mCompDB = nsnull;
|
||||
mRoot = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsXULTemplateBuilder::DocumentWillBeDestroyed(nsIDocument *aDocument)
|
||||
{
|
||||
@ -1376,9 +1401,8 @@ nsXULTemplateBuilder::GetTemplateRoot(nsIContent** aResult)
|
||||
|
||||
if (! templateID.IsEmpty()) {
|
||||
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(mRoot->GetDocument());
|
||||
NS_ASSERTION(domDoc, "expected a XUL document");
|
||||
if (! domDoc)
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMElement> domElement;
|
||||
domDoc->GetElementById(templateID, getter_AddRefs(domElement));
|
||||
@ -1407,9 +1431,8 @@ nsXULTemplateBuilder::GetTemplateRoot(nsIContent** aResult)
|
||||
// If we couldn't find a real child, look through the anonymous
|
||||
// kids, too.
|
||||
nsCOMPtr<nsIDocument> doc = mRoot->GetDocument();
|
||||
NS_ASSERTION(doc, "root element has no document");
|
||||
if (! doc)
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMNodeList> kids;
|
||||
doc->BindingManager()->GetXBLChildNodesFor(mRoot, getter_AddRefs(kids));
|
||||
|
@ -100,6 +100,10 @@ public:
|
||||
virtual void AttributeChanged(nsIDocument *aDocument, nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
PRInt32 aModType);
|
||||
virtual void ContentRemoved(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer);
|
||||
virtual void DocumentWillBeDestroyed(nsIDocument *aDocument);
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user