Backed out changeset 2e69a9d98234 (bug 1763672) for causing bustages on nsDocShell.cpp. CLOSED TREE

This commit is contained in:
criss
2022-04-13 18:03:11 +03:00
parent aad8aa40b8
commit 3901d02fd6
9 changed files with 13 additions and 355 deletions

View File

@@ -12860,8 +12860,7 @@ nsresult nsDocShell::OnLinkClick(
bool noOpenerImplied = false;
nsAutoString target(aTargetSpec);
if (aFileName.IsVoid() &&
ShouldOpenInBlankTarget(aTargetSpec, aURI, aContent, aIsUserTriggered)) {
if (ShouldOpenInBlankTarget(aTargetSpec, aURI, aContent)) {
target = u"_blank";
if (!aTargetSpec.Equals(target)) {
noOpenerImplied = true;
@@ -12887,32 +12886,8 @@ nsresult nsDocShell::OnLinkClick(
}
bool nsDocShell::ShouldOpenInBlankTarget(const nsAString& aOriginalTarget,
nsIURI* aLinkURI, nsIContent* aContent,
bool aIsUserTriggered) {
if (net::SchemeIsJavascript(aLinkURI)) {
return false;
}
// External links from within app tabs should always open in new tabs
// instead of replacing the app tab's page (Bug 575561)
// nsIURI.host can throw for non-nsStandardURL nsIURIs. If we fail to
// get either host, just return false to use the original target.
nsAutoCString linkHost;
if (NS_FAILED(aLinkURI->GetHost(linkHost))) {
return false;
}
// The targetTopLevelLinkClicksToBlank property on BrowsingContext allows
// privileged code to change the default targeting behaviour. In particular,
// if a user-initiated link click for the (or targetting the) top-level frame
// is detected, we default the target to "_blank" to give it a new
// top-level BrowsingContext.
if (mBrowsingContext->TargetTopLevelLinkClicksToBlank() && aIsUserTriggered &&
(aOriginalTarget.IsEmpty() && mBrowsingContext->IsTop() ||
aOriginalTarget == u"_top"_ns)) {
return true;
}
nsIURI* aLinkURI,
nsIContent* aContent) {
// Don't modify non-default targets.
if (!aOriginalTarget.IsEmpty()) {
return false;
@@ -12925,6 +12900,15 @@ bool nsDocShell::ShouldOpenInBlankTarget(const nsAString& aOriginalTarget,
return false;
}
// External links from within app tabs should always open in new tabs
// instead of replacing the app tab's page (Bug 575561)
// nsIURI.host can throw for non-nsStandardURL nsIURIs. If we fail to
// get either host, just return false to use the original target.
nsAutoCString linkHost;
if (NS_FAILED(aLinkURI->GetHost(linkHost))) {
return false;
}
nsCOMPtr<nsIURI> docURI = aContent->OwnerDoc()->GetDocumentURIObject();
if (!docURI) {
return false;