Go back to creating an inconsistent DOM and add a null-check elsewhere, because

the little mind of the focus code is blown by having no documentElement,
apparently. Bug 341730, r+sr=sicking, a=beltzner


git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@203221 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzbarsky%mit.edu
2006-07-20 03:20:49 +00:00
parent e65f8a086f
commit 56319bb6db
2 changed files with 11 additions and 12 deletions

View File

@@ -4928,17 +4928,15 @@ nsDocument::Destroy()
mIsGoingAway = PR_TRUE; mIsGoingAway = PR_TRUE;
DestroyLinkMap(); DestroyLinkMap();
for (PRInt32 indx = 0; indx < count; ++indx) { for (PRInt32 indx = 0; indx < count; ++indx) {
nsIContent* content = mChildren.ChildAt(indx); // XXXbz what we _should_ do here is to clear mChildren and null out
if (content == mRootContent) { // mRootContent. If we did this (or at least the latter), we could remove
// Null out mRootContent first; this is similar to what RemoveChildAt() // the silly null-checks in nsHTMLDocument::MatchLinks. Unfortunately,
// does. // doing that introduces several problems:
mRootContent = nsnull; // 1) Focus issues (see bug 341730). The fix for bug 303260 may fix these.
} // 2) Crashes in OnPageHide if it fires after Destroy. See bug 303260
// comments 9 and 10.
// XXXbz what about document observer notifications? We really need to get // So we're just creating an inconsistent DOM for now and hoping. :(
// rid of this Destroy() method! mChildren.ChildAt(indx)->UnbindFromTree();
content->UnbindFromTree();
} }
// Propagate the out-of-band notification to each PresShell's anonymous // Propagate the out-of-band notification to each PresShell's anonymous

View File

@@ -1732,8 +1732,9 @@ nsHTMLDocument::MatchLinks(nsIContent *aContent, PRInt32 aNamespaceID,
nsIAtom* aAtom, const nsAString& aData) nsIAtom* aAtom, const nsAString& aData)
{ {
nsINodeInfo *ni = aContent->GetNodeInfo(); nsINodeInfo *ni = aContent->GetNodeInfo();
nsIDocument *doc = aContent->GetDocument();
if (ni) { if (ni && doc) {
NS_ASSERTION(aContent->IsInDoc(), NS_ASSERTION(aContent->IsInDoc(),
"This method should never be called on content nodes that " "This method should never be called on content nodes that "
"are not in a document!"); "are not in a document!");