From 290cfd18f536cb0c8252ea1e9db4027e62c6bc26 Mon Sep 17 00:00:00 2001 From: "tbogard%aol.net" Date: Thu, 10 Feb 2000 07:41:11 +0000 Subject: [PATCH] Fixed a bug where when targetting to a "_content" window from within a XUL window that did not have a browser window would not find an already open browser to target into. r=hyatt git-svn-id: svn://10.0.0.236/trunk@60303 18797224-902f-48f8-a5cc-f745e15eee43 --- .../xpfe/appshell/src/nsChromeTreeOwner.cpp | 48 +++++++++++++------ .../xpfe/appshell/src/nsContentTreeOwner.cpp | 31 ++++++++---- 2 files changed, 55 insertions(+), 24 deletions(-) diff --git a/mozilla/xpfe/appshell/src/nsChromeTreeOwner.cpp b/mozilla/xpfe/appshell/src/nsChromeTreeOwner.cpp index cd51b8e2a66..61000f3f6a6 100644 --- a/mozilla/xpfe/appshell/src/nsChromeTreeOwner.cpp +++ b/mozilla/xpfe/appshell/src/nsChromeTreeOwner.cpp @@ -94,13 +94,21 @@ NS_IMETHODIMP nsChromeTreeOwner::FindItemWithName(const PRUnichar* aName, nsAutoString name(aName); + PRBool fIs_Content = PR_FALSE; + /* Special Cases */ if(name.Length() == 0) return NS_OK; if(name.EqualsIgnoreCase("_blank")) return NS_OK; if(name.EqualsIgnoreCase("_content")) - return mXULWindow->GetPrimaryContentShell(aFoundItem); + { + fIs_Content = PR_TRUE; + mXULWindow->GetPrimaryContentShell(aFoundItem); + if(*aFoundItem) + return NS_OK; + // Otherwise fall through and ask the other windows for a content area. + } nsCOMPtr windowMediator(do_GetService(kWindowMediatorCID)); NS_ENSURE_TRUE(windowMediator, NS_ERROR_FAILURE); @@ -119,22 +127,32 @@ NS_IMETHODIMP nsChromeTreeOwner::FindItemWithName(const PRUnichar* aName, nsCOMPtr xulWindow(do_QueryInterface(nextWindow)); NS_ENSURE_TRUE(xulWindow, NS_ERROR_FAILURE); - nsCOMPtr shell; - xulWindow->GetDocShell(getter_AddRefs(shell)); - - nsCOMPtr shellAsTreeItem(do_QueryInterface(shell)); - if(shellAsTreeItem && (aRequestor != shellAsTreeItem.get())) + nsCOMPtr shellAsTreeItem; + + if(fIs_Content) { - // Do this so we can pass in the tree owner as the requestor so the child knows not - // to call back up. - nsCOMPtr shellOwner; - shellAsTreeItem->GetTreeOwner(getter_AddRefs(shellOwner)); - nsCOMPtr shellOwnerSupports(do_QueryInterface(shellOwner)); - - shellAsTreeItem->FindItemWithName(aName, shellOwnerSupports, aFoundItem); - if(*aFoundItem) - return NS_OK; + xulWindow->GetPrimaryContentShell(getter_AddRefs(shellAsTreeItem)); + if(shellAsTreeItem) + *aFoundItem = shellAsTreeItem; } + else + { + nsCOMPtr shell; + xulWindow->GetDocShell(getter_AddRefs(shell)); + shellAsTreeItem = do_QueryInterface(shell); + if(shellAsTreeItem && (aRequestor != shellAsTreeItem.get())) + { + // Do this so we can pass in the tree owner as the requestor so the child knows not + // to call back up. + nsCOMPtr shellOwner; + shellAsTreeItem->GetTreeOwner(getter_AddRefs(shellOwner)); + nsCOMPtr shellOwnerSupports(do_QueryInterface(shellOwner)); + + shellAsTreeItem->FindItemWithName(aName, shellOwnerSupports, aFoundItem); + } + } + if(*aFoundItem) + return NS_OK; windowEnumerator->HasMoreElements(&more); } return NS_OK; diff --git a/mozilla/xpfe/appshell/src/nsContentTreeOwner.cpp b/mozilla/xpfe/appshell/src/nsContentTreeOwner.cpp index 48f5b8de425..3f873f989f6 100644 --- a/mozilla/xpfe/appshell/src/nsContentTreeOwner.cpp +++ b/mozilla/xpfe/appshell/src/nsContentTreeOwner.cpp @@ -100,13 +100,20 @@ NS_IMETHODIMP nsContentTreeOwner::FindItemWithName(const PRUnichar* aName, nsAutoString name(aName); + PRBool fIs_Content = PR_FALSE; + /* Special Cases */ if(name.Length() == 0) return NS_OK; if(name.EqualsIgnoreCase("_blank")) return NS_OK; if(name.EqualsIgnoreCase("_content")) - return mXULWindow->GetPrimaryContentShell(aFoundItem); + { + fIs_Content = PR_TRUE; + mXULWindow->GetPrimaryContentShell(aFoundItem); + if(*aFoundItem) + return NS_OK; + } nsCOMPtr windowMediator(do_GetService(kWindowMediatorCID)); NS_ENSURE_TRUE(windowMediator, NS_ERROR_FAILURE); @@ -127,15 +134,21 @@ NS_IMETHODIMP nsContentTreeOwner::FindItemWithName(const PRUnichar* aName, nsCOMPtr shellAsTreeItem; xulWindow->GetPrimaryContentShell(getter_AddRefs(shellAsTreeItem)); - if(shellAsTreeItem && (aRequestor != shellAsTreeItem.get())) - { - // Do this so we can pass in the tree owner as the requestor so the child knows not - // to call back up. - nsCOMPtr shellOwner; - shellAsTreeItem->GetTreeOwner(getter_AddRefs(shellOwner)); - nsCOMPtr shellOwnerSupports(do_QueryInterface(shellOwner)); - shellAsTreeItem->FindItemWithName(aName, shellOwnerSupports, aFoundItem); + if(shellAsTreeItem) + { + if(fIs_Content) + *aFoundItem = shellAsTreeItem; + else if(aRequestor != shellAsTreeItem.get()) + { + // Do this so we can pass in the tree owner as the requestor so the child knows not + // to call back up. + nsCOMPtr shellOwner; + shellAsTreeItem->GetTreeOwner(getter_AddRefs(shellOwner)); + nsCOMPtr shellOwnerSupports(do_QueryInterface(shellOwner)); + + shellAsTreeItem->FindItemWithName(aName, shellOwnerSupports, aFoundItem); + } if(*aFoundItem) return NS_OK; }