From 67f658ce247e6496e5d1aa2dc662a611ecce5241 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Thu, 15 Jul 2004 06:05:27 +0000 Subject: [PATCH] Fix bug 246012 by not going through presshells at all while deciding whether a docshell is an iframe. r+sr=jst --- content/events/src/nsEventStateManager.cpp | 37 ++++++---------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index 11df6193c8d..5542f8d0e70 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/content/events/src/nsEventStateManager.cpp @@ -5190,38 +5190,19 @@ nsEventStateManager::IsIFrameDoc(nsIDocShell* aDocShell) { NS_ASSERTION(aDocShell, "docshell is null"); - nsCOMPtr treeItem = do_QueryInterface(aDocShell); - nsCOMPtr parentItem; - treeItem->GetParent(getter_AddRefs(parentItem)); - if (!parentItem) - return PR_FALSE; - - nsCOMPtr parentDS = do_QueryInterface(parentItem); - nsCOMPtr parentPresShell; - parentDS->GetPresShell(getter_AddRefs(parentPresShell)); - NS_ASSERTION(parentPresShell, "presshell is null"); - - nsCOMPtr 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 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 domWindow = do_GetInterface(aDocShell); + if (!domWindow) { + NS_ERROR("We're a child of a docshell without a window?"); return PR_FALSE; } - nsCOMPtr doc(do_QueryInterface(domDoc)); - NS_ASSERTION(doc, "DOM document not implementing nsIDocument"); - - nsIContent *docContent = parentDoc->FindContentForSubDocument(doc); - - if (!docContent) + nsCOMPtr docContent = + do_QueryInterface(domWindow->GetFrameElementInternal()); + + if (!docContent) { return PR_FALSE; - + } + return docContent->Tag() == nsHTMLAtoms::iframe; }