зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1523638
- Part 10: Implement WindowGlobalParent::GetRootFrameLoader in terms of Top()->GetEmbedderElement(), r=farre
Differential Revision: https://phabricator.services.mozilla.com/D38552 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
83236ff0f4
Коммит
2a0d22e428
|
@ -64,7 +64,6 @@ WindowGlobalParent::WindowGlobalParent(const WindowGlobalInit& aInit,
|
|||
|
||||
void WindowGlobalParent::Init(const WindowGlobalInit& aInit) {
|
||||
MOZ_ASSERT(Manager(), "Should have a manager!");
|
||||
MOZ_ASSERT(!mFrameLoader, "Cannot Init() a WindowGlobalParent twice!");
|
||||
|
||||
// Register this WindowGlobal in the gWindowGlobalParentsById map.
|
||||
if (!gWindowGlobalParentsById) {
|
||||
|
@ -97,35 +96,6 @@ void WindowGlobalParent::Init(const WindowGlobalInit& aInit) {
|
|||
mBrowsingContext->SetCurrentWindowGlobal(this);
|
||||
}
|
||||
|
||||
// Determine what toplevel frame element our WindowGlobalParent is being
|
||||
// embedded in.
|
||||
RefPtr<Element> frameElement;
|
||||
if (mInProcess) {
|
||||
// In the in-process case, we can get it from the other side's
|
||||
// WindowGlobalChild.
|
||||
MOZ_ASSERT(Manager()->GetProtocolId() == PInProcessMsgStart);
|
||||
RefPtr<WindowGlobalChild> otherSide = GetChildActor();
|
||||
if (otherSide && otherSide->WindowGlobal()) {
|
||||
// Get the toplevel window from the other side.
|
||||
RefPtr<nsDocShell> docShell =
|
||||
nsDocShell::Cast(otherSide->WindowGlobal()->GetDocShell());
|
||||
if (docShell) {
|
||||
docShell->GetTopFrameElement(getter_AddRefs(frameElement));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// In the cross-process case, we can get the frame element from our manager.
|
||||
MOZ_ASSERT(Manager()->GetProtocolId() == PBrowserMsgStart);
|
||||
frameElement = static_cast<BrowserParent*>(Manager())->GetOwnerElement();
|
||||
}
|
||||
|
||||
// Extract the nsFrameLoader from the current frame element. We may not have a
|
||||
// nsFrameLoader if we are a chrome document.
|
||||
RefPtr<nsFrameLoaderOwner> flOwner = do_QueryObject(frameElement);
|
||||
if (flOwner) {
|
||||
mFrameLoader = flOwner->GetFrameLoader();
|
||||
}
|
||||
|
||||
// Ensure we have a document URI
|
||||
if (!mDocumentURI) {
|
||||
NS_NewURI(getter_AddRefs(mDocumentURI), "about:blank");
|
||||
|
@ -161,6 +131,17 @@ already_AddRefed<BrowserParent> WindowGlobalParent::GetBrowserParent() {
|
|||
return do_AddRef(static_cast<BrowserParent*>(Manager()));
|
||||
}
|
||||
|
||||
already_AddRefed<nsFrameLoader> WindowGlobalParent::GetRootFrameLoader() {
|
||||
dom::BrowsingContext* top = BrowsingContext()->Top();
|
||||
|
||||
RefPtr<nsFrameLoaderOwner> frameLoaderOwner =
|
||||
do_QueryObject(top->GetEmbedderElement());
|
||||
if (frameLoaderOwner) {
|
||||
return frameLoaderOwner->GetFrameLoader();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint64_t WindowGlobalParent::ContentParentId() {
|
||||
RefPtr<BrowserParent> browserParent = GetBrowserParent();
|
||||
return browserParent ? browserParent->Manager()->ChildID() : 0;
|
||||
|
@ -474,8 +455,7 @@ nsIGlobalObject* WindowGlobalParent::GetParentObject() {
|
|||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(WindowGlobalParent, WindowGlobalActor,
|
||||
mFrameLoader, mBrowsingContext,
|
||||
mWindowActors)
|
||||
mBrowsingContext, mWindowActors)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(WindowGlobalParent,
|
||||
WindowGlobalActor)
|
||||
|
|
|
@ -90,7 +90,7 @@ class WindowGlobalParent final : public WindowGlobalActor,
|
|||
// which this WindowGlobal is a part of. This will be the nsFrameLoader
|
||||
// holding the BrowserParent for remote tabs, and the root content frameloader
|
||||
// for non-remote tabs.
|
||||
nsFrameLoader* GetRootFrameLoader() { return mFrameLoader; }
|
||||
already_AddRefed<nsFrameLoader> GetRootFrameLoader();
|
||||
|
||||
// The current URI which loaded in the document.
|
||||
nsIURI* GetDocumentURI() override { return mDocumentURI; }
|
||||
|
@ -165,7 +165,6 @@ class WindowGlobalParent final : public WindowGlobalActor,
|
|||
// mutations which may have been made in the actual document.
|
||||
nsCOMPtr<nsIPrincipal> mDocumentPrincipal;
|
||||
nsCOMPtr<nsIURI> mDocumentURI;
|
||||
RefPtr<nsFrameLoader> mFrameLoader;
|
||||
RefPtr<CanonicalBrowsingContext> mBrowsingContext;
|
||||
nsRefPtrHashtable<nsStringHashKey, JSWindowActorParent> mWindowActors;
|
||||
uint64_t mInnerWindowId;
|
||||
|
|
Загрузка…
Ссылка в новой задаче