Bug 662170 - Navigating to anchor '#' should scroll to top of the page. r=bz
This commit is contained in:
@@ -8360,11 +8360,7 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
||||
// sometimes we might scroll even if we don't fire a hashchange
|
||||
// event! See bug 653741.
|
||||
if (!aSHEntry) {
|
||||
// Take the '#' off the hashes before passing them to
|
||||
// ScrollToAnchor.
|
||||
nsDependentCSubstring curHashName(curHash, 1);
|
||||
nsDependentCSubstring newHashName(newHash, 1);
|
||||
rv = ScrollToAnchor(curHashName, newHashName, aLoadType);
|
||||
rv = ScrollToAnchor(curHash, newHash, aLoadType);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
@@ -9159,16 +9155,20 @@ nsDocShell::ScrollToAnchor(nsACString & aCurHash, nsACString & aNewHash,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Take the '#' off aNewHash to get the ref name. (aNewHash might be empty,
|
||||
// but that's fine.)
|
||||
nsDependentCSubstring newHashName(aNewHash, 1);
|
||||
|
||||
// Both the new and current URIs refer to the same page. We can now
|
||||
// browse to the hash stored in the new URI.
|
||||
|
||||
if (!aNewHash.IsEmpty()) {
|
||||
if (!newHashName.IsEmpty()) {
|
||||
// anchor is there, but if it's a load from history,
|
||||
// we don't have any anchor jumping to do
|
||||
PRBool scroll = aLoadType != LOAD_HISTORY &&
|
||||
aLoadType != LOAD_RELOAD_NORMAL;
|
||||
|
||||
char *str = ToNewCString(aNewHash);
|
||||
char *str = ToNewCString(newHashName);
|
||||
if (!str) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
@@ -9210,7 +9210,7 @@ nsDocShell::ScrollToAnchor(nsACString & aCurHash, nsACString & aNewHash,
|
||||
nsXPIDLString uStr;
|
||||
|
||||
rv = textToSubURI->UnEscapeAndConvert(PromiseFlatCString(aCharset).get(),
|
||||
PromiseFlatCString(aNewHash).get(),
|
||||
PromiseFlatCString(newHashName).get(),
|
||||
getter_Copies(uStr));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user