/* -*- 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/. */
class nsIArray; class nsIBaseWindow; class nsIContent; class nsICookieJarSettings; class nsICSSDeclaration; class nsIDocShellTreeOwner; class nsIDOMWindowUtils; class nsIControllers; class nsIScriptContext; class nsIScriptTimeoutHandler; class nsIBrowserChild; class nsIPrintSettings; class nsITimeoutHandler; class nsIWebBrowserChrome; class nsIWebProgressListener; class mozIDOMWindowProxy;
class nsScreen; class nsHistory; class nsGlobalWindowObserver; class nsGlobalWindowOuter; class nsDOMWindowUtils; class nsIUserIdleService; struct nsRect;
class nsWindowSizes;
class IdleRequestExecutor;
class PromiseDocumentFlushedResolver;
namespace mozilla { class AbstractThread; class ScrollContainerFrame; class ErrorResult;
namespace glean { class Glean; class GleanPings;
} // namespace glean
namespace hal { enumclass ScreenOrientation : uint32_t;
}
namespace dom { class BarProp; class BrowsingContext; struct ChannelPixelLayout; class Credential; class ClientSource; class Console; class CookieStore; class Crypto; class CustomElementRegistry; class DataTransfer; class DocGroup; class External; class FunctionOrTrustedScriptOrString; class Gamepad; class ContentMediaController; enumclass ImageBitmapFormat : uint8_t; class IdleRequest; class IdleRequestCallback; class InstallTriggerImpl; class IntlUtils; class MediaQueryList; class Navigation; class OwningExternalOrWindowProxy; class Promise; class PostMessageEvent; struct RequestInit; class RequestOrUTF8String; class SharedWorker; class Selection; struct SizeToContentConstraints; class WebTaskScheduler; class WebTaskSchedulerMainThread; class SpeechSynthesis; class Timeout; class TrustedTypePolicyFactory; class VisualViewport; class VRDisplay; enumclass VRDisplayEventReason : uint8_t; class VREventObserver; struct WindowPostMessageOptions; class Worklet; namespace cache { class CacheStorage;
} // namespace cache class IDBFactory;
} // namespace dom
} // namespace mozilla
externconst JSClass OuterWindowProxyClass;
//***************************************************************************** // nsGlobalWindowInner: Global Object for Scripting //*****************************************************************************
// 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 // side effect of inheriting PRCList).
class nsGlobalWindowInner final : public mozilla::dom::EventTarget, public nsPIDOMWindowInner, private nsIDOMWindow, public nsIScriptGlobalObject, public nsIScriptObjectPrincipal, public nsSupportsWeakReference, public nsIInterfaceRequestor, public PRCListStr { public: using RemoteProxy = mozilla::dom::BrowsingContext;
using TimeStamp = mozilla::TimeStamp; using TimeDuration = mozilla::TimeDuration;
using InnerWindowByIdTable =
nsTHashMap<nsUint64HashKey, nsGlobalWindowInner*>;
static nsGlobalWindowInner* FromSupports(nsISupports* supports) { // Make sure this matches the casts we do in QueryInterface(). return (nsGlobalWindowInner*)(mozilla::dom::EventTarget*)supports;
}
JSObject* GetGlobalJSObject() final { return GetWrapper(); }
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(); }
// Calling Freeze() on a window will automatically Suspend() it. In // 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); virtualbool IsFrozen() const override; virtualbool HasActiveIndexedDBDatabases() override; virtualbool HasActivePeerConnections() override; virtualbool HasOpenWebSockets() const override; void SyncStateFromParentWindow();
// Called on the current inner window of a browsing context when its // background state changes according to selected tab or visibility of the // browser window. Used with Suspend()/Resume() or Freeze()/Thaw() because // background state may change while the inner window is not current. void UpdateBackgroundState();
// WebIDL permission Func for whether Glean APIs are permitted. staticbool IsGleanNeeded(JSContext*, JSObject*);
bool DoResolve(
JSContext* aCx, JS::Handle<JSObject*> aObj, JS::Handle<jsid> aId,
JS::MutableHandle<mozilla::Maybe<JS::PropertyDescriptor>> aDesc); // The return value is whether DoResolve might end up resolving the given id. // If in doubt, return true. staticbool MayResolve(jsid aId);
// GetScrollContainerFrame does not flush. Callers should do it themselves as // needed, depending on which info they actually want off the scroll container // frame.
mozilla::ScrollContainerFrame* GetScrollContainerFrame();
// 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);
void StartVRActivity(); void StopVRActivity();
// 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(); void NotifyDetectXRRuntimesCompleted(); void NotifyPresentationGenerationChanged(uint32_t aDisplayID);
// 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());
}
// 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, constchar* aPropName,
JS::Handle<JS::Value> aValue,
mozilla::ErrorResult& aError);
// 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);
// 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>
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...);
}
// Helper to convert a void returning child method into an implicit // CallState::Continue value. template <typenameReturn, typename Method, typename... Args> typename std::enable_if<std::is_void<Return>::value, mozilla::CallState>::type
CallDescendant(nsGlobalWindowInner* aWindow, Method aMethod,
Args&&... aArgs) {
(aWindow->*aMethod)(aArgs...); return mozilla::CallState::Continue;
}
// Helper that passes through the CallState value from a child method. template <typenameReturn, typename Method, typename... Args> typename std::enable_if<std::is_same<Return, mozilla::CallState>::value,
mozilla::CallState>::type
CallDescendant(nsGlobalWindowInner* aWindow, Method aMethod,
Args&&... aArgs) { return (aWindow->*aMethod)(aArgs...);
}
// Get the toplevel principal, returns null if this is a toplevel window.
nsIPrincipal* GetTopLevelAntiTrackingPrincipal();
// Get the client principal, returns null if the clientSource is not // available.
nsIPrincipal* GetClientPrincipal();
// Whether the chrome window is currently in a full screen transition. This // flag is updated from FullscreenTransitionTask. bool IsInFullScreenTransition();
// This method is called if this window loads a 3rd party tracking resource // and the storage is just been changed. The window can reset the partitioned // storage objects and switch to the first party cookie jar.
RefPtr<mozilla::GenericPromise> StorageAccessPermissionChanged(bool aGranted);
// NOTE: Chrome Only void DisconnectAndClearGroupMessageManagers() {
MOZ_RELEASE_ASSERT(IsChromeWindow()); for (constauto& entry : mChromeFields.mGroupMessageManagers) {
mozilla::dom::ChromeMessageBroadcaster* mm = entry.GetWeak(); if (mm) {
mm->Disconnect();
}
}
mChromeFields.mGroupMessageManagers.Clear();
}
// 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);
// 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);
// Try to fire the "load" event on our content embedder if we're an iframe.
MOZ_CAN_RUN_SCRIPT void FireFrameLoadEvent();
// Dispatch a runnable related to the global.
nsresult Dispatch(already_AddRefed<nsIRunnable>&& aRunnable) const final;
nsISerialEventTarget* SerialEventTarget() const final;
protected: // Whether we need to care about orientation changes. bool mHasOrientationChangeListeners : 1;
// 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;
// True if we have notified document-element-inserted observers for this // document. bool mDidFireDocElemInserted : 1;
// 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;
// Indicates that a request for XR runtime detection has been // requested, but has not yet been resolved bool mXRRuntimeDetectionInFlight : 1;
// 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;
// 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;
// Whether we told the JS engine that we were in pageload. bool mHintedWasLoading : 1;
// Whether this window has opened an external-protocol iframe without user // activation once already. Only relevant for top windows. bool mHasOpenedExternalProtocolFrame : 1;
// The document's principals and CSP are only stored if // FreeInnerObjects has been called.
nsCOMPtr<nsIPrincipal> mDocumentPrincipal;
nsCOMPtr<nsIPrincipal> mDocumentCookiePrincipal;
nsCOMPtr<nsIPrincipal> mDocumentStoragePrincipal;
nsCOMPtr<nsIPrincipal> mDocumentPartitionedPrincipal;
nsCOMPtr<nsIContentSecurityPolicy> mDocumentCsp;
// Used to cache the result of StorageAccess::StorageAllowedForWindow. // Don't use this field directly, use StorageAccess::StorageAllowedForWindow // instead.
mozilla::Maybe<mozilla::StorageAccess> mStorageAllowedCache;
uint32_t mStorageAllowedReasonCache;
// When window associated storage is accessed we need to notify the parent // process. This flag is used to ensure we only do it once per window // lifetime. bool hasNotifiedStorageKeyUsed{false};
// 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 {
RefPtr<mozilla::dom::ChromeMessageBroadcaster> mMessageManager;
nsRefPtrHashtable<nsStringHashKey, mozilla::dom::ChromeMessageBroadcaster>
mGroupMessageManagers{1};
} mChromeFields;
// Cache the DataTransfer created for a paste event, this will be reset after // the event is dispatched.
RefPtr<mozilla::dom::DataTransfer> mCurrentPasteDataTransfer;
// These fields are used by the inner and outer windows to prevent // programatically moving the window while the mouse is down. staticbool sMouseDown; staticbool sDragServiceDisabled;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.