bug #90722.(r=danm@netscape.com, sr=mscott@netscape.com) Added nsIWindowWatcher::GetWindowByName(...).

git-svn-id: svn://10.0.0.236/trunk@105296 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
rpotts%netscape.com 2001-10-12 21:42:24 +00:00
parent 25caa8b542
commit 25794bac66
2 changed files with 54 additions and 0 deletions

View File

@ -136,6 +136,16 @@ interface nsIWindowWatcher : nsISupports {
*/
nsIWebBrowserChrome getChromeForWindow(in nsIDOMWindow aWindow);
/**
Retrieve an existing window (or frame).
@param aTargetName the window name
@param aCurrentWindow a starting point in the window hierarchy to
begin the search. If null, each toplevel window
will be searched.
*/
nsIDOMWindow getWindowByName(in wstring aTargetName,
in nsIDOMWindow aCurrentWindow);
/** The Watcher serves as a global storage facility for the current active
(frontmost non-floating-palette-type) window, storing and returning
it on demand. Users must keep this attribute current, including after

View File

@ -960,6 +960,50 @@ nsWindowWatcher::GetChromeForWindow(nsIDOMWindow *aWindow, nsIWebBrowserChrome *
return NS_OK;
}
NS_IMETHODIMP
nsWindowWatcher::GetWindowByName(const PRUnichar *aTargetName,
nsIDOMWindow *aCurrentWindow,
nsIDOMWindow **aResult)
{
if (!aResult) {
return NS_ERROR_INVALID_ARG;
}
*aResult = nsnull;
nsCOMPtr<nsIWebNavigation> webNav;
nsCOMPtr<nsIDocShellTreeItem> treeItem;
// First, check if the TargetName exists in the aCurrentWindow hierarchy
webNav = do_GetInterface(aCurrentWindow);
if (webNav) {
nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem;
docShellTreeItem = do_QueryInterface(webNav);
if (docShellTreeItem) {
docShellTreeItem->FindItemWithName(aTargetName, nsnull,
getter_AddRefs(treeItem));
}
}
// Next, see if the TargetName exists in any window hierarchy
if (!treeItem) {
FindItemWithName(aTargetName, getter_AddRefs(treeItem));
}
if (treeItem) {
nsCOMPtr<nsIDOMWindow> domWindow;
domWindow = do_GetInterface(treeItem);
if (domWindow) {
*aResult = domWindow;
NS_ADDREF(*aResult);
}
}
return NS_OK;
}
PRBool
nsWindowWatcher::AddEnumerator(nsWatcherWindowEnumerator* inEnumerator)
{