Bug 861495 - Part 1: Add nsIWindowMediator.getOuterWindowWithId and warn on nsIDOMWindowUtils.getOuterWindowWithId use. r=bz
authorColby Russell <Sevenspade@gmail.com>
Tue, 07 May 2013 12:34:20 -0400
changeset 141958 c26f304056f214ba10db50bc8b3383e33c325c2c
parent 141957 3b401ef43264d3810cc66b5bf1776eea734d9063
child 141959 fe584ef9c4b6480c4e673b86d4b79b605583e313
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs861495
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 861495 - Part 1: Add nsIWindowMediator.getOuterWindowWithId and warn on nsIDOMWindowUtils.getOuterWindowWithId use. r=bz
dom/base/nsDOMWindowUtils.cpp
dom/interfaces/base/nsIDOMWindowUtils.idl
dom/locales/en-US/chrome/dom/dom.properties
xpfe/appshell/public/nsIWindowMediator.idl
xpfe/appshell/src/Makefile.in
xpfe/appshell/src/nsWindowMediator.cpp
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -66,16 +66,17 @@
 #include "mozilla/dom/indexedDB/IndexedDatabaseManager.h"
 #include "mozilla/dom/quota/QuotaManager.h"
 #include "GeckoProfiler.h"
 #include "nsDOMBlobBuilder.h"
 #include "nsIDOMFileHandle.h"
 #include "nsPrintfCString.h"
 #include "nsViewportInfo.h"
 #include "nsIFormControl.h"
+#include "nsIScriptError.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::layers;
 using namespace mozilla::widget;
 
 DOMCI_DATA(WindowUtils, nsDOMWindowUtils)
 
@@ -2509,16 +2510,23 @@ nsDOMWindowUtils::GetDisplayDPI(float *a
 NS_IMETHODIMP
 nsDOMWindowUtils::GetOuterWindowWithId(uint64_t aWindowID,
                                        nsIDOMWindow** aWindow)
 {
   if (!nsContentUtils::IsCallerChrome()) {
     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;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::WrapDOMFile(nsIFile *aFile,
                               nsIDOMFile **aDOMFile)
--- a/dom/interfaces/base/nsIDOMWindowUtils.idl
+++ b/dom/interfaces/base/nsIDOMWindowUtils.idl
@@ -1106,16 +1106,17 @@ interface nsIDOMWindowUtils : nsISupport
 
   /**
    * The DPI of the display
    */
   readonly attribute float displayDPI;
 
   /**
    * 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);
 
   [noscript] void RenderDocument(in nsConstRect aRect,
                                  in uint32_t aFlags,
                                  in nscolor aBackgroundColor,
                                  in gfxContext aThebesContext);
 
--- a/dom/locales/en-US/chrome/dom/dom.properties
+++ b/dom/locales/en-US/chrome/dom/dom.properties
@@ -128,8 +128,10 @@ PluginHangUIStopButton=Stop plugin
 # LOCALIZATION NOTE: Do not translate "mozHidden", "mozVisibilityState", "hidden", or "visibilityState"
 PrefixedVisibilityApiWarning='mozHidden' and 'mozVisibilityState' are deprecated.  Please use the unprefixed 'hidden' and 'visibilityState' instead.
 # LOCALIZATION NOTE: Do not translate "NodeIterator" or "detach()".
 NodeIteratorDetachWarning=Calling detach() on a NodeIterator no longer has an effect.
 # LOCALIZATION NOTE: Do not translate "Mozilla Audio Data API" and "Web Audio API".
 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.
--- a/xpfe/appshell/public/nsIWindowMediator.idl
+++ b/xpfe/appshell/public/nsIWindowMediator.idl
@@ -3,29 +3,29 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 #include "nsISimpleEnumerator.idl"
 
 %{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"
 %}
 
 interface nsIXULWindow;
 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
     * from the oldest window to the youngest.
     * @param  aWindowType the returned enumerator will enumerate only
     *                     windows of this type. ("type" is the
     *                     |windowtype| attribute of the XML <window> element.)
     *                     If null, all windows will be enumerated.
@@ -64,16 +64,21 @@ interface nsIWindowMediator: nsISupports
     * @param  aWindowType return the topmost window of this type.
     *                     ("type" is the |windowtype| attribute of
     *                     the XML <window> element.)
     *                     If null, return the topmost window of any type.
     * @return the topmost window
     */
   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
     */
   [noscript] void registerWindow(in nsIXULWindow aWindow);
 
   /** Remove the window from the list of known windows. Listeners (see
     * addListener) will be be notified through their onCloseWindow method.
--- a/xpfe/appshell/src/Makefile.in
+++ b/xpfe/appshell/src/Makefile.in
@@ -23,10 +23,12 @@ CPPSRCS		= \
 		nsXULWindow.cpp \
 		nsAppShellService.cpp \
 		nsAppShellWindowEnumerator.cpp \
 		nsWebShellWindow.cpp \
 		nsWindowMediator.cpp \
 		nsAppShellFactory.cpp \
 		$(NULL)
 
+LOCAL_INCLUDES += -I$(topsrcdir)/dom/base
+
 include $(topsrcdir)/config/rules.mk
 
--- a/xpfe/appshell/src/nsWindowMediator.cpp
+++ b/xpfe/appshell/src/nsWindowMediator.cpp
@@ -13,16 +13,17 @@
 #include "nsIDOMWindow.h"
 #include "nsIObserverService.h"
 #include "nsIServiceManager.h"
 #include "nsISimpleEnumerator.h"
 #include "nsAppShellWindowEnumerator.h"
 #include "nsWindowMediator.h"
 #include "nsIWindowMediatorListener.h"
 #include "nsXPIDLString.h"
+#include "nsGlobalWindow.h"
 
 #include "nsIDocShell.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIXULWindow.h"
 
 using namespace mozilla;
 
@@ -316,16 +317,25 @@ nsWindowMediator::MostRecentWindowInfo(c
     }
     searchInfo = searchInfo->mYounger;
     listEnd = mOldestWindow;
   }
   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)
 {
   NS_ENSURE_STATE(mReady);
   MutexAutoLock lock(mListLock);
   nsWindowInfo *info = GetInfoFor(inWindow);
   if (info) {
     // increment the window's time stamp
     info->mTimeStamp = ++mTimeStamp;