Bug 852687 - Adding getCurrentInnerWindowWithId to nsIWindowMediator. r=bz

This commit is contained in:
Gabor Krizsanits 2013-05-13 12:10:45 +02:00
parent 00a68469c0
commit b0a9e78705
2 changed files with 31 additions and 2 deletions

View File

@ -8,8 +8,8 @@
%{C++
#define NS_WINDOWMEDIATOR_CID \
{ 0x808b2fa3, 0x8a02, 0x49ca, \
{ 0x91, 0x04, 0x5f, 0x77, 0x29, 0x9e, 0x09, 0x0b } }
{ 0x79a2b7cc, 0xf05b, 0x4605, \
{ 0xbf, 0xa0, 0xfa, 0xc5, 0x4f, 0x27, 0xee, 0xc8 } }
#define NS_WINDOWMEDIATOR_CONTRACTID \
"@mozilla.org/appshell/window-mediator;1"
@ -74,6 +74,13 @@ interface nsIWindowMediator: nsISupports
*/
nsIDOMWindow getOuterWindowWithId(in unsigned long long aOuterWindowID);
/**
* Return the outer window with the given current window ID, if any.
* Can return null if no inner window with the ID exists or if it's not
* a current inner anymore.
*/
nsIDOMWindow getCurrentInnerWindowWithId(in unsigned long long aInnerWindowID);
/** Add the window to the list of known windows. Listeners (see
* addListener) will be notified through their onOpenWindow method.
* @param aWindow the window to add

View File

@ -330,6 +330,28 @@ nsWindowMediator::GetOuterWindowWithId(uint64_t aWindowID,
return NS_OK;
}
NS_IMETHODIMP
nsWindowMediator::GetCurrentInnerWindowWithId(uint64_t aWindowID,
nsIDOMWindow** aWindow)
{
nsCOMPtr<nsPIDOMWindow> inner = nsGlobalWindow::GetInnerWindowWithId(aWindowID);
// not found
if (!inner)
return NS_OK;
nsCOMPtr<nsPIDOMWindow> outer = inner->GetOuterWindow();
NS_ENSURE_TRUE(outer, NS_ERROR_UNEXPECTED);
// outer is already using another inner, so it's same as not found
if (outer->GetCurrentInnerWindow() != inner)
return NS_OK;
nsCOMPtr<nsIDOMWindow> ret = outer;
ret.forget(aWindow);
return NS_OK;
}
NS_IMETHODIMP
nsWindowMediator::UpdateWindowTimeStamp(nsIXULWindow* inWindow)
{