- Added a setter for history state to nsIWebShell. The history state should be set before loading a document on which state needs to be restored. If the history state is set, the webshell will set that history state on the pres shell inside nsWebShell::Embed() once the document viewer has been created.

This commit is contained in:
nisheeth%netscape.com 1999-08-31 14:49:21 +00:00
Родитель 9cf6aaace1
Коммит 7cd59d0ec7
3 изменённых файлов: 52 добавлений и 1 удалений

Просмотреть файл

@ -290,6 +290,7 @@ public:
NS_IMETHOD FindWebShellWithName(const PRUnichar* aName, nsIWebShell*& aResult);
NS_IMETHOD FocusAvailable(nsIWebShell* aFocusedWebShell, PRBool& aFocusTaken);
NS_IMETHOD GetHistoryState(nsISupports** aLayoutHistoryState);
NS_IMETHOD SetHistoryState(nsISupports* aLayoutHistoryState);
// nsIWebShellServices
NS_IMETHOD LoadDocument(const char* aURL,
@ -512,6 +513,7 @@ protected:
nsWebShellType mWebShellType;
nsIWebShell* mChromeShell; // Weak reference.
nsISupports* mHistoryState; // Weak reference. Session history owns this.
void ReleaseChildren();
void DestroyChildren();
@ -697,6 +699,7 @@ nsWebShell::nsWebShell()
#else
mNetSupport = nsnull;
#endif
mHistoryState = nsnull;
}
nsWebShell::~nsWebShell()
@ -974,6 +977,21 @@ nsWebShell::Embed(nsIContentViewer* aContentViewer,
mPrefs,
bounds,
mScrollPref);
// If the history state has been set by session history,
// set it on the pres shell now that we have a content
// viewer.
if (mContentViewer && mHistoryState) {
nsCOMPtr<nsIDocumentViewer> docv = do_QueryInterface(mContentViewer);
if (nsnull != docv) {
nsCOMPtr<nsIPresShell> shell;
rv = docv->GetPresShell(*getter_AddRefs(shell));
if (NS_SUCCEEDED(rv)) {
rv = shell->SetHistoryState((nsILayoutHistoryState*) mHistoryState);
}
}
}
if (NS_SUCCEEDED(rv)) {
mContentViewer->Show();
}
@ -2845,6 +2863,13 @@ nsWebShell::GetHistoryState(nsISupports** aLayoutHistoryState)
return rv;
}
NS_IMETHODIMP
nsWebShell::SetHistoryState(nsISupports* aLayoutHistoryState)
{
mHistoryState = aLayoutHistoryState;
return NS_OK;
}
//----------------------------------------------------------------------
// Web Shell Services API

Просмотреть файл

@ -462,9 +462,10 @@ public:
NS_IMETHOD GetUrlDispatcher(nsIUrlDispatcher *& aResult)=0;
/**
* Get the history state for the document.
* Get and set the history state for the document.
*/
NS_IMETHOD GetHistoryState(nsISupports** aLayoutHistoryState) = 0;
NS_IMETHOD SetHistoryState(nsISupports* aLayoutHistoryState) = 0;
};

Просмотреть файл

@ -290,6 +290,7 @@ public:
NS_IMETHOD FindWebShellWithName(const PRUnichar* aName, nsIWebShell*& aResult);
NS_IMETHOD FocusAvailable(nsIWebShell* aFocusedWebShell, PRBool& aFocusTaken);
NS_IMETHOD GetHistoryState(nsISupports** aLayoutHistoryState);
NS_IMETHOD SetHistoryState(nsISupports* aLayoutHistoryState);
// nsIWebShellServices
NS_IMETHOD LoadDocument(const char* aURL,
@ -512,6 +513,7 @@ protected:
nsWebShellType mWebShellType;
nsIWebShell* mChromeShell; // Weak reference.
nsISupports* mHistoryState; // Weak reference. Session history owns this.
void ReleaseChildren();
void DestroyChildren();
@ -697,6 +699,7 @@ nsWebShell::nsWebShell()
#else
mNetSupport = nsnull;
#endif
mHistoryState = nsnull;
}
nsWebShell::~nsWebShell()
@ -974,6 +977,21 @@ nsWebShell::Embed(nsIContentViewer* aContentViewer,
mPrefs,
bounds,
mScrollPref);
// If the history state has been set by session history,
// set it on the pres shell now that we have a content
// viewer.
if (mContentViewer && mHistoryState) {
nsCOMPtr<nsIDocumentViewer> docv = do_QueryInterface(mContentViewer);
if (nsnull != docv) {
nsCOMPtr<nsIPresShell> shell;
rv = docv->GetPresShell(*getter_AddRefs(shell));
if (NS_SUCCEEDED(rv)) {
rv = shell->SetHistoryState((nsILayoutHistoryState*) mHistoryState);
}
}
}
if (NS_SUCCEEDED(rv)) {
mContentViewer->Show();
}
@ -2845,6 +2863,13 @@ nsWebShell::GetHistoryState(nsISupports** aLayoutHistoryState)
return rv;
}
NS_IMETHODIMP
nsWebShell::SetHistoryState(nsISupports* aLayoutHistoryState)
{
mHistoryState = aLayoutHistoryState;
return NS_OK;
}
//----------------------------------------------------------------------
// Web Shell Services API