From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- dom/base/nsFrameLoader.h | 574 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 574 insertions(+) create mode 100644 dom/base/nsFrameLoader.h (limited to 'dom/base/nsFrameLoader.h') diff --git a/dom/base/nsFrameLoader.h b/dom/base/nsFrameLoader.h new file mode 100644 index 0000000000..1769070d91 --- /dev/null +++ b/dom/base/nsFrameLoader.h @@ -0,0 +1,574 @@ +/* -*- 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 for managing loading of a subframe (creation of the docshell, + * handling of loads in it, recursion-checking). + */ + +#ifndef nsFrameLoader_h_ +#define nsFrameLoader_h_ + +#include +#include "ErrorList.h" +#include "Units.h" +#include "js/RootingAPI.h" +#include "mozilla/AlreadyAddRefed.h" +#include "mozilla/Assertions.h" +#include "mozilla/Attributes.h" +#include "mozilla/LinkedList.h" +#include "mozilla/RefPtr.h" +#include "mozilla/dom/BrowsingContext.h" +#include "mozilla/dom/Nullable.h" +#include "mozilla/dom/Promise.h" +#include "mozilla/dom/WindowProxyHolder.h" +#include "mozilla/dom/ipc/IdType.h" +#include "mozilla/layers/LayersTypes.h" +#include "nsCOMPtr.h" +#include "nsCycleCollectionParticipant.h" +#include "nsDocShell.h" +#include "mozilla/dom/MessageManagerCallback.h" +#include "nsID.h" +#include "nsIFrame.h" +#include "nsIMutationObserver.h" +#include "nsISupports.h" +#include "nsRect.h" +#include "nsStringFwd.h" +#include "nsStubMutationObserver.h" +#include "nsWrapperCache.h" + +class nsIURI; +class nsSubDocumentFrame; +class AutoResetInShow; +class AutoResetInFrameSwap; +class nsFrameLoaderOwner; +class nsIRemoteTab; +class nsIDocShellTreeItem; +class nsIDocShellTreeOwner; +class nsILoadContext; +class nsIPrintSettings; +class nsIWebBrowserPersistDocumentReceiver; +class nsIWebProgressListener; +class nsIOpenWindowInfo; + +namespace mozilla { + +class OriginAttributes; + +namespace dom { +class ChromeMessageSender; +class ContentParent; +class Document; +class Element; +class InProcessBrowserChildMessageManager; +class MessageSender; +class ProcessMessageManager; +class BrowserParent; +class MutableTabContext; +class BrowserBridgeChild; +class RemoteBrowser; +struct RemotenessOptions; +struct NavigationIsolationOptions; +class SessionStoreChild; +class SessionStoreParent; + +namespace ipc { +class StructuredCloneData; +} // namespace ipc + +} // namespace dom + +namespace ipc { +class MessageChannel; +} // namespace ipc +} // namespace mozilla + +#if defined(MOZ_WIDGET_GTK) +typedef struct _GtkWidget GtkWidget; +#endif + +// IID for nsFrameLoader, because some places want to QI to it. +#define NS_FRAMELOADER_IID \ + { \ + 0x297fd0ea, 0x1b4a, 0x4c9a, { \ + 0xa4, 0x04, 0xe5, 0x8b, 0xe8, 0x95, 0x10, 0x50 \ + } \ + } + +class nsFrameLoader final : public nsStubMutationObserver, + public mozilla::dom::ipc::MessageManagerCallback, + public nsWrapperCache, + public mozilla::LinkedListElement { + friend class AutoResetInShow; + friend class AutoResetInFrameSwap; + friend class nsFrameLoaderOwner; + using Document = mozilla::dom::Document; + using Element = mozilla::dom::Element; + using BrowserParent = mozilla::dom::BrowserParent; + using BrowserBridgeChild = mozilla::dom::BrowserBridgeChild; + using BrowsingContext = mozilla::dom::BrowsingContext; + using BrowsingContextGroup = mozilla::dom::BrowsingContextGroup; + using Promise = mozilla::dom::Promise; + + public: + // Called by Frame Elements to create a new FrameLoader. + static already_AddRefed Create( + Element* aOwner, bool aNetworkCreated, + nsIOpenWindowInfo* aOpenWindowInfo = nullptr); + + // Called by nsFrameLoaderOwner::ChangeRemoteness when switching out + // FrameLoaders. + static already_AddRefed Recreate( + Element* aOwner, BrowsingContext* aContext, BrowsingContextGroup* aGroup, + const mozilla::dom::NavigationIsolationOptions& aRemotenessOptions, + bool aIsRemote, bool aNetworkCreated, bool aPreserveContext); + + NS_DECLARE_STATIC_IID_ACCESSOR(NS_FRAMELOADER_IID) + + NS_DECL_CYCLE_COLLECTING_ISUPPORTS + NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(nsFrameLoader) + + NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED + nsresult CheckForRecursiveLoad(nsIURI* aURI); + nsresult ReallyStartLoading(); + void StartDestroy(bool aForProcessSwitch); + void DestroyDocShell(); + void DestroyComplete(); + nsDocShell* GetExistingDocShell() const { return mDocShell; } + mozilla::dom::InProcessBrowserChildMessageManager* + GetBrowserChildMessageManager() const { + return mChildMessageManager; + } + nsresult UpdatePositionAndSize(nsSubDocumentFrame* aIFrame); + void PropagateIsUnderHiddenEmbedderElement( + bool aIsUnderHiddenEmbedderElement); + + void UpdateRemoteStyle(mozilla::StyleImageRendering aImageRendering); + + // When creating a nsFrameLoaderOwner which is a static clone, a + // `nsFrameLoader` is not immediately attached to it. Instead, it is added to + // the static clone document's `PendingFrameStaticClones` list. + // + // After the parent document has been fully cloned, a new frameloader will be + // created for the cloned iframe, and `FinishStaticClone` will be called on + // it, which will clone the inner document of the source nsFrameLoader. + nsresult FinishStaticClone(nsFrameLoader* aStaticCloneOf, + nsIPrintSettings* aPrintSettings, + bool* aOutHasInProcessPrintCallbacks); + + nsresult DoRemoteStaticClone(nsFrameLoader* aStaticCloneOf, + nsIPrintSettings* aPrintSettings); + + // WebIDL methods + + nsDocShell* GetDocShell(mozilla::ErrorResult& aRv); + + already_AddRefed GetRemoteTab(); + + already_AddRefed GetLoadContext(); + + mozilla::dom::BrowsingContext* GetBrowsingContext(); + mozilla::dom::BrowsingContext* GetExtantBrowsingContext(); + mozilla::dom::BrowsingContext* GetMaybePendingBrowsingContext() { + return mPendingBrowsingContext; + } + + /** + * Start loading the frame. This method figures out what to load + * from the owner content in the frame loader. + */ + void LoadFrame(bool aOriginalSrc); + + /** + * Loads the specified URI in this frame. Behaves identically to loadFrame, + * except that this method allows specifying the URI to load. + * + * @param aURI The URI to load. + * @param aTriggeringPrincipal The triggering principal for the load. May be + * null, in which case the node principal of the owner content will be + * used. + * @param aCsp The CSP to be used for the load. That is not the CSP to be + * applied to subresources within the frame, but to the iframe load + * itself. E.g. if the CSP holds upgrade-insecure-requests the the + * frame load is upgraded from http to https. + */ + nsresult LoadURI(nsIURI* aURI, nsIPrincipal* aTriggeringPrincipal, + nsIContentSecurityPolicy* aCsp, bool aOriginalSrc); + + /** + * Resume a redirected load within this frame. + * + * @param aPendingSwitchID ID of a process-switching load to be reusmed + * within this frame. + */ + void ResumeLoad(uint64_t aPendingSwitchID); + + /** + * Destroy the frame loader and everything inside it. This will + * clear the weak owner content reference. + */ + void Destroy(bool aForProcessSwitch = false); + + void AsyncDestroy() { + mNeedsAsyncDestroy = true; + Destroy(); + } + + void RequestUpdatePosition(mozilla::ErrorResult& aRv); + + already_AddRefed RequestTabStateFlush(mozilla::ErrorResult& aRv); + + void RequestEpochUpdate(uint32_t aEpoch); + + void RequestSHistoryUpdate(); + + MOZ_CAN_RUN_SCRIPT already_AddRefed PrintPreview( + nsIPrintSettings* aPrintSettings, BrowsingContext* aSourceBC, + mozilla::ErrorResult& aRv); + + void ExitPrintPreview(); + + void StartPersistence(BrowsingContext* aContext, + nsIWebBrowserPersistDocumentReceiver* aRecv, + mozilla::ErrorResult& aRv); + + // WebIDL getters + + already_AddRefed GetMessageManager(); + + already_AddRefed GetOwnerElement(); + + uint32_t LazyWidth() const; + + uint32_t LazyHeight() const; + + uint64_t ChildID() const { return mChildID; } + + bool DepthTooGreat() const { return mDepthTooGreat; } + + bool IsDead() const { return mDestroyCalled; } + + bool IsNetworkCreated() const { return mNetworkCreated; } + + /** + * Is this a frame loader for a bona fide