diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index b4d0c7fcd2a..d74961c945e 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -53,6 +53,8 @@ #include "nsIBrowserWindow.h" #include "nsIContent.h" #include "prlog.h" +#include "nsCOMPtr.h" +#include "nsIPresShell.h" #ifdef XP_PC #include @@ -1324,6 +1326,40 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec, } ShowHistory(); + // If it's a normal reload that uses the cache, look at the destination anchor + // and see if it's an element within the current document + if ((aType == nsURLReload) && (nsnull != mContentViewer)) { + nsCOMPtr docViewer; + if (NS_SUCCEEDED(mContentViewer->QueryInterface(kIDocumentViewerIID, + getter_AddRefs(docViewer)))) { + // Get the document object + nsCOMPtr doc; + docViewer->GetDocument(*getter_AddRefs(doc)); + + // Get the URL for the document + nsCOMPtr docURL = nsDontAddRef(doc->GetDocumentURL()); + + // See if they're the same + nsCOMPtr url; + NS_NewURL(getter_AddRefs(url), urlSpec); + + if ((PRBool)docURL->Equals(url)) { + // See if there's a destination anchor + const char* ref; + url->GetRef(&ref); + + if (nsnull != ref) { + // Get the pres shell object + nsCOMPtr presShell; + docViewer->GetPresShell(*getter_AddRefs(presShell)); + + presShell->GoToAnchor(nsAutoString(ref)); + return NS_OK; + } + } + } + } + // Stop loading the current document (if any...). This call may result in // firing an EndLoadURL notification for the old document... Stop(); diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index b4d0c7fcd2a..d74961c945e 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -53,6 +53,8 @@ #include "nsIBrowserWindow.h" #include "nsIContent.h" #include "prlog.h" +#include "nsCOMPtr.h" +#include "nsIPresShell.h" #ifdef XP_PC #include @@ -1324,6 +1326,40 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec, } ShowHistory(); + // If it's a normal reload that uses the cache, look at the destination anchor + // and see if it's an element within the current document + if ((aType == nsURLReload) && (nsnull != mContentViewer)) { + nsCOMPtr docViewer; + if (NS_SUCCEEDED(mContentViewer->QueryInterface(kIDocumentViewerIID, + getter_AddRefs(docViewer)))) { + // Get the document object + nsCOMPtr doc; + docViewer->GetDocument(*getter_AddRefs(doc)); + + // Get the URL for the document + nsCOMPtr docURL = nsDontAddRef(doc->GetDocumentURL()); + + // See if they're the same + nsCOMPtr url; + NS_NewURL(getter_AddRefs(url), urlSpec); + + if ((PRBool)docURL->Equals(url)) { + // See if there's a destination anchor + const char* ref; + url->GetRef(&ref); + + if (nsnull != ref) { + // Get the pres shell object + nsCOMPtr presShell; + docViewer->GetPresShell(*getter_AddRefs(presShell)); + + presShell->GoToAnchor(nsAutoString(ref)); + return NS_OK; + } + } + } + } + // Stop loading the current document (if any...). This call may result in // firing an EndLoadURL notification for the old document... Stop();