From 2aa4a82499d4becd2284cdb482213d541b8804dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 16:29:10 +0200 Subject: Adding upstream version 86.0.1. Signed-off-by: Daniel Baumann --- dom/base/nsFrameLoader.h | 568 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 568 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..ed5ab61934 --- /dev/null +++ b/dom/base/nsFrameLoader.h @@ -0,0 +1,568 @@ +/* -*- 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/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 TabListener; +class InProcessBrowserChildMessageManager; +class MessageSender; +class ProcessMessageManager; +class BrowserParent; +class MutableTabContext; +class BrowserBridgeChild; +class RemoteBrowser; +struct RemotenessOptions; + +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 { + friend class AutoResetInShow; + friend class AutoResetInFrameSwap; + friend class nsFrameLoaderOwner; + typedef mozilla::dom::Document Document; + typedef mozilla::dom::Element Element; + typedef mozilla::dom::BrowserParent BrowserParent; + typedef mozilla::dom::BrowserBridgeChild BrowserBridgeChild; + typedef mozilla::dom::BrowsingContext BrowsingContext; + typedef mozilla::dom::BrowsingContextGroup BrowsingContextGroup; + typedef mozilla::dom::Promise 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, + bool aIsRemote, bool aNetworkCreated, bool aPreserveContext); + + NS_DECLARE_STATIC_IID_ACCESSOR(NS_FRAMELOADER_IID) + + NS_DECL_CYCLE_COLLECTING_ISUPPORTS + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsFrameLoader) + + NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED + nsresult CheckForRecursiveLoad(nsIURI* aURI); + nsresult ReallyStartLoading(); + void StartDestroy(bool aForProcessSwitch); + void DestroyDocShell(); + void DestroyComplete(); + nsIDocShell* GetExistingDocShell() const { return mDocShell; } + mozilla::dom::InProcessBrowserChildMessageManager* + GetBrowserChildMessageManager() const { + return mChildMessageManager; + } + nsresult UpdatePositionAndSize(nsSubDocumentFrame* aIFrame); + void SendIsUnderHiddenEmbedderElement(bool aIsUnderHiddenEmbedderElement); + + // 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, + bool* aOutHasInProcessPrintCallbacks); + + nsresult DoRemoteStaticClone(nsFrameLoader* aStaticCloneOf); + + // WebIDL methods + + nsDocShell* GetDocShell(mozilla::ErrorResult& aRv); + + already_AddRefed GetRemoteTab(); + + already_AddRefed LoadContext(); + + 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 ActivateRemoteFrame(mozilla::ErrorResult& aRv); + + void DeactivateRemoteFrame(mozilla::ErrorResult& aRv); + + void SendCrossProcessMouseEvent(const nsAString& aType, float aX, float aY, + int32_t aButton, int32_t aClickCount, + int32_t aModifiers, + mozilla::ErrorResult& aRv); + + void ActivateFrameEvent(const nsAString& aType, bool aCapture, + mozilla::ErrorResult& aRv); + + void RequestNotifyAfterRemotePaint(); + + void RequestUpdatePosition(mozilla::ErrorResult& aRv); + + bool RequestTabStateFlush(uint32_t aFlushId, bool aIsFinal = false); + + void RequestEpochUpdate(uint32_t aEpoch); + + void RequestSHistoryUpdate(bool aImmediately = false); + + already_AddRefed PrintPreview( + nsIPrintSettings* aPrintSettings, + const mozilla::dom::Optional& aSourceOuterWindowID, + mozilla::ErrorResult& aRv); + + void ExitPrintPreview(); + + already_AddRefed Print(uint64_t aOuterWindowID, + nsIPrintSettings* aPrintSettings, + mozilla::ErrorResult& aRv); + + 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