Bug 861495 - Part 1: Add nsIWindowMediator.getOuterWindowWithId and warn on nsIDOMWindowUtils.getOuterWindowWithId use. r=bz

This commit is contained in:
Colby Russell 2013-05-07 12:34:20 -04:00
parent 51905450be
commit 1b1dd2fcc3
6 changed files with 31 additions and 3 deletions

View File

@ -71,6 +71,7 @@
#include "nsPrintfCString.h"
#include "nsViewportInfo.h"
#include "nsIFormControl.h"
#include "nsIScriptError.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -2514,6 +2515,13 @@ nsDOMWindowUtils::GetOuterWindowWithId(uint64_t aWindowID,
return NS_ERROR_DOM_SECURITY_ERR;
}
// XXX This method is deprecated. See bug 865664.
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
"DOM",
nsContentUtils::GetDocumentFromCaller(),
nsContentUtils::eDOM_PROPERTIES,
"GetWindowWithOuterIdWarning");
*aWindow = nsGlobalWindow::GetOuterWindowWithId(aWindowID);
NS_IF_ADDREF(*aWindow);
return NS_OK;

View File

@ -1111,6 +1111,7 @@ interface nsIDOMWindowUtils : nsISupports {
/**
* Return the outer window with the given ID, if any. Can return null.
* @deprecated Use nsIWindowMediator.getOuterWindowWithId. See bug 865664.
*/
nsIDOMWindow getOuterWindowWithId(in unsigned long long aOuterWindowID);

View File

@ -133,3 +133,5 @@ NodeIteratorDetachWarning=Calling detach() on a NodeIterator no longer has an ef
MozAudioDataWarning=The Mozilla Audio Data API is deprecated. Please use the Web Audio API instead.
# LOCALIZATION NOTE: Do not translate "LenientThis" and "this"
LenientThisWarning=Ignoring get or set of property that has [LenientThis] because the "this" object is incorrect.
# LOCALIZATION NOTE: Do not translate "nsIDOMWindowUtils", "getWindowWithOuterId", or "nsIWindowMediator"
GetWindowWithOuterIdWarning=Use of nsIDOMWindowUtils.getOuterWindowWithId() is deprecated. Instead, use the nsIWindowMediator method of the same name.

View File

@ -8,8 +8,8 @@
%{C++
#define NS_WINDOWMEDIATOR_CID \
{ 0x292e17c8, 0xccc1, 0x42e1, \
{ 0xac, 0x8b, 0xaf, 0x61, 0x7d, 0x54, 0x13, 0xb1 } }
{ 0x808b2fa3, 0x8a02, 0x49ca, \
{ 0x91, 0x04, 0x5f, 0x77, 0x29, 0x9e, 0x09, 0x0b } }
#define NS_WINDOWMEDIATOR_CONTRACTID \
"@mozilla.org/appshell/window-mediator;1"
@ -20,7 +20,7 @@ interface nsIWidget;
interface nsIDOMWindow;
interface nsIWindowMediatorListener;
[scriptable, uuid(292e17c8-ccc1-42e1-ac8b-af617d5413b1)]
[scriptable, uuid(808b2fa3-8a02-49ca-9104-5f77299e090b)]
interface nsIWindowMediator: nsISupports
{
/** Return an enumerator which iterates over all windows of type aWindowType
@ -69,6 +69,11 @@ interface nsIWindowMediator: nsISupports
*/
nsIDOMWindow getMostRecentWindow(in wstring aWindowType);
/**
* Return the outer window with the given ID, if any. Can return null.
*/
nsIDOMWindow getOuterWindowWithId(in unsigned long long aOuterWindowID);
/** 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

@ -28,5 +28,7 @@ CPPSRCS = \
nsAppShellFactory.cpp \
$(NULL)
LOCAL_INCLUDES += -I$(topsrcdir)/dom/base
include $(topsrcdir)/config/rules.mk

View File

@ -18,6 +18,7 @@
#include "nsWindowMediator.h"
#include "nsIWindowMediatorListener.h"
#include "nsXPIDLString.h"
#include "nsGlobalWindow.h"
#include "nsIDocShell.h"
#include "nsIInterfaceRequestor.h"
@ -320,6 +321,15 @@ nsWindowMediator::MostRecentWindowInfo(const PRUnichar* inType)
return foundInfo;
}
NS_IMETHODIMP
nsWindowMediator::GetOuterWindowWithId(uint64_t aWindowID,
nsIDOMWindow** aWindow)
{
*aWindow = nsGlobalWindow::GetOuterWindowWithId(aWindowID);
NS_IF_ADDREF(*aWindow);
return NS_OK;
}
NS_IMETHODIMP
nsWindowMediator::UpdateWindowTimeStamp(nsIXULWindow* inWindow)
{