/* -*- 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 nsDocShell_h__ #define nsDocShell_h__ #include "Units.h" #include "mozilla/Encoding.h" #include "mozilla/Maybe.h" #include "mozilla/NotNull.h" #include "mozilla/ScrollbarPreferences.h" #include "mozilla/UniquePtr.h" #include "mozilla/WeakPtr.h" #include "mozilla/dom/BrowsingContext.h" #include "mozilla/dom/WindowProxyHolder.h" #include "nsCOMPtr.h" #include "nsCharsetSource.h" #include "nsDocLoader.h" #include "nsIAuthPromptProvider.h" #include "nsIBaseWindow.h" #include "nsIDocShell.h" #include "nsIDocShellTreeItem.h" #include "nsIInterfaceRequestor.h" #include "nsILoadContext.h" #include "nsINetworkInterceptController.h" #include "nsIRefreshURI.h" #include "nsIWebNavigation.h" #include "nsIWebPageDescriptor.h" #include "nsIWebProgressListener.h" #include "nsPoint.h" // mCurrent/mDefaultScrollbarPreferences #include "nsRect.h" #include "nsString.h" #include "nsThreadUtils.h" #include "prtime.h" // Interfaces Needed namespace mozilla { class Encoding; class HTMLEditor; class ObservedDocShell; enum class TaskCategory; namespace dom { class ClientInfo; class ClientSource; class EventTarget; class SessionHistoryInfo; struct LoadingSessionHistoryInfo; struct Wireframe; } // namespace dom namespace net { class LoadInfo; class DocumentLoadListener; } // namespace net } // namespace mozilla class nsIController; class nsIDocShellTreeOwner; class nsIDocumentViewer; class nsIHttpChannel; class nsIMutableArray; class nsIPrompt; class nsIScrollableFrame; class nsIStringBundle; class nsIURIFixup; class nsIURIFixupInfo; class nsIURILoader; class nsIWebBrowserFind; class nsIWidget; class nsIReferrerInfo; class nsCommandManager; class nsDocShellEditorData; class nsDOMNavigationTiming; class nsDSURIContentListener; class nsGlobalWindowOuter; class FramingChecker; class OnLinkClickEvent; /* internally used ViewMode types */ enum ViewMode { viewNormal = 0x0, viewSource = 0x1 }; enum eCharsetReloadState { eCharsetReloadInit, eCharsetReloadRequested, eCharsetReloadStopOrigional }; class nsDocShell final : public nsDocLoader, public nsIDocShell, public nsIWebNavigation, public nsIBaseWindow, public nsIRefreshURI, public nsIWebProgressListener, public nsIWebPageDescriptor, public nsIAuthPromptProvider, public nsILoadContext, public nsINetworkInterceptController, public mozilla::SupportsWeakPtr { public: enum InternalLoad : uint32_t { INTERNAL_LOAD_FLAGS_NONE = 0x0, INTERNAL_LOAD_FLAGS_INHERIT_PRINCIPAL = 0x1, INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER = 0x2, INTERNAL_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP = 0x4, // This flag marks the first load in this object // @see nsIWebNavigation::LOAD_FLAGS_FIRST_LOAD INTERNAL_LOAD_FLAGS_FIRST_LOAD = 0x8, // The set of flags that should not be set before calling into // nsDocShell::LoadURI and other nsDocShell loading functions. INTERNAL_LOAD_FLAGS_LOADURI_SETUP_FLAGS = 0xf, INTERNAL_LOAD_FLAGS_BYPASS_CLASSIFIER = 0x10, INTERNAL_LOAD_FLAGS_FORCE_ALLOW_COOKIES = 0x20, // Whether the load should be treated as srcdoc load, rather than a URI one. INTERNAL_LOAD_FLAGS_IS_SRCDOC = 0x40, // Whether this is the load of a frame's original src attribute INTERNAL_LOAD_FLAGS_ORIGINAL_FRAME_SRC = 0x80, INTERNAL_LOAD_FLAGS_NO_OPENER = 0x100, // Whether a top-level data URI navigation is allowed for that load INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI = 0x200, // Whether the load should go through LoadURIDelegate. INTERNAL_LOAD_FLAGS_BYPASS_LOAD_URI_DELEGATE = 0x2000, }; // Event type dispatched by RestorePresentation class RestorePresentationEvent : public mozilla::Runnable { public: NS_DECL_NSIRUNNABLE explicit RestorePresentationEvent(nsDocShell* aDs) : mozilla::Runnable("nsDocShell::RestorePresentationEvent"), mDocShell(aDs) {} void Revoke() { mDocShell = nullptr; } private: RefPtr mDocShell; }; class InterfaceRequestorProxy : public nsIInterfaceRequestor { public: explicit InterfaceRequestorProxy(nsIInterfaceRequestor* aRequestor); NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIINTERFACEREQUESTOR private: virtual ~InterfaceRequestorProxy(); InterfaceRequestorProxy() = default; nsWeakPtr mWeakPtr; }; NS_DECL_ISUPPORTS_INHERITED NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDocShell, nsDocLoader) NS_DECL_NSIDOCSHELL NS_DECL_NSIDOCSHELLTREEITEM NS_DECL_NSIWEBNAVIGATION NS_DECL_NSIBASEWINDOW NS_DECL_NSIINTERFACEREQUESTOR NS_DECL_NSIWEBPROGRESSLISTENER NS_DECL_NSIREFRESHURI NS_DECL_NSIWEBPAGEDESCRIPTOR NS_DECL_NSIAUTHPROMPTPROVIDER NS_DECL_NSINETWORKINTERCEPTCONTROLLER // Create a new nsDocShell object. static already_AddRefed Create( mozilla::dom::BrowsingContext* aBrowsingContext, uint64_t aContentWindowID = 0); bool Initialize(); NS_IMETHOD Stop() override { // Need this here because otherwise nsIWebNavigation::Stop // overrides the docloader's Stop() return nsDocLoader::Stop(); } mozilla::ScrollbarPreference ScrollbarPreference() const { return mScrollbarPref; } void SetScrollbarPreference(mozilla::ScrollbarPreference); /* * The size, in CSS pixels, of the margins for the of an HTML document * in this docshell; used to implement the marginwidth attribute on HTML * /