2017-11-15 19:30:13 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* 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/. */
|
|
|
|
|
2017-11-15 19:33:29 +03:00
|
|
|
#ifndef nsGlobalWindowOuter_h___
|
|
|
|
#define nsGlobalWindowOuter_h___
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
#include "nsPIDOMWindow.h"
|
|
|
|
|
|
|
|
#include "nsTHashtable.h"
|
|
|
|
#include "nsHashKeys.h"
|
|
|
|
#include "nsRefPtrHashtable.h"
|
|
|
|
#include "nsInterfaceHashtable.h"
|
|
|
|
|
|
|
|
// Local Includes
|
|
|
|
// Helper Classes
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsWeakReference.h"
|
|
|
|
#include "nsDataHashtable.h"
|
|
|
|
#include "nsJSThingHashtable.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
|
|
|
|
// Interfaces Needed
|
|
|
|
#include "nsIBrowserDOMWindow.h"
|
|
|
|
#include "nsIInterfaceRequestor.h"
|
|
|
|
#include "nsIDOMChromeWindow.h"
|
|
|
|
#include "nsIScriptGlobalObject.h"
|
|
|
|
#include "nsIScriptObjectPrincipal.h"
|
|
|
|
#include "mozilla/EventListenerManager.h"
|
|
|
|
#include "nsIPrincipal.h"
|
|
|
|
#include "nsSize.h"
|
|
|
|
#include "mozilla/FlushType.h"
|
|
|
|
#include "prclist.h"
|
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2017-06-14 17:44:17 +03:00
|
|
|
#include "mozilla/dom/ChromeMessageBroadcaster.h"
|
2018-12-16 12:21:16 +03:00
|
|
|
#include "mozilla/dom/PopupBlocker.h"
|
2017-11-15 19:30:13 +03:00
|
|
|
#include "mozilla/dom/StorageEvent.h"
|
|
|
|
#include "mozilla/dom/StorageEventBinding.h"
|
|
|
|
#include "mozilla/dom/UnionTypes.h"
|
|
|
|
#include "mozilla/ErrorResult.h"
|
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "mozilla/GuardObjects.h"
|
|
|
|
#include "mozilla/LinkedList.h"
|
|
|
|
#include "nsWrapperCacheInlines.h"
|
2019-01-02 16:05:23 +03:00
|
|
|
#include "mozilla/dom/Document.h"
|
2017-11-15 19:30:13 +03:00
|
|
|
#include "mozilla/dom/EventTarget.h"
|
|
|
|
#include "mozilla/dom/WindowBinding.h"
|
|
|
|
#include "Units.h"
|
|
|
|
#include "nsComponentManagerUtils.h"
|
|
|
|
#include "nsSize.h"
|
|
|
|
#include "nsCheapSets.h"
|
|
|
|
#include "mozilla/dom/ImageBitmapSource.h"
|
|
|
|
#include "mozilla/UniquePtr.h"
|
2019-11-05 20:56:28 +03:00
|
|
|
#include "mozilla/dom/BrowsingContext.h"
|
2017-11-15 19:30:13 +03:00
|
|
|
|
2019-01-02 16:27:05 +03:00
|
|
|
class nsDocShell;
|
2017-11-15 19:30:13 +03:00
|
|
|
class nsIArray;
|
|
|
|
class nsIBaseWindow;
|
|
|
|
class nsIContent;
|
|
|
|
class nsICSSDeclaration;
|
|
|
|
class nsIDocShellTreeOwner;
|
2018-07-25 02:47:40 +03:00
|
|
|
class nsIDOMWindowUtils;
|
2017-11-15 19:30:13 +03:00
|
|
|
class nsIScrollableFrame;
|
|
|
|
class nsIControllers;
|
|
|
|
class nsIScriptContext;
|
|
|
|
class nsIScriptTimeoutHandler;
|
2019-04-10 02:15:02 +03:00
|
|
|
class nsIBrowserChild;
|
2017-11-15 19:30:13 +03:00
|
|
|
class nsITimeoutHandler;
|
|
|
|
class nsIWebBrowserChrome;
|
|
|
|
class mozIDOMWindowProxy;
|
|
|
|
|
2018-10-30 03:13:29 +03:00
|
|
|
class nsDocShellLoadState;
|
2017-11-15 19:30:13 +03:00
|
|
|
class nsScreen;
|
|
|
|
class nsHistory;
|
|
|
|
class nsGlobalWindowObserver;
|
2017-11-15 19:33:29 +03:00
|
|
|
class nsGlobalWindowInner;
|
2017-11-15 19:30:13 +03:00
|
|
|
class nsDOMWindowUtils;
|
|
|
|
struct nsRect;
|
|
|
|
|
|
|
|
class nsWindowSizes;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
class AbstractThread;
|
|
|
|
class DOMEventTargetHelper;
|
2019-06-11 23:43:40 +03:00
|
|
|
class ThrottledEventQueue;
|
2017-11-15 19:30:13 +03:00
|
|
|
namespace dom {
|
|
|
|
class BarProp;
|
|
|
|
struct ChannelPixelLayout;
|
|
|
|
class Console;
|
|
|
|
class Crypto;
|
|
|
|
class CustomElementRegistry;
|
|
|
|
class DocGroup;
|
|
|
|
class External;
|
|
|
|
class Function;
|
|
|
|
class Gamepad;
|
|
|
|
enum class ImageBitmapFormat : uint8_t;
|
|
|
|
class IncrementalRunnable;
|
|
|
|
class IntlUtils;
|
|
|
|
class Location;
|
|
|
|
class MediaQueryList;
|
|
|
|
class Navigator;
|
|
|
|
class OwningExternalOrWindowProxy;
|
|
|
|
class Promise;
|
2019-01-02 16:27:33 +03:00
|
|
|
class PostMessageData;
|
2017-11-15 19:30:13 +03:00
|
|
|
class PostMessageEvent;
|
|
|
|
struct RequestInit;
|
|
|
|
class RequestOrUSVString;
|
|
|
|
class Selection;
|
|
|
|
class SpeechSynthesis;
|
|
|
|
class Timeout;
|
|
|
|
class U2F;
|
|
|
|
class VRDisplay;
|
|
|
|
enum class VRDisplayEventReason : uint8_t;
|
|
|
|
class VREventObserver;
|
|
|
|
class WakeLock;
|
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
|
|
|
class WindowOrientationObserver;
|
|
|
|
#endif
|
|
|
|
class Worklet;
|
|
|
|
namespace cache {
|
|
|
|
class CacheStorage;
|
|
|
|
} // namespace cache
|
|
|
|
class IDBFactory;
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
extern already_AddRefed<nsIScriptTimeoutHandler> NS_CreateJSTimeoutHandler(
|
|
|
|
JSContext* aCx, nsGlobalWindowInner* aWindow,
|
|
|
|
mozilla::dom::Function& aFunction,
|
|
|
|
const mozilla::dom::Sequence<JS::Value>& aArguments,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
|
|
|
|
extern already_AddRefed<nsIScriptTimeoutHandler> NS_CreateJSTimeoutHandler(
|
|
|
|
JSContext* aCx, nsGlobalWindowInner* aWindow, const nsAString& aExpression,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
|
2019-08-14 20:15:15 +03:00
|
|
|
extern const JSClass OuterWindowProxyClass;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
//*****************************************************************************
|
2017-11-22 00:41:53 +03:00
|
|
|
// nsGlobalWindowOuter
|
2017-11-15 19:30:13 +03:00
|
|
|
//*****************************************************************************
|
2017-11-22 00:41:53 +03:00
|
|
|
|
|
|
|
// nsGlobalWindowOuter inherits PRCList for maintaining a list of all inner
|
|
|
|
// windows still in memory for any given outer window. This list is 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
|
2017-11-15 19:30:13 +03:00
|
|
|
// side effect of inheriting PRCList).
|
|
|
|
|
2018-03-02 18:30:03 +03:00
|
|
|
class nsGlobalWindowOuter final : public mozilla::dom::EventTarget,
|
|
|
|
public nsPIDOMWindowOuter,
|
|
|
|
private nsIDOMWindow
|
|
|
|
// NOTE: This interface is private, as it's only
|
|
|
|
// implemented on chrome windows.
|
|
|
|
,
|
|
|
|
private nsIDOMChromeWindow,
|
|
|
|
public nsIScriptGlobalObject,
|
|
|
|
public nsIScriptObjectPrincipal,
|
|
|
|
public nsSupportsWeakReference,
|
|
|
|
public nsIInterfaceRequestor,
|
2020-05-18 14:04:48 +03:00
|
|
|
public PRCListStr {
|
2017-11-15 19:30:13 +03:00
|
|
|
public:
|
2017-11-15 19:33:29 +03:00
|
|
|
typedef nsDataHashtable<nsUint64HashKey, nsGlobalWindowOuter*>
|
|
|
|
OuterWindowByIdTable;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
static void AssertIsOnMainThread()
|
|
|
|
#ifdef DEBUG
|
|
|
|
;
|
|
|
|
#else
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-11-15 19:33:29 +03:00
|
|
|
static nsGlobalWindowOuter* Cast(nsPIDOMWindowOuter* aPIWin) {
|
2017-11-15 19:34:04 +03:00
|
|
|
return static_cast<nsGlobalWindowOuter*>(aPIWin);
|
2017-11-15 19:33:29 +03:00
|
|
|
}
|
|
|
|
static const nsGlobalWindowOuter* Cast(const nsPIDOMWindowOuter* aPIWin) {
|
2017-11-15 19:34:04 +03:00
|
|
|
return static_cast<const nsGlobalWindowOuter*>(aPIWin);
|
2017-11-15 19:33:29 +03:00
|
|
|
}
|
|
|
|
static nsGlobalWindowOuter* Cast(mozIDOMWindowProxy* aWin) {
|
|
|
|
return Cast(nsPIDOMWindowOuter::From(aWin));
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsGlobalWindowOuter* GetOuterWindowWithId(uint64_t aWindowID) {
|
|
|
|
AssertIsOnMainThread();
|
|
|
|
|
|
|
|
if (!sOuterWindowsById) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsGlobalWindowOuter* outerWindow = sOuterWindowsById->Get(aWindowID);
|
|
|
|
return outerWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
static OuterWindowByIdTable* GetWindowsTable() {
|
|
|
|
AssertIsOnMainThread();
|
|
|
|
|
|
|
|
return sOuterWindowsById;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsGlobalWindowOuter* FromSupports(nsISupports* supports) {
|
|
|
|
// Make sure this matches the casts we do in QueryInterface().
|
|
|
|
return (nsGlobalWindowOuter*)(mozilla::dom::EventTarget*)supports;
|
|
|
|
}
|
|
|
|
|
2019-01-02 16:27:05 +03:00
|
|
|
static already_AddRefed<nsGlobalWindowOuter> Create(nsDocShell* aDocShell,
|
2018-10-10 13:20:36 +03:00
|
|
|
bool aIsChrome);
|
2017-11-15 19:33:29 +03:00
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
// public methods
|
|
|
|
nsPIDOMWindowOuter* GetPrivateParent();
|
|
|
|
|
|
|
|
// callback for close event
|
|
|
|
void ReallyCloseWindow();
|
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
|
|
|
|
// nsWrapperCache
|
|
|
|
virtual JSObject* WrapObject(JSContext* cx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override {
|
2017-11-15 19:34:20 +03:00
|
|
|
return EnsureInnerWindow() ? GetWrapper() : nullptr;
|
2017-11-15 19:30:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// nsIGlobalJSObjectHolder
|
2019-05-24 14:26:01 +03:00
|
|
|
JSObject* GetGlobalJSObject() final { return GetWrapper(); }
|
2019-05-03 13:08:07 +03:00
|
|
|
JSObject* GetGlobalJSObjectPreserveColor() const final {
|
|
|
|
return GetWrapperPreserveColor();
|
|
|
|
}
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
virtual nsresult EnsureScriptEnvironment() override;
|
|
|
|
|
|
|
|
virtual nsIScriptContext* GetScriptContext() override;
|
|
|
|
|
|
|
|
void PoisonOuterWindowProxy(JSObject* aObject);
|
|
|
|
|
|
|
|
virtual bool IsBlackForCC(bool aTracingNeeded = true) override;
|
|
|
|
|
|
|
|
// nsIScriptObjectPrincipal
|
|
|
|
virtual nsIPrincipal* GetPrincipal() override;
|
|
|
|
|
2019-04-12 08:31:32 +03:00
|
|
|
virtual nsIPrincipal* GetEffectiveStoragePrincipal() override;
|
|
|
|
|
2020-06-01 19:31:50 +03:00
|
|
|
virtual nsIPrincipal* IntrinsicStoragePrincipal() override;
|
2020-04-30 08:24:10 +03:00
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
// nsIDOMWindow
|
|
|
|
NS_DECL_NSIDOMWINDOW
|
|
|
|
|
|
|
|
// nsIDOMChromeWindow (only implemented on chrome windows)
|
|
|
|
NS_DECL_NSIDOMCHROMEWINDOW
|
|
|
|
|
2018-02-14 19:35:39 +03:00
|
|
|
mozilla::dom::ChromeMessageBroadcaster* GetMessageManager();
|
|
|
|
mozilla::dom::ChromeMessageBroadcaster* GetGroupMessageManager(
|
|
|
|
const nsAString& aGroup);
|
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
nsresult OpenJS(const nsAString& aUrl, const nsAString& aName,
|
2019-08-02 23:48:33 +03:00
|
|
|
const nsAString& aOptions,
|
|
|
|
mozilla::dom::BrowsingContext** _retval);
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
virtual mozilla::EventListenerManager* GetExistingListenerManager()
|
|
|
|
const override;
|
|
|
|
|
|
|
|
virtual mozilla::EventListenerManager* GetOrCreateListenerManager() override;
|
|
|
|
|
2018-04-05 20:42:42 +03:00
|
|
|
bool ComputeDefaultWantsUntrusted(mozilla::ErrorResult& aRv) final;
|
|
|
|
|
2019-01-02 16:26:56 +03:00
|
|
|
virtual nsPIDOMWindowOuter* GetOwnerGlobalForBindingsInternal() override;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
virtual nsIGlobalObject* GetOwnerGlobal() const override;
|
|
|
|
|
2018-04-05 20:42:41 +03:00
|
|
|
EventTarget* GetTargetForEventTargetChain() override;
|
2018-09-07 17:47:51 +03:00
|
|
|
|
2018-04-05 20:42:41 +03:00
|
|
|
using mozilla::dom::EventTarget::DispatchEvent;
|
|
|
|
bool DispatchEvent(mozilla::dom::Event& aEvent,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aRv) override;
|
|
|
|
|
2018-04-05 20:42:41 +03:00
|
|
|
void GetEventTargetParent(mozilla::EventChainPreVisitor& aVisitor) override;
|
|
|
|
|
2018-04-05 20:42:41 +03:00
|
|
|
nsresult PostHandleEvent(mozilla::EventChainPostVisitor& aVisitor) override;
|
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
// nsPIDOMWindow
|
|
|
|
virtual nsPIDOMWindowOuter* GetPrivateRoot() override;
|
|
|
|
|
|
|
|
// Outer windows only.
|
|
|
|
virtual void ActivateOrDeactivate(bool aActivate) override;
|
|
|
|
virtual void SetActive(bool aActive) override;
|
|
|
|
virtual bool IsTopLevelWindowActive() override;
|
|
|
|
virtual void SetIsBackground(bool aIsBackground) override;
|
|
|
|
virtual void SetChromeEventHandler(
|
|
|
|
mozilla::dom::EventTarget* aChromeEventHandler) override;
|
|
|
|
|
|
|
|
// Outer windows only.
|
2019-05-22 02:14:27 +03:00
|
|
|
virtual void SetInitialPrincipalToSubject(
|
|
|
|
nsIContentSecurityPolicy* aCSP) override;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
virtual already_AddRefed<nsISupports> SaveWindowState() override;
|
|
|
|
virtual nsresult RestoreWindowState(nsISupports* aState) override;
|
|
|
|
|
|
|
|
virtual bool IsSuspended() const override;
|
|
|
|
virtual bool IsFrozen() const override;
|
|
|
|
|
|
|
|
virtual nsresult FireDelayedDOMEvents() override;
|
|
|
|
|
|
|
|
// Outer windows only.
|
2019-01-02 16:05:23 +03:00
|
|
|
bool WouldReuseInnerWindow(Document* aNewDocument);
|
2017-11-15 19:34:13 +03:00
|
|
|
|
2019-12-13 02:11:01 +03:00
|
|
|
void DetachFromDocShell(bool aIsBeingDiscarded);
|
2017-11-15 19:30:13 +03:00
|
|
|
|
2019-08-08 19:07:12 +03:00
|
|
|
virtual nsresult SetNewDocument(
|
|
|
|
Document* aDocument, nsISupports* aState, bool aForceReuseInnerWindow,
|
|
|
|
mozilla::dom::WindowGlobalChild* aActor = nullptr) override;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
Bug 1510760, part 5 - Support local-to-remote window proxy transplanting. r=tcampbell,peterv
When a BrowsingContext changes from being local to remote, we have to
change all window proxies from being local to remote, using
transplanting. The actual window proxy becomes a remote window
proxy. Cross compartment wrappers (CCWs) to the window proxy also
become remote window proxies in their respective compartments, rather
than CCWs to a remote proxy in the old compartment of the window
proxy, because the window is no longer actually in that
compartment. This also avoids having to figure out what Xray behavior
for remote window proxies should be.
This patch uses the transplanting support I added to
GetRemoteOuterWindowProxy() in the previous patch to ensure that the
remote proxy map holds the correct value after transplanting finishes.
It drops the requirement that both arguments to JS_TransplantObject
have the same class, because we need to transplant a window proxy with
a remote window proxy. It also deals with this by not adding origobj
to the wrapper map unless it is a CCW, to handle transplanting to a
remote proxy.
The core design here, with the remote window proxies in every
compartment, is taken from a patch by peterv.
Differential Revision: https://phabricator.services.mozilla.com/D35730
--HG--
extra : moz-landing-system : lando
2019-07-18 22:36:19 +03:00
|
|
|
// Outer windows only.
|
|
|
|
static void PrepareForProcessChange(JSObject* aProxy);
|
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
// Outer windows only.
|
|
|
|
void DispatchDOMWindowCreated();
|
|
|
|
|
|
|
|
// Outer windows only.
|
|
|
|
virtual void EnsureSizeAndPositionUpToDate() override;
|
|
|
|
|
2019-05-09 23:21:28 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void EnterModalState() override;
|
2017-11-15 19:30:13 +03:00
|
|
|
virtual void LeaveModalState() override;
|
|
|
|
|
|
|
|
// Outer windows only.
|
|
|
|
virtual bool CanClose() override;
|
|
|
|
virtual void ForceClose() override;
|
|
|
|
|
|
|
|
// Outer windows only.
|
2020-06-01 20:11:48 +03:00
|
|
|
virtual bool DispatchCustomEvent(
|
|
|
|
const nsAString& aEventName,
|
|
|
|
mozilla::ChromeOnlyDispatch aChromeOnlyDispatch) override;
|
2017-11-15 19:30:13 +03:00
|
|
|
bool DispatchResizeEvent(const mozilla::CSSIntSize& aSize);
|
|
|
|
|
2018-09-12 18:51:30 +03:00
|
|
|
// For accessing protected field mFullscreen
|
2017-11-15 19:30:13 +03:00
|
|
|
friend class FullscreenTransitionTask;
|
|
|
|
|
|
|
|
// Outer windows only.
|
2018-02-06 09:50:00 +03:00
|
|
|
nsresult SetFullscreenInternal(FullscreenReason aReason,
|
|
|
|
bool aIsFullscreen) final;
|
2018-02-09 08:22:43 +03:00
|
|
|
void FullscreenWillChange(bool aIsFullscreen) final;
|
|
|
|
void FinishFullscreenChange(bool aIsFullscreen) final;
|
2019-10-18 03:15:08 +03:00
|
|
|
void ForceFullScreenInWidget() final;
|
2017-11-15 19:30:13 +03:00
|
|
|
bool SetWidgetFullscreen(FullscreenReason aReason, bool aIsFullscreen,
|
|
|
|
nsIWidget* aWidget, nsIScreen* aScreen);
|
2018-09-12 18:51:30 +03:00
|
|
|
bool Fullscreen() const;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
// nsIInterfaceRequestor
|
|
|
|
NS_DECL_NSIINTERFACEREQUESTOR
|
|
|
|
|
2019-06-20 23:52:55 +03:00
|
|
|
mozilla::dom::Nullable<mozilla::dom::WindowProxyHolder> IndexedGetterOuter(
|
|
|
|
uint32_t aIndex);
|
2017-11-15 19:30:13 +03:00
|
|
|
|
2019-07-26 19:48:31 +03:00
|
|
|
already_AddRefed<nsPIDOMWindowOuter> GetInProcessTop() override;
|
|
|
|
// Similar to GetInProcessTop() except that it stops at content frames that
|
|
|
|
// an extension has permission to access. This is used by the third-party
|
|
|
|
// util service in order to determine the top window for a channel which is
|
|
|
|
// used in third-partiness checks.
|
2019-01-23 17:55:49 +03:00
|
|
|
already_AddRefed<nsPIDOMWindowOuter>
|
|
|
|
GetTopExcludingExtensionAccessibleContentFrames(nsIURI* aURIBeingLoaded);
|
2019-07-26 19:48:31 +03:00
|
|
|
nsPIDOMWindowOuter* GetInProcessScriptableTop() override;
|
|
|
|
inline nsGlobalWindowOuter* GetInProcessTopInternal();
|
2017-11-15 19:30:13 +03:00
|
|
|
|
2019-07-26 19:48:31 +03:00
|
|
|
inline nsGlobalWindowOuter* GetInProcessScriptableTopInternal();
|
2017-11-15 19:30:13 +03:00
|
|
|
|
2019-01-02 16:27:05 +03:00
|
|
|
already_AddRefed<mozilla::dom::BrowsingContext> GetChildWindow(
|
|
|
|
const nsAString& aName);
|
2017-11-15 19:30:13 +03: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.
|
|
|
|
// Outer windows only.
|
|
|
|
bool ShouldPromptToBlockDialogs();
|
|
|
|
|
|
|
|
// These functions are used for controlling and determining whether dialogs
|
|
|
|
// (alert, prompt, confirm) are currently allowed in this window. If you want
|
|
|
|
// to temporarily disable dialogs, please use TemporarilyDisableDialogs, not
|
|
|
|
// EnableDialogs/DisableDialogs, because correctly determining whether to
|
|
|
|
// re-enable dialogs is actually quite difficult.
|
|
|
|
void EnableDialogs();
|
|
|
|
void DisableDialogs();
|
|
|
|
// Outer windows only.
|
|
|
|
bool AreDialogsEnabled();
|
|
|
|
|
|
|
|
class MOZ_RAII TemporarilyDisableDialogs {
|
|
|
|
public:
|
|
|
|
explicit TemporarilyDisableDialogs(
|
|
|
|
nsGlobalWindowOuter* aWindow MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
|
|
|
|
~TemporarilyDisableDialogs();
|
|
|
|
|
|
|
|
private:
|
|
|
|
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
|
|
|
|
|
|
|
// Always an inner window; this is the window whose dialog state we messed
|
|
|
|
// with. We just want to keep it alive, because we plan to poke at its
|
|
|
|
// members in our destructor.
|
|
|
|
RefPtr<nsGlobalWindowInner> mTopWindow;
|
|
|
|
// This is not a AutoRestore<bool> because that would require careful
|
|
|
|
// member destructor ordering, which is a bit fragile. This way we can
|
|
|
|
// explicitly restore things before we drop our ref to mTopWindow.
|
|
|
|
bool mSavedDialogsEnabled;
|
|
|
|
};
|
|
|
|
friend class TemporarilyDisableDialogs;
|
|
|
|
|
|
|
|
nsIScriptContext* GetContextInternal();
|
|
|
|
|
|
|
|
nsGlobalWindowInner* GetCurrentInnerWindowInternal() const;
|
|
|
|
|
|
|
|
nsGlobalWindowInner* EnsureInnerWindowInternal();
|
|
|
|
|
|
|
|
bool IsCreatingInnerWindow() const { return mCreatingInnerWindow; }
|
|
|
|
|
|
|
|
bool IsChromeWindow() const { return mIsChrome; }
|
|
|
|
|
|
|
|
// GetScrollFrame does not flush. Callers should do it themselves as needed,
|
|
|
|
// depending on which info they actually want off the scrollable frame.
|
|
|
|
nsIScrollableFrame* GetScrollFrame();
|
|
|
|
|
|
|
|
// Outer windows only.
|
|
|
|
void UnblockScriptedClosing();
|
|
|
|
|
|
|
|
static void Init();
|
|
|
|
static void ShutDown();
|
|
|
|
static bool IsCallerChrome();
|
|
|
|
|
|
|
|
friend class WindowStateHolder;
|
|
|
|
|
2017-11-15 19:33:29 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(
|
2018-04-20 07:49:30 +03:00
|
|
|
nsGlobalWindowOuter, mozilla::dom::EventTarget)
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
virtual bool TakeFocus(bool aFocus, uint32_t aFocusMethod) override;
|
|
|
|
virtual void SetReadyForFocus() override;
|
|
|
|
virtual void PageHidden() override;
|
|
|
|
|
2019-10-11 01:59:28 +03:00
|
|
|
/**
|
|
|
|
* Set a arguments for this window. This will be set on the window
|
|
|
|
* right away (if there's an existing document) and it will also be
|
|
|
|
* installed on the window when the next document is loaded.
|
|
|
|
*
|
|
|
|
* This function passes |arguments| back from nsWindowWatcher to
|
|
|
|
* nsGlobalWindow.
|
|
|
|
*/
|
|
|
|
nsresult SetArguments(nsIArray* aArguments);
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
bool IsClosedOrClosing() {
|
|
|
|
return (mIsClosed || mInClose || mHavePendingClose || mCleanedUp);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsCleanedUp() const { return mCleanedUp; }
|
|
|
|
|
2019-08-28 21:07:31 +03:00
|
|
|
bool HadOriginalOpener() const {
|
|
|
|
return GetBrowsingContext()->HadOriginalOpener();
|
|
|
|
}
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
bool IsTopLevelWindow();
|
|
|
|
|
|
|
|
virtual void FirePopupBlockedEvent(
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* aDoc, nsIURI* aPopupURI, const nsAString& aPopupWindowName,
|
2017-11-15 19:30:13 +03:00
|
|
|
const nsAString& aPopupWindowFeatures) override;
|
|
|
|
|
|
|
|
void AddSizeOfIncludingThis(nsWindowSizes& aWindowSizes) const;
|
|
|
|
|
|
|
|
void AllowScriptsToClose() { mAllowScriptsToClose = true; }
|
|
|
|
|
|
|
|
// Outer windows only.
|
|
|
|
uint32_t GetAutoActivateVRDisplayID();
|
|
|
|
// Outer windows only.
|
|
|
|
void SetAutoActivateVRDisplayID(uint32_t aAutoActivateVRDisplayID);
|
|
|
|
|
|
|
|
#define EVENT(name_, id_, type_, struct_) \
|
|
|
|
mozilla::dom::EventHandlerNonNull* GetOn##name_() { \
|
|
|
|
mozilla::EventListenerManager* elm = GetExistingListenerManager(); \
|
2018-07-25 01:15:19 +03:00
|
|
|
return elm ? elm->GetEventHandler(nsGkAtoms::on##name_) : nullptr; \
|
2017-11-15 19:30:13 +03:00
|
|
|
} \
|
|
|
|
void SetOn##name_(mozilla::dom::EventHandlerNonNull* handler) { \
|
|
|
|
mozilla::EventListenerManager* elm = GetOrCreateListenerManager(); \
|
|
|
|
if (elm) { \
|
2018-07-25 01:15:19 +03:00
|
|
|
elm->SetEventHandler(nsGkAtoms::on##name_, handler); \
|
2017-11-15 19:30:13 +03:00
|
|
|
} \
|
|
|
|
}
|
|
|
|
#define ERROR_EVENT(name_, id_, type_, struct_) \
|
|
|
|
mozilla::dom::OnErrorEventHandlerNonNull* GetOn##name_() { \
|
|
|
|
mozilla::EventListenerManager* elm = GetExistingListenerManager(); \
|
|
|
|
return elm ? elm->GetOnErrorEventHandler() : nullptr; \
|
|
|
|
} \
|
|
|
|
void SetOn##name_(mozilla::dom::OnErrorEventHandlerNonNull* handler) { \
|
|
|
|
mozilla::EventListenerManager* elm = GetOrCreateListenerManager(); \
|
|
|
|
if (elm) { \
|
|
|
|
elm->SetEventHandler(handler); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
#define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_) \
|
|
|
|
mozilla::dom::OnBeforeUnloadEventHandlerNonNull* GetOn##name_() { \
|
|
|
|
mozilla::EventListenerManager* elm = GetExistingListenerManager(); \
|
|
|
|
return elm ? elm->GetOnBeforeUnloadEventHandler() : nullptr; \
|
|
|
|
} \
|
|
|
|
void SetOn##name_( \
|
|
|
|
mozilla::dom::OnBeforeUnloadEventHandlerNonNull* handler) { \
|
|
|
|
mozilla::EventListenerManager* elm = GetOrCreateListenerManager(); \
|
|
|
|
if (elm) { \
|
|
|
|
elm->SetEventHandler(handler); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
#define WINDOW_ONLY_EVENT EVENT
|
|
|
|
#define TOUCH_EVENT EVENT
|
|
|
|
#include "mozilla/EventNameList.h"
|
|
|
|
#undef TOUCH_EVENT
|
|
|
|
#undef WINDOW_ONLY_EVENT
|
|
|
|
#undef BEFOREUNLOAD_EVENT
|
|
|
|
#undef ERROR_EVENT
|
|
|
|
#undef EVENT
|
|
|
|
|
|
|
|
nsISupports* GetParentObject() { return nullptr; }
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* GetDocument() { return GetDoc(); }
|
2017-11-15 19:30:13 +03:00
|
|
|
void GetNameOuter(nsAString& aName);
|
|
|
|
void SetNameOuter(const nsAString& aName, mozilla::ErrorResult& aError);
|
2018-08-03 19:24:41 +03:00
|
|
|
mozilla::dom::Location* GetLocation() override;
|
2017-11-15 19:30:13 +03:00
|
|
|
void GetStatusOuter(nsAString& aStatus);
|
|
|
|
void SetStatusOuter(const nsAString& aStatus);
|
|
|
|
void CloseOuter(bool aTrustedCaller);
|
|
|
|
nsresult Close() override;
|
|
|
|
bool GetClosedOuter();
|
|
|
|
bool Closed() override;
|
|
|
|
void StopOuter(mozilla::ErrorResult& aError);
|
2020-01-16 17:38:40 +03:00
|
|
|
void FocusOuter(mozilla::dom::CallerType aCallerType);
|
|
|
|
nsresult Focus(mozilla::dom::CallerType aCallerType) override;
|
2017-11-15 19:30:13 +03:00
|
|
|
void BlurOuter();
|
2019-10-11 22:32:09 +03:00
|
|
|
mozilla::dom::WindowProxyHolder GetFramesOuter();
|
2018-12-18 23:06:19 +03:00
|
|
|
uint32_t Length();
|
2019-01-02 16:26:56 +03:00
|
|
|
mozilla::dom::Nullable<mozilla::dom::WindowProxyHolder> GetTopOuter();
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
nsresult GetPrompter(nsIPrompt** aPrompt) override;
|
2020-02-24 18:33:38 +03:00
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
protected:
|
2019-08-28 21:07:38 +03:00
|
|
|
mozilla::dom::Nullable<mozilla::dom::WindowProxyHolder>
|
|
|
|
GetOpenerWindowOuter();
|
2017-11-15 19:30:13 +03:00
|
|
|
// Initializes the mWasOffline member variable
|
|
|
|
void InitWasOffline();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
public:
|
2019-08-28 21:07:38 +03:00
|
|
|
nsPIDOMWindowOuter* GetSameProcessOpener();
|
|
|
|
already_AddRefed<mozilla::dom::BrowsingContext> GetOpenerBrowsingContext();
|
|
|
|
mozilla::dom::Nullable<mozilla::dom::WindowProxyHolder> GetOpener() override;
|
2019-01-02 16:26:56 +03:00
|
|
|
mozilla::dom::Nullable<mozilla::dom::WindowProxyHolder> GetParentOuter();
|
2019-07-26 19:48:31 +03:00
|
|
|
already_AddRefed<nsPIDOMWindowOuter> GetInProcessParent() override;
|
|
|
|
nsPIDOMWindowOuter* GetInProcessScriptableParent() override;
|
|
|
|
nsPIDOMWindowOuter* GetInProcessScriptableParentOrNull() override;
|
2020-01-10 22:39:31 +03:00
|
|
|
mozilla::dom::Element* GetFrameElement(nsIPrincipal& aSubjectPrincipal);
|
2018-04-27 06:37:33 +03:00
|
|
|
mozilla::dom::Element* GetFrameElement() override;
|
2019-01-02 16:26:56 +03:00
|
|
|
mozilla::dom::Nullable<mozilla::dom::WindowProxyHolder> OpenOuter(
|
|
|
|
const nsAString& aUrl, const nsAString& aName, const nsAString& aOptions,
|
|
|
|
mozilla::ErrorResult& aError);
|
2017-11-15 19:30:13 +03:00
|
|
|
nsresult Open(const nsAString& aUrl, const nsAString& aName,
|
2018-10-30 03:13:29 +03:00
|
|
|
const nsAString& aOptions, nsDocShellLoadState* aLoadState,
|
2019-08-02 23:48:33 +03:00
|
|
|
bool aForceNoOpener,
|
|
|
|
mozilla::dom::BrowsingContext** _retval) override;
|
2018-01-22 20:59:15 +03:00
|
|
|
mozilla::dom::Navigator* GetNavigator() override;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
|
|
|
int16_t Orientation(mozilla::dom::CallerType aCallerType) const;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool AlertOrConfirm(bool aAlert, const nsAString& aMessage,
|
|
|
|
nsIPrincipal& aSubjectPrincipal,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
|
|
|
|
public:
|
|
|
|
void AlertOuter(const nsAString& aMessage, nsIPrincipal& aSubjectPrincipal,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
bool ConfirmOuter(const nsAString& aMessage, nsIPrincipal& aSubjectPrincipal,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void PromptOuter(const nsAString& aMessage, const nsAString& aInitial,
|
|
|
|
nsAString& aReturn, nsIPrincipal& aSubjectPrincipal,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void PrintOuter(mozilla::ErrorResult& aError);
|
|
|
|
mozilla::dom::Selection* GetSelectionOuter();
|
2018-05-08 20:52:36 +03:00
|
|
|
already_AddRefed<mozilla::dom::Selection> GetSelection() override;
|
2017-11-15 19:30:13 +03:00
|
|
|
already_AddRefed<mozilla::dom::MediaQueryList> MatchMediaOuter(
|
|
|
|
const nsAString& aQuery, mozilla::dom::CallerType aCallerType);
|
2018-04-03 07:42:41 +03:00
|
|
|
nsScreen* GetScreen();
|
2017-11-15 19:30:13 +03:00
|
|
|
void MoveToOuter(int32_t aXPos, int32_t aYPos,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void MoveByOuter(int32_t aXDif, int32_t aYDif,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
nsresult MoveBy(int32_t aXDif, int32_t aYDif) override;
|
|
|
|
void ResizeToOuter(int32_t aWidth, int32_t aHeight,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void ResizeByOuter(int32_t aWidthDif, int32_t aHeightDif,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
double GetScrollXOuter();
|
|
|
|
double GetScrollYOuter();
|
|
|
|
|
2019-04-13 15:39:47 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
2017-11-15 19:30:13 +03:00
|
|
|
void SizeToContentOuter(mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
nsIControllers* GetControllersOuter(mozilla::ErrorResult& aError);
|
|
|
|
nsresult GetControllers(nsIControllers** aControllers) override;
|
|
|
|
float GetMozInnerScreenXOuter(mozilla::dom::CallerType aCallerType);
|
|
|
|
float GetMozInnerScreenYOuter(mozilla::dom::CallerType aCallerType);
|
|
|
|
double GetDevicePixelRatioOuter(mozilla::dom::CallerType aCallerType);
|
2018-09-12 18:51:30 +03:00
|
|
|
bool GetFullscreenOuter();
|
2017-11-15 19:30:13 +03:00
|
|
|
bool GetFullScreen() override;
|
2018-09-12 18:51:30 +03:00
|
|
|
void SetFullscreenOuter(bool aFullscreen, mozilla::ErrorResult& aError);
|
|
|
|
nsresult SetFullScreen(bool aFullscreen) override;
|
2017-11-15 19:30:13 +03:00
|
|
|
bool FindOuter(const nsAString& aString, bool aCaseSensitive, bool aBackwards,
|
|
|
|
bool aWrapAround, bool aWholeWord, bool aSearchInFrames,
|
|
|
|
bool aShowDialog, mozilla::ErrorResult& aError);
|
|
|
|
uint64_t GetMozPaintCountOuter();
|
|
|
|
|
|
|
|
bool ShouldResistFingerprinting();
|
|
|
|
|
2019-01-02 16:26:56 +03:00
|
|
|
mozilla::dom::Nullable<mozilla::dom::WindowProxyHolder> OpenDialogOuter(
|
2017-11-15 19:30:13 +03:00
|
|
|
JSContext* aCx, const nsAString& aUrl, const nsAString& aName,
|
|
|
|
const nsAString& aOptions,
|
|
|
|
const mozilla::dom::Sequence<JS::Value>& aExtraArgument,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
nsresult OpenDialog(const nsAString& aUrl, const nsAString& aName,
|
|
|
|
const nsAString& aOptions, nsISupports* aExtraArgument,
|
2019-08-02 23:48:33 +03:00
|
|
|
mozilla::dom::BrowsingContext** _retval) override;
|
2018-05-08 20:52:42 +03:00
|
|
|
void UpdateCommands(const nsAString& anAction, mozilla::dom::Selection* aSel,
|
|
|
|
int16_t aReason) override;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
already_AddRefed<nsPIDOMWindowOuter> GetContentInternal(
|
|
|
|
mozilla::ErrorResult& aError, mozilla::dom::CallerType aCallerType);
|
|
|
|
void GetContentOuter(JSContext* aCx, JS::MutableHandle<JSObject*> aRetval,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
already_AddRefed<nsPIDOMWindowOuter> GetContent() {
|
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> win = GetContentInternal(
|
2018-02-01 22:21:14 +03:00
|
|
|
mozilla::IgnoreErrors(), mozilla::dom::CallerType::System);
|
2017-11-15 19:30:13 +03:00
|
|
|
return win.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
// ChromeWindow bits. Do NOT call these unless your window is in
|
|
|
|
// fact chrome.
|
|
|
|
nsIBrowserDOMWindow* GetBrowserDOMWindowOuter();
|
|
|
|
void SetBrowserDOMWindowOuter(nsIBrowserDOMWindow* aBrowserWindow);
|
2020-01-26 23:17:41 +03:00
|
|
|
void SetCursorOuter(const nsACString& aCursor, mozilla::ErrorResult& aError);
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
void GetReturnValueOuter(JSContext* aCx,
|
|
|
|
JS::MutableHandle<JS::Value> aReturnValue,
|
|
|
|
nsIPrincipal& aSubjectPrincipal,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void GetReturnValue(JSContext* aCx, JS::MutableHandle<JS::Value> aReturnValue,
|
|
|
|
nsIPrincipal& aSubjectPrincipal,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void SetReturnValueOuter(JSContext* aCx, JS::Handle<JS::Value> aReturnValue,
|
|
|
|
nsIPrincipal& aSubjectPrincipal,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void SetReturnValue(JSContext* aCx, JS::Handle<JS::Value> aReturnValue,
|
|
|
|
nsIPrincipal& aSubjectPrincipal,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
|
|
|
|
already_AddRefed<nsWindowRoot> GetWindowRootOuter();
|
|
|
|
|
2018-07-25 02:47:40 +03:00
|
|
|
nsIDOMWindowUtils* WindowUtils();
|
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
virtual bool IsInSyncOperation() override {
|
|
|
|
return GetExtantDoc() && GetExtantDoc()->IsInSyncOperation();
|
|
|
|
}
|
|
|
|
|
2018-10-15 13:37:11 +03:00
|
|
|
void ParentWindowChanged() {
|
2020-06-01 19:31:50 +03:00
|
|
|
// Reset our storage access flag when we get reparented.
|
|
|
|
mHasStorageAccess = false;
|
2018-10-15 13:37:11 +03:00
|
|
|
}
|
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
public:
|
|
|
|
int32_t GetInnerWidthOuter(mozilla::ErrorResult& aError);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
protected:
|
|
|
|
nsresult GetInnerWidth(int32_t* aWidth) override;
|
|
|
|
void SetInnerWidthOuter(int32_t aInnerWidth,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
public:
|
|
|
|
int32_t GetInnerHeightOuter(mozilla::ErrorResult& aError);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
protected:
|
|
|
|
nsresult GetInnerHeight(int32_t* aHeight) override;
|
|
|
|
void SetInnerHeightOuter(int32_t aInnerHeight,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
int32_t GetScreenXOuter(mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void SetScreenXOuter(int32_t aScreenX, mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
int32_t GetScreenYOuter(mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void SetScreenYOuter(int32_t aScreenY, mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
int32_t GetOuterWidthOuter(mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void SetOuterWidthOuter(int32_t aOuterWidth,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
int32_t GetOuterHeightOuter(mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void SetOuterHeightOuter(int32_t aOuterHeight,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
|
|
|
|
RefPtr<mozilla::dom::WakeLock> mWakeLock;
|
|
|
|
|
|
|
|
friend class HashchangeCallback;
|
|
|
|
friend class mozilla::dom::BarProp;
|
|
|
|
|
|
|
|
// Object Management
|
2017-11-15 19:33:29 +03:00
|
|
|
virtual ~nsGlobalWindowOuter();
|
2017-11-15 19:30:13 +03:00
|
|
|
void DropOuterWindowDocs();
|
|
|
|
void CleanUp();
|
|
|
|
void ClearControllers();
|
|
|
|
// Outer windows only.
|
|
|
|
void FinalClose();
|
|
|
|
|
|
|
|
inline void MaybeClearInnerWindow(nsGlobalWindowInner* aExpectedInner);
|
|
|
|
|
|
|
|
// Get the parent, returns null if this is a toplevel window
|
2019-07-26 19:48:31 +03:00
|
|
|
nsPIDOMWindowOuter* GetInProcessParentInternal();
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// Window Control Functions
|
|
|
|
|
|
|
|
// Outer windows only.
|
2019-08-02 23:48:33 +03:00
|
|
|
virtual nsresult OpenNoNavigate(
|
|
|
|
const nsAString& aUrl, const nsAString& aName, const nsAString& aOptions,
|
|
|
|
mozilla::dom::BrowsingContext** _retval) override;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
private:
|
2018-10-10 13:20:36 +03:00
|
|
|
explicit nsGlobalWindowOuter(uint64_t aWindowID);
|
|
|
|
|
2017-11-15 19:30:13 +03: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.
|
|
|
|
*
|
|
|
|
* @param aName the name to use for the new window
|
|
|
|
*
|
|
|
|
* @param aOptions the window options to use for the new window
|
|
|
|
*
|
|
|
|
* @param aDialog true when called from variants of OpenDialog. If this is
|
|
|
|
* true, this method will skip popup blocking checks. The aDialog
|
|
|
|
* argument is passed on to the window watcher.
|
|
|
|
*
|
|
|
|
* @param aCalledNoScript true when called via the [noscript] open()
|
|
|
|
* and openDialog() methods. When this is true, we do NOT want to use
|
|
|
|
* the JS stack for things like caller determination.
|
|
|
|
*
|
|
|
|
* @param aDoJSFixups true when this is the content-accessible JS version of
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* @param argv The arguments to pass to the new window. The first
|
|
|
|
* three args, if present, will be aUrl, aName, and aOptions. So this
|
|
|
|
* param only matters if there are more than 3 arguments.
|
|
|
|
*
|
|
|
|
* @param aExtraArgument Another way to pass arguments in. This is mutually
|
|
|
|
* exclusive with the argv approach.
|
|
|
|
*
|
2018-10-30 03:13:29 +03:00
|
|
|
* @param aLoadState to be passed on along to the windowwatcher.
|
2017-11-15 19:30:13 +03:00
|
|
|
*
|
|
|
|
* @param aForceNoOpener if true, will act as if "noopener" were passed in
|
|
|
|
* aOptions, but without affecting any other window
|
|
|
|
* features.
|
|
|
|
*
|
|
|
|
* @param aReturn [out] The window that was opened, if any. Will be null if
|
|
|
|
* aForceNoOpener is true of if aOptions contains
|
|
|
|
* "noopener".
|
|
|
|
*
|
|
|
|
* Outer windows only.
|
|
|
|
*/
|
|
|
|
nsresult OpenInternal(const nsAString& aUrl, const nsAString& aName,
|
|
|
|
const nsAString& aOptions, bool aDialog,
|
|
|
|
bool aContentModal, bool aCalledNoScript,
|
|
|
|
bool aDoJSFixups, bool aNavigate, nsIArray* argv,
|
|
|
|
nsISupports* aExtraArgument,
|
2018-10-30 03:13:29 +03:00
|
|
|
nsDocShellLoadState* aLoadState, bool aForceNoOpener,
|
2019-08-02 23:48:33 +03:00
|
|
|
mozilla::dom::BrowsingContext** aReturn);
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
public:
|
2018-07-11 13:38:47 +03:00
|
|
|
nsresult SecurityCheckURL(const char* aURL, nsIURI** aURI);
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
bool PopupWhitelisted();
|
2018-12-16 12:21:16 +03:00
|
|
|
mozilla::dom::PopupBlocker::PopupControlState RevisePopupAbuseLevel(
|
|
|
|
mozilla::dom::PopupBlocker::PopupControlState aState);
|
2017-11-15 19:30:13 +03:00
|
|
|
void FireAbuseEvents(const nsAString& aPopupURL,
|
|
|
|
const nsAString& aPopupWindowName,
|
|
|
|
const nsAString& aPopupWindowFeatures);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void ReportLargeAllocStatus();
|
|
|
|
|
|
|
|
public:
|
|
|
|
void FlushPendingNotifications(mozilla::FlushType aType);
|
|
|
|
|
|
|
|
// Outer windows only.
|
|
|
|
void EnsureReflowFlushAndPaint();
|
|
|
|
void CheckSecurityWidthAndHeight(int32_t* width, int32_t* height,
|
|
|
|
mozilla::dom::CallerType aCallerType);
|
|
|
|
void CheckSecurityLeftAndTop(int32_t* left, int32_t* top,
|
|
|
|
mozilla::dom::CallerType aCallerType);
|
|
|
|
|
|
|
|
// Outer windows only.
|
|
|
|
// Arguments to this function should have values in app units
|
|
|
|
void SetCSSViewportWidthAndHeight(nscoord width, nscoord height);
|
|
|
|
// Arguments to this function should have values in device pixels
|
2019-04-13 15:39:47 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
2017-11-15 19:30:13 +03:00
|
|
|
nsresult SetDocShellWidthAndHeight(int32_t width, int32_t height);
|
|
|
|
|
|
|
|
static bool CanSetProperty(const char* aPrefName);
|
|
|
|
|
|
|
|
static void MakeScriptDialogTitle(nsAString& aOutTitle,
|
|
|
|
nsIPrincipal* aSubjectPrincipal);
|
|
|
|
|
|
|
|
// Outer windows only.
|
2019-05-09 23:21:28 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
2017-11-15 19:30:13 +03:00
|
|
|
bool CanMoveResizeWindows(mozilla::dom::CallerType aCallerType);
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
// Outer windows only.
|
|
|
|
mozilla::CSSPoint GetScrollXY(bool aDoFlush);
|
|
|
|
|
|
|
|
int32_t GetScrollBoundaryOuter(mozilla::Side aSide);
|
|
|
|
|
|
|
|
// Outer windows only.
|
|
|
|
nsresult GetInnerSize(mozilla::CSSIntSize& aSize);
|
|
|
|
nsIntSize GetOuterSize(mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void SetOuterSize(int32_t aLengthCSSPixels, bool aIsWidth,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
nsRect GetInnerScreenRect();
|
2019-08-26 02:53:04 +03:00
|
|
|
static Maybe<mozilla::CSSIntSize> GetRDMDeviceSize(const Document& aDocument);
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
bool IsFrame();
|
|
|
|
|
|
|
|
// Outer windows only.
|
|
|
|
// 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.
|
|
|
|
bool WindowExists(const nsAString& aName, bool aForceNoOpener,
|
|
|
|
bool aLookForCallerOnJSStack);
|
|
|
|
|
|
|
|
already_AddRefed<nsIWidget> GetMainWidget();
|
|
|
|
nsIWidget* GetNearestWidget() const;
|
|
|
|
|
|
|
|
bool IsInModalState();
|
|
|
|
|
2020-06-01 19:31:50 +03:00
|
|
|
bool HasStorageAccess() const { return mHasStorageAccess; }
|
|
|
|
void SetHasStorageAccess(bool aHasStorageAccess) {
|
|
|
|
mHasStorageAccess = aHasStorageAccess;
|
2018-09-13 02:20:28 +03:00
|
|
|
}
|
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
// Convenience functions for the many methods that need to scale
|
2019-12-10 11:23:39 +03:00
|
|
|
// from device to CSS pixels. This computes it with cached scale in
|
|
|
|
// PresContext which may be not recent information of the widget.
|
|
|
|
// Note: if PresContext is not available, they will assume a 1:1 ratio.
|
2017-11-15 19:30:13 +03:00
|
|
|
int32_t DevToCSSIntPixels(int32_t px);
|
|
|
|
nsIntSize DevToCSSIntPixels(nsIntSize px);
|
2019-12-10 11:23:39 +03:00
|
|
|
|
|
|
|
// Convenience functions for the methods which call methods of nsIBaseWindow
|
|
|
|
// because it takes/returns device pixels. Unfortunately, mPresContext may
|
|
|
|
// have older scale value for the corresponding widget. Therefore, these
|
|
|
|
// helper methods convert between CSS pixels and device pixels with aWindow.
|
|
|
|
int32_t DevToCSSIntPixelsForBaseWindow(int32_t aDevicePixels,
|
|
|
|
nsIBaseWindow* aWindow);
|
|
|
|
nsIntSize DevToCSSIntPixelsForBaseWindow(nsIntSize aDeviceSize,
|
|
|
|
nsIBaseWindow* aWindow);
|
|
|
|
int32_t CSSToDevIntPixelsForBaseWindow(int32_t aCSSPixels,
|
|
|
|
nsIBaseWindow* aWindow);
|
|
|
|
nsIntSize CSSToDevIntPixelsForBaseWindow(nsIntSize aCSSSize,
|
|
|
|
nsIBaseWindow* aWindow);
|
2017-11-15 19:30:13 +03:00
|
|
|
|
2018-04-26 22:28:30 +03:00
|
|
|
virtual void SetFocusedElement(mozilla::dom::Element* aElement,
|
|
|
|
uint32_t aFocusMethod = 0,
|
|
|
|
bool aNeedsFocus = false) override;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
virtual uint32_t GetFocusMethod() override;
|
|
|
|
|
|
|
|
virtual bool ShouldShowFocusRing() override;
|
|
|
|
|
2019-06-20 23:52:55 +03:00
|
|
|
virtual void SetKeyboardIndicators(
|
|
|
|
UIStateChangeType aShowFocusRings) override;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
virtual already_AddRefed<nsPIWindowRoot> GetTopWindowRoot() override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void NotifyWindowIDDestroyed(const char* aTopic);
|
|
|
|
|
|
|
|
void ClearStatus();
|
|
|
|
|
|
|
|
virtual void UpdateParentTarget() override;
|
|
|
|
|
|
|
|
void InitializeShowFocusRings();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// Helper for getComputedStyle and getDefaultComputedStyle
|
|
|
|
already_AddRefed<nsICSSDeclaration> GetComputedStyleHelperOuter(
|
|
|
|
mozilla::dom::Element& aElt, const nsAString& aPseudoElt,
|
|
|
|
bool aDefaultStylesOnly);
|
|
|
|
|
|
|
|
// Outer windows only.
|
|
|
|
void PreloadLocalStorage();
|
|
|
|
|
|
|
|
// Returns CSS pixels based on primary screen. Outer windows only.
|
|
|
|
mozilla::CSSIntPoint GetScreenXY(mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
|
|
|
|
void PostMessageMozOuter(JSContext* aCx, JS::Handle<JS::Value> aMessage,
|
|
|
|
const nsAString& aTargetOrigin,
|
|
|
|
JS::Handle<JS::Value> aTransfer,
|
|
|
|
nsIPrincipal& aSubjectPrincipal,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
|
2019-01-02 16:29:18 +03:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Compute the principal to use for checking against the target principal in a
|
|
|
|
* postMessage call.
|
|
|
|
*
|
|
|
|
* @param aTargetOrigin The value passed as the targetOrigin argument to the
|
|
|
|
* postMessage call.
|
|
|
|
*
|
|
|
|
* @param aTargetOriginURI The origin of the URI contained in aTargetOrigin
|
|
|
|
* (see GatherPostMessageData).
|
|
|
|
*
|
|
|
|
* @param aCallerPrincipal The principal of the incumbent global of the
|
|
|
|
* postMessage call (see GatherPostMessageData).
|
|
|
|
*
|
|
|
|
* @param aSubjectPrincipal The subject principal for the postMessage call.
|
|
|
|
*
|
|
|
|
* @param aProvidedPrincipal [out] The principal to use for checking against
|
|
|
|
* the target's principal.
|
|
|
|
*
|
|
|
|
* @return Whether the postMessage call should continue or return now.
|
|
|
|
*/
|
|
|
|
bool GetPrincipalForPostMessage(const nsAString& aTargetOrigin,
|
|
|
|
nsIURI* aTargetOriginURI,
|
|
|
|
nsIPrincipal* aCallerPrincipal,
|
|
|
|
nsIPrincipal& aSubjectPrincipal,
|
|
|
|
nsIPrincipal** aProvidedPrincipal);
|
|
|
|
|
2019-01-02 16:27:33 +03:00
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Gather the necessary data from the caller for a postMessage call.
|
|
|
|
*
|
|
|
|
* @param aCx The JSContext.
|
|
|
|
*
|
|
|
|
* @param aTargetOrigin The value passed as the targetOrigin argument to the
|
|
|
|
* postMessage call.
|
|
|
|
*
|
|
|
|
* @param aSource [out] The browsing context for the incumbent global.
|
|
|
|
*
|
|
|
|
* @param aOrigin [out] The value to use for the origin property of the
|
|
|
|
* MessageEvent object.
|
|
|
|
*
|
|
|
|
* @param aTargetOriginURI [out] The origin of the URI contained in
|
|
|
|
* aTargetOrigin, null if aTargetOrigin is "/" or "*".
|
|
|
|
*
|
|
|
|
* @param aCallerPrincipal [out] The principal of the incumbent global of the
|
|
|
|
* postMessage call.
|
|
|
|
*
|
2019-01-02 16:29:18 +03:00
|
|
|
* @param aCallerInnerWindow [out] Inner window of the caller of
|
|
|
|
* postMessage, or null if the incumbent global is not a Window.
|
2019-01-02 16:27:33 +03:00
|
|
|
*
|
2020-01-15 23:20:31 +03:00
|
|
|
* @param aCallerURI [out] The URI of the document of the incumbent
|
2019-01-02 16:27:33 +03:00
|
|
|
* global if it's a Window, null otherwise.
|
|
|
|
*
|
2019-10-23 10:19:48 +03:00
|
|
|
* @param aCallerAgentCluterId [out] If a non-nullptr is passed, it would
|
|
|
|
* return the caller's agent cluster id.
|
|
|
|
*
|
2020-01-15 23:20:31 +03:00
|
|
|
* @param aScriptLocation [out] If we do not have a caller's URI, then
|
|
|
|
* use script location as a sourcename for creating an error object.
|
|
|
|
*
|
2019-01-02 16:27:33 +03:00
|
|
|
* @param aError [out] The error, if any.
|
|
|
|
*
|
|
|
|
* @return Whether the postMessage call should continue or return now.
|
|
|
|
*/
|
|
|
|
static bool GatherPostMessageData(
|
|
|
|
JSContext* aCx, const nsAString& aTargetOrigin,
|
|
|
|
mozilla::dom::BrowsingContext** aSource, nsAString& aOrigin,
|
|
|
|
nsIURI** aTargetOriginURI, nsIPrincipal** aCallerPrincipal,
|
2020-01-15 23:20:31 +03:00
|
|
|
nsGlobalWindowInner** aCallerInnerWindow, nsIURI** aCallerURI,
|
|
|
|
Maybe<nsID>* aCallerAgentClusterId, nsACString* aScriptLocation,
|
|
|
|
mozilla::ErrorResult& aError);
|
2019-01-02 16:27:33 +03:00
|
|
|
|
2017-11-15 19:30:13 +03: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();
|
|
|
|
|
|
|
|
// Helper called after moving/resizing, to update docShell's presContext
|
|
|
|
// if we have caused a resolution change by moving across monitors.
|
|
|
|
void CheckForDPIChange();
|
|
|
|
|
|
|
|
private:
|
|
|
|
enum class SecureContextFlags { eDefault, eIgnoreOpener };
|
|
|
|
// Called only on outer windows to compute the value that will be returned by
|
|
|
|
// IsSecureContext() for the inner window that corresponds to aDocument.
|
|
|
|
bool ComputeIsSecureContext(
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* aDocument,
|
2017-11-15 19:30:13 +03:00
|
|
|
SecureContextFlags aFlags = SecureContextFlags::eDefault);
|
|
|
|
|
2019-01-02 16:27:05 +03:00
|
|
|
void SetDocShell(nsDocShell* aDocShell);
|
2018-10-10 13:20:36 +03:00
|
|
|
|
2017-11-21 21:47:36 +03:00
|
|
|
// nsPIDOMWindow{Inner,Outer} should be able to see these helper methods.
|
2017-11-15 19:34:04 +03:00
|
|
|
friend class nsPIDOMWindowInner;
|
|
|
|
friend class nsPIDOMWindowOuter;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
void SetIsBackgroundInternal(bool aIsBackground);
|
|
|
|
|
2017-11-15 19:34:47 +03:00
|
|
|
nsresult GetInterfaceInternal(const nsIID& aIID, void** aSink);
|
|
|
|
|
2018-07-11 13:38:47 +03:00
|
|
|
void MaybeAllowStorageForOpenedWindow(nsIURI* aURI);
|
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
public:
|
|
|
|
// Dispatch a runnable related to the global.
|
|
|
|
virtual nsresult Dispatch(mozilla::TaskCategory aCategory,
|
|
|
|
already_AddRefed<nsIRunnable>&& aRunnable) override;
|
|
|
|
|
|
|
|
virtual nsISerialEventTarget* EventTargetFor(
|
|
|
|
mozilla::TaskCategory aCategory) const override;
|
|
|
|
|
|
|
|
virtual mozilla::AbstractThread* AbstractMainThreadFor(
|
|
|
|
mozilla::TaskCategory aCategory) override;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
protected:
|
2018-09-12 18:51:30 +03:00
|
|
|
bool mFullscreen : 1;
|
2017-11-15 19:30:13 +03:00
|
|
|
bool mFullscreenMode : 1;
|
2019-10-18 03:15:08 +03:00
|
|
|
bool mForceFullScreenInWidget : 1;
|
2017-11-15 19:30:13 +03:00
|
|
|
bool mIsClosed : 1;
|
|
|
|
bool mInClose : 1;
|
|
|
|
// 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.
|
|
|
|
bool mHavePendingClose : 1;
|
|
|
|
bool mIsPopupSpam : 1;
|
|
|
|
|
|
|
|
// Indicates whether scripts are allowed to close this window.
|
|
|
|
bool mBlockScriptedClosingFlag : 1;
|
|
|
|
|
|
|
|
// Window offline status. Checked to see if we need to fire offline event
|
|
|
|
bool mWasOffline : 1;
|
|
|
|
|
|
|
|
// Indicates whether we're in the middle of creating an initializing
|
|
|
|
// a new inner window object.
|
|
|
|
bool mCreatingInnerWindow : 1;
|
|
|
|
|
|
|
|
// Fast way to tell if this is a chrome window (without having to QI).
|
|
|
|
bool mIsChrome : 1;
|
|
|
|
|
|
|
|
// whether scripts may close the window,
|
|
|
|
// even if "dom.allow_scripts_to_close_windows" is false.
|
|
|
|
bool mAllowScriptsToClose : 1;
|
|
|
|
|
|
|
|
bool mTopLevelOuterContentWindow : 1;
|
|
|
|
|
2018-09-13 02:20:28 +03:00
|
|
|
// whether storage access has been granted to this frame.
|
2020-06-01 19:31:50 +03:00
|
|
|
bool mHasStorageAccess : 1;
|
2018-09-13 02:20:28 +03:00
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
nsCOMPtr<nsIScriptContext> mContext;
|
|
|
|
nsCOMPtr<nsIControllers> mControllers;
|
|
|
|
|
|
|
|
// For |window.arguments|, via |openDialog|.
|
|
|
|
nsCOMPtr<nsIArray> mArguments;
|
|
|
|
|
|
|
|
RefPtr<nsDOMWindowUtils> mWindowUtils;
|
|
|
|
nsString mStatus;
|
|
|
|
|
|
|
|
RefPtr<mozilla::dom::Storage> mLocalStorage;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPrincipal> mDocumentPrincipal;
|
2019-04-12 08:31:32 +03:00
|
|
|
nsCOMPtr<nsIPrincipal> mDocumentStoragePrincipal;
|
2020-06-01 19:31:50 +03:00
|
|
|
nsCOMPtr<nsIPrincipal> mDocumentIntrinsicStoragePrincipal;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
2018-11-23 18:14:23 +03:00
|
|
|
#ifdef DEBUG
|
2017-11-15 19:30:13 +03:00
|
|
|
uint32_t mSerial;
|
|
|
|
|
|
|
|
bool mSetOpenerWindowCalled;
|
|
|
|
nsCOMPtr<nsIURI> mLastOpenedURI;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
bool mCleanedUp;
|
|
|
|
|
2017-11-21 23:42:18 +03:00
|
|
|
// It's useful when we get matched EnterModalState/LeaveModalState calls, in
|
|
|
|
// which case the outer window is responsible for unsuspending events on the
|
|
|
|
// document. If we don't (for example, if the outer window is closed before
|
|
|
|
// the LeaveModalState call), then the inner window whose mDoc is our
|
|
|
|
// mSuspendedDoc is responsible for unsuspending it.
|
2019-01-02 16:05:23 +03:00
|
|
|
RefPtr<Document> mSuspendedDoc;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
// This is the CC generation the last time we called CanSkip.
|
|
|
|
uint32_t mCanSkipCCGeneration;
|
|
|
|
|
|
|
|
// When non-zero, the document should receive a vrdisplayactivate event
|
|
|
|
// after loading. The value is the ID of the VRDisplay that content should
|
|
|
|
// begin presentation on.
|
2017-11-21 23:42:18 +03:00
|
|
|
uint32_t mAutoActivateVRDisplayID;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
2017-11-15 19:33:29 +03:00
|
|
|
static OuterWindowByIdTable* sOuterWindowsById;
|
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
// Members in the mChromeFields member should only be used in chrome windows.
|
|
|
|
// All accesses to this field should be guarded by a check of mIsChrome.
|
|
|
|
struct ChromeFields {
|
|
|
|
nsCOMPtr<nsIBrowserDOMWindow> mBrowserDOMWindow;
|
2019-05-01 05:28:59 +03:00
|
|
|
// A weak pointer to the PresShell that we are doing fullscreen for.
|
2017-11-15 19:30:13 +03:00
|
|
|
// The pointer being set indicates we've set the IsInFullscreenChange
|
|
|
|
// flag on this pres shell.
|
|
|
|
nsWeakPtr mFullscreenPresShell;
|
|
|
|
} mChromeFields;
|
|
|
|
|
|
|
|
friend class nsDOMScriptableHelper;
|
|
|
|
friend class nsDOMWindowUtils;
|
2019-01-02 16:27:05 +03:00
|
|
|
friend class mozilla::dom::BrowsingContext;
|
2017-11-15 19:30:13 +03:00
|
|
|
friend class mozilla::dom::PostMessageEvent;
|
|
|
|
friend class DesktopNotification;
|
|
|
|
friend class mozilla::dom::TimeoutManager;
|
2017-11-15 19:33:29 +03:00
|
|
|
friend class nsGlobalWindowInner;
|
2017-11-15 19:30:13 +03:00
|
|
|
};
|
|
|
|
|
2017-11-15 19:33:29 +03:00
|
|
|
// XXX: EWW - This is an awful hack - let's not do this
|
|
|
|
#include "nsGlobalWindowInner.h"
|
|
|
|
|
|
|
|
inline nsISupports* ToSupports(nsGlobalWindowOuter* p) {
|
2018-04-20 07:49:30 +03:00
|
|
|
return static_cast<mozilla::dom::EventTarget*>(p);
|
2017-11-15 19:30:13 +03:00
|
|
|
}
|
|
|
|
|
2017-11-15 19:33:29 +03:00
|
|
|
inline nsISupports* ToCanonicalSupports(nsGlobalWindowOuter* p) {
|
2018-04-20 07:49:30 +03:00
|
|
|
return static_cast<mozilla::dom::EventTarget*>(p);
|
2017-11-15 19:30:13 +03:00
|
|
|
}
|
|
|
|
|
2017-11-15 19:33:29 +03:00
|
|
|
inline nsIGlobalObject* nsGlobalWindowOuter::GetOwnerGlobal() const {
|
2017-11-15 19:34:20 +03:00
|
|
|
return GetCurrentInnerWindowInternal();
|
2017-11-15 19:30:13 +03:00
|
|
|
}
|
|
|
|
|
2019-07-26 19:48:31 +03:00
|
|
|
inline nsGlobalWindowOuter* nsGlobalWindowOuter::GetInProcessTopInternal() {
|
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> top = GetInProcessTop();
|
2017-11-15 19:30:13 +03:00
|
|
|
if (top) {
|
|
|
|
return nsGlobalWindowOuter::Cast(top);
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-07-26 19:48:31 +03:00
|
|
|
inline nsGlobalWindowOuter*
|
|
|
|
nsGlobalWindowOuter::GetInProcessScriptableTopInternal() {
|
|
|
|
nsPIDOMWindowOuter* top = GetInProcessScriptableTop();
|
2017-11-15 19:30:13 +03:00
|
|
|
return nsGlobalWindowOuter::Cast(top);
|
|
|
|
}
|
|
|
|
|
2017-11-15 19:33:29 +03:00
|
|
|
inline nsIScriptContext* nsGlobalWindowOuter::GetContextInternal() {
|
|
|
|
return mContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline nsGlobalWindowInner* nsGlobalWindowOuter::GetCurrentInnerWindowInternal()
|
|
|
|
const {
|
2017-11-15 19:30:13 +03:00
|
|
|
return nsGlobalWindowInner::Cast(mInnerWindow);
|
|
|
|
}
|
|
|
|
|
2017-11-15 19:33:29 +03:00
|
|
|
inline nsGlobalWindowInner* nsGlobalWindowOuter::EnsureInnerWindowInternal() {
|
2019-04-11 15:12:04 +03:00
|
|
|
return nsGlobalWindowInner::Cast(EnsureInnerWindow());
|
2017-11-15 19:30:13 +03:00
|
|
|
}
|
|
|
|
|
2017-11-15 19:33:29 +03:00
|
|
|
inline bool nsGlobalWindowOuter::IsTopLevelWindow() {
|
2019-07-26 19:48:31 +03:00
|
|
|
nsPIDOMWindowOuter* parentWindow = GetInProcessScriptableTop();
|
2019-04-11 15:12:04 +03:00
|
|
|
return parentWindow == this;
|
2017-11-15 19:30:13 +03:00
|
|
|
}
|
|
|
|
|
2017-11-15 19:33:29 +03:00
|
|
|
inline bool nsGlobalWindowOuter::IsFrame() {
|
2019-07-26 19:48:31 +03:00
|
|
|
return GetInProcessParentInternal() != nullptr;
|
2017-11-15 19:30:13 +03:00
|
|
|
}
|
|
|
|
|
2017-11-15 19:33:29 +03:00
|
|
|
inline void nsGlobalWindowOuter::MaybeClearInnerWindow(
|
|
|
|
nsGlobalWindowInner* aExpectedInner) {
|
2019-04-11 17:12:43 +03:00
|
|
|
if (mInnerWindow == aExpectedInner) {
|
2017-11-15 19:30:13 +03:00
|
|
|
mInnerWindow = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-15 19:33:29 +03:00
|
|
|
#endif /* nsGlobalWindowOuter_h___ */
|