/* -*- 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/. */ #ifndef nsPIDOMWindow_h__ #define nsPIDOMWindow_h__ #include "nsIDOMWindow.h" #include "mozIDOMWindow.h" #include "nsCOMPtr.h" #include "nsTArray.h" #include "mozilla/dom/EventTarget.h" #include "mozilla/TaskCategory.h" #include "js/TypeDecls.h" #include "nsRefPtrHashtable.h" // Only fired for inner windows. #define DOM_WINDOW_DESTROYED_TOPIC "dom-window-destroyed" #define DOM_WINDOW_FROZEN_TOPIC "dom-window-frozen" #define DOM_WINDOW_THAWED_TOPIC "dom-window-thawed" class nsGlobalWindow; class nsIArray; class nsIContent; class nsICSSDeclaration; class nsIDocShell; class nsIDocShellLoadInfo; class nsIDocument; class nsIIdleObserver; class nsIPrincipal; class nsIScriptTimeoutHandler; class nsISerialEventTarget; class nsIURI; class nsPIDOMWindowInner; class nsPIDOMWindowOuter; class nsPIWindowRoot; class nsXBLPrototypeHandler; typedef uint32_t SuspendTypes; namespace mozilla { class ThrottledEventQueue; namespace dom { class AudioContext; class DocGroup; class TabGroup; class Element; class Performance; class ServiceWorkerRegistration; class Timeout; class TimeoutManager; class CustomElementRegistry; enum class CallerType : uint32_t; } // namespace dom } // namespace mozilla // Popup control state enum. The values in this enum must go from most // permissive to least permissive so that it's safe to push state in // all situations. Pushing popup state onto the stack never makes the // current popup state less permissive (see // nsGlobalWindow::PushPopupControlState()). enum PopupControlState { openAllowed = 0, // open that window without worries openControlled, // it's a popup, but allow it openBlocked, // it's a popup, but not from an allowed event openAbused, // it's a popup. disallow it, but allow domain override. openOverridden // disallow window open }; enum UIStateChangeType { UIStateChangeType_NoChange, UIStateChangeType_Set, UIStateChangeType_Clear, UIStateChangeType_Invalid // used for serialization only }; enum class FullscreenReason { // Toggling the fullscreen mode requires trusted context. ForFullscreenMode, // Fullscreen API is the API provided to untrusted content. ForFullscreenAPI, // This reason can only be used with exiting fullscreen. // It is otherwise identical to eForFullscreenAPI except it would // suppress the fullscreen transition. ForForceExitFullscreen }; namespace mozilla { namespace dom { class Location; // The states in this enum represent the different possible outcomes which the // window could be experiencing of loading a document with the // Large-Allocation header. The NONE case represents the case where no // Large-Allocation header was set. enum class LargeAllocStatus : uint8_t { // These are the OK states, NONE means that no large allocation status message // should be printed, while SUCCESS means that the success message should be // printed. NONE, SUCCESS, // These are the ERROR states. If a window is in one of these states, then the // next document loaded in that window should have an error message reported // to it. NON_GET, NON_E10S, NOT_ONLY_TOPLEVEL_IN_TABGROUP, NON_WIN32 }; } // namespace dom } // namespace mozilla // nsPIDOMWindowInner and nsPIDOMWindowOuter are identical in all respects // except for the type name. They *must* remain identical so that we can // reinterpret_cast between them. template class nsPIDOMWindow : public T { public: nsPIDOMWindowInner* AsInner(); const nsPIDOMWindowInner* AsInner() const; nsPIDOMWindowOuter* AsOuter(); const nsPIDOMWindowOuter* AsOuter() const; virtual nsPIDOMWindowOuter* GetPrivateRoot() = 0; virtual mozilla::dom::CustomElementRegistry* CustomElements() = 0; // Outer windows only. virtual void ActivateOrDeactivate(bool aActivate) = 0; // this is called GetTopWindowRoot to avoid conflicts with nsIDOMWindow::GetWindowRoot /** * |top| gets the root of the window hierarchy. * * This function does not cross chrome-content boundaries, so if this * window's parent is of a different type, |top| will return this window. * * When script reads the top property, we run GetScriptableTop, which * will not cross an