diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index e6b9aaef0f88..22a9832fa4e5 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -3043,10 +3043,10 @@ already_AddRefed nsFrameLoader::GetOwnerElement() { return do_AddRef(mOwnerContent); } -void nsFrameLoader::SetRemoteBrowser(nsIRemoteTab* aBrowserParent) { +void nsFrameLoader::InitializeFromBrowserParent(BrowserParent* aBrowserParent) { MOZ_ASSERT(!mBrowserParent); mIsRemoteFrame = true; - mBrowserParent = BrowserParent::GetFrom(aBrowserParent); + mBrowserParent = aBrowserParent; mChildID = mBrowserParent ? mBrowserParent->Manager()->ChildID() : 0; MaybeUpdatePrimaryBrowserParent(eBrowserParentChanged); ReallyLoadFrameScripts(); diff --git a/dom/base/nsFrameLoader.h b/dom/base/nsFrameLoader.h index 4c22faa71dcf..1dd2c6a95b32 100644 --- a/dom/base/nsFrameLoader.h +++ b/dom/base/nsFrameLoader.h @@ -342,7 +342,7 @@ class nsFrameLoader final : public nsStubMutationObserver, * this object, which means you can't have called ShowRemoteFrame() * or ReallyStartLoading(). */ - void SetRemoteBrowser(nsIRemoteTab* aBrowserParent); + void InitializeFromBrowserParent(BrowserParent* aBrowserParent); /** * Stashes a detached nsIFrame on the frame loader. We do this when we're diff --git a/dom/html/nsGenericHTMLFrameElement.cpp b/dom/html/nsGenericHTMLFrameElement.cpp index bdbe023eabce..0379603b5538 100644 --- a/dom/html/nsGenericHTMLFrameElement.cpp +++ b/dom/html/nsGenericHTMLFrameElement.cpp @@ -132,12 +132,26 @@ void nsGenericHTMLFrameElement::EnsureFrameLoader() { mFrameLoader = nsFrameLoader::Create(this, mOpenerWindow, mNetworkCreated); } -nsresult nsGenericHTMLFrameElement::CreateRemoteFrameLoader( - nsIRemoteTab* aBrowserParent) { +void nsGenericHTMLFrameElement::DisallowCreateFrameLoader() { + MOZ_ASSERT(!mFrameLoader); + MOZ_ASSERT(!mFrameLoaderCreationDisallowed); + mFrameLoaderCreationDisallowed = true; +} + +void nsGenericHTMLFrameElement::AllowCreateFrameLoader() { + MOZ_ASSERT(!mFrameLoader); + MOZ_ASSERT(mFrameLoaderCreationDisallowed); + mFrameLoaderCreationDisallowed = false; +} + +void nsGenericHTMLFrameElement::CreateRemoteFrameLoader( + BrowserParent* aBrowserParent) { MOZ_ASSERT(!mFrameLoader); EnsureFrameLoader(); - NS_ENSURE_STATE(mFrameLoader); - mFrameLoader->SetRemoteBrowser(aBrowserParent); + if (NS_WARN_IF(!mFrameLoader)) { + return; + } + mFrameLoader->InitializeFromBrowserParent(aBrowserParent); if (nsSubDocumentFrame* subdocFrame = do_QueryFrame(GetPrimaryFrame())) { // The reflow for this element already happened while we were waiting @@ -146,7 +160,6 @@ nsresult nsGenericHTMLFrameElement::CreateRemoteFrameLoader( // ReflowFinished, and we need to do it properly now. mFrameLoader->UpdatePositionAndSize(subdocFrame); } - return NS_OK; } void nsGenericHTMLFrameElement::PresetOpenerWindow( @@ -442,22 +455,6 @@ NS_IMETHODIMP nsGenericHTMLFrameElement::GetIsolated(bool* aOut) { return NS_OK; } -NS_IMETHODIMP -nsGenericHTMLFrameElement::DisallowCreateFrameLoader() { - MOZ_ASSERT(!mFrameLoader); - MOZ_ASSERT(!mFrameLoaderCreationDisallowed); - mFrameLoaderCreationDisallowed = true; - return NS_OK; -} - -NS_IMETHODIMP -nsGenericHTMLFrameElement::AllowCreateFrameLoader() { - MOZ_ASSERT(!mFrameLoader); - MOZ_ASSERT(mFrameLoaderCreationDisallowed); - mFrameLoaderCreationDisallowed = false; - return NS_OK; -} - NS_IMETHODIMP nsGenericHTMLFrameElement::InitializeBrowserAPI() { MOZ_ASSERT(mFrameLoader); diff --git a/dom/html/nsGenericHTMLFrameElement.h b/dom/html/nsGenericHTMLFrameElement.h index f3badcc4b2b7..a08b615aeef2 100644 --- a/dom/html/nsGenericHTMLFrameElement.h +++ b/dom/html/nsGenericHTMLFrameElement.h @@ -19,6 +19,7 @@ namespace mozilla { namespace dom { +class BrowserParent; template struct Nullable; class WindowProxyHolder; @@ -90,6 +91,31 @@ class nsGenericHTMLFrameElement : public nsGenericHTMLElement, mozilla::dom::WindowProxyHolder>& aOpenerWindow, mozilla::ErrorResult& aRv); + /** + * Normally, a frame tries to create its frame loader when its src is + * modified, or its contentWindow is accessed. + * + * disallowCreateFrameLoader prevents the frame element from creating its + * frame loader (in the same way that not being inside a document prevents the + * creation of a frame loader). allowCreateFrameLoader lifts this + * restriction. + * + * These methods are not re-entrant -- it is an error to call + * disallowCreateFrameLoader twice without first calling allowFrameLoader. + * + * It's also an error to call either method if we already have a frame loader. + */ + void DisallowCreateFrameLoader(); + void AllowCreateFrameLoader(); + + /** + * Create a remote (i.e., out-of-process) frame loader attached to the given + * remote tab. + * + * It is an error to call this method if we already have a frame loader. + */ + void CreateRemoteFrameLoader(mozilla::dom::BrowserParent* aBrowserParent); + static void InitStatics(); static bool BrowserFramesEnabled(); diff --git a/dom/interfaces/html/nsIMozBrowserFrame.idl b/dom/interfaces/html/nsIMozBrowserFrame.idl index 651664b60e89..82449c059f19 100644 --- a/dom/interfaces/html/nsIMozBrowserFrame.idl +++ b/dom/interfaces/html/nsIMozBrowserFrame.idl @@ -35,30 +35,6 @@ interface nsIMozBrowserFrame : nsIDOMMozBrowserFrame */ [infallible] readonly attribute boolean isolated; - /** - * Normally, a frame tries to create its frame loader when its src is - * modified, or its contentWindow is accessed. - * - * disallowCreateFrameLoader prevents the frame element from creating its - * frame loader (in the same way that not being inside a document prevents the - * creation of a frame loader). allowCreateFrameLoader lifts this restriction. - * - * These methods are not re-entrant -- it is an error to call - * disallowCreateFrameLoader twice without first calling allowFrameLoader. - * - * It's also an error to call either method if we already have a frame loader. - */ - void disallowCreateFrameLoader(); - void allowCreateFrameLoader(); - - /** - * Create a remote (i.e., out-of-process) frame loader attached to the given - * remote tab. - * - * It is an error to call this method if we already have a frame loader. - */ - void createRemoteFrameLoader(in nsIRemoteTab aRemoteTab); - /** * Initialize the API, and add frame message listener that supports API * invocations.