зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1615480 - Part 1: Return a raw pointer from Get[Extant]BrowsingContext, r=kmag
The BrowsingContext is guaranteed to be being kept alive by `nsFrameLoader::mBrowsingContext` and by the nsDocShell or RemoteBrowser object. This improves the ergonomics of this helper method, which may help avoid misuse of `mBrowsingContext`. Differential Revision: https://phabricator.services.mozilla.com/D62957 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
5065663562
Коммит
df715e383d
|
@ -3262,8 +3262,7 @@ already_AddRefed<nsILoadContext> nsFrameLoader::LoadContext() {
|
||||||
return loadContext.forget();
|
return loadContext.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<BrowsingContext> nsFrameLoader::GetBrowsingContext() {
|
BrowsingContext* nsFrameLoader::GetBrowsingContext() {
|
||||||
RefPtr<BrowsingContext> browsingContext;
|
|
||||||
if (IsRemoteFrame()) {
|
if (IsRemoteFrame()) {
|
||||||
Unused << EnsureRemoteBrowser();
|
Unused << EnsureRemoteBrowser();
|
||||||
} else if (mOwnerContent) {
|
} else if (mOwnerContent) {
|
||||||
|
@ -3272,15 +3271,15 @@ already_AddRefed<BrowsingContext> nsFrameLoader::GetBrowsingContext() {
|
||||||
return GetExtantBrowsingContext();
|
return GetExtantBrowsingContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<BrowsingContext> nsFrameLoader::GetExtantBrowsingContext() {
|
BrowsingContext* nsFrameLoader::GetExtantBrowsingContext() {
|
||||||
RefPtr<BrowsingContext> browsingContext;
|
BrowsingContext* browsingContext = nullptr;
|
||||||
if (mRemoteBrowser) {
|
if (mRemoteBrowser) {
|
||||||
browsingContext = mRemoteBrowser->GetBrowsingContext();
|
browsingContext = mRemoteBrowser->GetBrowsingContext();
|
||||||
} else if (mDocShell) {
|
} else if (mDocShell) {
|
||||||
browsingContext = mDocShell->GetBrowsingContext();
|
browsingContext = mDocShell->GetBrowsingContext();
|
||||||
}
|
}
|
||||||
MOZ_ASSERT_IF(browsingContext, browsingContext == mBrowsingContext);
|
MOZ_ASSERT_IF(browsingContext, browsingContext == mBrowsingContext);
|
||||||
return browsingContext.forget();
|
return browsingContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsFrameLoader::InitializeBrowserAPI() {
|
void nsFrameLoader::InitializeBrowserAPI() {
|
||||||
|
@ -3487,8 +3486,7 @@ void nsFrameLoader::SetWillChangeProcess() {
|
||||||
// resilient. For the moment, though, the surrounding process switch code
|
// resilient. For the moment, though, the surrounding process switch code
|
||||||
// is enough in flux that we're better off with a workable interim
|
// is enough in flux that we're better off with a workable interim
|
||||||
// solution.
|
// solution.
|
||||||
MOZ_DIAGNOSTIC_ASSERT(mBrowsingContext ==
|
MOZ_DIAGNOSTIC_ASSERT(mBrowsingContext == GetBrowsingContext());
|
||||||
RefPtr<BrowsingContext>(GetBrowsingContext()));
|
|
||||||
RefPtr<CanonicalBrowsingContext> bc(mBrowsingContext->Canonical());
|
RefPtr<CanonicalBrowsingContext> bc(mBrowsingContext->Canonical());
|
||||||
bc->SetInFlightProcessId(browserParent->Manager()->ChildID());
|
bc->SetInFlightProcessId(browserParent->Manager()->ChildID());
|
||||||
auto callback = [bc](auto) { bc->SetInFlightProcessId(0); };
|
auto callback = [bc](auto) { bc->SetInFlightProcessId(0); };
|
||||||
|
|
|
@ -152,8 +152,8 @@ class nsFrameLoader final : public nsStubMutationObserver,
|
||||||
|
|
||||||
already_AddRefed<nsILoadContext> LoadContext();
|
already_AddRefed<nsILoadContext> LoadContext();
|
||||||
|
|
||||||
already_AddRefed<mozilla::dom::BrowsingContext> GetBrowsingContext();
|
mozilla::dom::BrowsingContext* GetBrowsingContext();
|
||||||
already_AddRefed<mozilla::dom::BrowsingContext> GetExtantBrowsingContext();
|
mozilla::dom::BrowsingContext* GetExtantBrowsingContext();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start loading the frame. This method figures out what to load
|
* Start loading the frame. This method figures out what to load
|
||||||
|
|
|
@ -33,8 +33,7 @@ void nsFrameLoaderOwner::SetFrameLoader(nsFrameLoader* aNewFrameLoader) {
|
||||||
mFrameLoader = aNewFrameLoader;
|
mFrameLoader = aNewFrameLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<mozilla::dom::BrowsingContext>
|
mozilla::dom::BrowsingContext* nsFrameLoaderOwner::GetBrowsingContext() {
|
||||||
nsFrameLoaderOwner::GetBrowsingContext() {
|
|
||||||
if (mFrameLoader) {
|
if (mFrameLoader) {
|
||||||
return mFrameLoader->GetBrowsingContext();
|
return mFrameLoader->GetBrowsingContext();
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ class nsFrameLoaderOwner : public nsISupports {
|
||||||
already_AddRefed<nsFrameLoader> GetFrameLoader();
|
already_AddRefed<nsFrameLoader> GetFrameLoader();
|
||||||
void SetFrameLoader(nsFrameLoader* aNewFrameLoader);
|
void SetFrameLoader(nsFrameLoader* aNewFrameLoader);
|
||||||
|
|
||||||
already_AddRefed<mozilla::dom::BrowsingContext> GetBrowsingContext();
|
mozilla::dom::BrowsingContext* GetBrowsingContext();
|
||||||
|
|
||||||
// Destroy (if it exists) and recreate our frameloader, based on new
|
// Destroy (if it exists) and recreate our frameloader, based on new
|
||||||
// remoteness requirements. This should follow the same path as
|
// remoteness requirements. This should follow the same path as
|
||||||
|
|
Загрузка…
Ссылка в новой задаче