зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1654193 - Avoid getting nsIBrowser when creating nsFrameLoader, r=ckerschb,peterv
This is an alternative approach from D84307, which avoids needing an extra script runner by avoiding needing to access `nsIBrowser` from XULFrameElement::LoadSrc. Differential Revision: https://phabricator.services.mozilla.com/D85446
This commit is contained in:
Родитель
f60ca8ca4d
Коммит
6eacc7257b
|
@ -1913,3 +1913,5 @@ addExternalIface('ReferrerInfo', nativeType='nsIReferrerInfo')
|
|||
addExternalIface('nsIPermissionDelegateHandler',
|
||||
nativeType='nsIPermissionDelegateHandler',
|
||||
notflattened=True)
|
||||
addExternalIface('nsIOpenWindowInfo', nativeType='nsIOpenWindowInfo',
|
||||
notflattened=True)
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
interface nsIDocShell;
|
||||
interface nsIWebNavigation;
|
||||
interface nsIOpenWindowInfo;
|
||||
|
||||
[ChromeOnly,
|
||||
Exposed=Window]
|
||||
|
@ -19,6 +20,12 @@ interface XULFrameElement : XULElement
|
|||
readonly attribute Document? contentDocument;
|
||||
|
||||
readonly attribute unsigned long long browserId;
|
||||
|
||||
/**
|
||||
* The optional open window information provided by the window creation code
|
||||
* and used to initialize a new browser.
|
||||
*/
|
||||
attribute nsIOpenWindowInfo? openWindowInfo;
|
||||
};
|
||||
|
||||
XULFrameElement includes MozFrameLoaderOwner;
|
||||
|
|
|
@ -25,12 +25,6 @@ interface nsIBrowser : nsISupports
|
|||
*/
|
||||
readonly attribute FrameLoader sameProcessAsFrameLoader;
|
||||
|
||||
/**
|
||||
* Gets the optional open window information provided by the window creation
|
||||
* code and used to initialize a new browser.
|
||||
*/
|
||||
attribute nsIOpenWindowInfo openWindowInfo;
|
||||
|
||||
/*
|
||||
* Called by the child to inform the parent that links are dropped into
|
||||
* content area.
|
||||
|
|
|
@ -21,13 +21,15 @@ namespace dom {
|
|||
NS_IMPL_CYCLE_COLLECTION_CLASS(XULFrameElement)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(XULFrameElement, nsXULElement)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFrameLoader);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFrameLoader)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOpenWindowInfo)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(XULFrameElement, nsXULElement)
|
||||
if (tmp->mFrameLoader) {
|
||||
tmp->mFrameLoader->Destroy();
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mOpenWindowInfo)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(XULFrameElement, nsXULElement,
|
||||
|
@ -78,21 +80,24 @@ uint64_t XULFrameElement::BrowserId() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
nsIOpenWindowInfo* XULFrameElement::GetOpenWindowInfo() const {
|
||||
return mOpenWindowInfo;
|
||||
}
|
||||
|
||||
void XULFrameElement::SetOpenWindowInfo(nsIOpenWindowInfo* aInfo) {
|
||||
mOpenWindowInfo = aInfo;
|
||||
}
|
||||
|
||||
void XULFrameElement::LoadSrc() {
|
||||
if (!IsInUncomposedDoc() || !OwnerDoc()->GetRootElement()) {
|
||||
return;
|
||||
}
|
||||
RefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
|
||||
if (!frameLoader) {
|
||||
// We may have had a nsIOpenWindowInfo set on our nsIBrowser by browser
|
||||
// chrome, due to being used as the target for a `window.open` call. Fetch
|
||||
// that information if it's available, and clear it out so we don't read it
|
||||
// again.
|
||||
nsCOMPtr<nsIOpenWindowInfo> openWindowInfo;
|
||||
if (nsCOMPtr<nsIBrowser> browser = AsBrowser()) {
|
||||
browser->GetOpenWindowInfo(getter_AddRefs(openWindowInfo));
|
||||
browser->SetOpenWindowInfo(nullptr);
|
||||
}
|
||||
// We may have had a nsIOpenWindowInfo set on us by browser chrome, due to
|
||||
// being used as the target for a `window.open` call. Fetch that information
|
||||
// if it's available, and clear it out so we don't read it again.
|
||||
nsCOMPtr<nsIOpenWindowInfo> openWindowInfo = mOpenWindowInfo.forget();
|
||||
|
||||
// false as the networkCreated parameter so that xul:iframe/browser/editor
|
||||
// session history handling works like dynamic html:iframes. Usually xul
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "mozilla/dom/WindowProxyHolder.h"
|
||||
#include "js/TypeDecls.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsIOpenWindowInfo.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXULElement.h"
|
||||
|
@ -40,6 +41,8 @@ class XULFrameElement final : public nsXULElement, public nsFrameLoaderOwner {
|
|||
Nullable<WindowProxyHolder> GetContentWindow();
|
||||
Document* GetContentDocument();
|
||||
uint64_t BrowserId();
|
||||
nsIOpenWindowInfo* GetOpenWindowInfo() const;
|
||||
void SetOpenWindowInfo(nsIOpenWindowInfo* aInfo);
|
||||
|
||||
void SwapFrameLoaders(mozilla::dom::HTMLIFrameElement& aOtherLoaderOwner,
|
||||
mozilla::ErrorResult& rv);
|
||||
|
@ -71,6 +74,9 @@ class XULFrameElement final : public nsXULElement, public nsFrameLoaderOwner {
|
|||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
void LoadSrc();
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIOpenWindowInfo> mOpenWindowInfo;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
Загрузка…
Ссылка в новой задаче