2001-09-25 22:43:09 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2005-08-23 00:24:57 +00:00
|
|
|
/* vim: set ts=2 sw=2 et tw=80: */
|
2001-09-25 22:43:09 +00:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-17 21:52:36 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-10-14 10:58:25 +00:00
|
|
|
*
|
2004-04-17 21:52:36 +00:00
|
|
|
* 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/
|
1999-10-14 10:58:25 +00:00
|
|
|
*
|
2001-09-25 22:43:09 +00:00
|
|
|
* 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.
|
1999-10-14 10:58:25 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-17 21:52:36 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-25 22:43:09 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-25 22:43:09 +00:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-17 21:52:36 +00:00
|
|
|
* 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"),
|
2001-09-25 22:43:09 +00:00
|
|
|
* 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
|
2004-04-17 21:52:36 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-25 22:43:09 +00:00
|
|
|
* 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
|
2004-04-17 21:52:36 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-25 22:43:09 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-12-13 23:13:33 +00:00
|
|
|
|
1999-10-14 10:58:25 +00:00
|
|
|
|
|
|
|
#ifndef nsPIDOMWindow_h__
|
|
|
|
#define nsPIDOMWindow_h__
|
|
|
|
|
|
|
|
#include "nsISupports.h"
|
1999-11-30 09:29:43 +00:00
|
|
|
#include "nsIDOMLocation.h"
|
2000-06-23 00:42:21 +00:00
|
|
|
#include "nsIDOMXULCommandDispatcher.h"
|
2002-04-17 04:17:16 +00:00
|
|
|
#include "nsIDOMElement.h"
|
2004-05-03 21:48:36 +00:00
|
|
|
#include "nsIDOMWindowInternal.h"
|
|
|
|
#include "nsIChromeEventHandler.h"
|
|
|
|
#include "nsIDOMDocument.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2006-03-07 17:08:51 +00:00
|
|
|
#include "nsEvent.h"
|
1999-10-14 10:58:25 +00:00
|
|
|
|
2006-02-20 18:52:42 +00:00
|
|
|
class nsIPrincipal;
|
|
|
|
|
2004-09-04 19:28:46 +00:00
|
|
|
// Popup control state enum. The values in this enum must go from most
|
2004-09-05 08:24:29 +00:00
|
|
|
// permissive to least permissive so that it's safe to push state in
|
2004-09-04 19:28:46 +00:00
|
|
|
// all situations. Pushing popup state onto the stack never makes the
|
|
|
|
// current popup state less permissive (see
|
2004-12-10 19:48:22 +00:00
|
|
|
// nsGlobalWindow::PushPopupControlState()).
|
2004-09-04 19:28:46 +00:00
|
|
|
enum PopupControlState {
|
|
|
|
openAllowed = 0, // open that window without worries
|
|
|
|
openControlled, // it's a popup, but allow it
|
|
|
|
openAbused, // it's a popup. disallow it, but allow domain override.
|
|
|
|
openOverridden // disallow window open
|
|
|
|
};
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
class nsIDocShell;
|
2000-11-04 08:21:20 +00:00
|
|
|
class nsIFocusController;
|
2005-08-23 00:24:57 +00:00
|
|
|
class nsIDocument;
|
2006-06-13 03:07:47 +00:00
|
|
|
class nsIScriptTimeoutHandler;
|
2006-03-07 17:08:51 +00:00
|
|
|
class nsPresContext;
|
2004-12-10 19:48:22 +00:00
|
|
|
struct nsTimeout;
|
1999-12-14 00:55:37 +00:00
|
|
|
|
1999-10-14 10:58:25 +00:00
|
|
|
#define NS_PIDOMWINDOW_IID \
|
2006-08-15 17:31:16 +00:00
|
|
|
{ 0xbebce53b, 0xa4ec, 0x49e5, \
|
|
|
|
{ 0x82, 0x8e, 0x23, 0x08, 0x61, 0x2b, 0x41, 0x9b } }
|
1999-10-14 10:58:25 +00:00
|
|
|
|
2004-05-03 21:48:36 +00:00
|
|
|
class nsPIDOMWindow : public nsIDOMWindowInternal
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
{
|
1999-10-14 10:58:25 +00:00
|
|
|
public:
|
2005-11-11 14:36:26 +00:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_PIDOMWINDOW_IID)
|
1999-10-14 10:58:25 +00:00
|
|
|
|
2004-05-03 21:48:36 +00:00
|
|
|
virtual nsPIDOMWindow* GetPrivateRoot() = 0;
|
1999-11-30 09:29:43 +00:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
// This is private because activate/deactivate events are not part
|
|
|
|
// of the DOM spec.
|
2004-05-03 21:48:36 +00:00
|
|
|
virtual nsresult Activate() = 0;
|
|
|
|
virtual nsresult Deactivate() = 0;
|
2000-06-23 00:42:21 +00:00
|
|
|
|
2005-07-30 20:57:07 +00:00
|
|
|
nsIChromeEventHandler* GetChromeEventHandler() const
|
|
|
|
{
|
2004-05-03 21:48:36 +00:00
|
|
|
return mChromeEventHandler;
|
|
|
|
}
|
2000-07-11 23:34:44 +00:00
|
|
|
|
2005-07-30 20:57:07 +00:00
|
|
|
PRBool HasMutationListeners(PRUint32 aMutationEventType) const
|
2004-05-03 21:48:36 +00:00
|
|
|
{
|
2005-08-12 04:11:00 +00:00
|
|
|
const nsPIDOMWindow *win;
|
|
|
|
|
|
|
|
if (IsOuterWindow()) {
|
|
|
|
win = GetCurrentInnerWindow();
|
|
|
|
|
|
|
|
if (!win) {
|
|
|
|
NS_ERROR("No current inner window available!");
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!mOuterWindow) {
|
|
|
|
NS_ERROR("HasMutationListeners() called on orphan inner window!");
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
2005-07-30 20:57:07 +00:00
|
|
|
|
|
|
|
win = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (win->mMutationBits & aMutationEventType) != 0;
|
2004-05-03 21:48:36 +00:00
|
|
|
}
|
2000-07-11 23:34:44 +00:00
|
|
|
|
2005-07-30 20:57:07 +00:00
|
|
|
void SetMutationListeners(PRUint32 aType)
|
|
|
|
{
|
2005-08-12 04:11:00 +00:00
|
|
|
nsPIDOMWindow *win;
|
|
|
|
|
|
|
|
if (IsOuterWindow()) {
|
|
|
|
win = GetCurrentInnerWindow();
|
|
|
|
|
|
|
|
if (!win) {
|
|
|
|
NS_ERROR("No inner window available to set mutation bits on!");
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!mOuterWindow) {
|
|
|
|
NS_ERROR("HasMutationListeners() called on orphan inner window!");
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2005-07-30 20:57:07 +00:00
|
|
|
|
|
|
|
win = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
win->mMutationBits |= aType;
|
|
|
|
}
|
2000-07-11 23:34:44 +00:00
|
|
|
|
2004-05-03 21:48:36 +00:00
|
|
|
virtual nsIFocusController* GetRootFocusController() = 0;
|
2002-02-06 03:48:20 +00:00
|
|
|
|
2004-05-03 21:48:36 +00:00
|
|
|
// GetExtantDocument provides a backdoor to the DOM GetDocument accessor
|
2005-07-30 20:57:07 +00:00
|
|
|
nsIDOMDocument* GetExtantDocument() const
|
|
|
|
{
|
|
|
|
return mDocument;
|
|
|
|
}
|
2002-04-12 02:15:43 +00:00
|
|
|
|
2002-04-17 04:17:16 +00:00
|
|
|
// Internal getter/setter for the frame element, this version of the
|
|
|
|
// getter crosses chrome boundaries whereas the public scriptable
|
|
|
|
// one doesn't for security reasons.
|
2005-07-30 20:57:07 +00:00
|
|
|
nsIDOMElement* GetFrameElementInternal() const
|
|
|
|
{
|
2005-08-12 04:11:00 +00:00
|
|
|
if (mOuterWindow) {
|
2005-07-30 20:57:07 +00:00
|
|
|
return mOuterWindow->GetFrameElementInternal();
|
|
|
|
}
|
|
|
|
|
2005-08-12 04:11:00 +00:00
|
|
|
NS_ASSERTION(!IsInnerWindow(),
|
|
|
|
"GetFrameElementInternal() called on orphan inner window");
|
|
|
|
|
2005-07-30 20:57:07 +00:00
|
|
|
return mFrameElement;
|
|
|
|
}
|
|
|
|
|
2004-05-03 21:48:36 +00:00
|
|
|
void SetFrameElementInternal(nsIDOMElement *aFrameElement)
|
|
|
|
{
|
2005-08-12 04:11:00 +00:00
|
|
|
if (IsOuterWindow()) {
|
|
|
|
mFrameElement = aFrameElement;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mOuterWindow) {
|
|
|
|
NS_ERROR("frameElement set on inner window with no outer!");
|
|
|
|
|
|
|
|
return;
|
2005-07-30 20:57:07 +00:00
|
|
|
}
|
|
|
|
|
2005-08-12 04:11:00 +00:00
|
|
|
mOuterWindow->SetFrameElementInternal(aFrameElement);
|
2004-05-03 21:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PRBool IsLoadingOrRunningTimeout() const
|
|
|
|
{
|
2005-07-30 20:57:07 +00:00
|
|
|
const nsPIDOMWindow *win = GetCurrentInnerWindow();
|
|
|
|
|
|
|
|
if (!win) {
|
|
|
|
win = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
return !win->mIsDocumentLoaded || win->mRunningTimeout;
|
2004-05-03 21:48:36 +00:00
|
|
|
}
|
|
|
|
|
2005-05-04 20:22:32 +00:00
|
|
|
// Check whether a document is currently loading
|
|
|
|
PRBool IsLoading() const
|
|
|
|
{
|
2005-08-12 04:11:00 +00:00
|
|
|
const nsPIDOMWindow *win;
|
|
|
|
|
|
|
|
if (IsOuterWindow()) {
|
|
|
|
win = GetCurrentInnerWindow();
|
|
|
|
|
|
|
|
if (!win) {
|
|
|
|
NS_ERROR("No current inner window available!");
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!mOuterWindow) {
|
|
|
|
NS_ERROR("IsLoading() called on orphan inner window!");
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
2005-07-30 20:57:07 +00:00
|
|
|
|
|
|
|
win = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
return !win->mIsDocumentLoaded;
|
2005-05-04 20:22:32 +00:00
|
|
|
}
|
|
|
|
|
2004-10-20 02:19:57 +00:00
|
|
|
PRBool IsHandlingResizeEvent() const
|
|
|
|
{
|
2005-08-12 04:11:00 +00:00
|
|
|
const nsPIDOMWindow *win;
|
|
|
|
|
|
|
|
if (IsOuterWindow()) {
|
|
|
|
win = GetCurrentInnerWindow();
|
|
|
|
|
|
|
|
if (!win) {
|
|
|
|
NS_ERROR("No current inner window available!");
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!mOuterWindow) {
|
|
|
|
NS_ERROR("IsHandlingResizeEvent() called on orphan inner window!");
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
2005-07-30 20:57:07 +00:00
|
|
|
|
|
|
|
win = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
return win->mIsHandlingResizeEvent;
|
2004-10-20 02:19:57 +00:00
|
|
|
}
|
|
|
|
|
2006-08-15 17:31:16 +00:00
|
|
|
// Tell this window who opened it. This only has an effect if there is
|
|
|
|
// either no document currently in the window or if the document is the
|
|
|
|
// original document this window came with (an about:blank document either
|
|
|
|
// preloaded into it when it was created, or created by
|
|
|
|
// CreateAboutBlankContentViewer()).
|
2006-02-20 18:52:42 +00:00
|
|
|
virtual void SetOpenerScriptPrincipal(nsIPrincipal* aPrincipal) = 0;
|
2006-08-15 17:31:16 +00:00
|
|
|
// Ask this window who opened it.
|
|
|
|
virtual nsIPrincipal* GetOpenerScriptPrincipal() = 0;
|
2004-05-03 21:48:36 +00:00
|
|
|
|
2005-06-18 06:06:45 +00:00
|
|
|
virtual PopupControlState PushPopupControlState(PopupControlState aState,
|
|
|
|
PRBool aForce) const = 0;
|
2004-09-04 19:28:46 +00:00
|
|
|
virtual void PopPopupControlState(PopupControlState state) const = 0;
|
|
|
|
virtual PopupControlState GetPopupControlState() const = 0;
|
2006-02-07 20:46:39 +00:00
|
|
|
|
2005-07-30 20:57:07 +00:00
|
|
|
// Returns an object containing the window's state. This also suspends
|
2005-05-04 20:22:32 +00:00
|
|
|
// all running timeouts in the window.
|
|
|
|
virtual nsresult SaveWindowState(nsISupports **aState) = 0;
|
|
|
|
|
|
|
|
// Restore the window state from aState.
|
|
|
|
virtual nsresult RestoreWindowState(nsISupports *aState) = 0;
|
|
|
|
|
2005-08-25 07:06:59 +00:00
|
|
|
// Resume suspended timeouts in this window and in child windows.
|
|
|
|
virtual nsresult ResumeTimeouts() = 0;
|
2006-05-03 21:53:08 +00:00
|
|
|
|
|
|
|
// Fire any DOM notification events related to things that happened while
|
|
|
|
// the window was frozen.
|
|
|
|
virtual nsresult FireDelayedDOMEvents() = 0;
|
2005-08-25 07:06:59 +00:00
|
|
|
|
2006-06-13 03:07:47 +00:00
|
|
|
// Add a timeout to this window.
|
|
|
|
virtual nsresult SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler,
|
|
|
|
PRInt32 interval,
|
|
|
|
PRBool aIsInterval, PRInt32 *aReturn) = 0;
|
|
|
|
|
|
|
|
// Clear a timeout from this window.
|
|
|
|
virtual nsresult ClearTimeoutOrInterval(PRInt32 aTimerID) = 0;
|
|
|
|
|
2005-07-30 20:57:07 +00:00
|
|
|
nsPIDOMWindow *GetOuterWindow()
|
|
|
|
{
|
2005-08-12 04:11:00 +00:00
|
|
|
return mIsInnerWindow ? mOuterWindow : this;
|
2005-07-30 20:57:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsPIDOMWindow *GetCurrentInnerWindow() const
|
|
|
|
{
|
|
|
|
return mInnerWindow;
|
|
|
|
}
|
|
|
|
|
2005-12-11 20:38:29 +00:00
|
|
|
nsPIDOMWindow *EnsureInnerWindow()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(IsOuterWindow(), "EnsureInnerWindow called on inner window");
|
|
|
|
// GetDocument forces inner window creation if there isn't one already
|
|
|
|
nsCOMPtr<nsIDOMDocument> doc;
|
|
|
|
GetDocument(getter_AddRefs(doc));
|
|
|
|
return GetCurrentInnerWindow();
|
|
|
|
}
|
|
|
|
|
2005-07-30 20:57:07 +00:00
|
|
|
PRBool IsInnerWindow() const
|
|
|
|
{
|
2005-08-12 04:11:00 +00:00
|
|
|
return mIsInnerWindow;
|
2005-07-30 20:57:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PRBool IsOuterWindow() const
|
|
|
|
{
|
|
|
|
return !IsInnerWindow();
|
|
|
|
}
|
|
|
|
|
2005-08-23 00:24:57 +00:00
|
|
|
virtual PRBool WouldReuseInnerWindow(nsIDocument *aNewDocument) = 0;
|
|
|
|
|
2006-03-07 17:08:51 +00:00
|
|
|
/**
|
|
|
|
* Called before the capture phase of the event flow.
|
|
|
|
* This is used to create the event target chain and implementations
|
|
|
|
* should set the necessary members of nsEventChainPreVisitor.
|
|
|
|
* At least aVisitor.mCanHandle must be set,
|
|
|
|
* usually also aVisitor.mParentTarget if mCanHandle is PR_TRUE.
|
|
|
|
* First one tells that this object can handle the aVisitor.mEvent event and
|
|
|
|
* the latter one is the possible parent object for the event target chain.
|
|
|
|
* @see nsEventDispatcher.h for more documentation about aVisitor.
|
|
|
|
*
|
|
|
|
* @param aVisitor the visitor object which is used to create the
|
|
|
|
* event target chain for event dispatching.
|
|
|
|
*
|
|
|
|
* @note Only nsEventDispatcher should call this method.
|
|
|
|
*/
|
|
|
|
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called after the bubble phase of the system event group.
|
|
|
|
* The default handling of the event should happen here.
|
|
|
|
* @param aVisitor the visitor object which is used during post handling.
|
|
|
|
*
|
|
|
|
* @see nsEventDispatcher.h for documentation about aVisitor.
|
|
|
|
* @note Only nsEventDispatcher should call this method.
|
|
|
|
*/
|
|
|
|
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Dispatch an event.
|
|
|
|
* @param aEvent the event that is being dispatched.
|
|
|
|
* @param aDOMEvent the event that is being dispatched, use if you want to
|
|
|
|
* dispatch nsIDOMEvent, not only nsEvent.
|
|
|
|
* @param aPresContext the current presentation context, can be nsnull.
|
|
|
|
* @param aEventStatus the status returned from the function, can be nsnull.
|
|
|
|
*
|
|
|
|
* @note If both aEvent and aDOMEvent are used, aEvent must be the internal
|
|
|
|
* event of the aDOMEvent.
|
|
|
|
*
|
|
|
|
* If aDOMEvent is not nsnull (in which case aEvent can be nsnull) it is used
|
|
|
|
* for dispatching, otherwise aEvent is used.
|
|
|
|
*
|
|
|
|
* @deprecated This method is here just until all the callers outside Gecko
|
|
|
|
* have been converted to use nsIDOMEventTarget::dispatchEvent.
|
|
|
|
*/
|
|
|
|
virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
nsEventStatus* aEventStatus) = 0;
|
2005-11-28 23:56:44 +00:00
|
|
|
|
2005-12-01 19:35:27 +00:00
|
|
|
/**
|
|
|
|
* Get the docshell in this window.
|
|
|
|
*/
|
2005-11-28 23:56:44 +00:00
|
|
|
nsIDocShell *GetDocShell()
|
|
|
|
{
|
|
|
|
if (mOuterWindow) {
|
|
|
|
return mOuterWindow->mDocShell;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mDocShell;
|
|
|
|
}
|
|
|
|
|
2005-12-01 19:35:27 +00:00
|
|
|
/**
|
|
|
|
* Set or unset the docshell in the window.
|
|
|
|
*/
|
2005-11-28 23:56:44 +00:00
|
|
|
virtual void SetDocShell(nsIDocShell *aDocShell) = 0;
|
|
|
|
|
2005-12-01 19:35:27 +00:00
|
|
|
/**
|
|
|
|
* Set a new document in the window. Calling this method will in
|
|
|
|
* most cases create a new inner window. If this method is called on
|
|
|
|
* an inner window the call will be forewarded to the outer window,
|
|
|
|
* if the inner window is not the current inner window an
|
|
|
|
* NS_ERROR_NOT_AVAILABLE error code will be returned. This may be
|
|
|
|
* called with a pointer to the current document, in that case the
|
|
|
|
* document remains unchanged, but a new inner window will be
|
|
|
|
* created.
|
|
|
|
*/
|
|
|
|
virtual nsresult SetNewDocument(nsIDocument *aDocument,
|
|
|
|
nsISupports *aState,
|
|
|
|
PRBool aClearScope) = 0;
|
|
|
|
|
|
|
|
/**
|
2006-02-15 03:22:17 +00:00
|
|
|
* Set the opener window. aOriginalOpener is true if and only if this is the
|
|
|
|
* original opener for the window. That is, it can only be true at most once
|
|
|
|
* during the life cycle of a window, and then only the first time
|
|
|
|
* SetOpenerWindow is called. It might never be true, of course, if the
|
|
|
|
* window does not have an opener when it's created.
|
2005-12-01 19:35:27 +00:00
|
|
|
*/
|
2006-02-15 03:22:17 +00:00
|
|
|
virtual void SetOpenerWindow(nsIDOMWindowInternal *aOpener,
|
|
|
|
PRBool aOriginalOpener) = 0;
|
2005-12-01 19:35:27 +00:00
|
|
|
|
2006-04-08 03:23:37 +00:00
|
|
|
virtual void EnsureSizeUpToDate() = 0;
|
2005-11-28 23:56:44 +00:00
|
|
|
|
2006-07-05 22:48:04 +00:00
|
|
|
/**
|
|
|
|
* Callback for notifying a window about a modal dialog being
|
|
|
|
* opened/closed with the window as a parent.
|
|
|
|
*/
|
|
|
|
virtual void EnterModalState() = 0;
|
|
|
|
virtual void LeaveModalState() = 0;
|
|
|
|
|
|
|
|
|
2004-05-03 21:48:36 +00:00
|
|
|
protected:
|
2005-08-12 04:11:00 +00:00
|
|
|
// The nsPIDOMWindow constructor. The aOuterWindow argument should
|
|
|
|
// be null if and only if the created window itself is an outer
|
|
|
|
// window. In all other cases aOuterWindow should be the outer
|
|
|
|
// window for the inner window that is being created.
|
2005-07-30 20:57:07 +00:00
|
|
|
nsPIDOMWindow(nsPIDOMWindow *aOuterWindow)
|
2006-07-05 22:48:04 +00:00
|
|
|
: mFrameElement(nsnull), mDocShell(nsnull), mModalStateDepth(0),
|
|
|
|
mRunningTimeout(nsnull), mMutationBits(0), mIsDocumentLoaded(PR_FALSE),
|
2005-11-28 23:56:44 +00:00
|
|
|
mIsHandlingResizeEvent(PR_FALSE), mIsInnerWindow(aOuterWindow != nsnull),
|
|
|
|
mInnerWindow(nsnull), mOuterWindow(aOuterWindow)
|
2004-10-20 02:19:57 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-07-30 20:57:07 +00:00
|
|
|
// These two variables are special in that they're set to the same
|
|
|
|
// value on both the outer window and the current inner window. Make
|
|
|
|
// sure you keep them in sync!
|
2004-05-03 21:48:36 +00:00
|
|
|
nsCOMPtr<nsIChromeEventHandler> mChromeEventHandler; // strong
|
|
|
|
nsCOMPtr<nsIDOMDocument> mDocument; // strong
|
2005-07-30 20:57:07 +00:00
|
|
|
|
|
|
|
// These members are only used on outer windows.
|
2004-05-03 21:48:36 +00:00
|
|
|
nsIDOMElement *mFrameElement; // weak
|
2005-11-28 23:56:44 +00:00
|
|
|
nsIDocShell *mDocShell; // Weak Reference
|
2005-07-30 20:57:07 +00:00
|
|
|
|
2006-07-05 22:48:04 +00:00
|
|
|
PRUint32 mModalStateDepth;
|
|
|
|
|
2005-07-30 20:57:07 +00:00
|
|
|
// These variables are only used on inner windows.
|
2004-12-10 19:48:22 +00:00
|
|
|
nsTimeout *mRunningTimeout;
|
2002-04-17 04:17:16 +00:00
|
|
|
|
2004-05-03 21:48:36 +00:00
|
|
|
PRUint32 mMutationBits;
|
2003-05-05 20:55:37 +00:00
|
|
|
|
2004-10-20 02:19:57 +00:00
|
|
|
PRPackedBool mIsDocumentLoaded;
|
|
|
|
PRPackedBool mIsHandlingResizeEvent;
|
2005-08-12 04:11:00 +00:00
|
|
|
PRPackedBool mIsInnerWindow;
|
2005-07-30 20:57:07 +00:00
|
|
|
|
|
|
|
// And these are the references between inner and outer windows.
|
|
|
|
nsPIDOMWindow *mInnerWindow;
|
|
|
|
nsPIDOMWindow *mOuterWindow;
|
1999-10-14 10:58:25 +00:00
|
|
|
};
|
|
|
|
|
2004-09-04 19:28:46 +00:00
|
|
|
|
2005-11-11 14:36:26 +00:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsPIDOMWindow, NS_PIDOMWINDOW_IID)
|
|
|
|
|
2004-09-04 19:28:46 +00:00
|
|
|
#ifdef _IMPL_NS_LAYOUT
|
|
|
|
PopupControlState
|
2004-09-23 23:39:16 +00:00
|
|
|
PushPopupControlState(PopupControlState aState, PRBool aForce);
|
2004-09-04 19:28:46 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
PopPopupControlState(PopupControlState aState);
|
2004-12-22 16:37:51 +00:00
|
|
|
|
|
|
|
#define NS_AUTO_POPUP_STATE_PUSHER nsAutoPopupStatePusherInternal
|
|
|
|
#else
|
|
|
|
#define NS_AUTO_POPUP_STATE_PUSHER nsAutoPopupStatePusherExternal
|
2004-09-04 19:28:46 +00:00
|
|
|
#endif
|
|
|
|
|
2004-12-22 16:57:03 +00:00
|
|
|
// Helper class that helps with pushing and popping popup control
|
2004-09-04 19:28:46 +00:00
|
|
|
// state. Note that this class looks different from within code that's
|
|
|
|
// part of the layout library than it does in code outside the layout
|
2004-12-22 16:37:51 +00:00
|
|
|
// library. We give the two object layouts different names so the symbols
|
|
|
|
// don't conflict, but code should always use the name
|
|
|
|
// |nsAutoPopupStatePusher|.
|
|
|
|
class NS_AUTO_POPUP_STATE_PUSHER
|
2004-09-04 19:28:46 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
#ifdef _IMPL_NS_LAYOUT
|
2004-12-22 16:37:51 +00:00
|
|
|
NS_AUTO_POPUP_STATE_PUSHER(PopupControlState aState, PRBool aForce = PR_FALSE)
|
2004-09-23 23:39:16 +00:00
|
|
|
: mOldState(::PushPopupControlState(aState, aForce))
|
2004-09-04 19:28:46 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2004-12-22 16:37:51 +00:00
|
|
|
~NS_AUTO_POPUP_STATE_PUSHER()
|
2004-09-04 19:28:46 +00:00
|
|
|
{
|
|
|
|
PopPopupControlState(mOldState);
|
|
|
|
}
|
|
|
|
#else
|
2004-12-22 16:37:51 +00:00
|
|
|
NS_AUTO_POPUP_STATE_PUSHER(nsPIDOMWindow *aWindow, PopupControlState aState)
|
2004-09-04 19:28:46 +00:00
|
|
|
: mWindow(aWindow), mOldState(openAbused)
|
|
|
|
{
|
|
|
|
if (aWindow) {
|
2005-06-18 06:06:45 +00:00
|
|
|
mOldState = aWindow->PushPopupControlState(aState, PR_FALSE);
|
2004-09-04 19:28:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-22 16:37:51 +00:00
|
|
|
~NS_AUTO_POPUP_STATE_PUSHER()
|
2004-09-04 19:28:46 +00:00
|
|
|
{
|
|
|
|
if (mWindow) {
|
|
|
|
mWindow->PopPopupControlState(mOldState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
protected:
|
2004-09-05 08:24:29 +00:00
|
|
|
#ifndef _IMPL_NS_LAYOUT
|
|
|
|
nsCOMPtr<nsPIDOMWindow> mWindow;
|
|
|
|
#endif
|
2004-09-04 19:28:46 +00:00
|
|
|
PopupControlState mOldState;
|
|
|
|
|
|
|
|
private:
|
2004-09-05 21:29:45 +00:00
|
|
|
// Hide so that this class can only be stack-allocated
|
|
|
|
static void* operator new(size_t /*size*/) CPP_THROW_NEW { return nsnull; }
|
|
|
|
static void operator delete(void* /*memory*/) {}
|
2004-09-04 19:28:46 +00:00
|
|
|
};
|
|
|
|
|
2004-12-22 16:37:51 +00:00
|
|
|
#define nsAutoPopupStatePusher NS_AUTO_POPUP_STATE_PUSHER
|
|
|
|
|
1999-10-14 10:58:25 +00:00
|
|
|
#endif // nsPIDOMWindow_h__
|