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 nsGlobalWindowInner_h___
|
|
|
|
#define nsGlobalWindowInner_h___
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
#include "nsPIDOMWindow.h"
|
|
|
|
|
|
|
|
#include "nsHashKeys.h"
|
|
|
|
#include "nsRefPtrHashtable.h"
|
|
|
|
#include "nsInterfaceHashtable.h"
|
|
|
|
|
|
|
|
// Local Includes
|
|
|
|
// Helper Classes
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsWeakReference.h"
|
2021-03-10 13:47:47 +03:00
|
|
|
#include "nsTHashMap.h"
|
2017-11-15 19:30:13 +03:00
|
|
|
#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"
|
2019-06-17 07:36:29 +03:00
|
|
|
#include "mozilla/dom/DebuggerNotificationManager.h"
|
2020-12-03 02:06:05 +03:00
|
|
|
#include "mozilla/dom/GamepadHandle.h"
|
2020-11-23 19:07:21 +03:00
|
|
|
#include "mozilla/dom/Location.h"
|
2018-07-27 07:37:44 +03:00
|
|
|
#include "mozilla/dom/NavigatorBinding.h"
|
2017-11-15 19:30:13 +03:00
|
|
|
#include "mozilla/dom/StorageEvent.h"
|
|
|
|
#include "mozilla/dom/StorageEventBinding.h"
|
|
|
|
#include "mozilla/dom/UnionTypes.h"
|
2019-12-19 10:58:09 +03:00
|
|
|
#include "mozilla/CallState.h"
|
2017-11-15 19:30:13 +03:00
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "mozilla/LinkedList.h"
|
2018-07-27 07:37:44 +03:00
|
|
|
#include "mozilla/OwningNonNull.h"
|
2017-11-15 19:30:13 +03:00
|
|
|
#include "mozilla/TimeStamp.h"
|
|
|
|
#include "nsWrapperCacheInlines.h"
|
|
|
|
#include "mozilla/dom/EventTarget.h"
|
|
|
|
#include "mozilla/dom/WindowBinding.h"
|
2019-10-12 19:21:47 +03:00
|
|
|
#include "mozilla/dom/WindowProxyHolder.h"
|
2021-03-04 14:15:12 +03:00
|
|
|
#include "mozilla/glean/bindings/Glean.h"
|
|
|
|
#include "mozilla/glean/bindings/GleanPings.h"
|
2017-11-15 19:30:13 +03:00
|
|
|
#include "Units.h"
|
|
|
|
#include "nsComponentManagerUtils.h"
|
|
|
|
#include "nsSize.h"
|
|
|
|
#include "nsCheapSets.h"
|
|
|
|
#include "mozilla/dom/ImageBitmapSource.h"
|
|
|
|
#include "mozilla/UniquePtr.h"
|
2020-08-05 00:17:50 +03:00
|
|
|
#include "nsRefreshObservers.h"
|
2019-06-12 21:36:41 +03:00
|
|
|
#include "nsThreadUtils.h"
|
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;
|
2018-07-14 01:42:07 +03:00
|
|
|
class nsDOMOfflineResourceList;
|
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;
|
2020-11-23 19:21:38 +03:00
|
|
|
class nsIPrintSettings;
|
2017-11-15 19:30:13 +03:00
|
|
|
class nsITimeoutHandler;
|
|
|
|
class nsIWebBrowserChrome;
|
Bug 1636728 - Centralize printing entry points in nsGlobalWindowOuter, and move cloning out of nsPrintJob. r=jwatt,geckoview-reviewers,smaug,agi
This centralizes our print and preview setup in nsGlobalWindowOuter so
that we never re-clone a clone, and so that we reuse the window.open()
codepath to create the browsing context to clone into.
For window.print, for both old print dialog / silent printing and new
print preview UI, we now create a hidden browser (as in with visibility:
collapse, which takes no space but still gets a layout box).
* In the modern UI case, this browser is swapped with the actual print
preview clone, and the UI takes care of removing the browser.
* In the print dialog / silent printing case, the printing code calls
window.close() from nsDocumentViewer::OnDonePrinting().
* We don't need to care about the old print preview UI for this case
because it can't be open from window.print().
We need to fall back to an actual window when there's no
nsIBrowserDOMWindow around for WPT print tests and the like, which don't
have one. That seems fine, we could special-case this code path more if
needed but it doesn't seem worth it.
Differential Revision: https://phabricator.services.mozilla.com/D87063
2020-08-25 20:45:12 +03:00
|
|
|
class nsIWebProgressListener;
|
2017-11-15 19:30:13 +03:00
|
|
|
class mozIDOMWindowProxy;
|
|
|
|
|
|
|
|
class nsScreen;
|
|
|
|
class nsHistory;
|
|
|
|
class nsGlobalWindowObserver;
|
2017-11-15 19:33:29 +03:00
|
|
|
class nsGlobalWindowOuter;
|
2017-11-15 19:30:13 +03:00
|
|
|
class nsDOMWindowUtils;
|
2020-07-20 19:06:59 +03:00
|
|
|
class nsIUserIdleService;
|
2017-11-15 19:30:13 +03:00
|
|
|
struct nsRect;
|
|
|
|
|
|
|
|
class nsWindowSizes;
|
|
|
|
|
|
|
|
class IdleRequestExecutor;
|
|
|
|
|
2017-11-15 19:33:29 +03:00
|
|
|
class DialogValueHolder;
|
|
|
|
|
2018-02-12 04:14:49 +03:00
|
|
|
class PromiseDocumentFlushedResolver;
|
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
namespace mozilla {
|
|
|
|
class AbstractThread;
|
2020-11-23 19:12:02 +03:00
|
|
|
class ErrorResult;
|
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
namespace dom {
|
|
|
|
class BarProp;
|
2019-01-02 16:27:05 +03:00
|
|
|
class BrowsingContext;
|
2017-11-15 19:30:13 +03:00
|
|
|
struct ChannelPixelLayout;
|
2017-11-21 23:13:05 +03:00
|
|
|
class ClientSource;
|
2017-11-15 19:30:13 +03:00
|
|
|
class Console;
|
|
|
|
class Crypto;
|
|
|
|
class CustomElementRegistry;
|
|
|
|
class DocGroup;
|
|
|
|
class External;
|
|
|
|
class Function;
|
|
|
|
class Gamepad;
|
2020-08-24 07:27:08 +03:00
|
|
|
class ContentMediaController;
|
2017-11-15 19:30:13 +03:00
|
|
|
enum class ImageBitmapFormat : uint8_t;
|
|
|
|
class IdleRequest;
|
|
|
|
class IdleRequestCallback;
|
|
|
|
class IncrementalRunnable;
|
2018-03-22 06:18:51 +03:00
|
|
|
class InstallTriggerImpl;
|
2017-11-15 19:30:13 +03:00
|
|
|
class IntlUtils;
|
|
|
|
class MediaQueryList;
|
|
|
|
class OwningExternalOrWindowProxy;
|
|
|
|
class Promise;
|
|
|
|
class PostMessageEvent;
|
|
|
|
struct RequestInit;
|
|
|
|
class RequestOrUSVString;
|
2018-11-20 02:18:21 +03:00
|
|
|
class SharedWorker;
|
2017-11-15 19:30:13 +03:00
|
|
|
class Selection;
|
|
|
|
class SpeechSynthesis;
|
|
|
|
class Timeout;
|
|
|
|
class U2F;
|
2018-08-20 23:28:42 +03:00
|
|
|
class VisualViewport;
|
2017-11-15 19:30:13 +03:00
|
|
|
class VRDisplay;
|
|
|
|
enum class VRDisplayEventReason : uint8_t;
|
|
|
|
class VREventObserver;
|
|
|
|
class WakeLock;
|
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
|
|
|
class WindowOrientationObserver;
|
|
|
|
#endif
|
2018-10-29 18:26:30 +03:00
|
|
|
struct WindowPostMessageOptions;
|
2017-11-15 19:30:13 +03:00
|
|
|
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
|
|
|
// nsGlobalWindowInner: Global Object for Scripting
|
2017-11-15 19:30:13 +03:00
|
|
|
//*****************************************************************************
|
2017-11-22 00:41:53 +03:00
|
|
|
|
|
|
|
// nsGlobalWindowInner 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 nsGlobalWindowInner final : public mozilla::dom::EventTarget,
|
|
|
|
public nsPIDOMWindowInner,
|
|
|
|
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,
|
2021-04-14 22:34:23 +03:00
|
|
|
public PRCListStr {
|
2017-11-15 19:30:13 +03:00
|
|
|
public:
|
2019-01-02 16:29:18 +03:00
|
|
|
typedef mozilla::dom::BrowsingContext RemoteProxy;
|
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
typedef mozilla::TimeStamp TimeStamp;
|
|
|
|
typedef mozilla::TimeDuration TimeDuration;
|
|
|
|
|
2021-03-10 13:47:47 +03:00
|
|
|
typedef nsTHashMap<nsUint64HashKey, nsGlobalWindowInner*>
|
2017-11-15 19:33:29 +03:00
|
|
|
InnerWindowByIdTable;
|
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
static void AssertIsOnMainThread()
|
|
|
|
#ifdef DEBUG
|
|
|
|
;
|
|
|
|
#else
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-11-15 19:33:29 +03:00
|
|
|
static nsGlobalWindowInner* Cast(nsPIDOMWindowInner* aPIWin) {
|
2017-11-15 19:34:04 +03:00
|
|
|
return static_cast<nsGlobalWindowInner*>(aPIWin);
|
2017-11-15 19:33:29 +03:00
|
|
|
}
|
|
|
|
static const nsGlobalWindowInner* Cast(const nsPIDOMWindowInner* aPIWin) {
|
2017-11-15 19:34:04 +03:00
|
|
|
return static_cast<const nsGlobalWindowInner*>(aPIWin);
|
2017-11-15 19:33:29 +03:00
|
|
|
}
|
|
|
|
static nsGlobalWindowInner* Cast(mozIDOMWindow* aWin) {
|
|
|
|
return Cast(nsPIDOMWindowInner::From(aWin));
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsGlobalWindowInner* GetInnerWindowWithId(uint64_t aInnerWindowID) {
|
|
|
|
AssertIsOnMainThread();
|
|
|
|
|
|
|
|
if (!sInnerWindowsById) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsGlobalWindowInner* innerWindow = sInnerWindowsById->Get(aInnerWindowID);
|
|
|
|
return innerWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
static InnerWindowByIdTable* GetWindowsTable() {
|
|
|
|
AssertIsOnMainThread();
|
|
|
|
|
|
|
|
return sInnerWindowsById;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsGlobalWindowInner* FromSupports(nsISupports* supports) {
|
|
|
|
// Make sure this matches the casts we do in QueryInterface().
|
|
|
|
return (nsGlobalWindowInner*)(mozilla::dom::EventTarget*)supports;
|
|
|
|
}
|
|
|
|
|
|
|
|
static already_AddRefed<nsGlobalWindowInner> Create(
|
2019-08-08 19:07:12 +03:00
|
|
|
nsGlobalWindowOuter* aOuter, bool aIsChrome,
|
|
|
|
mozilla::dom::WindowGlobalChild* aActor);
|
2017-11-15 19:33:29 +03:00
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
// nsISupports
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
|
|
|
|
// nsWrapperCache
|
|
|
|
virtual JSObject* WrapObject(JSContext* cx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override {
|
2018-03-02 20:27:48 +03:00
|
|
|
return GetWrapper();
|
2017-11-15 19:30:13 +03:00
|
|
|
}
|
|
|
|
|
2019-05-03 00:23:35 +03:00
|
|
|
// nsIGlobalObject
|
2019-05-08 16:12:59 +03:00
|
|
|
JSObject* GetGlobalJSObject() final { return GetWrapper(); }
|
2019-05-03 13:08:07 +03:00
|
|
|
JSObject* GetGlobalJSObjectPreserveColor() const final {
|
|
|
|
return GetWrapperPreserveColor();
|
|
|
|
}
|
|
|
|
// The HasJSGlobal on nsIGlobalObject ends up having to do a virtual
|
|
|
|
// call to GetGlobalJSObjectPreserveColor(), because when it's
|
|
|
|
// making the call it doesn't know it's doing it on an
|
|
|
|
// nsGlobalWindowInner. Add a version here that can be entirely
|
|
|
|
// non-virtual.
|
|
|
|
bool HasJSGlobal() const { return GetGlobalJSObjectPreserveColor(); }
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
void TraceGlobalJSObject(JSTracer* aTrc);
|
|
|
|
|
|
|
|
virtual nsresult EnsureScriptEnvironment() override;
|
|
|
|
|
|
|
|
virtual nsIScriptContext* GetScriptContext() override;
|
|
|
|
|
|
|
|
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-03 09:09:52 +03:00
|
|
|
virtual nsIPrincipal* PartitionedPrincipal() 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
|
|
|
|
|
|
|
|
void CaptureEvents();
|
|
|
|
void ReleaseEvents();
|
|
|
|
void Dump(const nsAString& aStr);
|
|
|
|
void SetResizable(bool aResizable) const;
|
|
|
|
|
|
|
|
virtual mozilla::EventListenerManager* GetExistingListenerManager()
|
|
|
|
const override;
|
|
|
|
|
|
|
|
virtual mozilla::EventListenerManager* GetOrCreateListenerManager() override;
|
|
|
|
|
2019-06-17 07:36:29 +03:00
|
|
|
mozilla::Maybe<mozilla::dom::EventCallbackDebuggerNotificationType>
|
2020-12-10 14:09:32 +03:00
|
|
|
GetDebuggerNotificationType() const override;
|
2019-06-17 07:36:29 +03:00
|
|
|
|
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* GetTargetForDOMEvent() override;
|
2018-05-03 06:20:00 +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;
|
|
|
|
|
2021-03-02 15:13:20 +03:00
|
|
|
void Suspend(bool aIncludeSubWindows = true);
|
|
|
|
void Resume(bool aIncludeSubWindows = true);
|
2017-11-15 19:30:13 +03:00
|
|
|
virtual bool IsSuspended() const override;
|
2018-08-01 00:27:02 +03:00
|
|
|
|
|
|
|
// Calling Freeze() on a window will automatically Suspend() it. In
|
2021-03-02 15:13:20 +03:00
|
|
|
// addition, the window and its children (if aIncludeSubWindows is true) are
|
|
|
|
// further treated as no longer suitable for interaction with the user. For
|
|
|
|
// example, it may be marked non-visible, cannot be focused, etc. All worker
|
|
|
|
// threads are also frozen bringing them to a complete stop. A window can
|
|
|
|
// have Freeze() called multiple times and will only thaw after a matching
|
|
|
|
// number of Thaw() calls.
|
|
|
|
void Freeze(bool aIncludeSubWindows = true);
|
|
|
|
void Thaw(bool aIncludeSubWindows = true);
|
2017-11-15 19:30:13 +03:00
|
|
|
virtual bool IsFrozen() const override;
|
|
|
|
void SyncStateFromParentWindow();
|
|
|
|
|
2019-06-17 07:36:29 +03:00
|
|
|
mozilla::dom::DebuggerNotificationManager*
|
|
|
|
GetOrCreateDebuggerNotificationManager() override;
|
|
|
|
|
|
|
|
mozilla::dom::DebuggerNotificationManager*
|
|
|
|
GetExistingDebuggerNotificationManager() override;
|
|
|
|
|
2018-01-12 04:46:08 +03:00
|
|
|
mozilla::Maybe<mozilla::dom::ClientInfo> GetClientInfo() const override;
|
2017-12-08 22:46:42 +03:00
|
|
|
mozilla::Maybe<mozilla::dom::ClientState> GetClientState() const;
|
2018-01-12 04:46:08 +03:00
|
|
|
mozilla::Maybe<mozilla::dom::ServiceWorkerDescriptor> GetController()
|
|
|
|
const override;
|
2017-11-21 23:13:05 +03:00
|
|
|
|
2019-05-22 02:14:27 +03:00
|
|
|
void SetCsp(nsIContentSecurityPolicy* aCsp);
|
|
|
|
void SetPreloadCsp(nsIContentSecurityPolicy* aPreloadCsp);
|
|
|
|
nsIContentSecurityPolicy* GetCsp();
|
|
|
|
|
2018-01-31 20:10:26 +03:00
|
|
|
virtual RefPtr<mozilla::dom::ServiceWorker> GetOrCreateServiceWorker(
|
|
|
|
const mozilla::dom::ServiceWorkerDescriptor& aDescriptor) override;
|
|
|
|
|
2018-07-02 17:44:18 +03:00
|
|
|
RefPtr<mozilla::dom::ServiceWorkerRegistration> GetServiceWorkerRegistration(
|
|
|
|
const mozilla::dom::ServiceWorkerRegistrationDescriptor& aDescriptor)
|
|
|
|
const override;
|
|
|
|
|
2018-03-03 00:02:49 +03:00
|
|
|
RefPtr<mozilla::dom::ServiceWorkerRegistration>
|
|
|
|
GetOrCreateServiceWorkerRegistration(
|
|
|
|
const mozilla::dom::ServiceWorkerRegistrationDescriptor& aDescriptor)
|
|
|
|
override;
|
|
|
|
|
2017-12-19 18:04:48 +03:00
|
|
|
void NoteCalledRegisterForServiceWorkerScope(const nsACString& aScope);
|
|
|
|
|
2018-06-23 20:11:47 +03:00
|
|
|
void NoteDOMContentLoaded();
|
|
|
|
|
2021-03-22 00:46:25 +03:00
|
|
|
virtual nsresult FireDelayedDOMEvents(bool aIncludeSubWindows) override;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
virtual void MaybeUpdateTouchState() override;
|
|
|
|
|
|
|
|
// Inner windows only.
|
2018-05-31 12:28:50 +03:00
|
|
|
void RefreshRealmPrincipal();
|
2017-11-15 19:30:13 +03:00
|
|
|
|
2018-09-12 18:51:30 +03:00
|
|
|
// For accessing protected field mFullscreen
|
2017-11-15 19:30:13 +03:00
|
|
|
friend class FullscreenTransitionTask;
|
|
|
|
|
|
|
|
// Inner windows only.
|
|
|
|
virtual void SetHasGamepadEventListener(bool aHasGamepad = true) override;
|
2020-01-04 01:47:26 +03:00
|
|
|
void NotifyHasXRSession();
|
2017-11-15 19:30:13 +03:00
|
|
|
bool HasUsedVR() const;
|
|
|
|
bool IsVRContentDetected() const;
|
|
|
|
bool IsVRContentPresenting() const;
|
2019-12-12 06:10:51 +03:00
|
|
|
void RequestXRPermission();
|
|
|
|
void OnXRPermissionRequestAllow();
|
|
|
|
void OnXRPermissionRequestCancel();
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
using EventTarget::EventListenerAdded;
|
|
|
|
virtual void EventListenerAdded(nsAtom* aType) override;
|
|
|
|
using EventTarget::EventListenerRemoved;
|
|
|
|
virtual void EventListenerRemoved(nsAtom* aType) override;
|
|
|
|
|
|
|
|
// nsIInterfaceRequestor
|
|
|
|
NS_DECL_NSIINTERFACEREQUESTOR
|
|
|
|
|
|
|
|
// WebIDL interface.
|
2019-06-20 23:52:55 +03:00
|
|
|
mozilla::dom::Nullable<mozilla::dom::WindowProxyHolder> IndexedGetter(
|
|
|
|
uint32_t aIndex);
|
2017-11-15 19:30:13 +03:00
|
|
|
|
2020-04-22 16:08:25 +03:00
|
|
|
static bool IsPrivilegedChromeWindow(JSContext*, JSObject* aObj);
|
2017-11-15 19:30:13 +03:00
|
|
|
|
2020-04-22 16:08:25 +03:00
|
|
|
static bool IsRequestIdleCallbackEnabled(JSContext* aCx, JSObject*);
|
2017-11-15 19:30:13 +03:00
|
|
|
|
2020-04-22 16:08:25 +03:00
|
|
|
static bool DeviceSensorsEnabled(JSContext*, JSObject*);
|
|
|
|
|
|
|
|
static bool ContentPropertyEnabled(JSContext* aCx, JSObject*);
|
2017-07-24 11:07:00 +03:00
|
|
|
|
2021-05-07 15:29:05 +03:00
|
|
|
bool DoResolve(
|
|
|
|
JSContext* aCx, JS::Handle<JSObject*> aObj, JS::Handle<jsid> aId,
|
|
|
|
JS::MutableHandle<mozilla::Maybe<JS::PropertyDescriptor>> aDesc);
|
2017-11-15 19:30:13 +03:00
|
|
|
// The return value is whether DoResolve might end up resolving the given id.
|
|
|
|
// If in doubt, return true.
|
|
|
|
static bool MayResolve(jsid aId);
|
|
|
|
|
2019-03-13 15:33:15 +03:00
|
|
|
void GetOwnPropertyNames(JSContext* aCx, JS::MutableHandleVector<jsid> aNames,
|
2017-11-15 19:30:13 +03:00
|
|
|
bool aEnumerableOnly, mozilla::ErrorResult& aRv);
|
|
|
|
|
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
|
|
|
|
2019-05-01 02:56:17 +03:00
|
|
|
inline nsIBrowserChild* GetBrowserChild() { return mBrowserChild.get(); }
|
|
|
|
|
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.
|
|
|
|
//
|
2017-11-15 19:34:13 +03:00
|
|
|
// nsGlobalWindowOuter::ShouldPromptToBlockDialogs is implemented in terms of
|
|
|
|
// nsGlobalWindowInner::DialogsAreBeingAbused, and will get the scriptable top
|
2017-11-15 19:30:13 +03:00
|
|
|
// inner window automatically. Inner windows only.
|
|
|
|
bool DialogsAreBeingAbused();
|
|
|
|
|
|
|
|
nsIScriptContext* GetContextInternal();
|
|
|
|
|
2017-11-15 19:34:47 +03:00
|
|
|
nsGlobalWindowOuter* GetOuterWindowInternal() const;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
nsresult Observe(nsISupports* aSubject, const char* aTopic,
|
|
|
|
const char16_t* aData);
|
|
|
|
|
|
|
|
void ObserveStorageNotification(mozilla::dom::StorageEvent* aEvent,
|
|
|
|
const char16_t* aStorageType,
|
|
|
|
bool aPrivateBrowsing);
|
|
|
|
|
|
|
|
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
|
|
|
nsGlobalWindowInner, mozilla::dom::EventTarget)
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
// Call Unlink on this window. This may cause bad things to happen, so use
|
|
|
|
// with caution.
|
|
|
|
void RiskyUnlink();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
virtual bool TakeFocus(bool aFocus, uint32_t aFocusMethod) override;
|
|
|
|
virtual void SetReadyForFocus() override;
|
|
|
|
virtual void PageHidden() override;
|
|
|
|
virtual nsresult DispatchAsyncHashchange(nsIURI* aOldURI,
|
|
|
|
nsIURI* aNewURI) override;
|
|
|
|
virtual nsresult DispatchSyncPopState() override;
|
|
|
|
|
|
|
|
// Inner windows only.
|
|
|
|
virtual void EnableDeviceSensor(uint32_t aType) override;
|
|
|
|
virtual void DisableDeviceSensor(uint32_t aType) override;
|
|
|
|
|
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
|
|
|
virtual void EnableOrientationChangeListener() override;
|
|
|
|
virtual void DisableOrientationChangeListener() override;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void AddSizeOfIncludingThis(nsWindowSizes& aWindowSizes) const;
|
|
|
|
|
2021-05-27 20:55:45 +03:00
|
|
|
void CollectDOMSizesForDataDocuments(nsWindowSizes&) const;
|
|
|
|
void RegisterDataDocumentForMemoryReporting(Document*);
|
|
|
|
void UnregisterDataDocumentForMemoryReporting(Document*);
|
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
enum SlowScriptResponse {
|
|
|
|
ContinueSlowScript = 0,
|
|
|
|
ContinueSlowScriptAndKeepNotifying,
|
|
|
|
AlwaysContinueSlowScript,
|
|
|
|
KillSlowScript,
|
|
|
|
KillScriptGlobal
|
|
|
|
};
|
2019-04-04 23:00:36 +03:00
|
|
|
SlowScriptResponse ShowSlowScriptDialog(JSContext* aCx,
|
2020-07-24 03:01:57 +03:00
|
|
|
const nsString& aAddonId,
|
|
|
|
const double aDuration);
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
// Inner windows only.
|
2020-12-03 02:06:05 +03:00
|
|
|
void AddGamepad(mozilla::dom::GamepadHandle aHandle,
|
|
|
|
mozilla::dom::Gamepad* aGamepad);
|
|
|
|
void RemoveGamepad(mozilla::dom::GamepadHandle aHandle);
|
2017-11-15 19:30:13 +03:00
|
|
|
void GetGamepads(nsTArray<RefPtr<mozilla::dom::Gamepad>>& aGamepads);
|
2020-12-03 02:06:05 +03:00
|
|
|
already_AddRefed<mozilla::dom::Gamepad> GetGamepad(
|
|
|
|
mozilla::dom::GamepadHandle aHandle);
|
2017-11-15 19:30:13 +03:00
|
|
|
void SetHasSeenGamepadInput(bool aHasSeen);
|
|
|
|
bool HasSeenGamepadInput();
|
|
|
|
void SyncGamepadState();
|
|
|
|
void StopGamepadHaptics();
|
|
|
|
|
|
|
|
// Inner windows only.
|
|
|
|
// Enable/disable updates for gamepad input.
|
|
|
|
void EnableGamepadUpdates();
|
|
|
|
void DisableGamepadUpdates();
|
|
|
|
|
|
|
|
// Inner windows only.
|
|
|
|
// Enable/disable updates for VR
|
|
|
|
void EnableVRUpdates();
|
|
|
|
void DisableVRUpdates();
|
|
|
|
// Reset telemetry data when switching windows.
|
|
|
|
// aUpdate, true for accumulating the result to the histogram.
|
|
|
|
// false for only resetting the timestamp.
|
|
|
|
void ResetVRTelemetry(bool aUpdate);
|
|
|
|
|
2018-10-29 01:49:15 +03:00
|
|
|
void StartVRActivity();
|
|
|
|
void StopVRActivity();
|
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
// Update the VR displays for this window
|
|
|
|
bool UpdateVRDisplays(nsTArray<RefPtr<mozilla::dom::VRDisplay>>& aDisplays);
|
|
|
|
|
|
|
|
// Inner windows only.
|
|
|
|
// Called to inform that the set of active VR displays has changed.
|
|
|
|
void NotifyActiveVRDisplaysChanged();
|
2020-01-04 01:47:26 +03:00
|
|
|
void NotifyDetectXRRuntimesCompleted();
|
2018-08-08 02:09:42 +03:00
|
|
|
void NotifyPresentationGenerationChanged(uint32_t aDisplayID);
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
void DispatchVRDisplayActivate(uint32_t aDisplayID,
|
|
|
|
mozilla::dom::VRDisplayEventReason aReason);
|
|
|
|
void DispatchVRDisplayDeactivate(uint32_t aDisplayID,
|
|
|
|
mozilla::dom::VRDisplayEventReason aReason);
|
|
|
|
void DispatchVRDisplayConnect(uint32_t aDisplayID);
|
|
|
|
void DispatchVRDisplayDisconnect(uint32_t aDisplayID);
|
|
|
|
void DispatchVRDisplayPresentChange(uint32_t aDisplayID);
|
|
|
|
|
|
|
|
#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; }
|
|
|
|
|
|
|
|
static JSObject* CreateNamedPropertiesObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aProto);
|
|
|
|
|
2019-10-11 22:32:09 +03:00
|
|
|
mozilla::dom::WindowProxyHolder Window();
|
|
|
|
mozilla::dom::WindowProxyHolder Self() { return Window(); }
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* GetDocument() { return GetDoc(); }
|
2017-11-15 19:30:13 +03:00
|
|
|
void GetName(nsAString& aName, mozilla::ErrorResult& aError);
|
|
|
|
void SetName(const nsAString& aName, mozilla::ErrorResult& aError);
|
2019-01-02 16:29:18 +03:00
|
|
|
mozilla::dom::Location* Location() override;
|
2017-11-15 19:30:13 +03:00
|
|
|
nsHistory* GetHistory(mozilla::ErrorResult& aError);
|
|
|
|
mozilla::dom::CustomElementRegistry* CustomElements() override;
|
2020-04-06 21:21:59 +03:00
|
|
|
mozilla::dom::CustomElementRegistry* GetExistingCustomElements();
|
2017-11-15 19:30:13 +03:00
|
|
|
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);
|
2019-01-02 16:29:18 +03:00
|
|
|
void Close(mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
2017-11-15 19:30:13 +03:00
|
|
|
nsresult Close() override;
|
|
|
|
bool GetClosed(mozilla::ErrorResult& aError);
|
|
|
|
void Stop(mozilla::ErrorResult& aError);
|
2020-01-16 17:38:40 +03:00
|
|
|
void Focus(mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
nsresult Focus(mozilla::dom::CallerType aCallerType) override;
|
2021-02-09 17:56:56 +03:00
|
|
|
void Blur(mozilla::dom::CallerType aCallerType, mozilla::ErrorResult& aError);
|
2019-10-11 22:32:09 +03:00
|
|
|
mozilla::dom::WindowProxyHolder GetFrames(mozilla::ErrorResult& aError);
|
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> GetTop(
|
|
|
|
mozilla::ErrorResult& aError);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
protected:
|
2019-08-08 19:07:12 +03:00
|
|
|
explicit nsGlobalWindowInner(nsGlobalWindowOuter* aOuterWindow,
|
|
|
|
mozilla::dom::WindowGlobalChild* aActor);
|
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
|
|
|
mozilla::dom::Nullable<mozilla::dom::WindowProxyHolder> GetOpenerWindow(
|
|
|
|
mozilla::ErrorResult& aError);
|
2017-11-15 19:30:13 +03:00
|
|
|
void GetOpener(JSContext* aCx, JS::MutableHandle<JS::Value> aRetval,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void SetOpener(JSContext* aCx, JS::Handle<JS::Value> aOpener,
|
|
|
|
mozilla::ErrorResult& aError);
|
2018-04-04 15:57:17 +03:00
|
|
|
void GetEvent(JSContext* aCx, JS::MutableHandle<JS::Value> aRetval);
|
2019-01-02 16:26:56 +03:00
|
|
|
mozilla::dom::Nullable<mozilla::dom::WindowProxyHolder> GetParent(
|
|
|
|
mozilla::ErrorResult& aError);
|
2019-07-26 19:48:31 +03:00
|
|
|
nsPIDOMWindowOuter* GetInProcessScriptableParent() override;
|
2017-11-15 19:30:13 +03:00
|
|
|
mozilla::dom::Element* GetFrameElement(nsIPrincipal& aSubjectPrincipal,
|
|
|
|
mozilla::ErrorResult& aError);
|
2019-01-02 16:26:56 +03:00
|
|
|
mozilla::dom::Nullable<mozilla::dom::WindowProxyHolder> Open(
|
|
|
|
const nsAString& aUrl, const nsAString& aName, const nsAString& aOptions,
|
|
|
|
mozilla::ErrorResult& aError);
|
2018-07-14 01:42:07 +03:00
|
|
|
nsDOMOfflineResourceList* GetApplicationCache(mozilla::ErrorResult& aError);
|
|
|
|
nsDOMOfflineResourceList* GetApplicationCache() override;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
|
|
|
int16_t Orientation(mozilla::dom::CallerType aCallerType) const;
|
|
|
|
#endif
|
|
|
|
|
2018-02-22 10:49:51 +03:00
|
|
|
already_AddRefed<mozilla::dom::Console> GetConsole(JSContext* aCx,
|
|
|
|
mozilla::ErrorResult& aRv);
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
// https://w3c.github.io/webappsec-secure-contexts/#dom-window-issecurecontext
|
|
|
|
bool IsSecureContext() const;
|
|
|
|
|
|
|
|
void GetSidebar(mozilla::dom::OwningExternalOrWindowProxy& aResult,
|
|
|
|
mozilla::ErrorResult& aRv);
|
2019-08-01 00:38:00 +03:00
|
|
|
mozilla::dom::External* GetExternal(mozilla::ErrorResult& aRv);
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
mozilla::dom::Worklet* GetPaintWorklet(mozilla::ErrorResult& aRv);
|
|
|
|
|
|
|
|
void GetRegionalPrefsLocales(nsTArray<nsString>& aLocales);
|
|
|
|
|
2019-03-29 13:49:58 +03:00
|
|
|
void GetWebExposedLocales(nsTArray<nsString>& aLocales);
|
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
mozilla::dom::IntlUtils* GetIntlUtils(mozilla::ErrorResult& aRv);
|
|
|
|
|
2018-11-20 02:18:21 +03:00
|
|
|
void StoreSharedWorker(mozilla::dom::SharedWorker* aSharedWorker);
|
|
|
|
|
|
|
|
void ForgetSharedWorker(mozilla::dom::SharedWorker* aSharedWorker);
|
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
public:
|
|
|
|
void Alert(nsIPrincipal& aSubjectPrincipal, mozilla::ErrorResult& aError);
|
|
|
|
void Alert(const nsAString& aMessage, nsIPrincipal& aSubjectPrincipal,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
bool Confirm(const nsAString& aMessage, nsIPrincipal& aSubjectPrincipal,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void Prompt(const nsAString& aMessage, const nsAString& aInitial,
|
|
|
|
nsAString& aReturn, nsIPrincipal& aSubjectPrincipal,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
already_AddRefed<mozilla::dom::cache::CacheStorage> GetCaches(
|
|
|
|
mozilla::ErrorResult& aRv);
|
|
|
|
already_AddRefed<mozilla::dom::Promise> Fetch(
|
|
|
|
const mozilla::dom::RequestOrUSVString& aInput,
|
|
|
|
const mozilla::dom::RequestInit& aInit,
|
|
|
|
mozilla::dom::CallerType aCallerType, mozilla::ErrorResult& aRv);
|
|
|
|
void Print(mozilla::ErrorResult& aError);
|
Bug 1636728 - Centralize printing entry points in nsGlobalWindowOuter, and move cloning out of nsPrintJob. r=jwatt,geckoview-reviewers,smaug,agi
This centralizes our print and preview setup in nsGlobalWindowOuter so
that we never re-clone a clone, and so that we reuse the window.open()
codepath to create the browsing context to clone into.
For window.print, for both old print dialog / silent printing and new
print preview UI, we now create a hidden browser (as in with visibility:
collapse, which takes no space but still gets a layout box).
* In the modern UI case, this browser is swapped with the actual print
preview clone, and the UI takes care of removing the browser.
* In the print dialog / silent printing case, the printing code calls
window.close() from nsDocumentViewer::OnDonePrinting().
* We don't need to care about the old print preview UI for this case
because it can't be open from window.print().
We need to fall back to an actual window when there's no
nsIBrowserDOMWindow around for WPT print tests and the like, which don't
have one. That seems fine, we could special-case this code path more if
needed but it doesn't seem worth it.
Differential Revision: https://phabricator.services.mozilla.com/D87063
2020-08-25 20:45:12 +03:00
|
|
|
mozilla::dom::Nullable<mozilla::dom::WindowProxyHolder> PrintPreview(
|
|
|
|
nsIPrintSettings*, nsIWebProgressListener*, nsIDocShell*,
|
|
|
|
mozilla::ErrorResult&);
|
2017-11-15 19:30:13 +03:00
|
|
|
void PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
|
|
|
|
const nsAString& aTargetOrigin,
|
|
|
|
const mozilla::dom::Sequence<JSObject*>& aTransfer,
|
|
|
|
nsIPrincipal& aSubjectPrincipal,
|
|
|
|
mozilla::ErrorResult& aError);
|
2018-10-29 18:26:30 +03:00
|
|
|
void PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
|
|
|
|
const mozilla::dom::WindowPostMessageOptions& aOptions,
|
|
|
|
nsIPrincipal& aSubjectPrincipal,
|
|
|
|
mozilla::ErrorResult& aError);
|
2019-06-17 07:36:29 +03:00
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2017-11-15 19:30:13 +03:00
|
|
|
int32_t SetTimeout(JSContext* aCx, mozilla::dom::Function& aFunction,
|
|
|
|
int32_t aTimeout,
|
|
|
|
const mozilla::dom::Sequence<JS::Value>& aArguments,
|
|
|
|
mozilla::ErrorResult& aError);
|
2019-06-17 07:36:29 +03:00
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2017-11-15 19:30:13 +03:00
|
|
|
int32_t SetTimeout(JSContext* aCx, const nsAString& aHandler,
|
|
|
|
int32_t aTimeout,
|
|
|
|
const mozilla::dom::Sequence<JS::Value>& /* unused */,
|
|
|
|
mozilla::ErrorResult& aError);
|
2019-06-17 07:36:29 +03:00
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2017-11-15 19:30:13 +03:00
|
|
|
void ClearTimeout(int32_t aHandle);
|
2019-06-17 07:36:29 +03:00
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2017-11-15 19:30:13 +03:00
|
|
|
int32_t SetInterval(JSContext* aCx, mozilla::dom::Function& aFunction,
|
2018-05-03 06:20:00 +03:00
|
|
|
const int32_t aTimeout,
|
2017-11-15 19:30:13 +03:00
|
|
|
const mozilla::dom::Sequence<JS::Value>& aArguments,
|
|
|
|
mozilla::ErrorResult& aError);
|
2019-06-17 07:36:29 +03:00
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2017-11-15 19:30:13 +03:00
|
|
|
int32_t SetInterval(JSContext* aCx, const nsAString& aHandler,
|
2018-05-03 06:20:00 +03:00
|
|
|
const int32_t aTimeout,
|
2017-11-15 19:30:13 +03:00
|
|
|
const mozilla::dom::Sequence<JS::Value>& /* unused */,
|
|
|
|
mozilla::ErrorResult& aError);
|
2019-06-17 07:36:29 +03:00
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2017-11-15 19:30:13 +03:00
|
|
|
void ClearInterval(int32_t aHandle);
|
|
|
|
void GetOrigin(nsAString& aOrigin);
|
|
|
|
void Atob(const nsAString& aAsciiBase64String, nsAString& aBinaryData,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void Btoa(const nsAString& aBinaryData, nsAString& aAsciiBase64String,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
mozilla::dom::Storage* GetSessionStorage(mozilla::ErrorResult& aError);
|
|
|
|
mozilla::dom::Storage* GetLocalStorage(mozilla::ErrorResult& aError);
|
|
|
|
mozilla::dom::Selection* GetSelection(mozilla::ErrorResult& aError);
|
|
|
|
mozilla::dom::IDBFactory* GetIndexedDB(mozilla::ErrorResult& aError);
|
|
|
|
already_AddRefed<nsICSSDeclaration> GetComputedStyle(
|
|
|
|
mozilla::dom::Element& aElt, const nsAString& aPseudoElt,
|
|
|
|
mozilla::ErrorResult& aError) override;
|
2018-08-20 23:28:42 +03:00
|
|
|
mozilla::dom::VisualViewport* VisualViewport();
|
2017-11-15 19:30:13 +03:00
|
|
|
already_AddRefed<mozilla::dom::MediaQueryList> MatchMedia(
|
2020-12-17 17:04:35 +03:00
|
|
|
const nsACString& aQuery, mozilla::dom::CallerType aCallerType,
|
2017-11-15 19:30:13 +03:00
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
nsScreen* GetScreen(mozilla::ErrorResult& aError);
|
|
|
|
void MoveTo(int32_t aXPos, int32_t aYPos,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void MoveBy(int32_t aXDif, int32_t aYDif,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void ResizeTo(int32_t aWidth, int32_t aHeight,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void ResizeBy(int32_t aWidthDif, int32_t aHeightDif,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void Scroll(double aXScroll, double aYScroll);
|
|
|
|
void Scroll(const mozilla::dom::ScrollToOptions& aOptions);
|
|
|
|
void ScrollTo(double aXScroll, double aYScroll);
|
|
|
|
void ScrollTo(const mozilla::dom::ScrollToOptions& aOptions);
|
|
|
|
void ScrollBy(double aXScrollDif, double aYScrollDif);
|
|
|
|
void ScrollBy(const mozilla::dom::ScrollToOptions& aOptions);
|
|
|
|
void ScrollByLines(int32_t numLines,
|
|
|
|
const mozilla::dom::ScrollOptions& aOptions);
|
|
|
|
void ScrollByPages(int32_t numPages,
|
|
|
|
const mozilla::dom::ScrollOptions& aOptions);
|
|
|
|
void MozScrollSnap();
|
|
|
|
void GetInnerWidth(JSContext* aCx, JS::MutableHandle<JS::Value> aValue,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void SetInnerWidth(JSContext* aCx, JS::Handle<JS::Value> aValue,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void GetInnerHeight(JSContext* aCx, JS::MutableHandle<JS::Value> aValue,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void SetInnerHeight(JSContext* aCx, JS::Handle<JS::Value> aValue,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
double GetScrollX(mozilla::ErrorResult& aError);
|
|
|
|
double GetPageXOffset(mozilla::ErrorResult& aError) {
|
|
|
|
return GetScrollX(aError);
|
|
|
|
}
|
|
|
|
double GetScrollY(mozilla::ErrorResult& aError);
|
|
|
|
double GetPageYOffset(mozilla::ErrorResult& aError) {
|
|
|
|
return GetScrollY(aError);
|
|
|
|
}
|
2018-10-17 05:20:15 +03:00
|
|
|
|
|
|
|
int32_t GetScreenLeft(mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError) {
|
|
|
|
return GetScreenX(aCallerType, aError);
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t GetScreenTop(mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError) {
|
|
|
|
return GetScreenY(aCallerType, aError);
|
|
|
|
}
|
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
void GetScreenX(JSContext* aCx, JS::MutableHandle<JS::Value> aValue,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void SetScreenX(JSContext* aCx, JS::Handle<JS::Value> aValue,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void GetScreenY(JSContext* aCx, JS::MutableHandle<JS::Value> aValue,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void SetScreenY(JSContext* aCx, JS::Handle<JS::Value> aValue,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void GetOuterWidth(JSContext* aCx, JS::MutableHandle<JS::Value> aValue,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void SetOuterWidth(JSContext* aCx, JS::Handle<JS::Value> aValue,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void GetOuterHeight(JSContext* aCx, JS::MutableHandle<JS::Value> aValue,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void SetOuterHeight(JSContext* aCx, JS::Handle<JS::Value> aValue,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
2019-06-17 07:36:29 +03:00
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2017-11-15 19:30:13 +03:00
|
|
|
int32_t RequestAnimationFrame(mozilla::dom::FrameRequestCallback& aCallback,
|
|
|
|
mozilla::ErrorResult& aError);
|
2019-06-17 07:36:29 +03:00
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2017-11-15 19:30:13 +03:00
|
|
|
void CancelAnimationFrame(int32_t aHandle, mozilla::ErrorResult& aError);
|
|
|
|
|
|
|
|
uint32_t RequestIdleCallback(JSContext* aCx,
|
|
|
|
mozilla::dom::IdleRequestCallback& aCallback,
|
|
|
|
const mozilla::dom::IdleRequestOptions& aOptions,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void CancelIdleCallback(uint32_t aHandle);
|
|
|
|
|
|
|
|
#ifdef MOZ_WEBSPEECH
|
|
|
|
mozilla::dom::SpeechSynthesis* GetSpeechSynthesis(
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
bool HasActiveSpeechSynthesis();
|
|
|
|
#endif
|
2020-10-21 14:36:46 +03:00
|
|
|
|
|
|
|
mozilla::glean::Glean* Glean();
|
2020-12-14 19:50:07 +03:00
|
|
|
mozilla::glean::GleanPings* GleanPings();
|
2021-03-04 14:15:12 +03:00
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
already_AddRefed<nsICSSDeclaration> GetDefaultComputedStyle(
|
|
|
|
mozilla::dom::Element& aElt, const nsAString& aPseudoElt,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void SizeToContent(mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
mozilla::dom::Crypto* GetCrypto(mozilla::ErrorResult& aError);
|
|
|
|
mozilla::dom::U2F* GetU2f(mozilla::ErrorResult& aError);
|
|
|
|
nsIControllers* GetControllers(mozilla::ErrorResult& aError);
|
|
|
|
nsresult GetControllers(nsIControllers** aControllers) override;
|
|
|
|
mozilla::dom::Element* GetRealFrameElement(mozilla::ErrorResult& aError);
|
|
|
|
float GetMozInnerScreenX(mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
float GetMozInnerScreenY(mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
double GetDevicePixelRatio(mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
int32_t GetScrollMinX(mozilla::ErrorResult& aError);
|
|
|
|
int32_t GetScrollMinY(mozilla::ErrorResult& aError);
|
|
|
|
int32_t GetScrollMaxX(mozilla::ErrorResult& aError);
|
|
|
|
int32_t GetScrollMaxY(mozilla::ErrorResult& aError);
|
|
|
|
bool GetFullScreen(mozilla::ErrorResult& aError);
|
|
|
|
bool GetFullScreen() override;
|
2018-09-12 18:51:30 +03:00
|
|
|
void SetFullScreen(bool aFullscreen, mozilla::ErrorResult& aError);
|
2017-11-15 19:30:13 +03:00
|
|
|
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);
|
|
|
|
|
|
|
|
bool ShouldResistFingerprinting();
|
|
|
|
|
2019-02-23 00:27:44 +03:00
|
|
|
bool DidFireDocElemInserted() const { return mDidFireDocElemInserted; }
|
|
|
|
void SetDidFireDocElemInserted() { mDidFireDocElemInserted = true; }
|
|
|
|
|
2019-01-02 16:26:56 +03:00
|
|
|
mozilla::dom::Nullable<mozilla::dom::WindowProxyHolder> OpenDialog(
|
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);
|
2018-05-08 20:52:42 +03:00
|
|
|
void UpdateCommands(const nsAString& anAction, mozilla::dom::Selection* aSel,
|
|
|
|
int16_t aReason);
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
void GetContent(JSContext* aCx, JS::MutableHandle<JSObject*> aRetval,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
|
|
|
|
already_AddRefed<mozilla::dom::Promise> CreateImageBitmap(
|
2020-07-15 16:37:32 +03:00
|
|
|
const mozilla::dom::ImageBitmapSource& aImage, mozilla::ErrorResult& aRv);
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
already_AddRefed<mozilla::dom::Promise> CreateImageBitmap(
|
2020-05-19 23:48:21 +03:00
|
|
|
const mozilla::dom::ImageBitmapSource& aImage, int32_t aSx, int32_t aSy,
|
2020-07-15 16:37:32 +03:00
|
|
|
int32_t aSw, int32_t aSh, mozilla::ErrorResult& aRv);
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
// ChromeWindow bits. Do NOT call these unless your window is in
|
|
|
|
// fact chrome.
|
|
|
|
uint16_t WindowState();
|
|
|
|
bool IsFullyOccluded();
|
|
|
|
nsIBrowserDOMWindow* GetBrowserDOMWindow(mozilla::ErrorResult& aError);
|
|
|
|
void SetBrowserDOMWindow(nsIBrowserDOMWindow* aBrowserWindow,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void GetAttention(mozilla::ErrorResult& aError);
|
|
|
|
void GetAttentionWithCycleCount(int32_t aCycleCount,
|
|
|
|
mozilla::ErrorResult& aError);
|
2020-01-26 23:17:41 +03:00
|
|
|
void SetCursor(const nsACString& aCursor, mozilla::ErrorResult& aError);
|
2017-11-15 19:30:13 +03:00
|
|
|
void Maximize();
|
|
|
|
void Minimize();
|
|
|
|
void Restore();
|
2020-04-07 14:01:47 +03:00
|
|
|
void GetWorkspaceID(nsAString& workspaceID);
|
|
|
|
void MoveToWorkspace(const nsAString& workspaceID);
|
2017-11-15 19:30:13 +03:00
|
|
|
void NotifyDefaultButtonLoaded(mozilla::dom::Element& aDefaultButton,
|
|
|
|
mozilla::ErrorResult& aError);
|
2018-02-14 19:35:39 +03:00
|
|
|
mozilla::dom::ChromeMessageBroadcaster* MessageManager();
|
|
|
|
mozilla::dom::ChromeMessageBroadcaster* GetGroupMessageManager(
|
|
|
|
const nsAString& aGroup);
|
2017-11-15 19:30:13 +03:00
|
|
|
|
2018-02-12 04:14:49 +03:00
|
|
|
already_AddRefed<mozilla::dom::Promise> PromiseDocumentFlushed(
|
|
|
|
mozilla::dom::PromiseDocumentFlushedCallback& aCallback,
|
|
|
|
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);
|
|
|
|
|
2018-07-18 07:30:38 +03:00
|
|
|
void GetInterface(JSContext* aCx, JS::Handle<JS::Value> aIID,
|
2017-11-15 19:30:13 +03:00
|
|
|
JS::MutableHandle<JS::Value> aRetval,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
|
|
|
|
already_AddRefed<nsWindowRoot> GetWindowRoot(mozilla::ErrorResult& aError);
|
|
|
|
|
2017-12-19 18:04:47 +03:00
|
|
|
bool ShouldReportForServiceWorkerScope(const nsAString& aScope);
|
|
|
|
|
2019-08-01 00:38:00 +03:00
|
|
|
mozilla::dom::InstallTriggerImpl* GetInstallTrigger();
|
2018-03-22 06:18:51 +03:00
|
|
|
|
2018-07-25 02:47:40 +03:00
|
|
|
nsIDOMWindowUtils* GetWindowUtils(mozilla::ErrorResult& aRv);
|
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
void UpdateTopInnerWindow();
|
|
|
|
|
2020-11-23 19:07:43 +03:00
|
|
|
virtual bool IsInSyncOperation() override;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
2021-05-17 19:17:38 +03:00
|
|
|
// Early during inner window creation, `IsSharedMemoryAllowedInternal`
|
|
|
|
// is called before the `mDoc` field has been initialized in order to
|
|
|
|
// determine whether to expose the `SharedArrayBuffer` constructor on the
|
|
|
|
// JS global. We still want to consider the document's principal to see if
|
|
|
|
// it is a privileged extension which should be exposed to
|
|
|
|
// `SharedArrayBuffer`, however the inner window doesn't know the document's
|
|
|
|
// principal yet. `aPrincipalOverride` is used in that situation to provide
|
|
|
|
// the principal for the to-be-loaded document.
|
|
|
|
bool IsSharedMemoryAllowed() const override {
|
|
|
|
return IsSharedMemoryAllowedInternal(
|
|
|
|
const_cast<nsGlobalWindowInner*>(this)->GetPrincipal());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsSharedMemoryAllowedInternal(nsIPrincipal* aPrincipal = nullptr) const;
|
2019-11-15 15:25:57 +03:00
|
|
|
|
2019-10-30 14:01:42 +03:00
|
|
|
// https://whatpr.org/html/4734/structured-data.html#cross-origin-isolated
|
2020-03-25 16:53:46 +03:00
|
|
|
bool CrossOriginIsolated() const override;
|
2019-09-23 12:57:24 +03:00
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
protected:
|
|
|
|
// Web IDL helpers
|
|
|
|
|
|
|
|
// Redefine the property called aPropName on this window object to be a value
|
|
|
|
// property with the value aValue, much like we would do for a [Replaceable]
|
|
|
|
// property in IDL.
|
|
|
|
void RedefineProperty(JSContext* aCx, const char* aPropName,
|
|
|
|
JS::Handle<JS::Value> aValue,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
|
|
|
|
// Implementation guts for our writable IDL attributes that are really
|
|
|
|
// supposed to be readonly replaceable.
|
2020-11-13 15:44:01 +03:00
|
|
|
template <typename T>
|
|
|
|
using WindowCoordGetter = T (nsGlobalWindowInner::*)(
|
2017-11-15 19:33:29 +03:00
|
|
|
mozilla::dom::CallerType aCallerType, mozilla::ErrorResult&);
|
2020-11-13 15:44:01 +03:00
|
|
|
template <typename T>
|
|
|
|
using WindowCoordSetter = void (nsGlobalWindowInner::*)(
|
|
|
|
T, mozilla::dom::CallerType aCallerType, mozilla::ErrorResult&);
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
void GetReplaceableWindowCoord(JSContext* aCx, WindowCoordGetter<T> aGetter,
|
2017-11-15 19:30:13 +03:00
|
|
|
JS::MutableHandle<JS::Value> aRetval,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
2020-11-13 15:44:01 +03:00
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
void SetReplaceableWindowCoord(JSContext* aCx, WindowCoordSetter<T> aSetter,
|
2017-11-15 19:30:13 +03:00
|
|
|
JS::Handle<JS::Value> aValue,
|
|
|
|
const char* aPropName,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
// And the implementations of WindowCoordGetter/WindowCoordSetter.
|
|
|
|
protected:
|
2020-11-13 15:44:01 +03:00
|
|
|
double GetInnerWidth(mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
nsresult GetInnerWidth(double* aWidth) override;
|
|
|
|
void SetInnerWidth(double aInnerWidth, mozilla::dom::CallerType aCallerType,
|
2017-11-15 19:30:13 +03:00
|
|
|
mozilla::ErrorResult& aError);
|
2020-11-13 15:44:01 +03:00
|
|
|
double GetInnerHeight(mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
nsresult GetInnerHeight(double* aHeight) override;
|
|
|
|
void SetInnerHeight(double aInnerHeight, mozilla::dom::CallerType aCallerType,
|
2017-11-15 19:30:13 +03:00
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
int32_t GetScreenX(mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void SetScreenX(int32_t aScreenX, mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
int32_t GetScreenY(mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void SetScreenY(int32_t aScreenY, mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
int32_t GetOuterWidth(mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void SetOuterWidth(int32_t aOuterWidth, mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
int32_t GetOuterHeight(mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void SetOuterHeight(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 ~nsGlobalWindowInner();
|
2017-11-15 19:30:13 +03:00
|
|
|
|
2019-02-27 08:36:38 +03:00
|
|
|
void FreeInnerObjects();
|
2017-11-15 19:30:13 +03:00
|
|
|
|
2020-01-06 17:53:00 +03:00
|
|
|
// Initialize state that depends on the document. By this point, mDoc should
|
|
|
|
// be set correctly and have us set as its script global object.
|
|
|
|
void InitDocumentDependentState(JSContext* aCx);
|
2017-11-15 19:30:13 +03:00
|
|
|
|
2017-11-21 23:13:05 +03:00
|
|
|
nsresult EnsureClientSource();
|
|
|
|
nsresult ExecutionReady();
|
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
// Inner windows only.
|
|
|
|
nsresult DefineArgumentsProperty(nsIArray* aArguments);
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
private:
|
2021-03-12 19:23:10 +03:00
|
|
|
template <typename Method, typename... Args>
|
|
|
|
mozilla::CallState CallOnInProcessDescendantsInternal(
|
|
|
|
mozilla::dom::BrowsingContext* aBrowsingContext, bool aChildOnly,
|
|
|
|
Method aMethod, Args&&... aArgs);
|
|
|
|
|
2017-12-19 18:04:48 +03:00
|
|
|
// Call the given method on the immediate children of this window. The
|
|
|
|
// CallState returned by the last child method invocation is returned or
|
|
|
|
// CallState::Continue if the method returns void.
|
|
|
|
template <typename Method, typename... Args>
|
2021-03-12 19:23:10 +03:00
|
|
|
mozilla::CallState CallOnInProcessChildren(Method aMethod, Args&&... aArgs) {
|
|
|
|
MOZ_ASSERT(IsCurrentInnerWindow());
|
|
|
|
return CallOnInProcessDescendantsInternal(GetBrowsingContext(), true,
|
|
|
|
aMethod, aArgs...);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Call the given method on the descendant of this window. The CallState
|
|
|
|
// returned by the last descendant method invocation is returned or
|
|
|
|
// CallState::Continue if the method returns void.
|
|
|
|
template <typename Method, typename... Args>
|
|
|
|
mozilla::CallState CallOnInProcessDescendants(Method aMethod,
|
|
|
|
Args&&... aArgs) {
|
|
|
|
MOZ_ASSERT(IsCurrentInnerWindow());
|
|
|
|
return CallOnInProcessDescendantsInternal(GetBrowsingContext(), false,
|
|
|
|
aMethod, aArgs...);
|
|
|
|
}
|
2017-12-19 18:04:48 +03:00
|
|
|
|
|
|
|
// Helper to convert a void returning child method into an implicit
|
|
|
|
// CallState::Continue value.
|
|
|
|
template <typename Return, typename Method, typename... Args>
|
2019-12-19 10:58:09 +03:00
|
|
|
typename std::enable_if<std::is_void<Return>::value, mozilla::CallState>::type
|
2021-03-12 19:23:10 +03:00
|
|
|
CallDescendant(nsGlobalWindowInner* aWindow, Method aMethod,
|
|
|
|
Args&&... aArgs) {
|
2017-12-19 18:04:48 +03:00
|
|
|
(aWindow->*aMethod)(aArgs...);
|
2019-12-19 10:58:09 +03:00
|
|
|
return mozilla::CallState::Continue;
|
2017-12-19 18:04:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Helper that passes through the CallState value from a child method.
|
|
|
|
template <typename Return, typename Method, typename... Args>
|
2019-12-19 10:58:09 +03:00
|
|
|
typename std::enable_if<std::is_same<Return, mozilla::CallState>::value,
|
|
|
|
mozilla::CallState>::type
|
2021-03-12 19:23:10 +03:00
|
|
|
CallDescendant(nsGlobalWindowInner* aWindow, Method aMethod,
|
|
|
|
Args&&... aArgs) {
|
2017-12-19 18:04:48 +03:00
|
|
|
return (aWindow->*aMethod)(aArgs...);
|
|
|
|
}
|
2017-11-15 19:30:13 +03:00
|
|
|
|
2021-03-02 15:13:20 +03:00
|
|
|
void FreezeInternal(bool aIncludeSubWindows);
|
|
|
|
void ThawInternal(bool aIncludeSubWindows);
|
2017-11-15 19:30:13 +03:00
|
|
|
|
2019-12-19 10:58:09 +03:00
|
|
|
mozilla::CallState ShouldReportForServiceWorkerScopeInternal(
|
|
|
|
const nsACString& aScope, bool* aResultOut);
|
2017-12-19 18:04:48 +03:00
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
public:
|
|
|
|
// Timeout Functions
|
|
|
|
// |interval| is in milliseconds.
|
2019-06-17 07:36:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2017-11-15 19:30:13 +03:00
|
|
|
int32_t SetTimeoutOrInterval(
|
|
|
|
JSContext* aCx, mozilla::dom::Function& aFunction, int32_t aTimeout,
|
|
|
|
const mozilla::dom::Sequence<JS::Value>& aArguments, bool aIsInterval,
|
|
|
|
mozilla::ErrorResult& aError);
|
2019-06-17 07:36:29 +03:00
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2017-11-15 19:30:13 +03:00
|
|
|
int32_t SetTimeoutOrInterval(JSContext* aCx, const nsAString& aHandler,
|
|
|
|
int32_t aTimeout, bool aIsInterval,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
|
|
|
|
// Return true if |aTimeout| was cleared while its handler ran.
|
2019-03-19 23:52:03 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2017-11-15 19:30:13 +03:00
|
|
|
bool RunTimeoutHandler(mozilla::dom::Timeout* aTimeout,
|
|
|
|
nsIScriptContext* aScx);
|
|
|
|
|
|
|
|
// Helper Functions
|
|
|
|
already_AddRefed<nsIDocShellTreeOwner> GetTreeOwner();
|
|
|
|
already_AddRefed<nsIWebBrowserChrome> GetWebBrowserChrome();
|
|
|
|
bool IsPrivateBrowsing();
|
|
|
|
|
|
|
|
void FireOfflineStatusEventIfChanged();
|
|
|
|
|
|
|
|
public:
|
|
|
|
// Inner windows only.
|
|
|
|
nsresult FireHashchange(const nsAString& aOldURL, const nsAString& aNewURL);
|
|
|
|
|
|
|
|
void FlushPendingNotifications(mozilla::FlushType aType);
|
|
|
|
|
|
|
|
void ScrollTo(const mozilla::CSSIntPoint& aScroll,
|
|
|
|
const mozilla::dom::ScrollOptions& aOptions);
|
|
|
|
|
|
|
|
already_AddRefed<nsIWidget> GetMainWidget();
|
|
|
|
nsIWidget* GetNearestWidget() const;
|
|
|
|
|
|
|
|
bool IsInModalState();
|
|
|
|
|
2021-02-15 22:08:42 +03:00
|
|
|
void SetFocusedElement(mozilla::dom::Element* aElement,
|
2021-03-18 22:53:38 +03:00
|
|
|
uint32_t aFocusMethod = 0,
|
2021-03-20 04:10:02 +03:00
|
|
|
bool aNeedsFocus = false) override;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
2021-02-15 22:08:42 +03:00
|
|
|
uint32_t GetFocusMethod() override;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
2021-02-15 22:08:42 +03:00
|
|
|
bool ShouldShowFocusRing() override;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
// Inner windows only.
|
|
|
|
void UpdateCanvasFocus(bool aFocusChanged, nsIContent* aNewContent);
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual already_AddRefed<nsPIWindowRoot> GetTopWindowRoot() override;
|
|
|
|
|
2018-08-10 21:55:27 +03:00
|
|
|
// Get the toplevel principal, returns null if this is a toplevel window.
|
2019-10-24 15:57:21 +03:00
|
|
|
nsIPrincipal* GetTopLevelAntiTrackingPrincipal();
|
2018-08-10 21:55:27 +03:00
|
|
|
|
|
|
|
// Get the parent principal, returns null if this or the parent are not a
|
|
|
|
// toplevel window. This is mainly used to determine the anti-tracking storage
|
|
|
|
// area.
|
2018-07-13 13:02:19 +03:00
|
|
|
nsIPrincipal* GetTopLevelStorageAreaPrincipal();
|
|
|
|
|
2018-11-23 10:12:02 +03:00
|
|
|
// This method is called if this window loads a 3rd party tracking resource
|
|
|
|
// and the storage is just been granted. The window can reset the partitioned
|
|
|
|
// storage objects and switch to the first party cookie jar.
|
2020-06-03 09:10:58 +03:00
|
|
|
void StorageAccessPermissionGranted();
|
2018-11-23 10:12:02 +03:00
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
protected:
|
|
|
|
static void NotifyDOMWindowDestroyed(nsGlobalWindowInner* aWindow);
|
|
|
|
void NotifyWindowIDDestroyed(const char* aTopic);
|
|
|
|
|
|
|
|
static void NotifyDOMWindowFrozen(nsGlobalWindowInner* aWindow);
|
|
|
|
static void NotifyDOMWindowThawed(nsGlobalWindowInner* aWindow);
|
|
|
|
|
|
|
|
virtual void UpdateParentTarget() override;
|
|
|
|
|
|
|
|
void InitializeShowFocusRings();
|
|
|
|
|
|
|
|
// Clear the document-dependent slots on our JS wrapper. Inner windows only.
|
|
|
|
void ClearDocumentDependentSlots(JSContext* aCx);
|
|
|
|
|
|
|
|
// Inner windows only.
|
|
|
|
already_AddRefed<mozilla::dom::StorageEvent> CloneStorageEvent(
|
|
|
|
const nsAString& aType, const RefPtr<mozilla::dom::StorageEvent>& aEvent,
|
|
|
|
mozilla::ErrorResult& aRv);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
protected:
|
|
|
|
already_AddRefed<nsICSSDeclaration> GetComputedStyleHelper(
|
|
|
|
mozilla::dom::Element& aElt, const nsAString& aPseudoElt,
|
|
|
|
bool aDefaultStylesOnly, mozilla::ErrorResult& aError);
|
|
|
|
|
|
|
|
nsGlobalWindowInner* InnerForSetTimeoutOrInterval(
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
|
|
|
|
void PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
|
|
|
|
const nsAString& aTargetOrigin,
|
|
|
|
JS::Handle<JS::Value> aTransfer,
|
|
|
|
nsIPrincipal& aSubjectPrincipal,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Fire the JS engine's onNewGlobalObject hook. Only used on inner windows.
|
|
|
|
void FireOnNewGlobalObject();
|
|
|
|
|
2018-03-22 06:18:51 +03:00
|
|
|
// Helper for resolving the components shim.
|
2021-05-07 15:29:05 +03:00
|
|
|
bool ResolveComponentsShim(
|
|
|
|
JSContext* aCx, JS::Handle<JSObject*> aObj,
|
|
|
|
JS::MutableHandle<mozilla::Maybe<JS::PropertyDescriptor>> aDesc);
|
2018-03-22 06:18:51 +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
|
|
|
|
|
|
|
bool IsBackgroundInternal() const;
|
|
|
|
|
|
|
|
// NOTE: Chrome Only
|
|
|
|
void DisconnectAndClearGroupMessageManagers() {
|
|
|
|
MOZ_RELEASE_ASSERT(IsChromeWindow());
|
2021-03-12 19:14:58 +03:00
|
|
|
for (const auto& entry : mChromeFields.mGroupMessageManagers) {
|
|
|
|
mozilla::dom::ChromeMessageBroadcaster* mm = entry.GetWeak();
|
2017-11-15 19:30:13 +03:00
|
|
|
if (mm) {
|
2017-06-14 17:44:17 +03:00
|
|
|
mm->Disconnect();
|
2017-11-15 19:30:13 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
mChromeFields.mGroupMessageManagers.Clear();
|
|
|
|
}
|
|
|
|
|
2021-04-14 22:34:23 +03:00
|
|
|
// Call mDocumentFlushedResolvers items, and perform MicroTask checkpoint
|
|
|
|
// after that.
|
|
|
|
//
|
|
|
|
// If aUntilExhaustion is true, then we call resolvers that get added as a
|
|
|
|
// result synchronously, otherwise we wait until the next refresh driver tick.
|
|
|
|
void CallDocumentFlushedResolvers(bool aUntilExhaustion);
|
2018-03-03 14:37:59 +03:00
|
|
|
|
2021-04-14 22:34:23 +03:00
|
|
|
// Called after a refresh driver tick. See documentation of
|
|
|
|
// CallDocumentFlushedResolvers for the meaning of aUntilExhaustion.
|
|
|
|
//
|
|
|
|
// Returns whether we need to keep observing the refresh driver or not.
|
|
|
|
bool MaybeCallDocumentFlushedResolvers(bool aUntilExhaustion);
|
2018-02-12 04:14:49 +03:00
|
|
|
|
2019-06-06 17:57:17 +03:00
|
|
|
// Try to fire the "load" event on our content embedder if we're an iframe.
|
2020-03-12 01:29:53 +03:00
|
|
|
void FireFrameLoadEvent();
|
2019-06-06 17:57:17 +03:00
|
|
|
|
2020-05-16 00:18:07 +03:00
|
|
|
void UpdateAutoplayPermission();
|
2020-07-30 15:26:24 +03:00
|
|
|
void UpdateShortcutsPermission();
|
2020-08-12 18:38:12 +03:00
|
|
|
void UpdatePopupPermission();
|
|
|
|
|
|
|
|
void UpdatePermissions();
|
2020-05-16 00:18:07 +03:00
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
public:
|
2020-08-12 18:38:12 +03:00
|
|
|
static uint32_t GetShortcutsPermission(nsIPrincipal* aPrincipal);
|
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
// 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;
|
|
|
|
|
|
|
|
void DisableIdleCallbackRequests();
|
|
|
|
uint32_t LastIdleRequestHandle() const {
|
|
|
|
return mIdleRequestCallbackCounter - 1;
|
|
|
|
}
|
2019-03-19 10:22:05 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
void RunIdleRequest(mozilla::dom::IdleRequest* aRequest,
|
|
|
|
DOMHighResTimeStamp aDeadline, bool aDidTimeout);
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
void ExecuteIdleRequest(TimeStamp aDeadline);
|
2017-11-15 19:30:13 +03:00
|
|
|
void ScheduleIdleRequestDispatch();
|
|
|
|
void SuspendIdleRequests();
|
|
|
|
void ResumeIdleRequests();
|
|
|
|
|
2017-11-28 22:23:46 +03:00
|
|
|
typedef mozilla::LinkedList<RefPtr<mozilla::dom::IdleRequest>> IdleRequests;
|
2017-11-15 19:30:13 +03:00
|
|
|
void RemoveIdleCallback(mozilla::dom::IdleRequest* aRequest);
|
|
|
|
|
2019-06-12 21:36:41 +03:00
|
|
|
void SetActiveLoadingState(bool aIsLoading) override;
|
|
|
|
|
2020-01-28 16:06:40 +03:00
|
|
|
// Hint to the JS engine whether we are currently loading.
|
|
|
|
void HintIsLoading(bool aIsLoading);
|
|
|
|
|
2020-08-24 07:27:08 +03:00
|
|
|
mozilla::dom::ContentMediaController* GetContentMediaController();
|
|
|
|
|
2020-12-08 13:15:18 +03:00
|
|
|
bool TryOpenExternalProtocolIframe() {
|
|
|
|
if (mHasOpenedExternalProtocolFrame) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mHasOpenedExternalProtocolFrame = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-02-03 20:35:41 +03:00
|
|
|
nsTArray<uint32_t>& GetScrollMarks() { return mScrollMarks; }
|
|
|
|
void SetScrollMarks(const nsTArray<uint32_t>& aScrollMarks);
|
|
|
|
|
2020-08-24 07:27:08 +03:00
|
|
|
private:
|
|
|
|
RefPtr<mozilla::dom::ContentMediaController> mContentMediaController;
|
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
protected:
|
|
|
|
// Window offline status. Checked to see if we need to fire offline event
|
|
|
|
bool mWasOffline : 1;
|
|
|
|
|
|
|
|
// Represents whether the inner window's page has had a slow script notice.
|
|
|
|
// Only used by inner windows; will always be false for outer windows.
|
|
|
|
// This is used to implement Telemetry measures such as
|
|
|
|
// SLOW_SCRIPT_PAGE_COUNT.
|
|
|
|
bool mHasHadSlowScript : 1;
|
|
|
|
|
|
|
|
// Fast way to tell if this is a chrome window (without having to QI).
|
|
|
|
bool mIsChrome : 1;
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
bool mCleanMessageManager : 1;
|
|
|
|
|
|
|
|
// Indicates that the current document has never received a document focus
|
|
|
|
// event.
|
|
|
|
bool mNeedsFocus : 1;
|
|
|
|
bool mHasFocus : 1;
|
|
|
|
|
|
|
|
// true if tab navigation has occurred for this window. Focus rings
|
|
|
|
// should be displayed.
|
|
|
|
bool mFocusByKeyOccurred : 1;
|
|
|
|
|
2019-02-23 00:27:44 +03:00
|
|
|
// True if we have notified document-element-inserted observers for this
|
|
|
|
// document.
|
|
|
|
bool mDidFireDocElemInserted : 1;
|
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
// Indicates whether this window wants gamepad input events
|
|
|
|
bool mHasGamepad : 1;
|
|
|
|
|
2020-01-04 01:47:26 +03:00
|
|
|
// Indicates whether this window has content that has an XR session
|
|
|
|
// An XR session results in enumeration and activation of XR devices.
|
|
|
|
bool mHasXRSession : 1;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
// Indicates whether this window wants VRDisplayActivate events
|
|
|
|
bool mHasVRDisplayActivateEvents : 1;
|
2019-12-12 06:10:51 +03:00
|
|
|
|
2020-01-04 01:47:26 +03:00
|
|
|
// Indicates that a request for XR runtime detection has been
|
|
|
|
// requested, but has not yet been resolved
|
|
|
|
bool mXRRuntimeDetectionInFlight : 1;
|
|
|
|
|
2019-12-12 06:10:51 +03:00
|
|
|
// Indicates that an XR permission request has been requested
|
|
|
|
// but has not yet been resolved.
|
|
|
|
bool mXRPermissionRequestInFlight : 1;
|
|
|
|
|
|
|
|
// Indicates that an XR permission request has been granted.
|
|
|
|
// The page should not request permission multiple times.
|
|
|
|
bool mXRPermissionGranted : 1;
|
|
|
|
|
2019-12-13 02:11:01 +03:00
|
|
|
// True if this was the currently-active inner window for a BrowsingContext at
|
|
|
|
// the time it was discarded.
|
|
|
|
bool mWasCurrentInnerWindow : 1;
|
|
|
|
void SetWasCurrentInnerWindow() { mWasCurrentInnerWindow = true; }
|
|
|
|
bool WasCurrentInnerWindow() const override { return mWasCurrentInnerWindow; }
|
|
|
|
|
|
|
|
bool mHasSeenGamepadInput : 1;
|
|
|
|
|
2020-01-28 16:06:40 +03:00
|
|
|
// Whether we told the JS engine that we were in pageload.
|
|
|
|
bool mHintedWasLoading : 1;
|
|
|
|
|
2020-12-08 13:15:18 +03:00
|
|
|
// Whether this window has opened an external-protocol iframe without user
|
|
|
|
// activation once already. Only relevant for top windows.
|
|
|
|
bool mHasOpenedExternalProtocolFrame : 1;
|
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
nsCheapSet<nsUint32HashKey> mGamepadIndexSet;
|
2020-12-03 02:06:05 +03:00
|
|
|
nsRefPtrHashtable<nsGenericHashKey<mozilla::dom::GamepadHandle>,
|
|
|
|
mozilla::dom::Gamepad>
|
|
|
|
mGamepads;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
RefPtr<nsScreen> mScreen;
|
2017-11-21 23:06:21 +03:00
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
RefPtr<mozilla::dom::BarProp> mMenubar;
|
|
|
|
RefPtr<mozilla::dom::BarProp> mToolbar;
|
|
|
|
RefPtr<mozilla::dom::BarProp> mLocationbar;
|
|
|
|
RefPtr<mozilla::dom::BarProp> mPersonalbar;
|
|
|
|
RefPtr<mozilla::dom::BarProp> mStatusbar;
|
|
|
|
RefPtr<mozilla::dom::BarProp> mScrollbars;
|
2017-11-21 23:06:21 +03:00
|
|
|
|
|
|
|
RefPtr<nsGlobalWindowObserver> mObserver;
|
2017-11-15 19:30:13 +03:00
|
|
|
RefPtr<mozilla::dom::Crypto> mCrypto;
|
|
|
|
RefPtr<mozilla::dom::U2F> mU2F;
|
|
|
|
RefPtr<mozilla::dom::cache::CacheStorage> mCacheStorage;
|
|
|
|
RefPtr<mozilla::dom::Console> mConsole;
|
|
|
|
RefPtr<mozilla::dom::Worklet> mPaintWorklet;
|
|
|
|
// We need to store an nsISupports pointer to this object because the
|
|
|
|
// mozilla::dom::External class doesn't exist on b2g and using the type
|
|
|
|
// forward declared here means that ~nsGlobalWindow wouldn't compile because
|
|
|
|
// it wouldn't see the ~External function's declaration.
|
|
|
|
nsCOMPtr<nsISupports> mExternal;
|
2018-03-22 06:18:51 +03:00
|
|
|
RefPtr<mozilla::dom::InstallTriggerImpl> mInstallTrigger;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
RefPtr<mozilla::dom::Storage> mLocalStorage;
|
|
|
|
RefPtr<mozilla::dom::Storage> mSessionStorage;
|
|
|
|
|
|
|
|
RefPtr<mozilla::EventListenerManager> mListenerManager;
|
|
|
|
RefPtr<mozilla::dom::Location> mLocation;
|
|
|
|
RefPtr<nsHistory> mHistory;
|
|
|
|
RefPtr<mozilla::dom::CustomElementRegistry> mCustomElements;
|
|
|
|
|
2018-11-20 02:18:21 +03:00
|
|
|
nsTObserverArray<RefPtr<mozilla::dom::SharedWorker>> mSharedWorkers;
|
|
|
|
|
2018-08-20 23:28:42 +03:00
|
|
|
RefPtr<mozilla::dom::VisualViewport> mVisualViewport;
|
|
|
|
|
2019-05-22 02:14:27 +03:00
|
|
|
// The document's principals and CSP are only stored if
|
|
|
|
// FreeInnerObjects has been called.
|
2017-11-15 19:30:13 +03:00
|
|
|
nsCOMPtr<nsIPrincipal> mDocumentPrincipal;
|
2019-04-12 08:31:32 +03:00
|
|
|
nsCOMPtr<nsIPrincipal> mDocumentStoragePrincipal;
|
2020-06-03 09:09:52 +03:00
|
|
|
nsCOMPtr<nsIPrincipal> mDocumentPartitionedPrincipal;
|
2019-05-22 02:14:27 +03:00
|
|
|
nsCOMPtr<nsIContentSecurityPolicy> mDocumentCsp;
|
2019-04-12 08:31:32 +03:00
|
|
|
|
2019-06-17 07:36:29 +03:00
|
|
|
RefPtr<mozilla::dom::DebuggerNotificationManager>
|
|
|
|
mDebuggerNotificationManager;
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
// mBrowserChild is only ever populated in the content process.
|
|
|
|
nsCOMPtr<nsIBrowserChild> mBrowserChild;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
uint32_t mSuspendDepth;
|
|
|
|
uint32_t mFreezeDepth;
|
|
|
|
|
2018-11-23 18:14:23 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
uint32_t mSerial;
|
|
|
|
#endif
|
|
|
|
|
2021-02-15 22:08:42 +03:00
|
|
|
// the method that was used to focus mFocusedElement
|
2017-11-15 19:30:13 +03:00
|
|
|
uint32_t mFocusMethod;
|
|
|
|
|
|
|
|
// The current idle request callback handle
|
|
|
|
uint32_t mIdleRequestCallbackCounter;
|
|
|
|
IdleRequests mIdleRequestCallbacks;
|
|
|
|
RefPtr<IdleRequestExecutor> mIdleRequestExecutor;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
nsCOMPtr<nsIURI> mLastOpenedURI;
|
|
|
|
#endif
|
|
|
|
|
2018-07-14 01:42:07 +03:00
|
|
|
RefPtr<nsDOMOfflineResourceList> mApplicationCache;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
RefPtr<mozilla::dom::IDBFactory> mIndexedDB;
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
uint32_t mDialogAbuseCount;
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
TimeStamp mLastDialogQuitTime;
|
|
|
|
|
|
|
|
// This flag keeps track of whether dialogs are
|
|
|
|
// currently enabled on this window.
|
|
|
|
bool mAreDialogsEnabled;
|
|
|
|
|
2018-02-12 04:14:49 +03:00
|
|
|
// This flag keeps track of whether this window is currently
|
2021-04-14 22:34:23 +03:00
|
|
|
// observing refresh notifications from the refresh driver.
|
|
|
|
bool mObservingRefresh;
|
|
|
|
|
2018-02-12 04:14:49 +03:00
|
|
|
bool mIteratingDocumentFlushedResolvers;
|
|
|
|
|
2021-04-14 22:34:23 +03:00
|
|
|
bool TryToObserveRefresh();
|
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
nsTArray<uint32_t> mEnabledSensors;
|
|
|
|
|
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
|
|
|
mozilla::UniquePtr<mozilla::dom::WindowOrientationObserver>
|
|
|
|
mOrientationChangeObserver;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MOZ_WEBSPEECH
|
|
|
|
RefPtr<mozilla::dom::SpeechSynthesis> mSpeechSynthesis;
|
|
|
|
#endif
|
|
|
|
|
2020-10-21 14:36:46 +03:00
|
|
|
RefPtr<mozilla::glean::Glean> mGlean;
|
2020-12-14 19:50:07 +03:00
|
|
|
RefPtr<mozilla::glean::GleanPings> mGleanPings;
|
2020-10-21 14:36:46 +03:00
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
// This is the CC generation the last time we called CanSkip.
|
|
|
|
uint32_t mCanSkipCCGeneration;
|
|
|
|
|
|
|
|
// The VR Displays for this window
|
|
|
|
nsTArray<RefPtr<mozilla::dom::VRDisplay>> mVRDisplays;
|
|
|
|
|
|
|
|
RefPtr<mozilla::dom::VREventObserver> mVREventObserver;
|
|
|
|
|
2021-04-19 17:50:54 +03:00
|
|
|
// The number of unload and beforeunload even listeners registered on this
|
|
|
|
// window.
|
|
|
|
uint64_t mUnloadOrBeforeUnloadListenerCount = 0;
|
2017-11-15 19:30:13 +03:00
|
|
|
|
|
|
|
RefPtr<mozilla::dom::IntlUtils> mIntlUtils;
|
|
|
|
|
2017-11-21 23:13:05 +03:00
|
|
|
mozilla::UniquePtr<mozilla::dom::ClientSource> mClientSource;
|
|
|
|
|
2018-02-12 04:14:49 +03:00
|
|
|
nsTArray<mozilla::UniquePtr<PromiseDocumentFlushedResolver>>
|
|
|
|
mDocumentFlushedResolvers;
|
|
|
|
|
2021-02-03 20:35:41 +03:00
|
|
|
nsTArray<uint32_t> mScrollMarks;
|
|
|
|
|
2021-05-27 20:55:45 +03:00
|
|
|
nsTArray<nsWeakPtr> mDataDocumentsForMemoryReporting;
|
|
|
|
|
2017-11-15 19:33:29 +03:00
|
|
|
static InnerWindowByIdTable* sInnerWindowsById;
|
|
|
|
|
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 {
|
2017-06-14 17:44:17 +03:00
|
|
|
RefPtr<mozilla::dom::ChromeMessageBroadcaster> mMessageManager;
|
|
|
|
nsRefPtrHashtable<nsStringHashKey, mozilla::dom::ChromeMessageBroadcaster>
|
2020-02-21 13:41:47 +03:00
|
|
|
mGroupMessageManagers{1};
|
2017-11-15 19:30:13 +03:00
|
|
|
} mChromeFields;
|
|
|
|
|
2017-11-22 00:36:13 +03:00
|
|
|
// These fields are used by the inner and outer windows to prevent
|
|
|
|
// programatically moving the window while the mouse is down.
|
|
|
|
static bool sMouseDown;
|
|
|
|
static bool sDragServiceDisabled;
|
|
|
|
|
2017-11-15 19:30:13 +03:00
|
|
|
friend class nsDOMScriptableHelper;
|
|
|
|
friend class nsDOMWindowUtils;
|
|
|
|
friend class mozilla::dom::PostMessageEvent;
|
|
|
|
friend class DesktopNotification;
|
|
|
|
friend class mozilla::dom::TimeoutManager;
|
|
|
|
friend class IdleRequestExecutor;
|
2017-11-15 19:33:29 +03:00
|
|
|
friend class nsGlobalWindowOuter;
|
2017-11-15 19:30:13 +03:00
|
|
|
};
|
|
|
|
|
2017-11-15 19:33:29 +03:00
|
|
|
inline nsISupports* ToSupports(nsGlobalWindowInner* 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(nsGlobalWindowInner* 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
|
|
|
// XXX: EWW - This is an awful hack - let's not do this
|
|
|
|
#include "nsGlobalWindowOuter.h"
|
2017-11-15 19:30:13 +03:00
|
|
|
|
2017-11-15 19:33:29 +03:00
|
|
|
inline nsIGlobalObject* nsGlobalWindowInner::GetOwnerGlobal() const {
|
|
|
|
return const_cast<nsGlobalWindowInner*>(this);
|
2017-11-15 19:30:13 +03:00
|
|
|
}
|
|
|
|
|
2019-07-26 19:48:31 +03:00
|
|
|
inline nsGlobalWindowOuter* nsGlobalWindowInner::GetInProcessTopInternal() {
|
2017-11-15 19:34:13 +03:00
|
|
|
nsGlobalWindowOuter* outer = GetOuterWindowInternal();
|
2019-07-26 19:48:31 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> top = outer ? outer->GetInProcessTop() : nullptr;
|
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*
|
|
|
|
nsGlobalWindowInner::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* nsGlobalWindowInner::GetContextInternal() {
|
|
|
|
if (mOuterWindow) {
|
|
|
|
return GetOuterWindowInternal()->mContext;
|
2017-11-15 19:30:13 +03:00
|
|
|
}
|
|
|
|
|
2017-11-21 23:06:21 +03:00
|
|
|
return nullptr;
|
2017-11-15 19:33:29 +03:00
|
|
|
}
|
|
|
|
|
2017-11-15 19:34:47 +03:00
|
|
|
inline nsGlobalWindowOuter* nsGlobalWindowInner::GetOuterWindowInternal()
|
|
|
|
const {
|
2017-11-15 19:30:13 +03:00
|
|
|
return nsGlobalWindowOuter::Cast(GetOuterWindow());
|
|
|
|
}
|
|
|
|
|
2017-11-15 19:33:29 +03:00
|
|
|
#endif /* nsGlobalWindowInner_h___ */
|