Crash if JavaScript close() is executed from onchange handler. b=308025 r+sr=bzbarsky

This commit is contained in:
mats.palmgren%bredband.net 2005-09-14 05:03:20 +00:00
parent b7065e027d
commit 201de18c1d

View File

@ -3406,19 +3406,26 @@ nsEventStateManager::ShiftFocusInternal(PRBool aForward, nsIContent* aStart)
nsCOMPtr<nsIPresShell> parentShell;
parentDS->GetPresShell(getter_AddRefs(parentShell));
nsIDocument *parent_doc = parentShell->GetDocument();
nsIContent *docContent = parent_doc->FindContentForSubDocument(mDocument);
nsCOMPtr<nsIDocument> parent_doc = parentShell->GetDocument();
nsCOMPtr<nsIContent> docContent = parent_doc->FindContentForSubDocument(mDocument);
nsCOMPtr<nsPresContext> parentPC = parentShell->GetPresContext();
nsIEventStateManager *parentESM = parentPC->EventStateManager();
SetContentState(nsnull, NS_EVENT_STATE_FOCUS);
nsCOMPtr<nsISupports> parentContainer = parentPC->GetContainer();
if (parentContainer && docContent && docContent->GetCurrentDoc() == parent_doc) {
#ifdef DEBUG_DOCSHELL_FOCUS
printf("popping out focus to parent docshell\n");
printf("popping out focus to parent docshell\n");
#endif
parentESM->MoveCaretToFocus();
parentESM->ShiftFocus(aForward, docContent);
parentESM->MoveCaretToFocus();
parentESM->ShiftFocus(aForward, docContent);
#ifdef DEBUG_DOCSHELL_FOCUS
} else {
printf("can't pop out focus to parent docshell\n"); // bug 308025
#endif
}
}
} else {
PRBool tookFocus = PR_FALSE;