diff --git a/dom/public/idl/base/Makefile.in b/dom/public/idl/base/Makefile.in index 231a823b5fe..b812b201ed2 100644 --- a/dom/public/idl/base/Makefile.in +++ b/dom/public/idl/base/Makefile.in @@ -50,6 +50,7 @@ SDK_XPIDLSRCS = \ domstubs.idl \ nsIDOMBarProp.idl \ nsIDOMWindow.idl \ + nsIDOMWindow2.idl \ nsIDOMWindowCollection.idl \ $(NULL) diff --git a/dom/public/idl/base/nsIDOMWindow2.idl b/dom/public/idl/base/nsIDOMWindow2.idl new file mode 100644 index 00000000000..6824bab026f --- /dev/null +++ b/dom/public/idl/base/nsIDOMWindow2.idl @@ -0,0 +1,49 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Marco Pesenti Gritti + * Portions created by the Initial Developer are Copyright (C) 2004 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsIDOMWindow.idl" + +[scriptable, uuid(65455132-b96a-40ec-adea-52fa22b1028c)] +interface nsIDOMWindow2 : nsIDOMWindow +{ + /** + * Get the window root for this window. This is useful for hooking + * up event listeners to this window and every other window nested + * in the window root. + */ + [noscript] readonly attribute nsIDOMEventTarget windowRoot; +}; diff --git a/dom/public/idl/base/nsIDOMWindowInternal.idl b/dom/public/idl/base/nsIDOMWindowInternal.idl index 2d6a9f21481..f68af2c3ab0 100644 --- a/dom/public/idl/base/nsIDOMWindowInternal.idl +++ b/dom/public/idl/base/nsIDOMWindowInternal.idl @@ -37,14 +37,14 @@ * * ***** END LICENSE BLOCK ***** */ -#include "nsIDOMWindow.idl" +#include "nsIDOMWindow2.idl" interface nsIPrompt; interface nsIControllers; interface nsIDOMLocation; [scriptable, uuid(9c911860-7dd9-11d4-9a83-000064657374)] -interface nsIDOMWindowInternal : nsIDOMWindow +interface nsIDOMWindowInternal : nsIDOMWindow2 { readonly attribute nsIDOMWindowInternal window; diff --git a/dom/src/base/nsGlobalWindow.cpp b/dom/src/base/nsGlobalWindow.cpp index a3d628840b8..ccb34b350c8 100644 --- a/dom/src/base/nsGlobalWindow.cpp +++ b/dom/src/base/nsGlobalWindow.cpp @@ -355,6 +355,7 @@ NS_INTERFACE_MAP_BEGIN(GlobalWindowImpl) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIScriptGlobalObject) NS_INTERFACE_MAP_ENTRY(nsIDOMWindowInternal) NS_INTERFACE_MAP_ENTRY(nsIDOMWindow) + NS_INTERFACE_MAP_ENTRY(nsIDOMWindow2) NS_INTERFACE_MAP_ENTRY(nsIDOMJSWindow) NS_INTERFACE_MAP_ENTRY(nsIScriptGlobalObject) NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal) @@ -2666,6 +2667,25 @@ GlobalWindowImpl::SizeToContent() return NS_OK; } +NS_IMETHODIMP +GlobalWindowImpl::GetWindowRoot(nsIDOMEventTarget **aWindowRoot) +{ + *aWindowRoot = nsnull; + + nsIDOMWindowInternal *rootWindow = GlobalWindowImpl::GetPrivateRoot(); + nsCOMPtr piWin(do_QueryInterface(rootWindow)); + if (!piWin) { + return NS_OK; + } + + nsIChromeEventHandler *chromeHandler = piWin->GetChromeEventHandler(); + if (!chromeHandler) { + return NS_OK; + } + + return CallQueryInterface(chromeHandler, aWindowRoot); +} + NS_IMETHODIMP GlobalWindowImpl::Scroll(PRInt32 aXScroll, PRInt32 aYScroll) { diff --git a/dom/src/base/nsGlobalWindow.h b/dom/src/base/nsGlobalWindow.h index 3fef12d1b48..752d29c76e2 100644 --- a/dom/src/base/nsGlobalWindow.h +++ b/dom/src/base/nsGlobalWindow.h @@ -157,6 +157,9 @@ public: // nsIDOMWindow NS_DECL_NSIDOMWINDOW + // nsIDOMWindow2 + NS_DECL_NSIDOMWINDOW2 + // nsIDOMWindowInternal NS_DECL_NSIDOMWINDOWINTERNAL