From 3892d56d4af320f3c300b52f8266ffbefc1cf0d9 Mon Sep 17 00:00:00 2001 From: "radha%netscape.com" Date: Thu, 18 Aug 2005 11:16:37 +0000 Subject: [PATCH] Fix for bug 59774. Save scrollbar positions in sessionhistory when jumping from one anchor to another in a page. r=adamlock sr=alecf a=asa. Approved by ADT. --- docshell/shistory/public/nsISHEntry.idl | 4 ++++ docshell/shistory/src/nsSHEntry.cpp | 15 +++++++++++++++ docshell/shistory/src/nsSHEntry.h | 16 +++++++++------- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/docshell/shistory/public/nsISHEntry.idl b/docshell/shistory/public/nsISHEntry.idl index 6eec094c446e..e162f6977d0d 100644 --- a/docshell/shistory/public/nsISHEntry.idl +++ b/docshell/shistory/public/nsISHEntry.idl @@ -95,6 +95,10 @@ attribute boolean saveLayoutStateFlag; /** attribute to indicate whether the page is already expired in cache */ attribute boolean expirationStatus; +/** Set/Get scrollers' positon in anchored pages */ +void setScrollPosition(in PRInt32 x, in PRInt32 y); +void getScrollPosition(out PRInt32 x, out PRInt32 y); + /** Additional ways to create an entry */ void create(in nsIURI aURI, in wstring aTitle, in nsIDOMDocument aDocument, in nsIInputStream aInputStream, in nsILayoutHistoryState aHistoryLayoutState, diff --git a/docshell/shistory/src/nsSHEntry.cpp b/docshell/shistory/src/nsSHEntry.cpp index 09f512ca6d71..6652339a0629 100644 --- a/docshell/shistory/src/nsSHEntry.cpp +++ b/docshell/shistory/src/nsSHEntry.cpp @@ -69,6 +69,21 @@ NS_INTERFACE_MAP_END //***************************************************************************** // nsSHEntry: nsISHEntry //***************************************************************************** +NS_IMETHODIMP nsSHEntry::SetScrollPosition(PRInt32 x, PRInt32 y) +{ + mScrollPositionX = x; + mScrollPositionY = y; + return NS_OK; +} + +NS_IMETHODIMP nsSHEntry::GetScrollPosition(PRInt32 *x, PRInt32 *y) +{ + if (x && y) { + *x = mScrollPositionX; + *y = mScrollPositionY; + } + return NS_OK; +} NS_IMETHODIMP nsSHEntry::GetURI(nsIURI** aURI) { diff --git a/docshell/shistory/src/nsSHEntry.h b/docshell/shistory/src/nsSHEntry.h index ef49e23597a2..0321844a02a4 100644 --- a/docshell/shistory/src/nsSHEntry.h +++ b/docshell/shistory/src/nsSHEntry.h @@ -57,13 +57,15 @@ private: nsCOMPtr mURI; nsCOMPtr mReferrerURI; - nsCOMPtr mDocument; - nsString mTitle; - nsCOMPtr mPostData; - nsCOMPtr mLayoutHistoryState; - nsVoidArray mChildren; - PRUint32 mLoadType; - PRUint32 mID; + nsCOMPtr mDocument; + nsString mTitle; + nsCOMPtr mPostData; + nsCOMPtr mLayoutHistoryState; + nsVoidArray mChildren; + PRUint32 mLoadType; + PRUint32 mID; + PRInt32 mScrollPositionX; + PRInt32 mScrollPositionY; PRPackedBool mIsFrameNavigation; PRPackedBool mSaveLayoutState; PRPackedBool mExpired;