From 8746d3dc2b20331e4ca6f02dbb5d15815136fbe6 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 5 Sep 2014 14:28:46 -0400 Subject: [PATCH] Bug 974857. Compare attempted anchor traversals to both the actual page URI and the exposable URI, and do an anchor scroll if either one matches. r=smaug --- docshell/base/nsDocShell.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index fed0345c7c6..41fcc8b28c6 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -9416,14 +9416,7 @@ nsDocShell::InternalLoad(nsIURI * aURI, aLoadType == LOAD_HISTORY || aLoadType == LOAD_LINK) { - nsCOMPtr currentURI; - if (sURIFixup && mCurrentURI) { - rv = sURIFixup->CreateExposableURI(mCurrentURI, - getter_AddRefs(currentURI)); - NS_ENSURE_SUCCESS(rv, rv); - } else { - currentURI = mCurrentURI; - } + nsCOMPtr currentURI = mCurrentURI; // Split currentURI and aURI on the '#' character. Make sure we read // the return values of SplitURIAtHash; if it fails, we don't want to // allow a short-circuited navigation. @@ -9439,6 +9432,19 @@ nsDocShell::InternalLoad(nsIURI * aURI, NS_SUCCEEDED(splitRv2) && curBeforeHash.Equals(newBeforeHash); + if (!sameExceptHashes && sURIFixup && currentURI && + NS_SUCCEEDED(splitRv2)) { + // Maybe aURI came from the exposable form of currentURI? + nsCOMPtr currentExposableURI; + rv = sURIFixup->CreateExposableURI(currentURI, + getter_AddRefs(currentExposableURI)); + NS_ENSURE_SUCCESS(rv, rv); + splitRv1 = nsContentUtils::SplitURIAtHash(currentExposableURI, + curBeforeHash, curHash); + sameExceptHashes = NS_SUCCEEDED(splitRv1) && + curBeforeHash.Equals(newBeforeHash); + } + bool historyNavBetweenSameDoc = false; if (mOSHE && aSHEntry) { // We're doing a history load.