bug 129602, Embedders need to be able to reach the window root.

patch by marco@gnome.org r=caillon sr=jst
This commit is contained in:
cbiesinger%web.de 2004-05-26 18:10:47 +00:00
Родитель 18f583ef14
Коммит 0a95048591
5 изменённых файлов: 75 добавлений и 2 удалений

Просмотреть файл

@ -50,6 +50,7 @@ SDK_XPIDLSRCS = \
domstubs.idl \
nsIDOMBarProp.idl \
nsIDOMWindow.idl \
nsIDOMWindow2.idl \
nsIDOMWindowCollection.idl \
$(NULL)

Просмотреть файл

@ -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 <marco@gnome.org>
* 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;
};

Просмотреть файл

@ -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;

Просмотреть файл

@ -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<nsPIDOMWindow> 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)
{

Просмотреть файл

@ -157,6 +157,9 @@ public:
// nsIDOMWindow
NS_DECL_NSIDOMWINDOW
// nsIDOMWindow2
NS_DECL_NSIDOMWINDOW2
// nsIDOMWindowInternal
NS_DECL_NSIDOMWINDOWINTERNAL