mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1625172 - Use early return in LocationBase::SetURI. r=nika
Just a minor cleanup while I was reading through our navigation code. Differential Revision: https://phabricator.services.mozilla.com/D68393 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
3a63c03607
commit
87f03f5d28
@ -110,35 +110,37 @@ already_AddRefed<nsDocShellLoadState> LocationBase::CheckURL(
|
||||
void LocationBase::SetURI(nsIURI* aURI, nsIPrincipal& aSubjectPrincipal,
|
||||
ErrorResult& aRv, bool aReplace) {
|
||||
RefPtr<BrowsingContext> bc = GetBrowsingContext();
|
||||
if (bc && !bc->IsDiscarded()) {
|
||||
RefPtr<nsDocShellLoadState> loadState =
|
||||
CheckURL(aURI, aSubjectPrincipal, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
if (!bc || bc->IsDiscarded()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (aReplace) {
|
||||
loadState->SetLoadType(LOAD_STOP_CONTENT_AND_REPLACE);
|
||||
} else {
|
||||
loadState->SetLoadType(LOAD_STOP_CONTENT);
|
||||
}
|
||||
RefPtr<nsDocShellLoadState> loadState =
|
||||
CheckURL(aURI, aSubjectPrincipal, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the incumbent script's browsing context to set as source.
|
||||
nsCOMPtr<nsPIDOMWindowInner> sourceWindow =
|
||||
nsContentUtils::CallerInnerWindow();
|
||||
RefPtr<BrowsingContext> accessingBC;
|
||||
if (sourceWindow) {
|
||||
accessingBC = sourceWindow->GetBrowsingContext();
|
||||
loadState->SetSourceDocShell(sourceWindow->GetDocShell());
|
||||
}
|
||||
if (aReplace) {
|
||||
loadState->SetLoadType(LOAD_STOP_CONTENT_AND_REPLACE);
|
||||
} else {
|
||||
loadState->SetLoadType(LOAD_STOP_CONTENT);
|
||||
}
|
||||
|
||||
loadState->SetLoadFlags(nsIWebNavigation::LOAD_FLAGS_NONE);
|
||||
loadState->SetFirstParty(true);
|
||||
// Get the incumbent script's browsing context to set as source.
|
||||
nsCOMPtr<nsPIDOMWindowInner> sourceWindow =
|
||||
nsContentUtils::CallerInnerWindow();
|
||||
RefPtr<BrowsingContext> accessingBC;
|
||||
if (sourceWindow) {
|
||||
accessingBC = sourceWindow->GetBrowsingContext();
|
||||
loadState->SetSourceDocShell(sourceWindow->GetDocShell());
|
||||
}
|
||||
|
||||
nsresult rv = bc->LoadURI(accessingBC, loadState);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
aRv.Throw(rv);
|
||||
}
|
||||
loadState->SetLoadFlags(nsIWebNavigation::LOAD_FLAGS_NONE);
|
||||
loadState->SetFirstParty(true);
|
||||
|
||||
nsresult rv = bc->LoadURI(accessingBC, loadState);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
aRv.Throw(rv);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user