2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 sw=2 et tw=80: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* 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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsGlobalWindow_h___
|
|
|
|
#define nsGlobalWindow_h___
|
|
|
|
|
2013-08-21 23:30:55 -07:00
|
|
|
#include "nsPIDOMWindow.h"
|
|
|
|
|
2013-08-15 11:17:48 -07:00
|
|
|
#include "nsTHashtable.h"
|
|
|
|
#include "nsHashKeys.h"
|
|
|
|
#include "nsRefPtrHashtable.h"
|
2010-09-16 18:24:14 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Local Includes
|
|
|
|
// Helper Classes
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsWeakReference.h"
|
|
|
|
#include "nsDataHashtable.h"
|
2013-06-18 03:00:38 -07:00
|
|
|
#include "nsJSThingHashtable.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
|
|
|
|
// Interfaces Needed
|
|
|
|
#include "nsIBrowserDOMWindow.h"
|
2007-05-14 02:11:38 -07:00
|
|
|
#include "nsIDOMEventTarget.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIInterfaceRequestor.h"
|
|
|
|
#include "nsIDOMJSWindow.h"
|
|
|
|
#include "nsIDOMChromeWindow.h"
|
|
|
|
#include "nsIScriptGlobalObject.h"
|
2013-09-08 20:28:48 -07:00
|
|
|
#include "nsIScriptObjectPrincipal.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsITimer.h"
|
2007-07-26 10:52:26 -07:00
|
|
|
#include "nsIDOMModalContentWindow.h"
|
2011-06-23 19:18:01 -07:00
|
|
|
#include "nsEventListenerManager.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIPrincipal.h"
|
|
|
|
#include "nsSize.h"
|
|
|
|
#include "mozFlushType.h"
|
|
|
|
#include "prclist.h"
|
2010-01-28 06:53:53 -08:00
|
|
|
#include "nsIDOMStorageEvent.h"
|
2010-05-18 05:28:37 -07:00
|
|
|
#include "nsFrameMessageManager.h"
|
2012-11-01 07:06:22 -07:00
|
|
|
#include "mozilla/LinkedList.h"
|
2010-07-15 06:59:24 -07:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2011-08-24 12:49:25 -07:00
|
|
|
#include "nsIInlineEventHandlers.h"
|
2012-04-20 13:43:48 -07:00
|
|
|
#include "nsWrapperCacheInlines.h"
|
2012-06-29 01:32:21 -07:00
|
|
|
#include "nsIIdleObserver.h"
|
2013-04-25 08:13:21 -07:00
|
|
|
#include "nsIDocument.h"
|
2013-08-04 21:51:22 -07:00
|
|
|
#include "nsIDOMTouchEvent.h"
|
2013-01-29 05:44:01 -08:00
|
|
|
#include "mozilla/dom/EventTarget.h"
|
2013-07-01 00:14:24 -07:00
|
|
|
#include "Units.h"
|
2013-09-06 10:50:24 -07:00
|
|
|
#include "nsComponentManagerUtils.h"
|
2013-01-29 05:44:01 -08:00
|
|
|
|
2012-11-07 10:10:40 -08:00
|
|
|
#ifdef MOZ_B2G
|
|
|
|
#include "nsIDOMWindowB2G.h"
|
|
|
|
#endif // MOZ_B2G
|
|
|
|
|
2013-04-03 15:13:16 -07:00
|
|
|
#ifdef MOZ_WEBSPEECH
|
2013-04-04 15:12:34 -07:00
|
|
|
#include "nsISpeechSynthesisGetter.h"
|
2013-04-03 15:13:16 -07:00
|
|
|
#endif // MOZ_WEBSPEECH
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#define DEFAULT_HOME_PAGE "www.mozilla.org"
|
|
|
|
#define PREF_BROWSER_STARTUP_HOMEPAGE "browser.startup.homepage"
|
|
|
|
|
2010-09-16 18:24:14 -07:00
|
|
|
// Amount of time allowed between alert/prompt/confirm before enabling
|
|
|
|
// the stop dialog checkbox.
|
2012-08-13 12:03:59 -07:00
|
|
|
#define DEFAULT_SUCCESSIVE_DIALOG_TIME_LIMIT 3 // 3 sec
|
2010-09-16 18:24:14 -07:00
|
|
|
|
2012-08-13 12:03:59 -07:00
|
|
|
// Maximum number of successive dialogs before we prompt users to disable
|
|
|
|
// dialogs for this window.
|
|
|
|
#define MAX_SUCCESSIVE_DIALOG_COUNT 5
|
2010-09-16 18:24:14 -07:00
|
|
|
|
2012-06-29 01:32:21 -07:00
|
|
|
// Idle fuzz time upper limit
|
|
|
|
#define MAX_IDLE_FUZZ_TIME_MS 90000
|
|
|
|
|
|
|
|
// Min idle notification time in seconds.
|
|
|
|
#define MIN_IDLE_NOTIFICATION_TIME_S 1
|
|
|
|
|
2013-08-15 11:17:48 -07:00
|
|
|
class nsIArray;
|
|
|
|
class nsIBaseWindow;
|
2013-03-21 17:05:20 -07:00
|
|
|
class nsIContent;
|
2013-10-08 08:51:42 -07:00
|
|
|
class nsICSSDeclaration;
|
2013-08-15 11:17:48 -07:00
|
|
|
class nsIDocShellTreeOwner;
|
2013-02-16 20:43:16 -08:00
|
|
|
class nsIDOMCrypto;
|
2013-08-15 11:17:48 -07:00
|
|
|
class nsIDOMOfflineResourceList;
|
|
|
|
class nsIDOMMozWakeLock;
|
2009-09-02 20:57:46 -07:00
|
|
|
class nsIScrollableFrame;
|
2007-10-13 09:42:44 -07:00
|
|
|
class nsIControllers;
|
2013-08-15 11:17:48 -07:00
|
|
|
class nsIScriptContext;
|
|
|
|
class nsIScriptTimeoutHandler;
|
|
|
|
class nsIWebBrowserChrome;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-08-15 11:17:48 -07:00
|
|
|
class nsDOMWindowList;
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsLocation;
|
|
|
|
class nsScreen;
|
|
|
|
class nsHistory;
|
|
|
|
class nsGlobalWindowObserver;
|
|
|
|
class nsGlobalWindow;
|
2012-03-12 17:56:07 -07:00
|
|
|
class nsDOMEventTargetHelper;
|
2012-04-01 19:23:51 -07:00
|
|
|
class nsDOMWindowUtils;
|
2012-06-29 01:32:21 -07:00
|
|
|
class nsIIdleService;
|
2013-09-06 19:15:49 -07:00
|
|
|
struct nsIntSize;
|
|
|
|
struct nsRect;
|
2007-05-29 02:45:30 -07:00
|
|
|
|
2012-02-01 13:58:01 -08:00
|
|
|
class nsWindowSizes;
|
|
|
|
|
2011-11-02 06:44:16 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2013-05-31 03:30:00 -07:00
|
|
|
class BarProp;
|
2013-10-08 08:51:42 -07:00
|
|
|
class Function;
|
2013-08-15 11:17:48 -07:00
|
|
|
class Gamepad;
|
2011-11-02 06:44:16 -07:00
|
|
|
class Navigator;
|
2013-04-07 05:19:56 -07:00
|
|
|
class SpeechSynthesis;
|
2013-03-31 01:18:30 -07:00
|
|
|
namespace indexedDB {
|
|
|
|
class IDBFactory;
|
|
|
|
} // namespace indexedDB
|
2011-11-02 06:44:16 -07:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
extern nsresult
|
2008-01-29 18:11:48 -08:00
|
|
|
NS_CreateJSTimeoutHandler(nsGlobalWindow *aWindow,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool *aIsInterval,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t *aInterval,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIScriptTimeoutHandler **aRet);
|
|
|
|
|
2013-10-08 08:51:42 -07:00
|
|
|
extern already_AddRefed<nsIScriptTimeoutHandler>
|
|
|
|
NS_CreateJSTimeoutHandler(nsGlobalWindow *aWindow,
|
|
|
|
mozilla::dom::Function& aFunction,
|
|
|
|
const mozilla::dom::Sequence<JS::Value>& aArguments,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
|
|
|
|
extern already_AddRefed<nsIScriptTimeoutHandler>
|
|
|
|
NS_CreateJSTimeoutHandler(JSContext* aCx, nsGlobalWindow *aWindow,
|
|
|
|
const nsAString& aExpression,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
|
|
|
* Timeout struct that holds information about each script
|
|
|
|
* timeout. Holds a strong reference to an nsIScriptTimeoutHandler, which
|
|
|
|
* abstracts the language specific cruft.
|
|
|
|
*/
|
2012-11-01 07:06:22 -07:00
|
|
|
struct nsTimeout : mozilla::LinkedListElement<nsTimeout>
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsTimeout();
|
|
|
|
~nsTimeout();
|
|
|
|
|
2013-04-30 10:41:23 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(nsTimeout)
|
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(nsTimeout)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-01-03 13:48:01 -08:00
|
|
|
nsresult InitTimer(nsTimerCallbackFunc aFunc, uint32_t aDelay)
|
|
|
|
{
|
|
|
|
return mTimer->InitWithFuncCallback(aFunc, this, aDelay,
|
2012-07-24 10:50:45 -07:00
|
|
|
nsITimer::TYPE_ONE_SHOT);
|
|
|
|
}
|
|
|
|
|
2013-04-30 10:41:23 -07:00
|
|
|
bool HasRefCntOne();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Window for which this timeout fires
|
|
|
|
nsRefPtr<nsGlobalWindow> mWindow;
|
|
|
|
|
|
|
|
// The actual timer object
|
|
|
|
nsCOMPtr<nsITimer> mTimer;
|
|
|
|
|
|
|
|
// True if the timeout was cleared
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mCleared;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// True if this is one of the timeouts that are currently running
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mRunning;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-06-29 12:49:42 -07:00
|
|
|
// True if this is a repeating/interval timer
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsInterval;
|
2011-06-29 12:49:42 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Returned as value of setTimeout()
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mPublicId;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-06-29 12:49:42 -07:00
|
|
|
// Interval in milliseconds
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mInterval;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-15 06:59:24 -07:00
|
|
|
// mWhen and mTimeRemaining can't be in a union, sadly, because they
|
|
|
|
// have constructors.
|
|
|
|
// Nominal time to run this timeout. Use only when timeouts are not
|
|
|
|
// suspended.
|
|
|
|
mozilla::TimeStamp mWhen;
|
|
|
|
// Remaining time to wait. Used only when timeouts are suspended.
|
|
|
|
mozilla::TimeDuration mTimeRemaining;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Principal with which to execute
|
|
|
|
nsCOMPtr<nsIPrincipal> mPrincipal;
|
|
|
|
|
|
|
|
// stack depth at which timeout is firing
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mFiringDepth;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-08-26 11:07:39 -07:00
|
|
|
//
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mNestingLevel;
|
2009-08-26 11:07:39 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// The popup state at timeout creation time if not created from
|
|
|
|
// another timeout
|
|
|
|
PopupControlState mPopupState;
|
|
|
|
|
|
|
|
// The language-specific information about the callback.
|
|
|
|
nsCOMPtr<nsIScriptTimeoutHandler> mScriptHandler;
|
|
|
|
};
|
|
|
|
|
2012-06-29 01:32:21 -07:00
|
|
|
struct IdleObserverHolder
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIIdleObserver> mIdleObserver;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mTimeInS;
|
2012-07-13 15:39:46 -07:00
|
|
|
bool mPrevNotificationIdle;
|
2012-06-29 01:32:21 -07:00
|
|
|
|
|
|
|
IdleObserverHolder()
|
2012-07-13 15:39:46 -07:00
|
|
|
: mTimeInS(0), mPrevNotificationIdle(false)
|
2012-06-29 01:32:21 -07:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(IdleObserverHolder);
|
|
|
|
}
|
|
|
|
|
2012-07-13 15:39:46 -07:00
|
|
|
IdleObserverHolder(const IdleObserverHolder& aOther)
|
|
|
|
: mIdleObserver(aOther.mIdleObserver), mTimeInS(aOther.mTimeInS),
|
|
|
|
mPrevNotificationIdle(aOther.mPrevNotificationIdle)
|
2012-06-29 01:32:21 -07:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(IdleObserverHolder);
|
|
|
|
}
|
|
|
|
|
2012-07-13 15:39:46 -07:00
|
|
|
bool operator==(const IdleObserverHolder& aOther) const {
|
2012-06-29 01:32:21 -07:00
|
|
|
return
|
2012-07-13 15:39:46 -07:00
|
|
|
mIdleObserver == aOther.mIdleObserver &&
|
|
|
|
mTimeInS == aOther.mTimeInS;
|
2012-06-29 01:32:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
~IdleObserverHolder()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(IdleObserverHolder);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-05-17 10:43:19 -07:00
|
|
|
static inline already_AddRefed<nsIVariant>
|
|
|
|
CreateVoidVariant()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWritableVariant> writable =
|
|
|
|
do_CreateInstance(NS_VARIANT_CONTRACTID);
|
|
|
|
writable->SetAsVoid();
|
|
|
|
return writable.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Helper class to manage modal dialog arguments and all their quirks.
|
|
|
|
//
|
|
|
|
// Given our clunky embedding APIs, modal dialog arguments need to be passed
|
|
|
|
// as an nsISupports parameter to WindowWatcher, get stuck inside an array of
|
|
|
|
// length 1, and then passed back to the newly-created dialog.
|
|
|
|
//
|
|
|
|
// However, we need to track both the caller-passed value as well as the
|
|
|
|
// caller's, so that we can do an origin check (even for primitives) when the
|
|
|
|
// value is accessed. This class encapsulates that magic.
|
2013-05-17 10:43:19 -07:00
|
|
|
//
|
|
|
|
// We also use the same machinery for |returnValue|, which needs similar origin
|
|
|
|
// checks.
|
2013-05-17 10:43:19 -07:00
|
|
|
class DialogValueHolder : public nsISupports
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS(DialogValueHolder)
|
|
|
|
|
|
|
|
DialogValueHolder(nsIPrincipal* aSubject, nsIVariant* aValue)
|
|
|
|
: mOrigin(aSubject)
|
|
|
|
, mValue(aValue) {}
|
|
|
|
nsresult Get(nsIPrincipal* aSubject, nsIVariant** aResult)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIVariant> result;
|
|
|
|
if (aSubject->Subsumes(mOrigin)) {
|
|
|
|
result = mValue;
|
|
|
|
} else {
|
|
|
|
result = CreateVoidVariant();
|
|
|
|
}
|
|
|
|
result.forget(aResult);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
virtual ~DialogValueHolder() {}
|
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIPrincipal> mOrigin;
|
|
|
|
nsCOMPtr<nsIVariant> mValue;
|
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//*****************************************************************************
|
|
|
|
// nsGlobalWindow: Global Object for Scripting
|
|
|
|
//*****************************************************************************
|
|
|
|
// Beware that all scriptable interfaces implemented by
|
|
|
|
// nsGlobalWindow will be reachable from JS, if you make this class
|
|
|
|
// implement new interfaces you better know what you're
|
|
|
|
// doing. Security wise this is very sensitive code. --
|
|
|
|
// jst@netscape.com
|
|
|
|
|
|
|
|
// nsGlobalWindow inherits PRCList for maintaining a list of all inner
|
2008-01-29 17:31:29 -08:00
|
|
|
// windows still in memory for any given outer window. This list is
|
2007-03-22 10:30:00 -07:00
|
|
|
// needed to ensure that mOuterWindow doesn't end up dangling. The
|
|
|
|
// nature of PRCList means that the window itself is always in the
|
|
|
|
// list, and an outer window's list will also contain all inner window
|
|
|
|
// objects that are still in memory (and in reality all inner window
|
|
|
|
// object's lists also contain its outer and all other inner windows
|
|
|
|
// belonging to the same outer window, but that's an unimportant
|
|
|
|
// side effect of inheriting PRCList).
|
|
|
|
|
2013-01-29 05:44:01 -08:00
|
|
|
class nsGlobalWindow : public mozilla::dom::EventTarget,
|
|
|
|
public nsPIDOMWindow,
|
2007-03-22 10:30:00 -07:00
|
|
|
public nsIScriptGlobalObject,
|
2013-09-08 20:28:48 -07:00
|
|
|
public nsIScriptObjectPrincipal,
|
2007-03-22 10:30:00 -07:00
|
|
|
public nsIDOMJSWindow,
|
|
|
|
public nsSupportsWeakReference,
|
|
|
|
public nsIInterfaceRequestor,
|
2011-06-23 03:39:48 -07:00
|
|
|
public PRCListStr,
|
2011-08-24 12:49:25 -07:00
|
|
|
public nsIDOMWindowPerformance,
|
2011-08-24 12:49:25 -07:00
|
|
|
public nsITouchEventReceiver,
|
2013-02-16 20:43:19 -08:00
|
|
|
public nsIInlineEventHandlers
|
2012-11-07 10:10:40 -08:00
|
|
|
#ifdef MOZ_B2G
|
|
|
|
, public nsIDOMWindowB2G
|
|
|
|
#endif // MOZ_B2G
|
2013-04-03 15:13:16 -07:00
|
|
|
#ifdef MOZ_WEBSPEECH
|
2013-04-04 15:12:34 -07:00
|
|
|
, public nsISpeechSynthesisGetter
|
2013-04-03 15:13:16 -07:00
|
|
|
#endif // MOZ_WEBSPEECH
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2010-09-16 18:24:14 -07:00
|
|
|
typedef mozilla::TimeStamp TimeStamp;
|
|
|
|
typedef mozilla::TimeDuration TimeDuration;
|
2011-06-29 04:06:43 -07:00
|
|
|
typedef nsDataHashtable<nsUint64HashKey, nsGlobalWindow*> WindowByIdTable;
|
2010-09-16 18:24:14 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// public methods
|
|
|
|
nsPIDOMWindow* GetPrivateParent();
|
|
|
|
// callback for close event
|
|
|
|
void ReallyCloseWindow();
|
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
|
2011-08-20 06:53:34 -07:00
|
|
|
// nsWrapperCache
|
2013-04-25 09:29:54 -07:00
|
|
|
virtual JSObject *WrapObject(JSContext *cx,
|
|
|
|
JS::Handle<JSObject*> scope) MOZ_OVERRIDE
|
2011-08-20 06:53:34 -07:00
|
|
|
{
|
|
|
|
NS_ASSERTION(IsOuterWindow(),
|
|
|
|
"Inner window supports nsWrapperCache, fix WrapObject!");
|
2012-07-30 07:20:58 -07:00
|
|
|
return EnsureInnerWindow() ? GetWrapper() : nullptr;
|
2011-08-20 06:53:34 -07:00
|
|
|
}
|
|
|
|
|
2013-04-04 02:27:06 -07:00
|
|
|
// nsIGlobalJSObjectHolder
|
|
|
|
virtual JSObject *GetGlobalJSObject();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// nsIScriptGlobalObject
|
|
|
|
virtual nsIScriptContext *GetContext();
|
2010-06-08 09:13:08 -07:00
|
|
|
JSObject *FastGetGlobalJSObject()
|
|
|
|
{
|
|
|
|
return mJSObject;
|
|
|
|
}
|
2013-03-28 13:37:22 -07:00
|
|
|
void TraceGlobalJSObject(JSTracer* aTrc);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-23 10:13:29 -07:00
|
|
|
virtual nsresult EnsureScriptEnvironment();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-23 10:13:29 -07:00
|
|
|
virtual nsIScriptContext *GetScriptContext();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-04-02 13:08:41 -07:00
|
|
|
void PoisonOuterWindowProxy(JSObject *aObject);
|
2011-04-14 05:04:08 -07:00
|
|
|
virtual void OnFinalize(JSObject* aObject);
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual void SetScriptsEnabled(bool aEnabled, bool aFireTimeouts);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-01-26 07:03:21 -08:00
|
|
|
virtual bool IsBlackForCC();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// nsIScriptObjectPrincipal
|
|
|
|
virtual nsIPrincipal* GetPrincipal();
|
|
|
|
|
|
|
|
// nsIDOMWindow
|
|
|
|
NS_DECL_NSIDOMWINDOW
|
|
|
|
|
2012-11-07 10:10:40 -08:00
|
|
|
#ifdef MOZ_B2G
|
|
|
|
// nsIDOMWindowB2G
|
|
|
|
NS_DECL_NSIDOMWINDOWB2G
|
|
|
|
#endif // MOZ_B2G
|
|
|
|
|
2013-04-03 15:13:16 -07:00
|
|
|
#ifdef MOZ_WEBSPEECH
|
2013-04-04 15:12:34 -07:00
|
|
|
// nsISpeechSynthesisGetter
|
|
|
|
NS_DECL_NSISPEECHSYNTHESISGETTER
|
2013-04-03 15:13:16 -07:00
|
|
|
#endif // MOZ_WEBSPEECH
|
|
|
|
|
2011-06-23 03:39:48 -07:00
|
|
|
// nsIDOMWindowPerformance
|
|
|
|
NS_DECL_NSIDOMWINDOWPERFORMANCE
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// nsIDOMJSWindow
|
|
|
|
NS_DECL_NSIDOMJSWINDOW
|
|
|
|
|
|
|
|
// nsIDOMEventTarget
|
|
|
|
NS_DECL_NSIDOMEVENTTARGET
|
2013-10-22 16:32:04 -07:00
|
|
|
|
|
|
|
virtual nsEventListenerManager*
|
|
|
|
GetExistingListenerManager() const MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual nsEventListenerManager*
|
|
|
|
GetOrCreateListenerManager() MOZ_OVERRIDE;
|
|
|
|
|
2013-04-16 14:16:08 -07:00
|
|
|
using mozilla::dom::EventTarget::RemoveEventListener;
|
|
|
|
virtual void AddEventListener(const nsAString& aType,
|
2013-09-23 17:25:17 -07:00
|
|
|
mozilla::dom::EventListener* aListener,
|
2013-04-16 14:16:08 -07:00
|
|
|
bool aUseCapture,
|
|
|
|
const mozilla::dom::Nullable<bool>& aWantsUntrusted,
|
|
|
|
mozilla::ErrorResult& aRv) MOZ_OVERRIDE;
|
2013-05-30 14:46:39 -07:00
|
|
|
virtual nsIDOMWindow* GetOwnerGlobal() MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
if (IsOuterWindow()) {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GetOuterFromCurrentInner(this);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-08-24 12:49:25 -07:00
|
|
|
// nsITouchEventReceiver
|
|
|
|
NS_DECL_NSITOUCHEVENTRECEIVER
|
|
|
|
|
2011-08-24 12:49:25 -07:00
|
|
|
// nsIInlineEventHandlers
|
|
|
|
NS_DECL_NSIINLINEEVENTHANDLERS
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// nsPIDOMWindow
|
|
|
|
virtual NS_HIDDEN_(nsPIDOMWindow*) GetPrivateRoot();
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual NS_HIDDEN_(void) ActivateOrDeactivate(bool aActivate);
|
|
|
|
virtual NS_HIDDEN_(void) SetActive(bool aActive);
|
|
|
|
virtual NS_HIDDEN_(void) SetIsBackground(bool aIsBackground);
|
2013-04-05 17:44:15 -07:00
|
|
|
virtual NS_HIDDEN_(void) SetChromeEventHandler(mozilla::dom::EventTarget* aChromeEventHandler);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-09-05 11:32:06 -07:00
|
|
|
virtual NS_HIDDEN_(void) SetInitialPrincipalToSubject();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual NS_HIDDEN_(PopupControlState) PushPopupControlState(PopupControlState state, bool aForce) const;
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual NS_HIDDEN_(void) PopPopupControlState(PopupControlState state) const;
|
|
|
|
virtual NS_HIDDEN_(PopupControlState) GetPopupControlState() const;
|
|
|
|
|
2012-09-06 00:20:26 -07:00
|
|
|
virtual already_AddRefed<nsISupports> SaveWindowState();
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual NS_HIDDEN_(nsresult) RestoreWindowState(nsISupports *aState);
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual NS_HIDDEN_(void) SuspendTimeouts(uint32_t aIncrease = 1,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aFreezeChildren = true);
|
|
|
|
virtual NS_HIDDEN_(nsresult) ResumeTimeouts(bool aThawChildren = true);
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual NS_HIDDEN_(uint32_t) TimeoutSuspendCount();
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual NS_HIDDEN_(nsresult) FireDelayedDOMEvents();
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual NS_HIDDEN_(bool) IsFrozen() const
|
2008-01-16 13:54:33 -08:00
|
|
|
{
|
|
|
|
return mIsFrozen;
|
|
|
|
}
|
2013-09-04 04:37:46 -07:00
|
|
|
virtual NS_HIDDEN_(bool) IsRunningTimeout() { return mTimeoutFiringDepth > 0; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual NS_HIDDEN_(bool) WouldReuseInnerWindow(nsIDocument *aNewDocument);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
virtual NS_HIDDEN_(void) SetDocShell(nsIDocShell* aDocShell);
|
2012-05-25 12:00:32 -07:00
|
|
|
virtual void DetachFromDocShell();
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual NS_HIDDEN_(nsresult) SetNewDocument(nsIDocument *aDocument,
|
2010-09-15 15:54:00 -07:00
|
|
|
nsISupports *aState,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aForceReuseInnerWindow);
|
2010-06-10 09:23:40 -07:00
|
|
|
void DispatchDOMWindowCreated();
|
2011-07-15 03:31:34 -07:00
|
|
|
virtual NS_HIDDEN_(void) SetOpenerWindow(nsIDOMWindow* aOpener,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aOriginalOpener);
|
2013-07-01 00:14:24 -07:00
|
|
|
// Outer windows only.
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual NS_HIDDEN_(void) EnsureSizeUpToDate();
|
|
|
|
|
2013-08-12 12:54:51 -07:00
|
|
|
virtual NS_HIDDEN_(void) EnterModalState();
|
|
|
|
virtual NS_HIDDEN_(void) LeaveModalState();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual NS_HIDDEN_(bool) CanClose();
|
2010-01-28 10:35:20 -08:00
|
|
|
virtual NS_HIDDEN_(nsresult) ForceClose();
|
|
|
|
|
2010-08-02 06:34:54 -07:00
|
|
|
virtual NS_HIDDEN_(void) MaybeUpdateTouchState();
|
|
|
|
virtual NS_HIDDEN_(void) UpdateTouchState();
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual NS_HIDDEN_(bool) DispatchCustomEvent(const char *aEventName);
|
2013-08-16 04:16:20 -07:00
|
|
|
virtual NS_HIDDEN_(bool) DispatchResizeEvent(const nsIntSize& aSize);
|
2012-06-14 23:31:27 -07:00
|
|
|
virtual NS_HIDDEN_(void) RefreshCompartmentPrincipal();
|
2012-02-19 13:02:08 -08:00
|
|
|
virtual NS_HIDDEN_(nsresult) SetFullScreenInternal(bool aIsFullScreen, bool aRequireTrust);
|
2009-08-21 07:42:37 -07:00
|
|
|
|
2011-08-03 11:12:08 -07:00
|
|
|
virtual NS_HIDDEN_(void) SetHasGamepadEventListener(bool aHasGamepad = true);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// nsIInterfaceRequestor
|
|
|
|
NS_DECL_NSIINTERFACEREQUESTOR
|
|
|
|
|
2012-10-02 01:07:35 -07:00
|
|
|
// WebIDL interface.
|
2012-10-02 01:07:36 -07:00
|
|
|
already_AddRefed<nsIDOMWindow> IndexedGetter(uint32_t aIndex, bool& aFound);
|
2012-10-02 01:07:35 -07:00
|
|
|
|
2013-07-09 07:45:13 -07:00
|
|
|
void GetSupportedNames(nsTArray<nsString>& aNames);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Object Management
|
|
|
|
nsGlobalWindow(nsGlobalWindow *aOuterWindow);
|
|
|
|
|
2009-05-12 13:20:42 -07:00
|
|
|
static nsGlobalWindow *FromSupports(nsISupports *supports)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// Make sure this matches the casts we do in QueryInterface().
|
2013-04-05 17:44:15 -07:00
|
|
|
return (nsGlobalWindow *)(mozilla::dom::EventTarget *)supports;
|
2009-05-12 13:20:42 -07:00
|
|
|
}
|
|
|
|
static nsGlobalWindow *FromWrapper(nsIXPConnectWrappedNative *wrapper)
|
|
|
|
{
|
|
|
|
return FromSupports(wrapper->Native());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-05-23 08:27:10 -07:00
|
|
|
/**
|
|
|
|
* Wrap nsIDOMWindow::GetTop so we can overload the inline GetTop()
|
|
|
|
* implementation below. (nsIDOMWindow::GetTop simply calls
|
|
|
|
* nsIDOMWindow::GetRealTop().)
|
|
|
|
*/
|
|
|
|
nsresult GetTop(nsIDOMWindow **aWindow)
|
|
|
|
{
|
|
|
|
return nsIDOMWindow::GetTop(aWindow);
|
|
|
|
}
|
|
|
|
|
2010-09-16 18:24:14 -07:00
|
|
|
inline nsGlobalWindow *GetTop()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMWindow> top;
|
|
|
|
GetTop(getter_AddRefs(top));
|
|
|
|
if (top)
|
2012-06-07 07:43:23 -07:00
|
|
|
return static_cast<nsGlobalWindow *>(top.get());
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2012-06-07 07:43:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
inline nsGlobalWindow* GetScriptableTop()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMWindow> top;
|
|
|
|
GetScriptableTop(getter_AddRefs(top));
|
2013-10-08 08:51:42 -07:00
|
|
|
return static_cast<nsGlobalWindow *>(top.get());
|
2010-09-16 18:24:14 -07:00
|
|
|
}
|
|
|
|
|
2013-05-05 00:03:19 -07:00
|
|
|
already_AddRefed<nsIDOMWindow> GetChildWindow(const nsAString& aName);
|
2013-03-14 22:38:26 -07:00
|
|
|
|
2013-10-08 14:00:12 -07:00
|
|
|
// These return true if we've reached the state in this top level window
|
|
|
|
// where we ask the user if further dialogs should be blocked.
|
|
|
|
//
|
|
|
|
// DialogsAreBeingAbused must be called on the scriptable top inner window.
|
|
|
|
//
|
|
|
|
// ShouldPromptToBlockDialogs is implemented in terms of
|
|
|
|
// DialogsAreBeingAbused, and will get the scriptable top inner window
|
|
|
|
// automatically.
|
|
|
|
bool ShouldPromptToBlockDialogs();
|
2012-08-13 12:03:59 -07:00
|
|
|
bool DialogsAreBeingAbused();
|
2010-09-16 18:24:14 -07:00
|
|
|
|
2012-08-13 12:03:59 -07:00
|
|
|
// Ask the user if further dialogs should be blocked, if dialogs are currently
|
|
|
|
// being abused. This is used in the cases where we have no modifiable UI to
|
|
|
|
// show, in that case we show a separate dialog to ask this question.
|
|
|
|
bool ConfirmDialogIfNeeded();
|
2010-09-16 18:24:14 -07:00
|
|
|
|
2013-10-08 14:00:12 -07:00
|
|
|
// These functions are used for controlling and determining whether dialogs
|
|
|
|
// (alert, prompt, confirm) are currently allowed in this window.
|
|
|
|
void EnableDialogs();
|
|
|
|
void DisableDialogs();
|
|
|
|
bool AreDialogsEnabled();
|
2010-09-16 18:24:14 -07:00
|
|
|
|
2011-11-21 16:34:21 -08:00
|
|
|
virtual void SetHasAudioAvailableEventListeners();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIScriptContext *GetContextInternal()
|
|
|
|
{
|
|
|
|
if (mOuterWindow) {
|
|
|
|
return GetOuterWindowInternal()->mContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mContext;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
nsIScriptContext *GetScriptContextInternal(uint32_t aLangID)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-06-29 11:46:39 -07:00
|
|
|
NS_ASSERTION(aLangID == nsIProgrammingLanguage::JAVASCRIPT,
|
|
|
|
"We don't support this language ID");
|
2007-03-22 10:30:00 -07:00
|
|
|
if (mOuterWindow) {
|
2010-06-29 11:46:39 -07:00
|
|
|
return GetOuterWindowInternal()->mContext;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-06-29 11:46:39 -07:00
|
|
|
return mContext;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsGlobalWindow *GetOuterWindowInternal()
|
|
|
|
{
|
2007-07-08 00:08:04 -07:00
|
|
|
return static_cast<nsGlobalWindow *>(GetOuterWindow());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-10-22 16:32:04 -07:00
|
|
|
nsGlobalWindow *GetCurrentInnerWindowInternal() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2007-07-08 00:08:04 -07:00
|
|
|
return static_cast<nsGlobalWindow *>(mInnerWindow);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsGlobalWindow *EnsureInnerWindowInternal()
|
|
|
|
{
|
2007-07-08 00:08:04 -07:00
|
|
|
return static_cast<nsGlobalWindow *>(EnsureInnerWindow());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsCreatingInnerWindow() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return mCreatingInnerWindow;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsChromeWindow() const
|
2007-08-02 16:34:38 -07:00
|
|
|
{
|
|
|
|
return mIsChrome;
|
|
|
|
}
|
|
|
|
|
2012-11-22 17:25:28 -08:00
|
|
|
// GetScrollFrame does not flush. Callers should do it themselves as needed,
|
|
|
|
// depending on which info they actually want off the scrollable frame.
|
|
|
|
nsIScrollableFrame *GetScrollFrame();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult Observe(nsISupports* aSubject, const char* aTopic,
|
|
|
|
const PRUnichar* aData);
|
|
|
|
|
2013-05-21 10:45:56 -07:00
|
|
|
void UnblockScriptedClosing();
|
|
|
|
|
2011-08-31 07:54:39 -07:00
|
|
|
static void Init();
|
2007-03-22 10:30:00 -07:00
|
|
|
static void ShutDown();
|
2008-02-12 20:17:18 -08:00
|
|
|
static void CleanupCachedXBLHandlers(nsGlobalWindow* aWindow);
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool IsCallerChrome();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
static void RunPendingTimeoutsRecursive(nsGlobalWindow *aTopWindow,
|
|
|
|
nsGlobalWindow *aWindow);
|
|
|
|
|
|
|
|
friend class WindowStateHolder;
|
|
|
|
|
2012-01-26 07:03:21 -08:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsGlobalWindow,
|
2013-01-29 05:44:01 -08:00
|
|
|
nsIDOMEventTarget)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-11-26 02:14:29 -08:00
|
|
|
virtual NS_HIDDEN_(JSObject*)
|
2008-02-12 20:17:18 -08:00
|
|
|
GetCachedXBLPrototypeHandler(nsXBLPrototypeHandler* aKey);
|
|
|
|
|
|
|
|
virtual NS_HIDDEN_(void)
|
|
|
|
CacheXBLPrototypeHandler(nsXBLPrototypeHandler* aKey,
|
2013-03-20 13:09:09 -07:00
|
|
|
JS::Handle<JSObject*> aHandler);
|
2008-02-12 20:17:18 -08:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual bool TakeFocus(bool aFocus, uint32_t aFocusMethod);
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 11:00:39 -07:00
|
|
|
virtual void SetReadyForFocus();
|
|
|
|
virtual void PageHidden();
|
2011-03-31 13:30:32 -07:00
|
|
|
virtual nsresult DispatchAsyncHashchange(nsIURI *aOldURI, nsIURI *aNewURI);
|
2011-02-28 23:08:56 -08:00
|
|
|
virtual nsresult DispatchSyncPopState();
|
2009-09-01 09:45:05 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual void EnableDeviceSensor(uint32_t aType);
|
|
|
|
virtual void DisableDeviceSensor(uint32_t aType);
|
2012-03-24 17:29:49 -07:00
|
|
|
|
2012-09-10 23:05:00 -07:00
|
|
|
virtual void EnableTimeChangeNotifications();
|
|
|
|
virtual void DisableTimeChangeNotifications();
|
|
|
|
|
2012-11-07 10:10:40 -08:00
|
|
|
#ifdef MOZ_B2G
|
2012-09-30 06:47:48 -07:00
|
|
|
virtual void EnableNetworkEvent(uint32_t aType);
|
|
|
|
virtual void DisableNetworkEvent(uint32_t aType);
|
2012-11-07 10:10:40 -08:00
|
|
|
#endif // MOZ_B2G
|
2012-09-30 06:47:48 -07:00
|
|
|
|
2013-05-17 10:43:19 -07:00
|
|
|
virtual nsresult SetArguments(nsIArray *aArguments);
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 11:00:39 -07:00
|
|
|
|
2010-03-11 20:42:05 -08:00
|
|
|
void MaybeForgiveSpamCount();
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsClosedOrClosing() {
|
2010-03-11 20:42:05 -08:00
|
|
|
return (mIsClosed ||
|
|
|
|
mInClose ||
|
|
|
|
mHavePendingClose ||
|
|
|
|
mCleanedUp);
|
|
|
|
}
|
|
|
|
|
2013-04-23 21:22:37 -07:00
|
|
|
static void FirePopupBlockedEvent(nsIDocument* aDoc,
|
2010-08-27 08:49:08 -07:00
|
|
|
nsIDOMWindow *aRequestingWindow, nsIURI *aPopupURI,
|
|
|
|
const nsAString &aPopupWindowName,
|
|
|
|
const nsAString &aPopupWindowFeatures);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint32_t GetSerial() {
|
2010-09-09 15:15:40 -07:00
|
|
|
return mSerial;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
static nsGlobalWindow* GetOuterWindowWithId(uint64_t aWindowID) {
|
2011-09-03 16:43:22 -07:00
|
|
|
if (!sWindowsById) {
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2011-09-03 16:43:22 -07:00
|
|
|
}
|
|
|
|
|
2011-06-29 04:03:54 -07:00
|
|
|
nsGlobalWindow* outerWindow = sWindowsById->Get(aWindowID);
|
2012-07-30 07:20:58 -07:00
|
|
|
return outerWindow && !outerWindow->IsInnerWindow() ? outerWindow : nullptr;
|
2010-10-20 17:24:16 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
static nsGlobalWindow* GetInnerWindowWithId(uint64_t aInnerWindowID) {
|
2011-09-02 16:49:08 -07:00
|
|
|
if (!sWindowsById) {
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2011-09-02 16:49:08 -07:00
|
|
|
}
|
|
|
|
|
2011-08-24 13:44:35 -07:00
|
|
|
nsGlobalWindow* innerWindow = sWindowsById->Get(aInnerWindowID);
|
2012-07-30 07:20:58 -07:00
|
|
|
return innerWindow && innerWindow->IsInnerWindow() ? innerWindow : nullptr;
|
2011-08-24 13:44:35 -07:00
|
|
|
}
|
|
|
|
|
2011-06-29 04:06:43 -07:00
|
|
|
static WindowByIdTable* GetWindowsTable() {
|
|
|
|
return sWindowsById;
|
|
|
|
}
|
|
|
|
|
2013-09-30 16:20:23 -07:00
|
|
|
void AddSizeOfIncludingThis(nsWindowSizes* aWindowSizes) const;
|
2011-06-29 04:06:43 -07:00
|
|
|
|
2012-01-26 07:03:21 -08:00
|
|
|
void UnmarkGrayTimers();
|
2012-03-12 17:56:07 -07:00
|
|
|
|
|
|
|
void AddEventTargetObject(nsDOMEventTargetHelper* aObject);
|
|
|
|
void RemoveEventTargetObject(nsDOMEventTargetHelper* aObject);
|
2012-03-04 08:02:00 -08:00
|
|
|
|
2012-07-13 15:39:46 -07:00
|
|
|
void NotifyIdleObserver(IdleObserverHolder* aIdleObserverHolder,
|
2012-06-29 01:32:21 -07:00
|
|
|
bool aCallOnidle);
|
2012-07-13 15:39:46 -07:00
|
|
|
nsresult HandleIdleActiveEvent();
|
2012-08-22 08:56:38 -07:00
|
|
|
bool ContainsIdleObserver(nsIIdleObserver* aIdleObserver, uint32_t timeInS);
|
2012-06-29 01:32:21 -07:00
|
|
|
void HandleIdleObserverCallback();
|
|
|
|
|
2012-10-12 03:17:56 -07:00
|
|
|
void AllowScriptsToClose()
|
|
|
|
{
|
|
|
|
mAllowScriptsToClose = true;
|
|
|
|
}
|
2012-11-26 06:19:02 -08:00
|
|
|
|
2013-08-12 12:54:49 -07:00
|
|
|
enum SlowScriptResponse {
|
|
|
|
ContinueSlowScript = 0,
|
|
|
|
AlwaysContinueSlowScript,
|
|
|
|
KillSlowScript
|
|
|
|
};
|
|
|
|
SlowScriptResponse ShowSlowScriptDialog();
|
|
|
|
|
2011-08-03 11:12:08 -07:00
|
|
|
#ifdef MOZ_GAMEPAD
|
2012-02-15 16:47:13 -08:00
|
|
|
void AddGamepad(uint32_t aIndex, mozilla::dom::Gamepad* aGamepad);
|
2013-04-02 17:59:27 -07:00
|
|
|
void RemoveGamepad(uint32_t aIndex);
|
2012-02-15 16:47:13 -08:00
|
|
|
void GetGamepads(nsTArray<nsRefPtr<mozilla::dom::Gamepad> >& aGamepads);
|
|
|
|
already_AddRefed<mozilla::dom::Gamepad> GetGamepad(uint32_t aIndex);
|
2011-08-03 11:12:08 -07:00
|
|
|
void SetHasSeenGamepadInput(bool aHasSeen);
|
|
|
|
bool HasSeenGamepadInput();
|
|
|
|
void SyncGamepadState();
|
2013-04-02 17:59:27 -07:00
|
|
|
static PLDHashOperator EnumGamepadsForSync(const uint32_t& aKey,
|
2012-02-15 16:47:13 -08:00
|
|
|
mozilla::dom::Gamepad* aData,
|
|
|
|
void* aUserArg);
|
2013-06-23 17:58:53 -07:00
|
|
|
static PLDHashOperator EnumGamepadsForGet(const uint32_t& aKey,
|
2012-02-15 16:47:13 -08:00
|
|
|
mozilla::dom::Gamepad* aData,
|
|
|
|
void* aUserArg);
|
2011-08-03 11:12:08 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Enable/disable updates for gamepad input.
|
|
|
|
void EnableGamepadUpdates();
|
|
|
|
void DisableGamepadUpdates();
|
|
|
|
|
|
|
|
|
2012-11-26 06:19:02 -08:00
|
|
|
#define EVENT(name_, id_, type_, struct_) \
|
|
|
|
mozilla::dom::EventHandlerNonNull* GetOn##name_() \
|
|
|
|
{ \
|
2013-10-22 16:32:04 -07:00
|
|
|
nsEventListenerManager *elm = GetExistingListenerManager(); \
|
2013-08-16 03:06:24 -07:00
|
|
|
return elm ? elm->GetEventHandler(nsGkAtoms::on##name_, EmptyString()) \
|
|
|
|
: nullptr; \
|
2012-11-26 06:19:02 -08:00
|
|
|
} \
|
2013-09-17 04:01:28 -07:00
|
|
|
void SetOn##name_(mozilla::dom::EventHandlerNonNull* handler) \
|
2012-11-26 06:19:02 -08:00
|
|
|
{ \
|
2013-10-22 16:32:04 -07:00
|
|
|
nsEventListenerManager *elm = GetOrCreateListenerManager(); \
|
2012-11-26 06:19:02 -08:00
|
|
|
if (elm) { \
|
2013-09-17 04:01:28 -07:00
|
|
|
elm->SetEventHandler(nsGkAtoms::on##name_, EmptyString(), handler); \
|
2012-11-26 06:19:02 -08:00
|
|
|
} \
|
|
|
|
}
|
|
|
|
#define ERROR_EVENT(name_, id_, type_, struct_) \
|
|
|
|
mozilla::dom::OnErrorEventHandlerNonNull* GetOn##name_() \
|
|
|
|
{ \
|
2013-10-22 16:32:04 -07:00
|
|
|
nsEventListenerManager *elm = GetExistingListenerManager(); \
|
2012-11-26 06:19:02 -08:00
|
|
|
return elm ? elm->GetOnErrorEventHandler() : nullptr; \
|
|
|
|
} \
|
2013-09-17 04:01:28 -07:00
|
|
|
void SetOn##name_(mozilla::dom::OnErrorEventHandlerNonNull* handler) \
|
2012-11-26 06:19:02 -08:00
|
|
|
{ \
|
2013-10-22 16:32:04 -07:00
|
|
|
nsEventListenerManager *elm = GetOrCreateListenerManager(); \
|
2012-11-26 06:19:02 -08:00
|
|
|
if (elm) { \
|
2013-09-17 04:01:28 -07:00
|
|
|
elm->SetEventHandler(handler); \
|
2012-11-26 06:19:02 -08:00
|
|
|
} \
|
|
|
|
}
|
|
|
|
#define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_) \
|
2013-10-08 08:51:15 -07:00
|
|
|
mozilla::dom::OnBeforeUnloadEventHandlerNonNull* GetOn##name_() \
|
2012-11-26 06:19:02 -08:00
|
|
|
{ \
|
2013-10-22 16:32:04 -07:00
|
|
|
nsEventListenerManager *elm = GetExistingListenerManager(); \
|
2012-11-26 06:19:02 -08:00
|
|
|
return elm ? elm->GetOnBeforeUnloadEventHandler() : nullptr; \
|
|
|
|
} \
|
2013-10-08 08:51:15 -07:00
|
|
|
void SetOn##name_(mozilla::dom::OnBeforeUnloadEventHandlerNonNull* handler) \
|
2012-11-26 06:19:02 -08:00
|
|
|
{ \
|
2013-10-22 16:32:04 -07:00
|
|
|
nsEventListenerManager *elm = GetOrCreateListenerManager(); \
|
2012-11-26 06:19:02 -08:00
|
|
|
if (elm) { \
|
2013-09-17 04:01:28 -07:00
|
|
|
elm->SetEventHandler(handler); \
|
2012-11-26 06:19:02 -08:00
|
|
|
} \
|
|
|
|
}
|
|
|
|
#define WINDOW_ONLY_EVENT EVENT
|
|
|
|
#define TOUCH_EVENT EVENT
|
|
|
|
#include "nsEventNameList.h"
|
|
|
|
#undef TOUCH_EVENT
|
|
|
|
#undef WINDOW_ONLY_EVENT
|
|
|
|
#undef BEFOREUNLOAD_EVENT
|
|
|
|
#undef ERROR_EVENT
|
|
|
|
#undef EVENT
|
|
|
|
|
2013-10-08 08:51:42 -07:00
|
|
|
nsISupports* GetParentObject()
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIDOMWindow* GetWindow(mozilla::ErrorResult& aError);
|
|
|
|
nsIDOMWindow* GetSelf(mozilla::ErrorResult& aError);
|
|
|
|
nsIDocument* GetDocument()
|
|
|
|
{
|
|
|
|
return GetDoc();
|
|
|
|
}
|
|
|
|
void GetName(nsAString& aName, mozilla::ErrorResult& aError);
|
|
|
|
void SetName(const nsAString& aName, mozilla::ErrorResult& aError);
|
|
|
|
nsIDOMLocation* GetLocation(mozilla::ErrorResult& aError);
|
|
|
|
nsHistory* GetHistory(mozilla::ErrorResult& aError);
|
|
|
|
mozilla::dom::BarProp* GetLocationbar(mozilla::ErrorResult& aError);
|
|
|
|
mozilla::dom::BarProp* GetMenubar(mozilla::ErrorResult& aError);
|
|
|
|
mozilla::dom::BarProp* GetPersonalbar(mozilla::ErrorResult& aError);
|
|
|
|
mozilla::dom::BarProp* GetScrollbars(mozilla::ErrorResult& aError);
|
|
|
|
mozilla::dom::BarProp* GetStatusbar(mozilla::ErrorResult& aError);
|
|
|
|
mozilla::dom::BarProp* GetToolbar(mozilla::ErrorResult& aError);
|
|
|
|
void GetStatus(nsAString& aStatus, mozilla::ErrorResult& aError);
|
|
|
|
void SetStatus(const nsAString& aStatus, mozilla::ErrorResult& aError);
|
|
|
|
void Close(mozilla::ErrorResult& aError);
|
|
|
|
bool GetClosed(mozilla::ErrorResult& aError);
|
|
|
|
void Stop(mozilla::ErrorResult& aError);
|
|
|
|
void Focus(mozilla::ErrorResult& aError);
|
|
|
|
void Blur(mozilla::ErrorResult& aError);
|
|
|
|
already_AddRefed<nsIDOMWindow> GetFrames(mozilla::ErrorResult& aError);
|
|
|
|
uint32_t Length();
|
|
|
|
already_AddRefed<nsIDOMWindow> GetTop(mozilla::ErrorResult& aError)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMWindow> top;
|
|
|
|
aError = GetScriptableTop(getter_AddRefs(top));
|
|
|
|
return top.forget();
|
|
|
|
}
|
|
|
|
nsIDOMWindow* GetOpener(mozilla::ErrorResult& aError);
|
|
|
|
void SetOpener(nsIDOMWindow* aOpener, mozilla::ErrorResult& aError);
|
|
|
|
using nsIDOMWindow::GetParent;
|
|
|
|
already_AddRefed<nsIDOMWindow> GetParent(mozilla::ErrorResult& aError);
|
|
|
|
mozilla::dom::Element* GetFrameElement(mozilla::ErrorResult& aError);
|
|
|
|
already_AddRefed<nsIDOMWindow> Open(const nsAString& aUrl,
|
|
|
|
const nsAString& aName,
|
|
|
|
const nsAString& aOptions,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
mozilla::dom::Navigator* GetNavigator(mozilla::ErrorResult& aError);
|
|
|
|
nsIDOMOfflineResourceList* GetApplicationCache(mozilla::ErrorResult& aError);
|
|
|
|
void Alert(const nsAString& aMessage, mozilla::ErrorResult& aError);
|
|
|
|
bool Confirm(const nsAString& aMessage, mozilla::ErrorResult& aError);
|
|
|
|
void Prompt(const nsAString& aMessage, const nsAString& aInitial,
|
|
|
|
nsAString& aReturn, mozilla::ErrorResult& aError);
|
|
|
|
void Print(mozilla::ErrorResult& aError);
|
|
|
|
JS::Value ShowModalDialog(JSContext* aCx, const nsAString& aUrl, const mozilla::dom::Optional<JS::Handle<JS::Value> >& aArgument, const nsAString& aOptions, mozilla::ErrorResult& aError);
|
|
|
|
void PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
|
|
|
|
const nsAString& aTargetOrigin,
|
|
|
|
const mozilla::dom::Optional<mozilla::dom::Sequence<JS::Value > >& aTransfer,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
int32_t SetTimeout(JSContext* aCx, mozilla::dom::Function& aFunction,
|
|
|
|
int32_t aTimeout,
|
|
|
|
const mozilla::dom::Sequence<JS::Value>& aArguments,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
int32_t SetTimeout(JSContext* aCx, const nsAString& aHandler,
|
|
|
|
int32_t aTimeout, mozilla::ErrorResult& aError);
|
|
|
|
void ClearTimeout(int32_t aHandle, mozilla::ErrorResult& aError);
|
|
|
|
int32_t SetInterval(JSContext* aCx, mozilla::dom::Function& aFunction,
|
|
|
|
const mozilla::dom::Optional<int32_t>& aTimeout,
|
|
|
|
const mozilla::dom::Sequence<JS::Value>& aArguments,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
int32_t SetInterval(JSContext* aCx, const nsAString& aHandler,
|
|
|
|
const mozilla::dom::Optional<int32_t>& aTimeout,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void ClearInterval(int32_t aHandle, mozilla::ErrorResult& aError);
|
|
|
|
void Atob(const nsAString& aAsciiBase64String, nsAString& aBinaryData,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void Btoa(const nsAString& aBinaryData, nsAString& aAsciiBase64String,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
nsIDOMStorage* GetSessionStorage(mozilla::ErrorResult& aError);
|
|
|
|
nsIDOMStorage* GetLocalStorage(mozilla::ErrorResult& aError);
|
|
|
|
nsISelection* GetSelection(mozilla::ErrorResult& aError);
|
|
|
|
mozilla::dom::indexedDB::IDBFactory* GetIndexedDB(mozilla::ErrorResult& aError);
|
|
|
|
already_AddRefed<nsICSSDeclaration>
|
|
|
|
GetComputedStyle(mozilla::dom::Element& aElt, const nsAString& aPseudoElt,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
already_AddRefed<nsIDOMMediaQueryList> MatchMedia(const nsAString& aQuery,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
nsScreen* GetScreen(mozilla::ErrorResult& aError);
|
|
|
|
void MoveTo(int32_t aXPos, int32_t aYPos, mozilla::ErrorResult& aError);
|
|
|
|
void MoveBy(int32_t aXDif, int32_t aYDif, mozilla::ErrorResult& aError);
|
|
|
|
void ResizeTo(int32_t aWidth, int32_t aHeight,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void ResizeBy(int32_t aWidthDif, int32_t aHeightDif,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
int32_t GetInnerWidth(mozilla::ErrorResult& aError);
|
|
|
|
void SetInnerWidth(int32_t aInnerWidth, mozilla::ErrorResult& aError);
|
|
|
|
int32_t GetInnerHeight(mozilla::ErrorResult& aError);
|
|
|
|
void SetInnerHeight(int32_t aInnerHeight, mozilla::ErrorResult& aError);
|
|
|
|
int32_t GetScrollX(mozilla::ErrorResult& aError);
|
|
|
|
int32_t GetPageXOffset(mozilla::ErrorResult& aError)
|
|
|
|
{
|
|
|
|
return GetScrollX(aError);
|
|
|
|
}
|
|
|
|
int32_t GetScrollY(mozilla::ErrorResult& aError);
|
|
|
|
int32_t GetPageYOffset(mozilla::ErrorResult& aError)
|
|
|
|
{
|
|
|
|
return GetScrollY(aError);
|
|
|
|
}
|
|
|
|
int32_t GetScreenX(mozilla::ErrorResult& aError);
|
|
|
|
void SetScreenX(int32_t aScreenX, mozilla::ErrorResult& aError);
|
|
|
|
int32_t GetScreenY(mozilla::ErrorResult& aError);
|
|
|
|
void SetScreenY(int32_t aScreenY, mozilla::ErrorResult& aError);
|
|
|
|
int32_t GetOuterWidth(mozilla::ErrorResult& aError);
|
|
|
|
void SetOuterWidth(int32_t aOuterWidth, mozilla::ErrorResult& aError);
|
|
|
|
int32_t GetOuterHeight(mozilla::ErrorResult& aError);
|
|
|
|
void SetOuterHeight(int32_t aOuterHeight, mozilla::ErrorResult& aError);
|
|
|
|
int32_t RequestAnimationFrame(mozilla::dom::FrameRequestCallback& aCallback,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void CancelAnimationFrame(int32_t aHandle, mozilla::ErrorResult& aError);
|
|
|
|
nsPerformance* GetPerformance(mozilla::ErrorResult& aError);
|
2013-04-07 05:19:56 -07:00
|
|
|
#ifdef MOZ_WEBSPEECH
|
2013-10-08 08:51:42 -07:00
|
|
|
mozilla::dom::SpeechSynthesis*
|
|
|
|
GetSpeechSynthesis(mozilla::ErrorResult& aError);
|
2013-04-07 05:19:56 -07:00
|
|
|
#endif
|
2013-10-08 08:51:42 -07:00
|
|
|
already_AddRefed<nsICSSDeclaration>
|
|
|
|
GetDefaultComputedStyle(mozilla::dom::Element& aElt,
|
|
|
|
const nsAString& aPseudoElt,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
mozilla::dom::indexedDB::IDBFactory*
|
|
|
|
GetMozIndexedDB(mozilla::ErrorResult& aError)
|
|
|
|
{
|
|
|
|
return GetIndexedDB(aError);
|
|
|
|
}
|
|
|
|
int32_t MozRequestAnimationFrame(nsIFrameRequestCallback* aRequestCallback,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void MozCancelAnimationFrame(int32_t aHandle, mozilla::ErrorResult& aError)
|
|
|
|
{
|
|
|
|
return CancelAnimationFrame(aHandle, aError);
|
|
|
|
}
|
|
|
|
void MozCancelRequestAnimationFrame(int32_t aHandle,
|
|
|
|
mozilla::ErrorResult& aError)
|
|
|
|
{
|
|
|
|
return CancelAnimationFrame(aHandle, aError);
|
|
|
|
}
|
|
|
|
int64_t GetMozAnimationStartTime(mozilla::ErrorResult& aError);
|
|
|
|
void SizeToContent(mozilla::ErrorResult& aError);
|
|
|
|
nsIDOMCrypto* GetCrypto(mozilla::ErrorResult& aError);
|
|
|
|
nsIDOMPkcs11* GetPkcs11()
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
nsIControllers* GetControllers(mozilla::ErrorResult& aError);
|
|
|
|
float GetMozInnerScreenX(mozilla::ErrorResult& aError);
|
|
|
|
float GetMozInnerScreenY(mozilla::ErrorResult& aError);
|
|
|
|
float GetDevicePixelRatio(mozilla::ErrorResult& aError);
|
|
|
|
int32_t GetScrollMaxX(mozilla::ErrorResult& aError);
|
|
|
|
int32_t GetScrollMaxY(mozilla::ErrorResult& aError);
|
|
|
|
bool GetFullScreen(mozilla::ErrorResult& aError);
|
|
|
|
void SetFullScreen(bool aFullScreen, mozilla::ErrorResult& aError);
|
|
|
|
void Back(mozilla::ErrorResult& aError);
|
|
|
|
void Forward(mozilla::ErrorResult& aError);
|
|
|
|
void Home(mozilla::ErrorResult& aError);
|
|
|
|
bool Find(const nsAString& aString, bool aCaseSensitive, bool aBackwards,
|
|
|
|
bool aWrapAround, bool aWholeWord, bool aSearchInFrames,
|
|
|
|
bool aShowDialog, mozilla::ErrorResult& aError);
|
|
|
|
uint64_t GetMozPaintCount(mozilla::ErrorResult& aError);
|
|
|
|
already_AddRefed<nsIDOMWindow> OpenDialog(JSContext* aCx,
|
|
|
|
const nsAString& aUrl,
|
|
|
|
const nsAString& aName,
|
|
|
|
const nsAString& aOptions,
|
|
|
|
const mozilla::dom::Sequence<JS::Value>& aExtraArgument,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
JSObject* GetContent(JSContext* aCx, mozilla::ErrorResult& aError);
|
2013-06-01 01:53:00 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2012-06-29 01:32:21 -07:00
|
|
|
// Array of idle observers that are notified of idle events.
|
|
|
|
nsTObserverArray<IdleObserverHolder> mIdleObservers;
|
|
|
|
|
|
|
|
// Idle timer used for function callbacks to notify idle observers.
|
|
|
|
nsCOMPtr<nsITimer> mIdleTimer;
|
|
|
|
|
|
|
|
// Idle fuzz time added to idle timer callbacks.
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mIdleFuzzFactor;
|
2012-06-29 01:32:21 -07:00
|
|
|
|
|
|
|
// Index in mArrayIdleObservers
|
|
|
|
// Next idle observer to notify user idle status
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mIdleCallbackIndex;
|
2012-06-29 01:32:21 -07:00
|
|
|
|
|
|
|
// If false then the topic is "active"
|
|
|
|
// If true then the topic is "idle"
|
|
|
|
bool mCurrentlyIdle;
|
|
|
|
|
|
|
|
// Set to true when a fuzz time needs to be applied
|
|
|
|
// to active notifications to the idle observer.
|
|
|
|
bool mAddActiveEventFuzzTime;
|
|
|
|
|
|
|
|
nsCOMPtr <nsIIdleService> mIdleService;
|
|
|
|
|
2012-11-01 05:40:11 -07:00
|
|
|
nsCOMPtr <nsIDOMMozWakeLock> mWakeLock;
|
|
|
|
|
2012-06-29 01:32:21 -07:00
|
|
|
static bool sIdleObserversAPIFuzzTimeDisabled;
|
|
|
|
|
2011-03-31 13:30:32 -07:00
|
|
|
friend class HashchangeCallback;
|
2013-05-31 03:30:00 -07:00
|
|
|
friend class mozilla::dom::BarProp;
|
2011-03-31 13:30:32 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Object Management
|
|
|
|
virtual ~nsGlobalWindow();
|
2013-07-26 15:46:13 -07:00
|
|
|
void CleanUp();
|
2007-03-22 10:30:00 -07:00
|
|
|
void ClearControllers();
|
2010-01-28 10:35:20 -08:00
|
|
|
nsresult FinalClose();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-09 08:10:18 -07:00
|
|
|
inline void MaybeClearInnerWindow(nsGlobalWindow* aExpectedInner)
|
|
|
|
{
|
|
|
|
if(mInnerWindow == aExpectedInner) {
|
2012-07-30 07:20:58 -07:00
|
|
|
mInnerWindow = nullptr;
|
2012-05-09 08:10:18 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-15 04:06:39 -07:00
|
|
|
void FreeInnerObjects();
|
2012-04-05 15:33:20 -07:00
|
|
|
JSObject *CallerGlobal();
|
2008-01-29 21:30:11 -08:00
|
|
|
nsGlobalWindow *CallerInnerWindow();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-06-17 01:11:16 -07:00
|
|
|
// Only to be called on an inner window.
|
|
|
|
// aDocument must not be null.
|
|
|
|
void InnerSetNewDocument(nsIDocument* aDocument);
|
2010-03-12 16:59:18 -08:00
|
|
|
|
2009-10-06 17:09:16 -07:00
|
|
|
nsresult DefineArgumentsProperty(nsIArray *aArguments);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Get the parent, returns null if this is a toplevel window
|
2011-07-15 03:31:34 -07:00
|
|
|
nsIDOMWindow* GetParentInternal();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// popup tracking
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsPopupSpamWindow()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (IsInnerWindow() && !mOuterWindow) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return GetOuterWindowInternal()->mIsPopupSpam;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetPopupSpamWindow(bool aPopup)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (IsInnerWindow() && !mOuterWindow) {
|
|
|
|
NS_ERROR("SetPopupSpamWindow() called on inner window w/o an outer!");
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GetOuterWindowInternal()->mIsPopupSpam = aPopup;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Window Control Functions
|
2012-08-14 07:58:00 -07:00
|
|
|
|
|
|
|
virtual nsresult
|
|
|
|
OpenNoNavigate(const nsAString& aUrl,
|
|
|
|
const nsAString& aName,
|
|
|
|
const nsAString& aOptions,
|
|
|
|
nsIDOMWindow **_retval);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2012-08-14 07:58:00 -07:00
|
|
|
* @param aUrl the URL we intend to load into the window. If aNavigate is
|
|
|
|
* true, we'll actually load this URL into the window. Otherwise,
|
|
|
|
* aUrl is advisory; OpenInternal will not load the URL into the
|
|
|
|
* new window.
|
|
|
|
*
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param aName the name to use for the new window
|
2012-08-14 07:58:00 -07:00
|
|
|
*
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param aOptions the window options to use for the new window
|
2012-08-14 07:58:00 -07:00
|
|
|
*
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param aDialog true when called from variants of OpenDialog. If this is
|
2012-08-14 07:58:00 -07:00
|
|
|
* true, this method will skip popup blocking checks. The aDialog
|
|
|
|
* argument is passed on to the window watcher.
|
|
|
|
*
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param aCalledNoScript true when called via the [noscript] open()
|
2012-08-14 07:58:00 -07:00
|
|
|
* and openDialog() methods. When this is true, we do NOT want to use
|
|
|
|
* the JS stack for things like caller determination.
|
|
|
|
*
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param aDoJSFixups true when this is the content-accessible JS version of
|
2012-08-14 07:58:00 -07:00
|
|
|
* window opening. When true, popups do not cause us to throw, we save
|
|
|
|
* the caller's principal in the new window for later consumption, and
|
|
|
|
* we make sure that there is a document in the newly-opened window.
|
|
|
|
* Note that this last will only be done if the newly-opened window is
|
|
|
|
* non-chrome.
|
|
|
|
*
|
|
|
|
* @param aNavigate true if we should navigate to the provided URL, false
|
|
|
|
* otherwise. When aNavigate is false, we also skip our can-load
|
|
|
|
* security check, on the assumption that whoever *actually* loads this
|
|
|
|
* page will do their own security check.
|
|
|
|
*
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param argv The arguments to pass to the new window. The first
|
2012-08-14 07:58:00 -07:00
|
|
|
* three args, if present, will be aUrl, aName, and aOptions. So this
|
|
|
|
* param only matters if there are more than 3 arguments.
|
|
|
|
*
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param argc The number of arguments in argv.
|
2012-08-14 07:58:00 -07:00
|
|
|
*
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param aExtraArgument Another way to pass arguments in. This is mutually
|
2012-08-14 07:58:00 -07:00
|
|
|
* exclusive with the argv/argc approach.
|
|
|
|
*
|
|
|
|
* @param aJSCallerContext The calling script's context. This must be null
|
|
|
|
* when aCalledNoScript is true.
|
2012-07-23 20:30:12 -07:00
|
|
|
*
|
2012-08-14 07:58:00 -07:00
|
|
|
* @param aReturn [out] The window that was opened, if any.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
NS_HIDDEN_(nsresult) OpenInternal(const nsAString& aUrl,
|
|
|
|
const nsAString& aName,
|
|
|
|
const nsAString& aOptions,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aDialog,
|
|
|
|
bool aContentModal,
|
|
|
|
bool aCalledNoScript,
|
|
|
|
bool aDoJSFixups,
|
2012-08-14 07:58:00 -07:00
|
|
|
bool aNavigate,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIArray *argv,
|
|
|
|
nsISupports *aExtraArgument,
|
|
|
|
nsIPrincipal *aCalleePrincipal,
|
|
|
|
JSContext *aJSCallerContext,
|
|
|
|
nsIDOMWindow **aReturn);
|
|
|
|
|
|
|
|
// Timeout Functions
|
2010-07-15 06:59:24 -07:00
|
|
|
// Language agnostic timeout function (all args passed).
|
|
|
|
// |interval| is in milliseconds.
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t interval,
|
|
|
|
bool aIsInterval, int32_t *aReturn);
|
2013-10-08 08:51:42 -07:00
|
|
|
int32_t SetTimeoutOrInterval(mozilla::dom::Function& aFunction,
|
|
|
|
int32_t aTimeout,
|
|
|
|
const mozilla::dom::Sequence<JS::Value>& aArguments,
|
|
|
|
bool aIsInterval, mozilla::ErrorResult& aError);
|
|
|
|
int32_t SetTimeoutOrInterval(JSContext* aCx, const nsAString& aHandler,
|
|
|
|
int32_t aTimeout, bool aIsInterval,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void ClearTimeoutOrInterval(int32_t aTimerID,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
nsresult ClearTimeoutOrInterval(int32_t aTimerID)
|
|
|
|
{
|
|
|
|
mozilla::ErrorResult rv;
|
|
|
|
ClearTimeoutOrInterval(aTimerID, rv);
|
|
|
|
return rv.ErrorCode();
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// JS specific timeout functions (JS args grabbed from context).
|
2012-08-22 08:56:38 -07:00
|
|
|
nsresult SetTimeoutOrInterval(bool aIsInterval, int32_t* aReturn);
|
2011-06-29 12:49:42 -07:00
|
|
|
nsresult ResetTimersForNonBackgroundWindow();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// The timeout implementation functions.
|
|
|
|
void RunTimeout(nsTimeout *aTimeout);
|
2012-07-30 07:20:58 -07:00
|
|
|
void RunTimeout() { RunTimeout(nullptr); }
|
2012-04-24 11:16:29 -07:00
|
|
|
// Return true if |aTimeout| was cleared while its handler ran.
|
|
|
|
bool RunTimeoutHandler(nsTimeout* aTimeout, nsIScriptContext* aScx);
|
|
|
|
// Return true if |aTimeout| needs to be reinserted into the timeout list.
|
|
|
|
bool RescheduleTimeout(nsTimeout* aTimeout, const TimeStamp& now,
|
|
|
|
bool aRunningPendingTimeouts);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void ClearAllTimeouts();
|
|
|
|
// Insert aTimeout into the list, before all timeouts that would
|
|
|
|
// fire after it, but no earlier than mTimeoutInsertionPoint, if any.
|
|
|
|
void InsertTimeoutIntoList(nsTimeout *aTimeout);
|
|
|
|
static void TimerCallback(nsITimer *aTimer, void *aClosure);
|
|
|
|
|
|
|
|
// Helper Functions
|
2013-04-25 23:51:01 -07:00
|
|
|
already_AddRefed<nsIDocShellTreeOwner> GetTreeOwner();
|
|
|
|
already_AddRefed<nsIBaseWindow> GetTreeOwnerWindow();
|
2013-04-25 23:51:04 -07:00
|
|
|
already_AddRefed<nsIWebBrowserChrome> GetWebBrowserChrome();
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult SecurityCheckURL(const char *aURL);
|
|
|
|
nsresult BuildURIfromBase(const char *aURL,
|
|
|
|
nsIURI **aBuiltURI,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool *aFreeSecurityPass, JSContext **aCXused);
|
|
|
|
bool PopupWhitelisted();
|
2009-09-16 11:46:05 -07:00
|
|
|
PopupControlState RevisePopupAbuseLevel(PopupControlState);
|
2011-09-28 23:19:26 -07:00
|
|
|
void FireAbuseEvents(bool aBlocked, bool aWindow,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsAString &aPopupURL,
|
|
|
|
const nsAString &aPopupWindowName,
|
|
|
|
const nsAString &aPopupWindowFeatures);
|
|
|
|
void FireOfflineStatusEvent();
|
2012-06-29 01:32:21 -07:00
|
|
|
|
|
|
|
nsresult ScheduleNextIdleObserverCallback();
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t GetFuzzTimeMS();
|
2012-06-29 01:32:21 -07:00
|
|
|
nsresult ScheduleActiveTimerCallback();
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t FindInsertionIndex(IdleObserverHolder* aIdleObserver);
|
2012-06-29 01:32:21 -07:00
|
|
|
virtual nsresult RegisterIdleObserver(nsIIdleObserver* aIdleObserverPtr);
|
|
|
|
nsresult FindIndexOfElementToRemove(nsIIdleObserver* aIdleObserver,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t* aRemoveElementIndex);
|
2012-06-29 01:32:21 -07:00
|
|
|
virtual nsresult UnregisterIdleObserver(nsIIdleObserver* aIdleObserverPtr);
|
|
|
|
|
2011-03-31 13:30:32 -07:00
|
|
|
nsresult FireHashchange(const nsAString &aOldURL, const nsAString &aNewURL);
|
2009-11-26 21:01:43 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
void FlushPendingNotifications(mozFlushType aType);
|
|
|
|
void EnsureReflowFlushAndPaint();
|
2013-04-25 23:50:54 -07:00
|
|
|
void CheckSecurityWidthAndHeight(int32_t* width, int32_t* height);
|
|
|
|
void CheckSecurityLeftAndTop(int32_t* left, int32_t* top);
|
2010-12-21 14:35:09 -08:00
|
|
|
|
|
|
|
// Arguments to this function should have values in app units
|
2013-04-25 23:50:54 -07:00
|
|
|
void SetCSSViewportWidthAndHeight(nscoord width, nscoord height);
|
2010-12-21 14:35:09 -08:00
|
|
|
// Arguments to this function should have values in device pixels
|
2012-08-22 08:56:38 -07:00
|
|
|
nsresult SetDocShellWidthAndHeight(int32_t width, int32_t height);
|
2010-12-21 14:35:09 -08:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool CanSetProperty(const char *aPrefName);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
static void MakeScriptDialogTitle(nsAString &aOutTitle);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool CanMoveResizeWindows();
|
2008-03-19 13:27:34 -07:00
|
|
|
|
2012-10-27 21:24:02 -07:00
|
|
|
bool GetBlurSuppression();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// If aDoFlush is true, we'll flush our own layout; otherwise we'll try to
|
|
|
|
// just flush our parent and only flush ourselves if we think we need to.
|
2013-10-08 08:51:42 -07:00
|
|
|
mozilla::CSSIntPoint GetScrollXY(bool aDoFlush, mozilla::ErrorResult& aError);
|
|
|
|
nsresult GetScrollXY(int32_t* aScrollX, int32_t* aScrollY, bool aDoFlush);
|
|
|
|
void GetScrollMaxXY(int32_t* aScrollMaxX, int32_t* aScrollMaxY,
|
|
|
|
mozilla::ErrorResult& aError);
|
2012-06-29 01:32:21 -07:00
|
|
|
|
2013-07-01 00:14:24 -07:00
|
|
|
// Outer windows only.
|
|
|
|
nsresult GetInnerSize(mozilla::CSSIntSize& aSize);
|
|
|
|
|
2013-10-08 08:51:42 -07:00
|
|
|
nsIntSize GetOuterSize(mozilla::ErrorResult& aError);
|
|
|
|
void SetOuterSize(int32_t aLengthCSSPixels, bool aIsWidth,
|
|
|
|
mozilla::ErrorResult& aError);
|
2009-07-29 20:16:44 -07:00
|
|
|
nsRect GetInnerScreenRect();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-01 00:14:34 -07:00
|
|
|
void ScrollTo(const mozilla::CSSIntPoint& aScroll);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsFrame()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
return GetParentInternal() != nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// If aLookForCallerOnJSStack is true, this method will look at the JS stack
|
|
|
|
// to determine who the caller is. If it's false, it'll use |this| as the
|
|
|
|
// caller.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool WindowExists(const nsAString& aName, bool aLookForCallerOnJSStack);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
already_AddRefed<nsIWidget> GetMainWidget();
|
2009-07-15 02:54:30 -07:00
|
|
|
nsIWidget* GetNearestWidget();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void Freeze()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!IsFrozen(), "Double-freezing?");
|
2011-10-17 07:59:28 -07:00
|
|
|
mIsFrozen = true;
|
2011-05-22 14:30:07 -07:00
|
|
|
NotifyDOMWindowFrozen(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void Thaw()
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
mIsFrozen = false;
|
2011-05-22 14:30:07 -07:00
|
|
|
NotifyDOMWindowThawed(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsInModalState();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-02-10 00:29:53 -08:00
|
|
|
// Convenience functions for the many methods that need to scale
|
|
|
|
// from device to CSS pixels or vice versa. Note: if a presentation
|
|
|
|
// context is not available, they will assume a 1:1 ratio.
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t DevToCSSIntPixels(int32_t px);
|
|
|
|
int32_t CSSToDevIntPixels(int32_t px);
|
2009-02-10 00:29:53 -08:00
|
|
|
nsIntSize DevToCSSIntPixels(nsIntSize px);
|
|
|
|
nsIntSize CSSToDevIntPixels(nsIntSize px);
|
|
|
|
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 11:00:39 -07:00
|
|
|
virtual void SetFocusedNode(nsIContent* aNode,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aFocusMethod = 0,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aNeedsFocus = false);
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 11:00:39 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint32_t GetFocusMethod();
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 11:00:39 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool ShouldShowFocusRing();
|
2010-04-21 07:53:42 -07:00
|
|
|
|
|
|
|
virtual void SetKeyboardIndicators(UIStateChangeType aShowAccelerators,
|
|
|
|
UIStateChangeType aShowFocusRings);
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual void GetKeyboardIndicators(bool* aShowAccelerators,
|
|
|
|
bool* aShowFocusRings);
|
2010-04-21 07:53:42 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
void UpdateCanvasFocus(bool aFocusChanged, nsIContent* aNewContent);
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 11:00:39 -07:00
|
|
|
|
2013-04-04 00:02:11 -07:00
|
|
|
public:
|
|
|
|
virtual already_AddRefed<nsPIWindowRoot> GetTopWindowRoot() MOZ_OVERRIDE;
|
2010-02-20 08:07:03 -08:00
|
|
|
|
2013-04-04 00:02:11 -07:00
|
|
|
protected:
|
2008-02-13 15:41:17 -08:00
|
|
|
static void NotifyDOMWindowDestroyed(nsGlobalWindow* aWindow);
|
2010-05-14 14:17:52 -07:00
|
|
|
void NotifyWindowIDDestroyed(const char* aTopic);
|
2011-05-22 14:30:07 -07:00
|
|
|
|
|
|
|
static void NotifyDOMWindowFrozen(nsGlobalWindow* aWindow);
|
|
|
|
static void NotifyDOMWindowThawed(nsGlobalWindow* aWindow);
|
2012-06-29 01:32:21 -07:00
|
|
|
|
2010-06-01 13:36:16 -07:00
|
|
|
void ClearStatus();
|
2008-02-13 15:41:17 -08:00
|
|
|
|
2010-06-16 04:43:36 -07:00
|
|
|
virtual void UpdateParentTarget();
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetIsTabModalPromptAllowed();
|
2011-02-16 10:27:25 -08:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
inline int32_t DOMMinTimeoutValue() const;
|
2011-03-25 18:05:55 -07:00
|
|
|
|
2012-03-24 01:18:21 -07:00
|
|
|
nsresult CreateOuterObject(nsGlobalWindow* aNewInner);
|
2013-05-10 19:39:45 -07:00
|
|
|
nsresult SetOuterObject(JSContext* aCx, JS::Handle<JSObject*> aOuterObject);
|
2012-03-30 10:31:16 -07:00
|
|
|
nsresult CloneStorageEvent(const nsAString& aType,
|
|
|
|
nsCOMPtr<nsIDOMStorageEvent>& aEvent);
|
2012-03-24 01:18:21 -07:00
|
|
|
|
2012-05-23 08:27:10 -07:00
|
|
|
// Implements Get{Real,Scriptable}Top.
|
|
|
|
nsresult GetTopImpl(nsIDOMWindow **aWindow, bool aScriptable);
|
|
|
|
|
2012-10-02 01:07:35 -07:00
|
|
|
// Outer windows only.
|
|
|
|
nsDOMWindowList* GetWindowList();
|
|
|
|
|
2012-10-17 14:01:56 -07:00
|
|
|
// Helper for getComputedStyle and getDefaultComputedStyle
|
2013-10-08 08:51:42 -07:00
|
|
|
already_AddRefed<nsICSSDeclaration>
|
|
|
|
GetComputedStyleHelper(mozilla::dom::Element& aElt,
|
|
|
|
const nsAString& aPseudoElt,
|
|
|
|
bool aDefaultStylesOnly,
|
|
|
|
mozilla::ErrorResult& aError);
|
2012-10-17 14:01:56 -07:00
|
|
|
nsresult GetComputedStyleHelper(nsIDOMElement* aElt,
|
|
|
|
const nsAString& aPseudoElt,
|
|
|
|
bool aDefaultStylesOnly,
|
|
|
|
nsIDOMCSSStyleDeclaration** aReturn);
|
|
|
|
|
2013-04-15 05:38:48 -07:00
|
|
|
void PreloadLocalStorage();
|
|
|
|
|
2013-10-08 08:51:42 -07:00
|
|
|
// Returns device pixels.
|
|
|
|
nsIntPoint GetScreenXY(mozilla::ErrorResult& aError);
|
|
|
|
|
|
|
|
int32_t RequestAnimationFrame(const nsIDocument::FrameRequestCallbackHolder& aCallback,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
|
|
|
|
nsGlobalWindow* InnerForSetTimeoutOrInterval(mozilla::ErrorResult& aError);
|
|
|
|
|
|
|
|
mozilla::dom::Element* GetRealFrameElement(mozilla::ErrorResult& aError);
|
|
|
|
|
|
|
|
void PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
|
|
|
|
const nsAString& aTargetOrigin,
|
|
|
|
JS::Handle<JS::Value> aTransfer,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
|
|
|
|
already_AddRefed<nsIVariant>
|
|
|
|
ShowModalDialog(const nsAString& aUrl, nsIVariant* aArgument,
|
|
|
|
const nsAString& aOptions, mozilla::ErrorResult& aError);
|
|
|
|
|
|
|
|
already_AddRefed<nsIDOMWindow>
|
|
|
|
GetContentInternal(mozilla::ErrorResult& aError);
|
2013-04-25 08:13:21 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// When adding new member variables, be careful not to create cycles
|
|
|
|
// through JavaScript. If there is any chance that a member variable
|
|
|
|
// could own objects that are implemented in JavaScript, then those
|
|
|
|
// objects will keep the global object (this object) alive. To prevent
|
|
|
|
// these cycles, ownership of such members must be released in
|
2012-05-25 12:00:32 -07:00
|
|
|
// |CleanUp| and |DetachFromDocShell|.
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// This member is also used on both inner and outer windows, but
|
|
|
|
// for slightly different purposes. On inner windows it means the
|
|
|
|
// inner window is held onto by session history and should not
|
|
|
|
// change. On outer windows it means that the window is in a state
|
|
|
|
// where we don't want to force creation of a new inner window since
|
|
|
|
// we're in the middle of doing just that.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsFrozen : 1;
|
2012-06-29 01:32:21 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// These members are only used on outer window objects. Make sure
|
|
|
|
// you never set any of these on an inner object!
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mFullScreen : 1;
|
|
|
|
bool mIsClosed : 1;
|
|
|
|
bool mInClose : 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
// mHavePendingClose means we've got a termination function set to
|
|
|
|
// close us when the JS stops executing or that we have a close
|
|
|
|
// event posted. If this is set, just ignore window.close() calls.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mHavePendingClose : 1;
|
|
|
|
bool mHadOriginalOpener : 1;
|
|
|
|
bool mIsPopupSpam : 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Indicates whether scripts are allowed to close this window.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mBlockScriptedClosingFlag : 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Track what sorts of events we need to fire when thawed
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mFireOfflineStatusChangeEventOnThaw : 1;
|
2012-06-29 01:32:21 -07:00
|
|
|
bool mNotifyIdleObserversIdleOnThaw : 1;
|
|
|
|
bool mNotifyIdleObserversActiveOnThaw : 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Indicates whether we're in the middle of creating an initializing
|
|
|
|
// a new inner window object.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mCreatingInnerWindow : 1;
|
2007-08-02 16:34:38 -07:00
|
|
|
|
|
|
|
// Fast way to tell if this is a chrome window (without having to QI).
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsChrome : 1;
|
2007-08-02 16:34:38 -07:00
|
|
|
|
2011-01-23 11:51:00 -08:00
|
|
|
// Hack to indicate whether a chrome window needs its message manager
|
|
|
|
// to be disconnected, since clean up code is shared in the global
|
|
|
|
// window superclass.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mCleanMessageManager : 1;
|
2011-01-23 11:51:00 -08:00
|
|
|
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 11:00:39 -07:00
|
|
|
// Indicates that the current document has never received a document focus
|
|
|
|
// event.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mNeedsFocus : 1;
|
|
|
|
bool mHasFocus : 1;
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 11:00:39 -07:00
|
|
|
|
2010-04-21 07:53:42 -07:00
|
|
|
// whether to show keyboard accelerators
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mShowAccelerators : 1;
|
2010-04-21 07:53:42 -07:00
|
|
|
|
|
|
|
// whether to show focus rings
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mShowFocusRings : 1;
|
2010-04-21 07:53:42 -07:00
|
|
|
|
|
|
|
// when true, show focus rings for the current focused content only.
|
|
|
|
// This will be reset when another element is focused
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mShowFocusRingForContent : 1;
|
2010-04-21 07:53:42 -07:00
|
|
|
|
2010-05-13 05:19:50 -07:00
|
|
|
// true if tab navigation has occurred for this window. Focus rings
|
2010-04-21 07:53:42 -07:00
|
|
|
// should be displayed.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mFocusByKeyOccurred : 1;
|
2010-04-21 07:53:42 -07:00
|
|
|
|
2011-08-03 11:12:08 -07:00
|
|
|
// Indicates whether this window wants gamepad input events
|
|
|
|
bool mHasGamepad : 1;
|
|
|
|
#ifdef MOZ_GAMEPAD
|
2012-02-15 16:47:13 -08:00
|
|
|
nsRefPtrHashtable<nsUint32HashKey, mozilla::dom::Gamepad> mGamepads;
|
2011-08-03 11:12:08 -07:00
|
|
|
bool mHasSeenGamepadInput;
|
|
|
|
#endif
|
|
|
|
|
2010-05-14 14:17:52 -07:00
|
|
|
// whether we've sent the destroy notification for our window id
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mNotifiedIDDestroyed : 1;
|
2012-10-12 03:17:56 -07:00
|
|
|
// whether scripts may close the window,
|
|
|
|
// even if "dom.allow_scripts_to_close_windows" is false.
|
|
|
|
bool mAllowScriptsToClose : 1;
|
2010-05-14 14:17:52 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIScriptContext> mContext;
|
2008-02-08 13:09:36 -08:00
|
|
|
nsWeakPtr mOpener;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIControllers> mControllers;
|
2013-05-17 10:43:19 -07:00
|
|
|
|
|
|
|
// For |window.arguments|, via |openDialog|.
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIArray> mArguments;
|
2013-05-17 10:43:19 -07:00
|
|
|
|
|
|
|
// For |window.dialogArguments|, via |showModalDialog|.
|
|
|
|
nsRefPtr<DialogValueHolder> mDialogArguments;
|
|
|
|
|
2013-10-08 08:51:42 -07:00
|
|
|
nsRefPtr<mozilla::dom::Navigator> mNavigator;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsRefPtr<nsScreen> mScreen;
|
|
|
|
nsRefPtr<nsDOMWindowList> mFrames;
|
2013-05-31 03:30:00 -07:00
|
|
|
nsRefPtr<mozilla::dom::BarProp> mMenubar;
|
|
|
|
nsRefPtr<mozilla::dom::BarProp> mToolbar;
|
|
|
|
nsRefPtr<mozilla::dom::BarProp> mLocationbar;
|
|
|
|
nsRefPtr<mozilla::dom::BarProp> mPersonalbar;
|
|
|
|
nsRefPtr<mozilla::dom::BarProp> mStatusbar;
|
|
|
|
nsRefPtr<mozilla::dom::BarProp> mScrollbars;
|
2012-04-01 19:23:51 -07:00
|
|
|
nsRefPtr<nsDOMWindowUtils> mWindowUtils;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsString mStatus;
|
|
|
|
nsString mDefaultStatus;
|
|
|
|
nsGlobalWindowObserver* mObserver;
|
|
|
|
nsCOMPtr<nsIDOMCrypto> mCrypto;
|
2013-02-16 20:43:16 -08:00
|
|
|
|
2009-05-16 06:59:30 -07:00
|
|
|
nsCOMPtr<nsIDOMStorage> mLocalStorage;
|
2010-01-28 06:53:53 -08:00
|
|
|
nsCOMPtr<nsIDOMStorage> mSessionStorage;
|
2009-03-18 16:43:45 -07:00
|
|
|
|
2010-06-29 11:46:39 -07:00
|
|
|
nsCOMPtr<nsIXPConnectJSObjectHolder> mInnerWindowHolder;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// These member variable are used only on inner windows.
|
2011-06-23 19:18:01 -07:00
|
|
|
nsRefPtr<nsEventListenerManager> mListenerManager;
|
2011-07-08 11:04:25 -07:00
|
|
|
// mTimeouts is generally sorted by mWhen, unless mTimeoutInsertionPoint is
|
|
|
|
// non-null. In that case, the dummy timeout pointed to by
|
|
|
|
// mTimeoutInsertionPoint may have a later mWhen than some of the timeouts
|
|
|
|
// that come after it.
|
2012-11-01 07:06:22 -07:00
|
|
|
mozilla::LinkedList<nsTimeout> mTimeouts;
|
2007-03-22 10:30:00 -07:00
|
|
|
// If mTimeoutInsertionPoint is non-null, insertions should happen after it.
|
2011-07-08 11:04:25 -07:00
|
|
|
// This is a dummy timeout at the moment; if that ever changes, the logic in
|
|
|
|
// ResetTimersForNonBackgroundWindow needs to change.
|
2007-03-22 10:30:00 -07:00
|
|
|
nsTimeout* mTimeoutInsertionPoint;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mTimeoutPublicIdCounter;
|
|
|
|
uint32_t mTimeoutFiringDepth;
|
2010-08-06 17:17:33 -07:00
|
|
|
nsRefPtr<nsLocation> mLocation;
|
2011-02-01 09:19:35 -08:00
|
|
|
nsRefPtr<nsHistory> mHistory;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// These member variables are used on both inner and the outer windows.
|
|
|
|
nsCOMPtr<nsIPrincipal> mDocumentPrincipal;
|
2013-07-23 02:58:26 -07:00
|
|
|
|
|
|
|
// The JS global object. Global objects are always allocated tenured.
|
|
|
|
JS::TenuredHeap<JSObject*> mJSObject;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-01-14 06:39:21 -08:00
|
|
|
typedef nsCOMArray<nsIDOMStorageEvent> nsDOMStorageEventArray;
|
2010-01-28 06:53:53 -08:00
|
|
|
nsDOMStorageEventArray mPendingStorageEvents;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mTimeoutsSuspendDepth;
|
2009-02-17 12:07:39 -08:00
|
|
|
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 11:00:39 -07:00
|
|
|
// the method that was used to focus mFocusedNode
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mFocusMethod;
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 11:00:39 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mSerial;
|
2010-09-09 15:15:40 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef DEBUG
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mSetOpenerWindowCalled;
|
2008-04-28 14:51:11 -07:00
|
|
|
nsCOMPtr<nsIURI> mLastOpenedURI;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2013-08-07 17:07:41 -07:00
|
|
|
#ifdef MOZ_B2G
|
|
|
|
bool mNetworkUploadObserverEnabled;
|
|
|
|
bool mNetworkDownloadObserverEnabled;
|
|
|
|
#endif // MOZ_B2G
|
|
|
|
|
2013-08-07 17:45:54 -07:00
|
|
|
bool mCleanedUp;
|
|
|
|
|
2008-01-16 13:54:33 -08:00
|
|
|
nsCOMPtr<nsIDOMOfflineResourceList> mApplicationCache;
|
|
|
|
|
2013-09-02 01:41:57 -07:00
|
|
|
nsAutoPtr<nsJSThingHashtable<nsPtrHashKey<nsXBLPrototypeHandler>, JSObject*> > mCachedXBLPrototypeHandlers;
|
2008-02-12 20:17:18 -08:00
|
|
|
|
2009-03-03 12:11:14 -08:00
|
|
|
nsCOMPtr<nsIDocument> mSuspendedDoc;
|
|
|
|
|
2013-03-31 01:18:30 -07:00
|
|
|
nsRefPtr<mozilla::dom::indexedDB::IDBFactory> mIndexedDB;
|
2010-06-23 12:46:08 -07:00
|
|
|
|
2012-08-13 12:03:59 -07:00
|
|
|
// This counts the number of windows that have been opened in rapid succession
|
|
|
|
// (i.e. within dom.successive_dialog_time_limit of each other). It is reset
|
|
|
|
// to 0 once a dialog is opened after dom.successive_dialog_time_limit seconds
|
|
|
|
// have elapsed without any other dialogs.
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mDialogAbuseCount;
|
2010-09-16 18:24:14 -07:00
|
|
|
|
2012-08-13 12:03:59 -07:00
|
|
|
// This holds the time when the last modal dialog was shown. If more than
|
|
|
|
// MAX_DIALOG_LIMIT dialogs are shown within the time span defined by
|
|
|
|
// dom.successive_dialog_time_limit, we show a checkbox or confirmation prompt
|
|
|
|
// to allow disabling of further dialogs from this window.
|
2010-09-16 18:24:14 -07:00
|
|
|
TimeStamp mLastDialogQuitTime;
|
2012-08-13 12:03:59 -07:00
|
|
|
|
2013-10-08 14:00:12 -07:00
|
|
|
// This flag keeps track of whether dialogs are
|
|
|
|
// currently enabled on this window.
|
|
|
|
bool mAreDialogsEnabled;
|
2012-08-13 12:05:34 -07:00
|
|
|
|
2012-03-12 17:56:07 -07:00
|
|
|
nsTHashtable<nsPtrHashKey<nsDOMEventTargetHelper> > mEventTargetObjects;
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
nsTArray<uint32_t> mEnabledSensors;
|
2012-03-24 17:30:03 -07:00
|
|
|
|
2013-04-07 05:19:56 -07:00
|
|
|
#ifdef MOZ_WEBSPEECH
|
|
|
|
// mSpeechSynthesis is only used on inner windows.
|
|
|
|
nsRefPtr<mozilla::dom::SpeechSynthesis> mSpeechSynthesis;
|
|
|
|
#endif
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
friend class nsDOMScriptableHelper;
|
|
|
|
friend class nsDOMWindowUtils;
|
2008-05-02 12:26:47 -07:00
|
|
|
friend class PostMessageEvent;
|
2013-04-10 07:20:43 -07:00
|
|
|
friend class DesktopNotification;
|
2010-10-20 17:24:16 -07:00
|
|
|
|
2011-06-29 04:03:54 -07:00
|
|
|
static WindowByIdTable* sWindowsById;
|
2011-08-14 10:22:29 -07:00
|
|
|
static bool sWarnedAboutWindowInternal;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2013-10-08 08:51:42 -07:00
|
|
|
inline nsISupports*
|
|
|
|
ToSupports(nsGlobalWindow *p)
|
|
|
|
{
|
|
|
|
return static_cast<nsIDOMEventTarget*>(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline nsISupports*
|
|
|
|
ToCanonicalSupports(nsGlobalWindow *p)
|
|
|
|
{
|
|
|
|
return static_cast<nsIDOMEventTarget*>(p);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
|
|
|
* nsGlobalChromeWindow inherits from nsGlobalWindow. It is the global
|
|
|
|
* object created for a Chrome Window only.
|
|
|
|
*/
|
|
|
|
class nsGlobalChromeWindow : public nsGlobalWindow,
|
|
|
|
public nsIDOMChromeWindow
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
// nsIDOMChromeWindow interface
|
|
|
|
NS_DECL_NSIDOMCHROMEWINDOW
|
|
|
|
|
|
|
|
nsGlobalChromeWindow(nsGlobalWindow *aOuterWindow)
|
|
|
|
: nsGlobalWindow(aOuterWindow)
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
mIsChrome = true;
|
|
|
|
mCleanMessageManager = true;
|
2011-01-23 11:51:00 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
~nsGlobalChromeWindow()
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(mCleanMessageManager,
|
|
|
|
"chrome windows may always disconnect the msg manager");
|
|
|
|
if (mMessageManager) {
|
|
|
|
static_cast<nsFrameMessageManager *>(
|
|
|
|
mMessageManager.get())->Disconnect();
|
|
|
|
}
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
mCleanMessageManager = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-06-21 07:51:49 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsGlobalChromeWindow,
|
|
|
|
nsGlobalWindow)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIBrowserDOMWindow> mBrowserDOMWindow;
|
2012-08-27 07:13:02 -07:00
|
|
|
nsCOMPtr<nsIMessageBroadcaster> mMessageManager;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2007-07-26 10:52:26 -07:00
|
|
|
/*
|
|
|
|
* nsGlobalModalWindow inherits from nsGlobalWindow. It is the global
|
|
|
|
* object created for a modal content windows only (i.e. not modal
|
|
|
|
* chrome dialogs).
|
|
|
|
*/
|
|
|
|
class nsGlobalModalWindow : public nsGlobalWindow,
|
|
|
|
public nsIDOMModalContentWindow
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsGlobalModalWindow(nsGlobalWindow *aOuterWindow)
|
|
|
|
: nsGlobalWindow(aOuterWindow)
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
mIsModalContentWindow = true;
|
2007-07-26 10:52:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_NSIDOMMODALCONTENTWINDOW
|
|
|
|
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsGlobalModalWindow, nsGlobalWindow)
|
|
|
|
|
|
|
|
protected:
|
2013-05-17 10:43:19 -07:00
|
|
|
// For use by outer windows only.
|
|
|
|
nsRefPtr<DialogValueHolder> mReturnValue;
|
2007-07-26 10:52:26 -07:00
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/* factory function */
|
2012-04-14 06:03:16 -07:00
|
|
|
inline already_AddRefed<nsGlobalWindow>
|
|
|
|
NS_NewScriptGlobalObject(bool aIsChrome, bool aIsModalContentWindow)
|
|
|
|
{
|
|
|
|
nsRefPtr<nsGlobalWindow> global;
|
|
|
|
|
|
|
|
if (aIsChrome) {
|
2012-07-30 07:20:58 -07:00
|
|
|
global = new nsGlobalChromeWindow(nullptr);
|
2012-04-14 06:03:16 -07:00
|
|
|
} else if (aIsModalContentWindow) {
|
2012-07-30 07:20:58 -07:00
|
|
|
global = new nsGlobalModalWindow(nullptr);
|
2012-04-14 06:03:16 -07:00
|
|
|
} else {
|
2012-07-30 07:20:58 -07:00
|
|
|
global = new nsGlobalWindow(nullptr);
|
2012-04-14 06:03:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return global.forget();
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#endif /* nsGlobalWindow_h___ */
|