Fix bug 246012 by not going through presshells at all while deciding whether a

docshell is an iframe.  r+sr=jst
This commit is contained in:
bzbarsky%mit.edu 2004-07-15 06:05:27 +00:00
Родитель 4c3a6e6c55
Коммит 67f658ce24
1 изменённых файлов: 9 добавлений и 28 удалений

Просмотреть файл

@ -5190,38 +5190,19 @@ nsEventStateManager::IsIFrameDoc(nsIDocShell* aDocShell)
{
NS_ASSERTION(aDocShell, "docshell is null");
nsCOMPtr<nsIDocShellTreeItem> treeItem = do_QueryInterface(aDocShell);
nsCOMPtr<nsIDocShellTreeItem> parentItem;
treeItem->GetParent(getter_AddRefs(parentItem));
if (!parentItem)
return PR_FALSE;
nsCOMPtr<nsIDocShell> parentDS = do_QueryInterface(parentItem);
nsCOMPtr<nsIPresShell> parentPresShell;
parentDS->GetPresShell(getter_AddRefs(parentPresShell));
NS_ASSERTION(parentPresShell, "presshell is null");
nsCOMPtr<nsIDocument> parentDoc;
parentPresShell->GetDocument(getter_AddRefs(parentDoc));
// The current docshell may not have a presshell, eg if it's a display:none
// iframe or if the presshell just hasn't been created yet. Get the
// document off the docshell directly.
nsCOMPtr<nsIDOMDocument> domDoc = do_GetInterface(aDocShell);
if (!domDoc) {
NS_ERROR("No document in docshell! How are we to decide whether this"
" is an iframe? Arbitrarily deciding it's not.");
nsCOMPtr<nsPIDOMWindow> domWindow = do_GetInterface(aDocShell);
if (!domWindow) {
NS_ERROR("We're a child of a docshell without a window?");
return PR_FALSE;
}
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
NS_ASSERTION(doc, "DOM document not implementing nsIDocument");
nsIContent *docContent = parentDoc->FindContentForSubDocument(doc);
if (!docContent)
nsCOMPtr<nsIContent> docContent =
do_QueryInterface(domWindow->GetFrameElementInternal());
if (!docContent) {
return PR_FALSE;
}
return docContent->Tag() == nsHTMLAtoms::iframe;
}