/* -*- 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 "nsIDocShell.h" #include "nsStringFwd.h" #include "nsIFrameLoaderOwner.h" #include "nsPoint.h" #include "nsSize.h" #include "nsWrapperCache.h" #include "nsIURI.h" #include "nsFrameMessageManager.h" #include "mozilla/dom/BindingUtils.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/ParentSHistory.h" #include "mozilla/Attributes.h" #include "nsStubMutationObserver.h" #include "Units.h" #include "nsIFrame.h" #include "nsPluginTags.h" class nsIURI; class nsSubDocumentFrame; class nsView; class AutoResetInShow; class AutoResetInFrameSwap; class nsITabParent; class nsIDocShellTreeItem; class nsIDocShellTreeOwner; class nsILoadContext; class nsIMessageSender; class nsIPrintSettings; class nsIWebBrowserPersistDocumentReceiver; class nsIWebProgressListener; namespace mozilla { class OriginAttributes; namespace dom { class ChromeMessageSender; class ContentParent; class InProcessTabChildMessageManager; class MessageSender; class PBrowserParent; class ProcessMessageManager; class Promise; class TabParent; class MutableTabContext; namespace ipc { class StructuredCloneData; } // namespace ipc } // namespace dom namespace layout { class RenderFrameParent; } // namespace layout } // 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; typedef mozilla::dom::PBrowserParent PBrowserParent; typedef mozilla::dom::TabParent TabParent; typedef mozilla::layout::RenderFrameParent RenderFrameParent; public: static nsFrameLoader* Create(mozilla::dom::Element* aOwner, nsPIDOMWindowOuter* aOpener, bool aNetworkCreated, int32_t aJSPluginID = nsFakePluginTag::NOT_JSPLUGIN); 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(); void DestroyDocShell(); void DestroyComplete(); nsIDocShell* GetExistingDocShell() { return mDocShell; } mozilla::dom::InProcessTabChildMessageManager* GetTabChildMessageManager() const { return mChildMessageManager; } nsresult CreateStaticClone(nsFrameLoader* aDest); nsresult UpdatePositionAndSize(nsSubDocumentFrame *aIFrame); // WebIDL methods nsIDocShell* GetDocShell(mozilla::ErrorResult& aRv); already_AddRefed GetTabParent(); already_AddRefed LoadContext(); /** * 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. */ nsresult LoadURI(nsIURI* aURI, bool aOriginalSrc); void AddProcessChangeBlockingPromise(mozilla::dom::Promise& aPromise, mozilla::ErrorResult& aRv); /** * Destroy the frame loader and everything inside it. This will * clear the weak owner content reference. */ void Destroy(); 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, bool aIgnoreRootScrollFrame, mozilla::ErrorResult& aRv); void ActivateFrameEvent(const nsAString& aType, bool aCapture, mozilla::ErrorResult& aRv); void RequestNotifyAfterRemotePaint(); void RequestFrameLoaderClose(mozilla::ErrorResult& aRv); void RequestUpdatePosition(mozilla::ErrorResult& aRv); void Print(uint64_t aOuterWindowID, nsIPrintSettings* aPrintSettings, nsIWebProgressListener* aProgressListener, mozilla::ErrorResult& aRv); void StartPersistence(uint64_t aOuterWindowID, 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 ClampScrollPosition() const { return mClampScrollPosition; } void SetClampScrollPosition(bool aClamp); bool ClipSubdocument() const { return mClipSubdocument; } void SetClipSubdocument(bool aClip); bool DepthTooGreat() const { return mDepthTooGreat; } bool IsDead() const { return mDestroyCalled; } /** * Is this a frame loader for a bona fide