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:
parent
25caa8b542
commit
25794bac66
@ -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
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user