From d850dc207231c2f5695f6b348041d5ca38016d3c Mon Sep 17 00:00:00 2001 From: "kmcclusk%netscape.com" Date: Wed, 17 Oct 2001 01:06:19 +0000 Subject: [PATCH] Scroll browser window to top-left if anchor can not be found (quirks only) bug 80784. r=kin@netscape.com sr=attinasi@netscape.com --- layout/base/nsPresShell.cpp | 18 +++++++++++++++++- layout/html/base/src/nsPresShell.cpp | 18 +++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 8801f678896c..604d87a160ab 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -3914,7 +3914,23 @@ PresShell::GoToAnchor(const nsString& aAnchorName) } } } else { - rv = NS_ERROR_FAILURE; + rv = NS_ERROR_FAILURE; //changed to NS_OK in quirks mode if ScrollTo is called + + // Scroll to the top/left if the anchor can not be + // found (quirks mode only). @see bug 80784 + nsCompatibility compatMode; + mPresContext->GetCompatibilityMode(&compatMode); + + if ((compatMode == eCompatibility_NavQuirks) && (mViewManager)) { + // Get the viewport scroller + nsIScrollableView* scrollingView; + mViewManager->GetRootScrollableView(&scrollingView); + if (scrollingView) { + // Scroll to the top of the page + scrollingView->ScrollTo(0, 0, NS_VMREFRESH_IMMEDIATE); + rv = NS_OK; + } + } } return rv; diff --git a/layout/html/base/src/nsPresShell.cpp b/layout/html/base/src/nsPresShell.cpp index 8801f678896c..604d87a160ab 100644 --- a/layout/html/base/src/nsPresShell.cpp +++ b/layout/html/base/src/nsPresShell.cpp @@ -3914,7 +3914,23 @@ PresShell::GoToAnchor(const nsString& aAnchorName) } } } else { - rv = NS_ERROR_FAILURE; + rv = NS_ERROR_FAILURE; //changed to NS_OK in quirks mode if ScrollTo is called + + // Scroll to the top/left if the anchor can not be + // found (quirks mode only). @see bug 80784 + nsCompatibility compatMode; + mPresContext->GetCompatibilityMode(&compatMode); + + if ((compatMode == eCompatibility_NavQuirks) && (mViewManager)) { + // Get the viewport scroller + nsIScrollableView* scrollingView; + mViewManager->GetRootScrollableView(&scrollingView); + if (scrollingView) { + // Scroll to the top of the page + scrollingView->ScrollTo(0, 0, NS_VMREFRESH_IMMEDIATE); + rv = NS_OK; + } + } } return rv;